@po-ui/ng-sync 5.22.3 → 6.2.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.
- package/README.md +22 -22
- package/{esm2015/lib/index.js → esm2020/lib/index.mjs} +15 -15
- package/{esm2015/lib/models/index.js → esm2020/lib/models/index.mjs} +6 -6
- package/{esm2015/lib/models/po-data-message.model.js → esm2020/lib/models/po-data-message.model.mjs} +57 -57
- package/esm2020/lib/models/po-data-transform.model.mjs +22 -0
- package/esm2020/lib/models/po-entity/po-entity.model.mjs +214 -0
- package/{esm2015/lib/models/po-event-sourcing-error-response.model.js → esm2020/lib/models/po-event-sourcing-error-response.model.mjs} +17 -17
- package/{esm2015/lib/models/po-network-status.model.js → esm2020/lib/models/po-network-status.model.mjs} +44 -44
- package/{esm2015/lib/models/po-network-type.enum.js → esm2020/lib/models/po-network-type.enum.mjs} +30 -30
- package/esm2020/lib/models/po-query-builder/po-query-builder.model.mjs +238 -0
- package/{esm2015/lib/models/po-request-type.enum.js → esm2020/lib/models/po-request-type.enum.mjs} +16 -16
- package/esm2020/lib/po-sync.module.mjs +45 -0
- package/{esm2015/lib/services/po-event-sourcing/enums/po-event-sourcing-operation.enum.js → esm2020/lib/services/po-event-sourcing/enums/po-event-sourcing-operation.enum.mjs} +17 -17
- package/{esm2015/lib/services/po-event-sourcing/index.js → esm2020/lib/services/po-event-sourcing/index.mjs} +4 -4
- package/esm2020/lib/services/po-event-sourcing/interfaces/po-event-sourcing-item.interface.mjs +2 -0
- package/esm2020/lib/services/po-event-sourcing/interfaces/po-event-sourcing-summary-item.interface.mjs +2 -0
- package/esm2020/lib/services/po-event-sourcing/po-event-sourcing.service.mjs +372 -0
- package/{esm2015/lib/services/po-http-client/interfaces/po-http-header-option.interface.js → esm2020/lib/services/po-http-client/interfaces/po-http-header-option.interface.mjs} +11 -11
- package/esm2020/lib/services/po-http-client/interfaces/po-http-request-data.interface.mjs +2 -0
- package/esm2020/lib/services/po-http-client/interfaces/po-response-api.interface.mjs +2 -0
- package/esm2020/lib/services/po-http-client/po-http-client.service.mjs +148 -0
- package/{esm2015/lib/services/po-http-client/po-http-request-type.enum.js → esm2020/lib/services/po-http-client/po-http-request-type.enum.mjs} +25 -25
- package/esm2020/lib/services/po-network/po-network.service.mjs +58 -0
- package/{esm2015/lib/services/po-schema/index.js → esm2020/lib/services/po-schema/index.mjs} +4 -4
- package/esm2020/lib/services/po-schema/po-schema-definition/po-schema-definition.service.mjs +77 -0
- package/{esm2015/lib/services/po-schema/po-schema-util/po-schema-util.model.js → esm2020/lib/services/po-schema/po-schema-util/po-schema-util.model.mjs} +124 -124
- package/esm2020/lib/services/po-schema/po-schema.service.mjs +174 -0
- package/esm2020/lib/services/po-sync/interfaces/po-sync-config.interface.mjs +2 -0
- package/esm2020/lib/services/po-sync/interfaces/po-sync-field-options.interface.mjs +2 -0
- package/esm2020/lib/services/po-sync/interfaces/po-sync-response.interface.mjs +2 -0
- package/esm2020/lib/services/po-sync/interfaces/po-sync-schema.interface.mjs +2 -0
- package/esm2020/lib/services/po-sync/po-sync.service.mjs +325 -0
- package/{esm2015/lib/utils/utils.js → esm2020/lib/utils/utils.mjs} +63 -63
- package/esm2020/po-ui-ng-sync.mjs +5 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +2 -2
- package/fesm2015/{po-ui-ng-sync.js → po-ui-ng-sync.mjs} +2074 -2058
- package/fesm2015/po-ui-ng-sync.mjs.map +1 -0
- package/fesm2020/po-ui-ng-sync.mjs +2018 -0
- package/fesm2020/po-ui-ng-sync.mjs.map +1 -0
- package/lib/index.d.ts +14 -14
- package/lib/models/index.d.ts +5 -5
- package/lib/models/po-data-message.model.d.ts +46 -46
- package/lib/models/po-data-transform.model.d.ts +52 -52
- package/lib/models/po-entity/po-entity.model.d.ts +122 -122
- package/lib/models/po-event-sourcing-error-response.model.d.ts +20 -20
- package/lib/models/po-network-status.model.d.ts +25 -25
- package/lib/models/po-network-type.enum.d.ts +28 -28
- package/lib/models/po-query-builder/po-query-builder.model.d.ts +126 -126
- package/lib/models/po-request-type.enum.d.ts +14 -14
- package/lib/po-sync.module.d.ts +12 -7
- package/lib/services/po-event-sourcing/enums/po-event-sourcing-operation.enum.d.ts +11 -11
- package/lib/services/po-event-sourcing/index.d.ts +3 -3
- package/lib/services/po-event-sourcing/interfaces/po-event-sourcing-item.interface.d.ts +26 -26
- package/lib/services/po-event-sourcing/interfaces/po-event-sourcing-summary-item.interface.d.ts +16 -16
- package/lib/services/po-event-sourcing/po-event-sourcing.service.d.ts +74 -71
- package/lib/services/po-http-client/interfaces/po-http-header-option.interface.d.ts +15 -15
- package/lib/services/po-http-client/interfaces/po-http-request-data.interface.d.ts +24 -24
- package/lib/services/po-http-client/interfaces/po-response-api.interface.d.ts +14 -14
- package/lib/services/po-http-client/po-http-client.service.d.ts +78 -75
- package/lib/services/po-http-client/po-http-request-type.enum.d.ts +23 -23
- package/lib/services/po-network/po-network.service.d.ts +36 -33
- package/lib/services/po-schema/index.d.ts +3 -3
- package/lib/services/po-schema/po-schema-definition/po-schema-definition.service.d.ts +51 -48
- package/lib/services/po-schema/po-schema-util/po-schema-util.model.d.ts +79 -79
- package/lib/services/po-schema/po-schema.service.d.ts +98 -95
- package/lib/services/po-sync/interfaces/po-sync-config.interface.d.ts +24 -24
- package/lib/services/po-sync/interfaces/po-sync-field-options.interface.d.ts +15 -15
- package/lib/services/po-sync/interfaces/po-sync-response.interface.d.ts +20 -20
- package/lib/services/po-sync/interfaces/po-sync-schema.interface.d.ts +37 -37
- package/lib/services/po-sync/po-sync.service.d.ts +162 -159
- package/lib/utils/utils.d.ts +36 -36
- package/package.json +30 -15
- package/po-ui-ng-sync-6.2.0.tgz +0 -0
- package/po-ui-ng-sync.d.ts +5 -8
- package/public-api.d.ts +1 -1
- package/schematics/README.md +169 -169
- package/schematics/collection.json +15 -15
- package/schematics/migrations.json +30 -25
- package/schematics/ng-add/index.d.ts +7 -7
- package/schematics/ng-add/index.js +33 -33
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/index.spec.d.ts +1 -1
- package/schematics/ng-add/index.spec.js +62 -62
- package/schematics/ng-add/index.spec.js.map +1 -1
- package/schematics/ng-add/schema.json +7 -7
- package/schematics/ng-generate/schema/files/__path__/__name@dasherize__/__name@dasherize__.constants.ts.template +13 -13
- package/schematics/ng-generate/schema/index.d.ts +4 -4
- package/schematics/ng-generate/schema/index.js +12 -12
- package/schematics/ng-generate/schema/index.js.map +1 -1
- package/schematics/ng-generate/schema/index.spec.d.ts +1 -1
- package/schematics/ng-generate/schema/index.spec.js +44 -44
- package/schematics/ng-generate/schema/index.spec.js.map +1 -1
- package/schematics/ng-generate/schema/schema.d.ts +3 -3
- package/schematics/ng-generate/schema/schema.js +2 -2
- package/schematics/ng-generate/schema/schema.json +31 -31
- package/schematics/ng-update/v2/changes.d.ts +8 -8
- package/schematics/ng-update/v2/changes.js +20 -20
- package/schematics/ng-update/v2/index.d.ts +5 -5
- package/schematics/ng-update/v2/index.js +101 -101
- package/schematics/ng-update/v2/index.js.map +1 -1
- package/schematics/ng-update/v3/changes.d.ts +2 -2
- package/schematics/ng-update/v3/changes.js +14 -14
- package/schematics/ng-update/v3/index.d.ts +1 -1
- package/schematics/ng-update/v3/index.js +16 -16
- package/schematics/ng-update/v3/index.js.map +1 -1
- package/schematics/ng-update/v4/changes.d.ts +2 -2
- package/schematics/ng-update/v4/changes.js +14 -14
- package/schematics/ng-update/v4/index.d.ts +1 -1
- package/schematics/ng-update/v4/index.js +15 -15
- package/schematics/ng-update/v4/index.js.map +1 -1
- package/schematics/ng-update/v5/changes.d.ts +2 -2
- package/schematics/ng-update/v5/changes.js +13 -13
- package/schematics/ng-update/v5/index.d.ts +1 -1
- package/schematics/ng-update/v5/index.js +15 -15
- package/schematics/ng-update/v5/index.js.map +1 -1
- package/schematics/ng-update/v6/changes.d.ts +2 -0
- package/schematics/ng-update/v6/changes.js +14 -0
- package/schematics/ng-update/v6/changes.js.map +1 -0
- package/schematics/ng-update/v6/index.d.ts +1 -0
- package/schematics/ng-update/v6/index.js +16 -0
- package/schematics/ng-update/v6/index.js.map +1 -0
- package/bundles/po-ui-ng-sync.umd.js +0 -3002
- package/bundles/po-ui-ng-sync.umd.js.map +0 -1
- package/esm2015/lib/models/po-data-transform.model.js +0 -22
- package/esm2015/lib/models/po-entity/po-entity.model.js +0 -229
- package/esm2015/lib/models/po-query-builder/po-query-builder.model.js +0 -241
- package/esm2015/lib/po-sync.module.js +0 -31
- package/esm2015/lib/services/po-event-sourcing/interfaces/po-event-sourcing-item.interface.js +0 -2
- package/esm2015/lib/services/po-event-sourcing/interfaces/po-event-sourcing-summary-item.interface.js +0 -2
- package/esm2015/lib/services/po-event-sourcing/po-event-sourcing.service.js +0 -411
- package/esm2015/lib/services/po-http-client/interfaces/po-http-request-data.interface.js +0 -2
- package/esm2015/lib/services/po-http-client/interfaces/po-response-api.interface.js +0 -2
- package/esm2015/lib/services/po-http-client/po-http-client.service.js +0 -147
- package/esm2015/lib/services/po-network/po-network.service.js +0 -58
- package/esm2015/lib/services/po-schema/po-schema-definition/po-schema-definition.service.js +0 -80
- package/esm2015/lib/services/po-schema/po-schema.service.js +0 -198
- package/esm2015/lib/services/po-sync/interfaces/po-sync-config.interface.js +0 -2
- package/esm2015/lib/services/po-sync/interfaces/po-sync-field-options.interface.js +0 -2
- package/esm2015/lib/services/po-sync/interfaces/po-sync-response.interface.js +0 -2
- package/esm2015/lib/services/po-sync/interfaces/po-sync-schema.interface.js +0 -2
- package/esm2015/lib/services/po-sync/po-sync.service.js +0 -336
- package/esm2015/po-ui-ng-sync.js +0 -9
- package/fesm2015/po-ui-ng-sync.js.map +0 -1
- package/po-ui-ng-sync-5.22.3.tgz +0 -0
- package/po-ui-ng-sync.metadata.json +0 -1
|
@@ -1,3002 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('http-status-codes'), require('rxjs'), require('rxjs/operators'), require('@po-ui/ng-storage'), require('@angular/common/http'), require('@ionic-native/network/ngx')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@po-ui/ng-sync', ['exports', '@angular/core', 'http-status-codes', 'rxjs', 'rxjs/operators', '@po-ui/ng-storage', '@angular/common/http', '@ionic-native/network/ngx'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['po-ui'] = global['po-ui'] || {}, global['po-ui']['ng-sync'] = {}), global.ng.core, global.HttpStatus, global.rxjs, global.rxjs.operators, global.ngStorage, global.ng.common.http, global.ngx));
|
|
5
|
-
}(this, (function (exports, core, HttpStatus, rxjs, operators, ngStorage, http, ngx) { 'use strict';
|
|
6
|
-
|
|
7
|
-
function _interopNamespace(e) {
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return e[k];
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n['default'] = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var HttpStatus__namespace = /*#__PURE__*/_interopNamespace(HttpStatus);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @description
|
|
31
|
-
*
|
|
32
|
-
* Classe responsável por adaptar dados de APIs que não seguem
|
|
33
|
-
* o padrão de [API do PO UI](https://po-ui.io/guides/api).
|
|
34
|
-
*
|
|
35
|
-
* Essa classe deve ser estendida por uma classe que implemente cada um de seus métodos, adaptando os parâmetros de
|
|
36
|
-
* acordo com a API do *backend* existente que se deseja comunicar.
|
|
37
|
-
*/
|
|
38
|
-
var PoDataTransform = /** @class */ (function () {
|
|
39
|
-
function PoDataTransform() {
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* @docsPrivate
|
|
43
|
-
*
|
|
44
|
-
* Método responsável por receber e armazenar os dados retornados pela API para manipulação na classe `PoDataTransform`.
|
|
45
|
-
*
|
|
46
|
-
* @param {any} data Dados retornados pela API.
|
|
47
|
-
*/
|
|
48
|
-
PoDataTransform.prototype.transform = function (data) {
|
|
49
|
-
this.data = data;
|
|
50
|
-
};
|
|
51
|
-
return PoDataTransform;
|
|
52
|
-
}());
|
|
53
|
-
|
|
54
|
-
/*! *****************************************************************************
|
|
55
|
-
Copyright (c) Microsoft Corporation.
|
|
56
|
-
|
|
57
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
58
|
-
purpose with or without fee is hereby granted.
|
|
59
|
-
|
|
60
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
61
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
62
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
63
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
64
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
65
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
66
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
67
|
-
***************************************************************************** */
|
|
68
|
-
/* global Reflect, Promise */
|
|
69
|
-
var extendStatics = function (d, b) {
|
|
70
|
-
extendStatics = Object.setPrototypeOf ||
|
|
71
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
72
|
-
function (d, b) { for (var p in b)
|
|
73
|
-
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
74
|
-
d[p] = b[p]; };
|
|
75
|
-
return extendStatics(d, b);
|
|
76
|
-
};
|
|
77
|
-
function __extends(d, b) {
|
|
78
|
-
if (typeof b !== "function" && b !== null)
|
|
79
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
80
|
-
extendStatics(d, b);
|
|
81
|
-
function __() { this.constructor = d; }
|
|
82
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
83
|
-
}
|
|
84
|
-
var __assign = function () {
|
|
85
|
-
__assign = Object.assign || function __assign(t) {
|
|
86
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
87
|
-
s = arguments[i];
|
|
88
|
-
for (var p in s)
|
|
89
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
90
|
-
t[p] = s[p];
|
|
91
|
-
}
|
|
92
|
-
return t;
|
|
93
|
-
};
|
|
94
|
-
return __assign.apply(this, arguments);
|
|
95
|
-
};
|
|
96
|
-
function __rest(s, e) {
|
|
97
|
-
var t = {};
|
|
98
|
-
for (var p in s)
|
|
99
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
100
|
-
t[p] = s[p];
|
|
101
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
102
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
103
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
104
|
-
t[p[i]] = s[p[i]];
|
|
105
|
-
}
|
|
106
|
-
return t;
|
|
107
|
-
}
|
|
108
|
-
function __decorate(decorators, target, key, desc) {
|
|
109
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
110
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
111
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
112
|
-
else
|
|
113
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
114
|
-
if (d = decorators[i])
|
|
115
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
116
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
117
|
-
}
|
|
118
|
-
function __param(paramIndex, decorator) {
|
|
119
|
-
return function (target, key) { decorator(target, key, paramIndex); };
|
|
120
|
-
}
|
|
121
|
-
function __metadata(metadataKey, metadataValue) {
|
|
122
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
123
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
124
|
-
}
|
|
125
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
126
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
127
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
128
|
-
function fulfilled(value) { try {
|
|
129
|
-
step(generator.next(value));
|
|
130
|
-
}
|
|
131
|
-
catch (e) {
|
|
132
|
-
reject(e);
|
|
133
|
-
} }
|
|
134
|
-
function rejected(value) { try {
|
|
135
|
-
step(generator["throw"](value));
|
|
136
|
-
}
|
|
137
|
-
catch (e) {
|
|
138
|
-
reject(e);
|
|
139
|
-
} }
|
|
140
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
141
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
function __generator(thisArg, body) {
|
|
145
|
-
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
146
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
147
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
148
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
149
|
-
function step(op) {
|
|
150
|
-
if (f)
|
|
151
|
-
throw new TypeError("Generator is already executing.");
|
|
152
|
-
while (_)
|
|
153
|
-
try {
|
|
154
|
-
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)
|
|
155
|
-
return t;
|
|
156
|
-
if (y = 0, t)
|
|
157
|
-
op = [op[0] & 2, t.value];
|
|
158
|
-
switch (op[0]) {
|
|
159
|
-
case 0:
|
|
160
|
-
case 1:
|
|
161
|
-
t = op;
|
|
162
|
-
break;
|
|
163
|
-
case 4:
|
|
164
|
-
_.label++;
|
|
165
|
-
return { value: op[1], done: false };
|
|
166
|
-
case 5:
|
|
167
|
-
_.label++;
|
|
168
|
-
y = op[1];
|
|
169
|
-
op = [0];
|
|
170
|
-
continue;
|
|
171
|
-
case 7:
|
|
172
|
-
op = _.ops.pop();
|
|
173
|
-
_.trys.pop();
|
|
174
|
-
continue;
|
|
175
|
-
default:
|
|
176
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
177
|
-
_ = 0;
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
181
|
-
_.label = op[1];
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
185
|
-
_.label = t[1];
|
|
186
|
-
t = op;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
if (t && _.label < t[2]) {
|
|
190
|
-
_.label = t[2];
|
|
191
|
-
_.ops.push(op);
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
if (t[2])
|
|
195
|
-
_.ops.pop();
|
|
196
|
-
_.trys.pop();
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
op = body.call(thisArg, _);
|
|
200
|
-
}
|
|
201
|
-
catch (e) {
|
|
202
|
-
op = [6, e];
|
|
203
|
-
y = 0;
|
|
204
|
-
}
|
|
205
|
-
finally {
|
|
206
|
-
f = t = 0;
|
|
207
|
-
}
|
|
208
|
-
if (op[0] & 5)
|
|
209
|
-
throw op[1];
|
|
210
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
214
|
-
if (k2 === undefined)
|
|
215
|
-
k2 = k;
|
|
216
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
217
|
-
}) : (function (o, m, k, k2) {
|
|
218
|
-
if (k2 === undefined)
|
|
219
|
-
k2 = k;
|
|
220
|
-
o[k2] = m[k];
|
|
221
|
-
});
|
|
222
|
-
function __exportStar(m, o) {
|
|
223
|
-
for (var p in m)
|
|
224
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
225
|
-
__createBinding(o, m, p);
|
|
226
|
-
}
|
|
227
|
-
function __values(o) {
|
|
228
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
229
|
-
if (m)
|
|
230
|
-
return m.call(o);
|
|
231
|
-
if (o && typeof o.length === "number")
|
|
232
|
-
return {
|
|
233
|
-
next: function () {
|
|
234
|
-
if (o && i >= o.length)
|
|
235
|
-
o = void 0;
|
|
236
|
-
return { value: o && o[i++], done: !o };
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
240
|
-
}
|
|
241
|
-
function __read(o, n) {
|
|
242
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
243
|
-
if (!m)
|
|
244
|
-
return o;
|
|
245
|
-
var i = m.call(o), r, ar = [], e;
|
|
246
|
-
try {
|
|
247
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
248
|
-
ar.push(r.value);
|
|
249
|
-
}
|
|
250
|
-
catch (error) {
|
|
251
|
-
e = { error: error };
|
|
252
|
-
}
|
|
253
|
-
finally {
|
|
254
|
-
try {
|
|
255
|
-
if (r && !r.done && (m = i["return"]))
|
|
256
|
-
m.call(i);
|
|
257
|
-
}
|
|
258
|
-
finally {
|
|
259
|
-
if (e)
|
|
260
|
-
throw e.error;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return ar;
|
|
264
|
-
}
|
|
265
|
-
/** @deprecated */
|
|
266
|
-
function __spread() {
|
|
267
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
268
|
-
ar = ar.concat(__read(arguments[i]));
|
|
269
|
-
return ar;
|
|
270
|
-
}
|
|
271
|
-
/** @deprecated */
|
|
272
|
-
function __spreadArrays() {
|
|
273
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
274
|
-
s += arguments[i].length;
|
|
275
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
276
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
277
|
-
r[k] = a[j];
|
|
278
|
-
return r;
|
|
279
|
-
}
|
|
280
|
-
function __spreadArray(to, from, pack) {
|
|
281
|
-
if (pack || arguments.length === 2)
|
|
282
|
-
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
283
|
-
if (ar || !(i in from)) {
|
|
284
|
-
if (!ar)
|
|
285
|
-
ar = Array.prototype.slice.call(from, 0, i);
|
|
286
|
-
ar[i] = from[i];
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
290
|
-
}
|
|
291
|
-
function __await(v) {
|
|
292
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
293
|
-
}
|
|
294
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
295
|
-
if (!Symbol.asyncIterator)
|
|
296
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
297
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
298
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
299
|
-
function verb(n) { if (g[n])
|
|
300
|
-
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
301
|
-
function resume(n, v) { try {
|
|
302
|
-
step(g[n](v));
|
|
303
|
-
}
|
|
304
|
-
catch (e) {
|
|
305
|
-
settle(q[0][3], e);
|
|
306
|
-
} }
|
|
307
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
308
|
-
function fulfill(value) { resume("next", value); }
|
|
309
|
-
function reject(value) { resume("throw", value); }
|
|
310
|
-
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
311
|
-
resume(q[0][0], q[0][1]); }
|
|
312
|
-
}
|
|
313
|
-
function __asyncDelegator(o) {
|
|
314
|
-
var i, p;
|
|
315
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
316
|
-
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; }
|
|
317
|
-
}
|
|
318
|
-
function __asyncValues(o) {
|
|
319
|
-
if (!Symbol.asyncIterator)
|
|
320
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
321
|
-
var m = o[Symbol.asyncIterator], i;
|
|
322
|
-
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);
|
|
323
|
-
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); }); }; }
|
|
324
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
325
|
-
}
|
|
326
|
-
function __makeTemplateObject(cooked, raw) {
|
|
327
|
-
if (Object.defineProperty) {
|
|
328
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
cooked.raw = raw;
|
|
332
|
-
}
|
|
333
|
-
return cooked;
|
|
334
|
-
}
|
|
335
|
-
;
|
|
336
|
-
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
337
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
338
|
-
}) : function (o, v) {
|
|
339
|
-
o["default"] = v;
|
|
340
|
-
};
|
|
341
|
-
function __importStar(mod) {
|
|
342
|
-
if (mod && mod.__esModule)
|
|
343
|
-
return mod;
|
|
344
|
-
var result = {};
|
|
345
|
-
if (mod != null)
|
|
346
|
-
for (var k in mod)
|
|
347
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
348
|
-
__createBinding(result, mod, k);
|
|
349
|
-
__setModuleDefault(result, mod);
|
|
350
|
-
return result;
|
|
351
|
-
}
|
|
352
|
-
function __importDefault(mod) {
|
|
353
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
354
|
-
}
|
|
355
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
356
|
-
if (kind === "a" && !f)
|
|
357
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
358
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
359
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
360
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
361
|
-
}
|
|
362
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
363
|
-
if (kind === "m")
|
|
364
|
-
throw new TypeError("Private method is not writable");
|
|
365
|
-
if (kind === "a" && !f)
|
|
366
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
367
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
368
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
369
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Retorna um *array* contendo os pares `[chave, valor]` do objeto.
|
|
374
|
-
*
|
|
375
|
-
* Semelhante ao método `Object.entries()` nativo do javascript.
|
|
376
|
-
*
|
|
377
|
-
* > Veja mais em: https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Object/entries
|
|
378
|
-
*
|
|
379
|
-
* @param object Objeto que será extraído os pares [chave, valor].
|
|
380
|
-
*/
|
|
381
|
-
var getObjectEntries = function (object) {
|
|
382
|
-
var objectName = Object.keys(object)[0];
|
|
383
|
-
var objectValue = object[objectName];
|
|
384
|
-
return [objectName, objectValue];
|
|
385
|
-
};
|
|
386
|
-
/**
|
|
387
|
-
* Recebe um objeto e valida se o seu valor é diferente de *undefined* ou *null*.
|
|
388
|
-
*
|
|
389
|
-
* @param {object} parameter Objeto contento o nome do parâmetro que está sendo validado
|
|
390
|
-
* e o seu valor.
|
|
391
|
-
*/
|
|
392
|
-
var validateParameter = function (parameter) {
|
|
393
|
-
var _a = __read(getObjectEntries(parameter), 2), paramName = _a[0], paramValue = _a[1];
|
|
394
|
-
if (paramValue === undefined || paramValue === null) {
|
|
395
|
-
throw new Error("The " + paramName + " parameter cannot be undefined or null");
|
|
396
|
-
}
|
|
397
|
-
};
|
|
398
|
-
/**
|
|
399
|
-
* Recebe um objeto e valida se o seu valor é uma instância de *Array* e se não
|
|
400
|
-
* está vazio.
|
|
401
|
-
*
|
|
402
|
-
* @param value Objeto contento o nome da propriedade que está sendo validada e o seu valor.
|
|
403
|
-
*/
|
|
404
|
-
var validateArray = function (value) {
|
|
405
|
-
validateParameter(value);
|
|
406
|
-
var _a = __read(getObjectEntries(value), 2), paramName = _a[0], paramValue = _a[1];
|
|
407
|
-
if (!(paramValue instanceof Array)) {
|
|
408
|
-
throw new Error(paramName + " is not an Array instance");
|
|
409
|
-
}
|
|
410
|
-
if (!paramValue.length) {
|
|
411
|
-
throw new Error(paramName + " cannot be empty array");
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
/**
|
|
415
|
-
* Recebe um arquivo e converte para uma string base64
|
|
416
|
-
*
|
|
417
|
-
* @param Objeto do tipo file.
|
|
418
|
-
*/
|
|
419
|
-
var toBase64 = function (file) { return new Promise(function (resolve, reject) {
|
|
420
|
-
var reader = new FileReader();
|
|
421
|
-
reader.readAsDataURL(file);
|
|
422
|
-
reader.onload = function () { return resolve(reader.result); };
|
|
423
|
-
/* istanbul ignore next */
|
|
424
|
-
reader.onerror = function (error) { return reject(error); };
|
|
425
|
-
}); };
|
|
426
|
-
/**
|
|
427
|
-
* Recebe uma string base64 e converte para um arquivo
|
|
428
|
-
*
|
|
429
|
-
* @param string base64.
|
|
430
|
-
*/
|
|
431
|
-
var toFile = function (url, fileName, mimeType) { return fetch(url)
|
|
432
|
-
.then(function (result) { return result.arrayBuffer(); })
|
|
433
|
-
.then(function (buffer) { return new File([buffer], fileName, { type: mimeType }); }); };
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* @description
|
|
437
|
-
*
|
|
438
|
-
* Classe que define a resposta de erro para um item da fila de eventos que não foi enviado ao servidor por
|
|
439
|
-
* alguma inconsistência.
|
|
440
|
-
*
|
|
441
|
-
* > Pode ser utilizada em casos onde um item da fila é enviado ao servidor com inconsistência nos dados, por exemplo
|
|
442
|
-
* uma operação de *delete* ou *update* sem o `id` do objeto.
|
|
443
|
-
*/
|
|
444
|
-
var PoEventSourcingErrorResponse = /** @class */ (function () {
|
|
445
|
-
/* istanbul ignore next */
|
|
446
|
-
function PoEventSourcingErrorResponse(_a) {
|
|
447
|
-
var message = _a.message, operation = _a.operation;
|
|
448
|
-
this.message = message;
|
|
449
|
-
this.operation = operation;
|
|
450
|
-
}
|
|
451
|
-
return PoEventSourcingErrorResponse;
|
|
452
|
-
}());
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* @docsPrivate
|
|
456
|
-
*
|
|
457
|
-
* Define as operações realizadas no sync.
|
|
458
|
-
*/
|
|
459
|
-
var PoEventSourcingOperation;
|
|
460
|
-
(function (PoEventSourcingOperation) {
|
|
461
|
-
// Operação de exclusão.
|
|
462
|
-
PoEventSourcingOperation["Delete"] = "DELETE";
|
|
463
|
-
// Operação de requisição HTTP.
|
|
464
|
-
PoEventSourcingOperation["Http"] = "HTTP";
|
|
465
|
-
// Operação de inserção.
|
|
466
|
-
PoEventSourcingOperation["Insert"] = "INSERT";
|
|
467
|
-
// Operação de alteração.
|
|
468
|
-
PoEventSourcingOperation["Update"] = "UPDATE";
|
|
469
|
-
})(PoEventSourcingOperation || (PoEventSourcingOperation = {}));
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* @usedBy PoHttpClientService, PoHttpCommandResponse, PoSyncService
|
|
473
|
-
*
|
|
474
|
-
* @description
|
|
475
|
-
*
|
|
476
|
-
* Define o método de requisição HTTP.
|
|
477
|
-
*/
|
|
478
|
-
exports.PoHttpRequestType = void 0;
|
|
479
|
-
(function (PoHttpRequestType) {
|
|
480
|
-
/** Método `delete` do protocolo HTTP. */
|
|
481
|
-
PoHttpRequestType["DELETE"] = "DELETE";
|
|
482
|
-
/** Método `get` do protocolo HTTP. */
|
|
483
|
-
PoHttpRequestType["GET"] = "GET";
|
|
484
|
-
/** Método `head` do protocolo HTTP. */
|
|
485
|
-
PoHttpRequestType["HEAD"] = "HEAD";
|
|
486
|
-
/** Método `options` do protocolo HTTP. */
|
|
487
|
-
PoHttpRequestType["OPTIONS"] = "OPTIONS";
|
|
488
|
-
/** Método `patch` do protocolo HTTP. */
|
|
489
|
-
PoHttpRequestType["PATCH"] = "PATCH";
|
|
490
|
-
/** Método `post` do protocolo HTTP. */
|
|
491
|
-
PoHttpRequestType["POST"] = "POST";
|
|
492
|
-
/** Método `put` do protocolo HTTP. */
|
|
493
|
-
PoHttpRequestType["PUT"] = "PUT";
|
|
494
|
-
})(exports.PoHttpRequestType || (exports.PoHttpRequestType = {}));
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* @docsPrivate
|
|
498
|
-
*
|
|
499
|
-
* @description
|
|
500
|
-
*
|
|
501
|
-
* Serviço para execução de requisições HTTP.
|
|
502
|
-
*/
|
|
503
|
-
var PoHttpClientService = /** @class */ (function () {
|
|
504
|
-
function PoHttpClientService(httpClient) {
|
|
505
|
-
this.httpClient = httpClient;
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Constrói uma requisição HTTP personalizada.
|
|
509
|
-
*
|
|
510
|
-
* @param {PoHttpRequestData} poHttpOperationData Parâmetros para a construção
|
|
511
|
-
* da requisição.
|
|
512
|
-
*/
|
|
513
|
-
PoHttpClientService.prototype.createRequest = function (poHttpOperationData) {
|
|
514
|
-
var httpHeaders = this.createHttpHeaders(poHttpOperationData.headers);
|
|
515
|
-
return this.httpClient.request(poHttpOperationData.method, poHttpOperationData.url, {
|
|
516
|
-
observe: 'response',
|
|
517
|
-
headers: httpHeaders,
|
|
518
|
-
body: poHttpOperationData.body
|
|
519
|
-
});
|
|
520
|
-
};
|
|
521
|
-
/**
|
|
522
|
-
* Constrói uma requisição com o método `delete`.
|
|
523
|
-
*
|
|
524
|
-
* @param {string} url URL da requisição.
|
|
525
|
-
* @param {Array<PoHeaderOption>} httpHeaders Cabeçalhos da requisição.
|
|
526
|
-
*/
|
|
527
|
-
PoHttpClientService.prototype.delete = function (url, httpHeaders) {
|
|
528
|
-
var requestData = {
|
|
529
|
-
url: url,
|
|
530
|
-
method: exports.PoHttpRequestType.DELETE,
|
|
531
|
-
headers: httpHeaders
|
|
532
|
-
};
|
|
533
|
-
return this.createRequest(requestData);
|
|
534
|
-
};
|
|
535
|
-
/**
|
|
536
|
-
* Constrói uma requisição com o método `get`.
|
|
537
|
-
*
|
|
538
|
-
* @param {string} url URL da requisição.
|
|
539
|
-
* @param {Array<PoHeaderOption>} httpHeaders Cabeçalhos da requisição.
|
|
540
|
-
*/
|
|
541
|
-
PoHttpClientService.prototype.get = function (url, httpHeaders) {
|
|
542
|
-
var requestData = {
|
|
543
|
-
url: url,
|
|
544
|
-
method: exports.PoHttpRequestType.GET,
|
|
545
|
-
headers: httpHeaders
|
|
546
|
-
};
|
|
547
|
-
return this.createRequest(requestData);
|
|
548
|
-
};
|
|
549
|
-
/**
|
|
550
|
-
* Constrói uma requisição com o método `head`.
|
|
551
|
-
*
|
|
552
|
-
* @param {string} url URL da requisição.
|
|
553
|
-
* @param {Array<PoHeaderOption>} httpHeaders Cabeçalhos da requisição.
|
|
554
|
-
*/
|
|
555
|
-
PoHttpClientService.prototype.head = function (url, httpHeaders) {
|
|
556
|
-
var requestData = {
|
|
557
|
-
url: url,
|
|
558
|
-
method: exports.PoHttpRequestType.HEAD,
|
|
559
|
-
headers: httpHeaders
|
|
560
|
-
};
|
|
561
|
-
return this.createRequest(requestData);
|
|
562
|
-
};
|
|
563
|
-
/**
|
|
564
|
-
* Constrói uma requisição com o método `options`.
|
|
565
|
-
*
|
|
566
|
-
* @param {string} url URL da requisição.
|
|
567
|
-
* @param {Array<PoHeaderOption>} httpHeaders Cabeçalhos da requisição.
|
|
568
|
-
*/
|
|
569
|
-
PoHttpClientService.prototype.options = function (url, httpHeaders) {
|
|
570
|
-
var requestData = {
|
|
571
|
-
url: url,
|
|
572
|
-
method: exports.PoHttpRequestType.OPTIONS,
|
|
573
|
-
headers: httpHeaders
|
|
574
|
-
};
|
|
575
|
-
return this.createRequest(requestData);
|
|
576
|
-
};
|
|
577
|
-
/**
|
|
578
|
-
* Constrói uma requisição com o método `patch`.
|
|
579
|
-
*
|
|
580
|
-
* @param {string} url URL da requisição.
|
|
581
|
-
* @param {any} body Corpo da requisição.
|
|
582
|
-
* @param {Array<PoHeaderOption>} httpHeaders Cabeçalhos da requisição.
|
|
583
|
-
*/
|
|
584
|
-
PoHttpClientService.prototype.patch = function (url, body, httpHeaders) {
|
|
585
|
-
var requestData = {
|
|
586
|
-
url: url,
|
|
587
|
-
method: exports.PoHttpRequestType.PATCH,
|
|
588
|
-
headers: httpHeaders,
|
|
589
|
-
body: body
|
|
590
|
-
};
|
|
591
|
-
return this.createRequest(requestData);
|
|
592
|
-
};
|
|
593
|
-
/**
|
|
594
|
-
* Constrói uma requisição com o método `post`.
|
|
595
|
-
*
|
|
596
|
-
* @param {string} url URL da requisição.
|
|
597
|
-
* @param {any} body Corpo da requisição.
|
|
598
|
-
* @param {Array<PoHeaderOption>} httpHeaders Cabeçalhos da requisição.
|
|
599
|
-
*/
|
|
600
|
-
PoHttpClientService.prototype.post = function (url, body, httpHeaders) {
|
|
601
|
-
var requestData = {
|
|
602
|
-
url: url,
|
|
603
|
-
method: exports.PoHttpRequestType.POST,
|
|
604
|
-
headers: httpHeaders,
|
|
605
|
-
body: body
|
|
606
|
-
};
|
|
607
|
-
return this.createRequest(requestData);
|
|
608
|
-
};
|
|
609
|
-
/**
|
|
610
|
-
* Constrói uma requisição com o método `put`.
|
|
611
|
-
*
|
|
612
|
-
* @param {string} url URL da requisição.
|
|
613
|
-
* @param {any} body Corpo da requisição.
|
|
614
|
-
* @param {Array<PoHeaderOption>} httpHeaders Cabeçalhos da requisição.
|
|
615
|
-
*/
|
|
616
|
-
PoHttpClientService.prototype.put = function (url, body, httpHeaders) {
|
|
617
|
-
var requestData = {
|
|
618
|
-
url: url,
|
|
619
|
-
method: exports.PoHttpRequestType.PUT,
|
|
620
|
-
headers: httpHeaders,
|
|
621
|
-
body: body
|
|
622
|
-
};
|
|
623
|
-
return this.createRequest(requestData);
|
|
624
|
-
};
|
|
625
|
-
PoHttpClientService.prototype.createHttpHeaders = function (poHttpOperationHeaders) {
|
|
626
|
-
var httpHeaders = new http.HttpHeaders();
|
|
627
|
-
if (poHttpOperationHeaders && poHttpOperationHeaders.length > 0) {
|
|
628
|
-
poHttpOperationHeaders.forEach(function (poHttpHeader) { return (httpHeaders = httpHeaders.append(poHttpHeader.name, poHttpHeader.value)); });
|
|
629
|
-
}
|
|
630
|
-
return httpHeaders;
|
|
631
|
-
};
|
|
632
|
-
return PoHttpClientService;
|
|
633
|
-
}());
|
|
634
|
-
PoHttpClientService.decorators = [
|
|
635
|
-
{ type: core.Injectable }
|
|
636
|
-
];
|
|
637
|
-
PoHttpClientService.ctorParameters = function () { return [
|
|
638
|
-
{ type: http.HttpClient }
|
|
639
|
-
]; };
|
|
640
|
-
|
|
641
|
-
/**
|
|
642
|
-
* @docsPrivate
|
|
643
|
-
*
|
|
644
|
-
* @description
|
|
645
|
-
*
|
|
646
|
-
* Método de requisição HTTP.
|
|
647
|
-
*/
|
|
648
|
-
var PoRequestType;
|
|
649
|
-
(function (PoRequestType) {
|
|
650
|
-
PoRequestType["GET"] = "get";
|
|
651
|
-
PoRequestType["DELETE"] = "delete";
|
|
652
|
-
PoRequestType["DIFF"] = "diff";
|
|
653
|
-
PoRequestType["PATCH"] = "patch";
|
|
654
|
-
PoRequestType["POST"] = "post";
|
|
655
|
-
})(PoRequestType || (PoRequestType = {}));
|
|
656
|
-
|
|
657
|
-
/**
|
|
658
|
-
* @docsPrivate
|
|
659
|
-
*
|
|
660
|
-
* @description
|
|
661
|
-
*
|
|
662
|
-
* Serviço utilitário para operações no PoSyncSchema.
|
|
663
|
-
*/
|
|
664
|
-
var PoSchemaUtil = /** @class */ (function () {
|
|
665
|
-
function PoSchemaUtil() {
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Verica se existem campos locais no *schema* informado.
|
|
669
|
-
*
|
|
670
|
-
* @param {PoSyncSchema} schema **Schema* a ser processado.
|
|
671
|
-
*
|
|
672
|
-
* @returns {boolean} Valor do tipo *boolean* que indica se existem campos locais no *schema* informado.
|
|
673
|
-
*/
|
|
674
|
-
PoSchemaUtil.containsLocalFields = function (schema) {
|
|
675
|
-
if (schema.fields) {
|
|
676
|
-
return !!schema.fields.find(function (field) { return typeof field === 'object' && field.local; });
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
/**
|
|
680
|
-
* Retorna o valor atual do `lastSync` para determinado *schema*.
|
|
681
|
-
*
|
|
682
|
-
* @param {Array<PoSyncSchema>} storageSchemas Lista de *schemas* a serem pesquisados.
|
|
683
|
-
* @param {string} schemaName Nome do *schema* que se deseja ler o lastSync.
|
|
684
|
-
*
|
|
685
|
-
* @returns {string} Retorna uma *string* com o valor da última sincronização.
|
|
686
|
-
*/
|
|
687
|
-
PoSchemaUtil.getLastSync = function (storageSchemas, schemaName) {
|
|
688
|
-
if (storageSchemas) {
|
|
689
|
-
var schemaFound = storageSchemas.find(function (schema) { return schema.name === schemaName; });
|
|
690
|
-
return schemaFound && schemaFound.lastSync ? schemaFound.lastSync : PoSchemaUtil.defaultLastSync;
|
|
691
|
-
}
|
|
692
|
-
return PoSchemaUtil.defaultLastSync;
|
|
693
|
-
};
|
|
694
|
-
/**
|
|
695
|
-
* Retorna a lista de campos locais definidos no *schema*.
|
|
696
|
-
*
|
|
697
|
-
* @param {PoSyncSchema} schema **Schema* a ser processado.
|
|
698
|
-
*/
|
|
699
|
-
PoSchemaUtil.getLocalFieldNames = function (schema) {
|
|
700
|
-
if (schema.fields) {
|
|
701
|
-
return schema.fields.reduce(function (fieldsAccumulator, currentField) {
|
|
702
|
-
if (typeof currentField === 'object' && currentField.local) {
|
|
703
|
-
fieldsAccumulator.push(currentField.name);
|
|
704
|
-
}
|
|
705
|
-
return fieldsAccumulator;
|
|
706
|
-
}, []);
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
/**
|
|
710
|
-
* Retorna a lista de campos não locais definidos no *schema*.
|
|
711
|
-
*
|
|
712
|
-
* @param {PoSyncSchema} schema **Schema* a ser processado.
|
|
713
|
-
*/
|
|
714
|
-
PoSchemaUtil.getNonLocalFieldNames = function (schema) {
|
|
715
|
-
if (schema.fields) {
|
|
716
|
-
return schema.fields.reduce(function (fieldsAccumulator, currentField) {
|
|
717
|
-
if (typeof currentField === 'string' || !currentField.local) {
|
|
718
|
-
fieldsAccumulator.push(typeof currentField === 'string' ? currentField : currentField.name);
|
|
719
|
-
}
|
|
720
|
-
return fieldsAccumulator;
|
|
721
|
-
}, []);
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
/**
|
|
725
|
-
* Retorna o `id` referente ao registro do *schema* informado.
|
|
726
|
-
*
|
|
727
|
-
* @param {object} record Registro que será buscado o id.
|
|
728
|
-
* @param {PoSyncSchema} schema **Schema* a ser processado.
|
|
729
|
-
*/
|
|
730
|
-
PoSchemaUtil.getRecordId = function (record, schema) {
|
|
731
|
-
return record[schema.idField] || record[PoSchemaUtil.syncInternalIdFieldName];
|
|
732
|
-
};
|
|
733
|
-
/**
|
|
734
|
-
* Retorna a url correspondente do `PoSyncSchema` dependendo do tipo da requisição `PoRequestType`.
|
|
735
|
-
*
|
|
736
|
-
* @param {PoSyncSchema} schema **Schema* a ser processado.
|
|
737
|
-
* @param {PoRequestType} requestType Tipo da requisição.
|
|
738
|
-
*/
|
|
739
|
-
PoSchemaUtil.getUrl = function (schema, requestType) {
|
|
740
|
-
return schema[requestType + "UrlApi"];
|
|
741
|
-
};
|
|
742
|
-
/**
|
|
743
|
-
* Compara se dois objetos são iguais baseado na lista de campos.
|
|
744
|
-
*
|
|
745
|
-
* @param {Array<string>} fields Lista de campos a serem considerados na comparação.
|
|
746
|
-
* @param {any} model1 Objeto 1 a ser comparado.
|
|
747
|
-
* @param {any} model2 Objeto 2 a ser comparado.
|
|
748
|
-
*/
|
|
749
|
-
PoSchemaUtil.isModelsEqual = function (fields, model1, model2) {
|
|
750
|
-
if (fields) {
|
|
751
|
-
return fields.every(function (field) { return JSON.stringify(model1[field]) === JSON.stringify(model2[field]); });
|
|
752
|
-
}
|
|
753
|
-
};
|
|
754
|
-
/**
|
|
755
|
-
* Retorna uma lista com dois objetos referentes ao registro informado.
|
|
756
|
-
* O primeiro é o registro com os campos que vão para o servidor e o segundo é com os campos locais.
|
|
757
|
-
*
|
|
758
|
-
* @param {PoSyncSchema} schema **Schema* do registro.
|
|
759
|
-
* @param {object} record Registro que será realizada a separação dos campos locais e do servidor.
|
|
760
|
-
*/
|
|
761
|
-
PoSchemaUtil.separateSchemaFields = function (schema, record) {
|
|
762
|
-
var localFields = PoSchemaUtil.getLocalFieldNames(schema);
|
|
763
|
-
var localRecord = {};
|
|
764
|
-
var serverRecord = {};
|
|
765
|
-
Object.keys(record).forEach(function (field) {
|
|
766
|
-
if (localFields.includes(field)) {
|
|
767
|
-
localRecord[field] = record[field];
|
|
768
|
-
}
|
|
769
|
-
else {
|
|
770
|
-
serverRecord[field] = record[field];
|
|
771
|
-
}
|
|
772
|
-
});
|
|
773
|
-
return { serverRecord: serverRecord, localRecord: localRecord };
|
|
774
|
-
};
|
|
775
|
-
return PoSchemaUtil;
|
|
776
|
-
}());
|
|
777
|
-
/** Valor `default` para o campo `lastSync`. */
|
|
778
|
-
PoSchemaUtil.defaultLastSync = new Date(-8640000000000000).toISOString();
|
|
779
|
-
/** Nome da chave do identificador interno do sync. */
|
|
780
|
-
PoSchemaUtil.syncInternalIdFieldName = 'SyncInternalId';
|
|
781
|
-
/** Nome da chave no `storage` para os Schemas. */
|
|
782
|
-
PoSchemaUtil.syncSchemasName = 'SyncSchemas';
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* @docsPrivate
|
|
786
|
-
*
|
|
787
|
-
* @description
|
|
788
|
-
*
|
|
789
|
-
* Serviço que disponibiliza métodos que permite operar sobre as definições dos *schemas*.
|
|
790
|
-
*/
|
|
791
|
-
var PoSchemaDefinitionService = /** @class */ (function () {
|
|
792
|
-
function PoSchemaDefinitionService(poStorage) {
|
|
793
|
-
this.poStorage = poStorage;
|
|
794
|
-
}
|
|
795
|
-
/**
|
|
796
|
-
* Destrói a chave do *storage* que contém as definições dos *schemas*.
|
|
797
|
-
*
|
|
798
|
-
* > Para que não venham ocorrer erros em ações que dependam das definições dos *schemas*,
|
|
799
|
-
* recomenda-se utilizar o método `prepare()` em seguida.
|
|
800
|
-
*
|
|
801
|
-
* @returns {Promise<void>} Promessa que é resolvida quando a chave referente as definições dos *schemas* for destruída.
|
|
802
|
-
*/
|
|
803
|
-
PoSchemaDefinitionService.prototype.destroy = function () {
|
|
804
|
-
return this.poStorage.remove(PoSchemaUtil.syncSchemasName);
|
|
805
|
-
};
|
|
806
|
-
/**
|
|
807
|
-
* Busca um *schema* a partir do nome informado.
|
|
808
|
-
*
|
|
809
|
-
* @param {string} schemaName Nome do *schema*.
|
|
810
|
-
* @returns {Promise<PoSyncSchema>} Promessa que é resolvida quando o *schema* for retornado.
|
|
811
|
-
*/
|
|
812
|
-
PoSchemaDefinitionService.prototype.get = function (schemaName) {
|
|
813
|
-
return this.poStorage.getItemByField(PoSchemaUtil.syncSchemasName, 'name', schemaName);
|
|
814
|
-
};
|
|
815
|
-
/**
|
|
816
|
-
* Retorna uma promessa com a lista dos *schemas* definidos.
|
|
817
|
-
*
|
|
818
|
-
* @returns {Promise<Array<PoSyncSchema>>} Promessa que é resolvida quando a lista dos *schemas* definidos for retornada.
|
|
819
|
-
*/
|
|
820
|
-
PoSchemaDefinitionService.prototype.getAll = function () {
|
|
821
|
-
return this.poStorage.get(PoSchemaUtil.syncSchemasName);
|
|
822
|
-
};
|
|
823
|
-
/**
|
|
824
|
-
* Salva uma lista de *schemas*.
|
|
825
|
-
*
|
|
826
|
-
* @param {Array<PoSyncSchema>} schemas Lista de schemas que serão salvos.
|
|
827
|
-
* @returns {Promise<Array<PoSyncSchema>>} Promessa que é resolvida quando a lista de *schemas* for salva.
|
|
828
|
-
*/
|
|
829
|
-
PoSchemaDefinitionService.prototype.saveAll = function (schemas) {
|
|
830
|
-
return this.poStorage.set(PoSchemaUtil.syncSchemasName, schemas);
|
|
831
|
-
};
|
|
832
|
-
/**
|
|
833
|
-
* Atualiza um *schema* a partir do *schema name*.
|
|
834
|
-
*
|
|
835
|
-
* @param {PoSyncSchema} updatedSchema **Schema* que será atualizado.
|
|
836
|
-
*/
|
|
837
|
-
PoSchemaDefinitionService.prototype.update = function (updatedSchema) {
|
|
838
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
839
|
-
var schemas, replaceUpdatedSchema;
|
|
840
|
-
return __generator(this, function (_a) {
|
|
841
|
-
switch (_a.label) {
|
|
842
|
-
case 0: return [4 /*yield*/, this.getAll()];
|
|
843
|
-
case 1:
|
|
844
|
-
schemas = _a.sent();
|
|
845
|
-
replaceUpdatedSchema = function (schema) {
|
|
846
|
-
if (schema.name === updatedSchema.name) {
|
|
847
|
-
return updatedSchema;
|
|
848
|
-
}
|
|
849
|
-
else {
|
|
850
|
-
return schema;
|
|
851
|
-
}
|
|
852
|
-
};
|
|
853
|
-
schemas = schemas.map(replaceUpdatedSchema);
|
|
854
|
-
return [2 /*return*/, this.saveAll(schemas)];
|
|
855
|
-
}
|
|
856
|
-
});
|
|
857
|
-
});
|
|
858
|
-
};
|
|
859
|
-
return PoSchemaDefinitionService;
|
|
860
|
-
}());
|
|
861
|
-
PoSchemaDefinitionService.decorators = [
|
|
862
|
-
{ type: core.Injectable }
|
|
863
|
-
];
|
|
864
|
-
PoSchemaDefinitionService.ctorParameters = function () { return [
|
|
865
|
-
{ type: ngStorage.PoStorageService }
|
|
866
|
-
]; };
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* @docsPrivate
|
|
870
|
-
*
|
|
871
|
-
* @description
|
|
872
|
-
*
|
|
873
|
-
* Serviço que realiza as operações nos `schemas`.
|
|
874
|
-
*/
|
|
875
|
-
var PoSchemaService = /** @class */ (function () {
|
|
876
|
-
function PoSchemaService(poSchemaDefinitionService, poStorage) {
|
|
877
|
-
this.poSchemaDefinitionService = poSchemaDefinitionService;
|
|
878
|
-
this.poStorage = poStorage;
|
|
879
|
-
}
|
|
880
|
-
/**
|
|
881
|
-
* Retorna o id a partir de uma chave de um *schema*.
|
|
882
|
-
*
|
|
883
|
-
* @param {string} schemaKey Chave do *schema* em que será realizada a busca do id.
|
|
884
|
-
*/
|
|
885
|
-
PoSchemaService.getIdByRecordKey = function (schemaKey) {
|
|
886
|
-
return schemaKey.split(':')[1];
|
|
887
|
-
};
|
|
888
|
-
/**
|
|
889
|
-
* Retorna a chave do *schema* informado.
|
|
890
|
-
*
|
|
891
|
-
* @param {string} schemaName Nome do *schema*.
|
|
892
|
-
* @param {any} recordId Id do registro.
|
|
893
|
-
* @param {boolean} isLocalKey Indica se é uma chave local.
|
|
894
|
-
*/
|
|
895
|
-
PoSchemaService.getRecordKey = function (schemaName, recordId, isLocalKey) {
|
|
896
|
-
if (isLocalKey === void 0) { isLocalKey = false; }
|
|
897
|
-
return isLocalKey ? schemaName + "_local:" + recordId : schemaName + ":" + recordId;
|
|
898
|
-
};
|
|
899
|
-
/**
|
|
900
|
-
* Verifica se o dado informado é uma chave de um *schema*.
|
|
901
|
-
*
|
|
902
|
-
* @param {string} data Dado que será verificado se é uma chave de um *schema*.
|
|
903
|
-
* @param {string} schemaName Nome do *schema*.
|
|
904
|
-
*/
|
|
905
|
-
PoSchemaService.isSchemaKey = function (data, schemaName) {
|
|
906
|
-
return data ? data.startsWith(schemaName + ":") : false;
|
|
907
|
-
};
|
|
908
|
-
/**
|
|
909
|
-
* Cria um novo registro para o *schema* informado.
|
|
910
|
-
*
|
|
911
|
-
* @param {PoSyncSchema} schema **Schema* em que será criado o registro.
|
|
912
|
-
* @param {object} newRecord Registro que será criado.
|
|
913
|
-
*/
|
|
914
|
-
PoSchemaService.prototype.create = function (schema, newRecord) {
|
|
915
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
916
|
-
var id;
|
|
917
|
-
return __generator(this, function (_a) {
|
|
918
|
-
id = PoSchemaUtil.getRecordId(newRecord, schema);
|
|
919
|
-
return [2 /*return*/, this.save(schema, newRecord, id)];
|
|
920
|
-
});
|
|
921
|
-
});
|
|
922
|
-
};
|
|
923
|
-
/**
|
|
924
|
-
* Destrói as chaves do *storage* que contém os registros dos *schemas*.
|
|
925
|
-
*
|
|
926
|
-
* @returns {Promise<void>} Promessa que é resolvida quando as chaves referentes aos *schemas* forem destruídas.
|
|
927
|
-
*/
|
|
928
|
-
PoSchemaService.prototype.destroySchemasRecords = function () {
|
|
929
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
930
|
-
var schemas, storageKeys, _loop_1, this_1, storageKeys_1, storageKeys_1_1, key, e_1_1;
|
|
931
|
-
var e_1, _a;
|
|
932
|
-
return __generator(this, function (_b) {
|
|
933
|
-
switch (_b.label) {
|
|
934
|
-
case 0: return [4 /*yield*/, this.poSchemaDefinitionService.getAll()];
|
|
935
|
-
case 1:
|
|
936
|
-
schemas = _b.sent();
|
|
937
|
-
return [4 /*yield*/, this.poStorage.keys()];
|
|
938
|
-
case 2:
|
|
939
|
-
storageKeys = _b.sent();
|
|
940
|
-
_loop_1 = function (key) {
|
|
941
|
-
var schemaKey, id;
|
|
942
|
-
return __generator(this, function (_c) {
|
|
943
|
-
switch (_c.label) {
|
|
944
|
-
case 0:
|
|
945
|
-
schemaKey = schemas.find(function (schema) { return PoSchemaService.isSchemaKey(key, schema.name); });
|
|
946
|
-
if (!schemaKey) return [3 /*break*/, 2];
|
|
947
|
-
id = PoSchemaService.getIdByRecordKey(key);
|
|
948
|
-
return [4 /*yield*/, this_1.remove(schemaKey.name, id)];
|
|
949
|
-
case 1:
|
|
950
|
-
_c.sent();
|
|
951
|
-
_c.label = 2;
|
|
952
|
-
case 2: return [2 /*return*/];
|
|
953
|
-
}
|
|
954
|
-
});
|
|
955
|
-
};
|
|
956
|
-
this_1 = this;
|
|
957
|
-
_b.label = 3;
|
|
958
|
-
case 3:
|
|
959
|
-
_b.trys.push([3, 8, 9, 10]);
|
|
960
|
-
storageKeys_1 = __values(storageKeys), storageKeys_1_1 = storageKeys_1.next();
|
|
961
|
-
_b.label = 4;
|
|
962
|
-
case 4:
|
|
963
|
-
if (!!storageKeys_1_1.done) return [3 /*break*/, 7];
|
|
964
|
-
key = storageKeys_1_1.value;
|
|
965
|
-
return [5 /*yield**/, _loop_1(key)];
|
|
966
|
-
case 5:
|
|
967
|
-
_b.sent();
|
|
968
|
-
_b.label = 6;
|
|
969
|
-
case 6:
|
|
970
|
-
storageKeys_1_1 = storageKeys_1.next();
|
|
971
|
-
return [3 /*break*/, 4];
|
|
972
|
-
case 7: return [3 /*break*/, 10];
|
|
973
|
-
case 8:
|
|
974
|
-
e_1_1 = _b.sent();
|
|
975
|
-
e_1 = { error: e_1_1 };
|
|
976
|
-
return [3 /*break*/, 10];
|
|
977
|
-
case 9:
|
|
978
|
-
try {
|
|
979
|
-
if (storageKeys_1_1 && !storageKeys_1_1.done && (_a = storageKeys_1.return)) _a.call(storageKeys_1);
|
|
980
|
-
}
|
|
981
|
-
finally { if (e_1) throw e_1.error; }
|
|
982
|
-
return [7 /*endfinally*/];
|
|
983
|
-
case 10: return [2 /*return*/];
|
|
984
|
-
}
|
|
985
|
-
});
|
|
986
|
-
});
|
|
987
|
-
};
|
|
988
|
-
/**
|
|
989
|
-
* Retorna o registro referente ao *schema* informado.
|
|
990
|
-
*
|
|
991
|
-
* @param {string} schemaName Nome do *schema*.
|
|
992
|
-
* @param {any} recordId Id do registro.
|
|
993
|
-
*/
|
|
994
|
-
PoSchemaService.prototype.get = function (schemaName, recordId) {
|
|
995
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
996
|
-
var isLocalRecord, localRecord, record;
|
|
997
|
-
return __generator(this, function (_a) {
|
|
998
|
-
switch (_a.label) {
|
|
999
|
-
case 0:
|
|
1000
|
-
isLocalRecord = true;
|
|
1001
|
-
return [4 /*yield*/, this.getRecord(schemaName, recordId, isLocalRecord)];
|
|
1002
|
-
case 1:
|
|
1003
|
-
localRecord = _a.sent();
|
|
1004
|
-
return [4 /*yield*/, this.getRecord(schemaName, recordId)];
|
|
1005
|
-
case 2:
|
|
1006
|
-
record = _a.sent();
|
|
1007
|
-
return [2 /*return*/, Object.assign(record, localRecord)];
|
|
1008
|
-
}
|
|
1009
|
-
});
|
|
1010
|
-
});
|
|
1011
|
-
};
|
|
1012
|
-
/**
|
|
1013
|
-
* Retorna todos os registros referente ao *schema* informado.
|
|
1014
|
-
*
|
|
1015
|
-
* @param {string} schemaName Nome do *schema*.
|
|
1016
|
-
*/
|
|
1017
|
-
PoSchemaService.prototype.getAll = function (schemaName) {
|
|
1018
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1019
|
-
var storageKeys, schemaRecords, storageKeys_2, storageKeys_2_1, key, id, _a, _b, e_2_1;
|
|
1020
|
-
var e_2, _c;
|
|
1021
|
-
return __generator(this, function (_d) {
|
|
1022
|
-
switch (_d.label) {
|
|
1023
|
-
case 0: return [4 /*yield*/, this.poStorage.keys()];
|
|
1024
|
-
case 1:
|
|
1025
|
-
storageKeys = _d.sent();
|
|
1026
|
-
schemaRecords = [];
|
|
1027
|
-
_d.label = 2;
|
|
1028
|
-
case 2:
|
|
1029
|
-
_d.trys.push([2, 7, 8, 9]);
|
|
1030
|
-
storageKeys_2 = __values(storageKeys), storageKeys_2_1 = storageKeys_2.next();
|
|
1031
|
-
_d.label = 3;
|
|
1032
|
-
case 3:
|
|
1033
|
-
if (!!storageKeys_2_1.done) return [3 /*break*/, 6];
|
|
1034
|
-
key = storageKeys_2_1.value;
|
|
1035
|
-
if (!PoSchemaService.isSchemaKey(key, schemaName)) return [3 /*break*/, 5];
|
|
1036
|
-
id = PoSchemaService.getIdByRecordKey(key);
|
|
1037
|
-
_b = (_a = schemaRecords).push;
|
|
1038
|
-
return [4 /*yield*/, this.get(schemaName, id)];
|
|
1039
|
-
case 4:
|
|
1040
|
-
_b.apply(_a, [_d.sent()]);
|
|
1041
|
-
_d.label = 5;
|
|
1042
|
-
case 5:
|
|
1043
|
-
storageKeys_2_1 = storageKeys_2.next();
|
|
1044
|
-
return [3 /*break*/, 3];
|
|
1045
|
-
case 6: return [3 /*break*/, 9];
|
|
1046
|
-
case 7:
|
|
1047
|
-
e_2_1 = _d.sent();
|
|
1048
|
-
e_2 = { error: e_2_1 };
|
|
1049
|
-
return [3 /*break*/, 9];
|
|
1050
|
-
case 8:
|
|
1051
|
-
try {
|
|
1052
|
-
if (storageKeys_2_1 && !storageKeys_2_1.done && (_c = storageKeys_2.return)) _c.call(storageKeys_2);
|
|
1053
|
-
}
|
|
1054
|
-
finally { if (e_2) throw e_2.error; }
|
|
1055
|
-
return [7 /*endfinally*/];
|
|
1056
|
-
case 9: return [2 /*return*/, schemaRecords];
|
|
1057
|
-
}
|
|
1058
|
-
});
|
|
1059
|
-
});
|
|
1060
|
-
};
|
|
1061
|
-
/**
|
|
1062
|
-
* Aguarda a liberação do recurso limitado, posteriormente o envolve em um comportamento
|
|
1063
|
-
* de bloqueio e desbloqueio.
|
|
1064
|
-
*
|
|
1065
|
-
* @param {Function} limitedResource Função que será envolvida no comportamento de bloqueio e desbloqueio.
|
|
1066
|
-
*/
|
|
1067
|
-
PoSchemaService.prototype.limitedCallWrap = function (limitedResource) {
|
|
1068
|
-
return this.poStorage.limitedCallWrap(limitedResource);
|
|
1069
|
-
};
|
|
1070
|
-
/**
|
|
1071
|
-
* Remove um registro de um *schema* informado.
|
|
1072
|
-
*
|
|
1073
|
-
* @param {string} schemaName Nome do *schema*.
|
|
1074
|
-
* @param {any} recordId Id do registro.
|
|
1075
|
-
*/
|
|
1076
|
-
PoSchemaService.prototype.remove = function (schemaName, recordId) {
|
|
1077
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1078
|
-
var recordKey, localRecordKey;
|
|
1079
|
-
return __generator(this, function (_a) {
|
|
1080
|
-
switch (_a.label) {
|
|
1081
|
-
case 0:
|
|
1082
|
-
recordKey = PoSchemaService.getRecordKey(schemaName, recordId);
|
|
1083
|
-
localRecordKey = PoSchemaService.getRecordKey(schemaName, recordId, true);
|
|
1084
|
-
return [4 /*yield*/, this.poStorage.remove(recordKey)];
|
|
1085
|
-
case 1:
|
|
1086
|
-
_a.sent();
|
|
1087
|
-
return [4 /*yield*/, this.poStorage.remove(localRecordKey)];
|
|
1088
|
-
case 2:
|
|
1089
|
-
_a.sent();
|
|
1090
|
-
return [2 /*return*/];
|
|
1091
|
-
}
|
|
1092
|
-
});
|
|
1093
|
-
});
|
|
1094
|
-
};
|
|
1095
|
-
/**
|
|
1096
|
-
* Atualiza um registro de um *schema* informado.
|
|
1097
|
-
*
|
|
1098
|
-
* @param {PoSyncSchema} schema **Schema* referente ao registro que será alterado.
|
|
1099
|
-
* @param {object} record Registro que será atualizado.
|
|
1100
|
-
* @param {any} recordId Id do registro que deseja ser alterado. Deve ser utilizado em casos em que o id foi alterado.
|
|
1101
|
-
*/
|
|
1102
|
-
PoSchemaService.prototype.update = function (schema, record, recordId) {
|
|
1103
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1104
|
-
var id;
|
|
1105
|
-
return __generator(this, function (_a) {
|
|
1106
|
-
switch (_a.label) {
|
|
1107
|
-
case 0:
|
|
1108
|
-
id = PoSchemaUtil.getRecordId(record, schema);
|
|
1109
|
-
if (!recordId) return [3 /*break*/, 2];
|
|
1110
|
-
return [4 /*yield*/, this.updateRecordId(schema.name, record, recordId)];
|
|
1111
|
-
case 1:
|
|
1112
|
-
record = _a.sent();
|
|
1113
|
-
_a.label = 2;
|
|
1114
|
-
case 2: return [2 /*return*/, this.save(schema, record, id)];
|
|
1115
|
-
}
|
|
1116
|
-
});
|
|
1117
|
-
});
|
|
1118
|
-
};
|
|
1119
|
-
/**
|
|
1120
|
-
* Atualiza todos os registros de um *schema*.
|
|
1121
|
-
*
|
|
1122
|
-
* @param {PoSyncSchema} schema **Schema* referente aos registros que serão alterados.
|
|
1123
|
-
* @param {Array<object>} records Lista de registros que serão alterados.
|
|
1124
|
-
*/
|
|
1125
|
-
PoSchemaService.prototype.updateAll = function (schema, records) {
|
|
1126
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1127
|
-
var records_1, records_1_1, record, e_3_1;
|
|
1128
|
-
var e_3, _a;
|
|
1129
|
-
return __generator(this, function (_b) {
|
|
1130
|
-
switch (_b.label) {
|
|
1131
|
-
case 0:
|
|
1132
|
-
_b.trys.push([0, 5, 6, 7]);
|
|
1133
|
-
records_1 = __values(records), records_1_1 = records_1.next();
|
|
1134
|
-
_b.label = 1;
|
|
1135
|
-
case 1:
|
|
1136
|
-
if (!!records_1_1.done) return [3 /*break*/, 4];
|
|
1137
|
-
record = records_1_1.value;
|
|
1138
|
-
return [4 /*yield*/, this.update(schema, record)];
|
|
1139
|
-
case 2:
|
|
1140
|
-
_b.sent();
|
|
1141
|
-
_b.label = 3;
|
|
1142
|
-
case 3:
|
|
1143
|
-
records_1_1 = records_1.next();
|
|
1144
|
-
return [3 /*break*/, 1];
|
|
1145
|
-
case 4: return [3 /*break*/, 7];
|
|
1146
|
-
case 5:
|
|
1147
|
-
e_3_1 = _b.sent();
|
|
1148
|
-
e_3 = { error: e_3_1 };
|
|
1149
|
-
return [3 /*break*/, 7];
|
|
1150
|
-
case 6:
|
|
1151
|
-
try {
|
|
1152
|
-
if (records_1_1 && !records_1_1.done && (_a = records_1.return)) _a.call(records_1);
|
|
1153
|
-
}
|
|
1154
|
-
finally { if (e_3) throw e_3.error; }
|
|
1155
|
-
return [7 /*endfinally*/];
|
|
1156
|
-
case 7: return [2 /*return*/];
|
|
1157
|
-
}
|
|
1158
|
-
});
|
|
1159
|
-
});
|
|
1160
|
-
};
|
|
1161
|
-
PoSchemaService.prototype.getRecord = function (schemaName, recordId, isLocalRecord) {
|
|
1162
|
-
if (isLocalRecord === void 0) { isLocalRecord = false; }
|
|
1163
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1164
|
-
return __generator(this, function (_a) {
|
|
1165
|
-
switch (_a.label) {
|
|
1166
|
-
case 0: return [4 /*yield*/, this.poStorage.get(PoSchemaService.getRecordKey(schemaName, recordId, isLocalRecord))];
|
|
1167
|
-
case 1: return [2 /*return*/, (_a.sent()) || {}];
|
|
1168
|
-
}
|
|
1169
|
-
});
|
|
1170
|
-
});
|
|
1171
|
-
};
|
|
1172
|
-
PoSchemaService.prototype.save = function (schema, record, recordId) {
|
|
1173
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1174
|
-
var _a, serverRecord, localRecord, recordKey;
|
|
1175
|
-
return __generator(this, function (_b) {
|
|
1176
|
-
switch (_b.label) {
|
|
1177
|
-
case 0:
|
|
1178
|
-
_a = PoSchemaUtil.separateSchemaFields(schema, record), serverRecord = _a.serverRecord, localRecord = _a.localRecord;
|
|
1179
|
-
recordKey = PoSchemaService.getRecordKey(schema.name, recordId);
|
|
1180
|
-
return [4 /*yield*/, this.poStorage.set(recordKey, serverRecord)];
|
|
1181
|
-
case 1:
|
|
1182
|
-
_b.sent();
|
|
1183
|
-
return [4 /*yield*/, this.saveLocalFields(schema.name, localRecord, recordId)];
|
|
1184
|
-
case 2:
|
|
1185
|
-
_b.sent();
|
|
1186
|
-
return [2 /*return*/, record];
|
|
1187
|
-
}
|
|
1188
|
-
});
|
|
1189
|
-
});
|
|
1190
|
-
};
|
|
1191
|
-
PoSchemaService.prototype.saveLocalFields = function (schemaName, localFields, recordId) {
|
|
1192
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1193
|
-
var containsLocalFields, localRecordKey;
|
|
1194
|
-
return __generator(this, function (_a) {
|
|
1195
|
-
switch (_a.label) {
|
|
1196
|
-
case 0:
|
|
1197
|
-
containsLocalFields = Object.keys(localFields).length;
|
|
1198
|
-
if (!containsLocalFields) return [3 /*break*/, 2];
|
|
1199
|
-
localRecordKey = PoSchemaService.getRecordKey(schemaName, recordId, true);
|
|
1200
|
-
return [4 /*yield*/, this.poStorage.set(localRecordKey, localFields)];
|
|
1201
|
-
case 1:
|
|
1202
|
-
_a.sent();
|
|
1203
|
-
_a.label = 2;
|
|
1204
|
-
case 2: return [2 /*return*/];
|
|
1205
|
-
}
|
|
1206
|
-
});
|
|
1207
|
-
});
|
|
1208
|
-
};
|
|
1209
|
-
PoSchemaService.prototype.updateRecordId = function (schemaName, record, recordId) {
|
|
1210
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1211
|
-
var isLocalRecord, localRecord;
|
|
1212
|
-
return __generator(this, function (_a) {
|
|
1213
|
-
switch (_a.label) {
|
|
1214
|
-
case 0:
|
|
1215
|
-
isLocalRecord = true;
|
|
1216
|
-
return [4 /*yield*/, this.getRecord(schemaName, recordId, isLocalRecord)];
|
|
1217
|
-
case 1:
|
|
1218
|
-
localRecord = _a.sent();
|
|
1219
|
-
return [4 /*yield*/, this.remove(schemaName, recordId)];
|
|
1220
|
-
case 2:
|
|
1221
|
-
_a.sent();
|
|
1222
|
-
return [2 /*return*/, Object.assign(record, localRecord)];
|
|
1223
|
-
}
|
|
1224
|
-
});
|
|
1225
|
-
});
|
|
1226
|
-
};
|
|
1227
|
-
return PoSchemaService;
|
|
1228
|
-
}());
|
|
1229
|
-
PoSchemaService.decorators = [
|
|
1230
|
-
{ type: core.Injectable }
|
|
1231
|
-
];
|
|
1232
|
-
PoSchemaService.ctorParameters = function () { return [
|
|
1233
|
-
{ type: PoSchemaDefinitionService },
|
|
1234
|
-
{ type: ngStorage.PoStorageService }
|
|
1235
|
-
]; };
|
|
1236
|
-
|
|
1237
|
-
var PoEventSourcingService = /** @class */ (function () {
|
|
1238
|
-
function PoEventSourcingService(poSchemaDefinition, poSchemaService, poStorage, poHttpClient) {
|
|
1239
|
-
this.poSchemaDefinition = poSchemaDefinition;
|
|
1240
|
-
this.poSchemaService = poSchemaService;
|
|
1241
|
-
this.poStorage = poStorage;
|
|
1242
|
-
this.poHttpClient = poHttpClient;
|
|
1243
|
-
this.stoppedQueueEventSourcing = false;
|
|
1244
|
-
this.responseSubject = new rxjs.Subject();
|
|
1245
|
-
this.schemasSyncConfig = {};
|
|
1246
|
-
}
|
|
1247
|
-
PoEventSourcingService.getUrl = function (eventSourcingItem, schema, requestType) {
|
|
1248
|
-
var schemaUrl = PoSchemaUtil.getUrl(schema, requestType);
|
|
1249
|
-
var schemaId = eventSourcingItem.record[schema.idField];
|
|
1250
|
-
if (requestType === PoRequestType.GET) {
|
|
1251
|
-
return schemaUrl;
|
|
1252
|
-
}
|
|
1253
|
-
if ([PoRequestType.DELETE, PoRequestType.PATCH].includes(requestType)) {
|
|
1254
|
-
return schemaUrl ? schemaUrl + "/" + schemaId : PoSchemaUtil.getUrl(schema, PoRequestType.GET) + "/" + schemaId;
|
|
1255
|
-
}
|
|
1256
|
-
if (requestType === PoRequestType.POST) {
|
|
1257
|
-
return schemaUrl ? schemaUrl : PoSchemaUtil.getUrl(schema, PoRequestType.GET);
|
|
1258
|
-
}
|
|
1259
|
-
};
|
|
1260
|
-
PoEventSourcingService.prototype.create = function (schemaName, newItem, customRequestId) {
|
|
1261
|
-
var eventSourcingItem = this.createEventSourcingItem(PoEventSourcingOperation.Insert, newItem, schemaName, customRequestId);
|
|
1262
|
-
return this.insertEventSourcingQueue(eventSourcingItem);
|
|
1263
|
-
};
|
|
1264
|
-
PoEventSourcingService.prototype.createBatchEvents = function (schemaName, eventList) {
|
|
1265
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1266
|
-
var eventSourcingList;
|
|
1267
|
-
return __generator(this, function (_b) {
|
|
1268
|
-
switch (_b.label) {
|
|
1269
|
-
case 0:
|
|
1270
|
-
eventSourcingList = this.createEventSourcingList(schemaName, eventList);
|
|
1271
|
-
return [4 /*yield*/, this.poStorage.appendArrayToArray(PoEventSourcingService.event_sourcing_name, eventSourcingList)];
|
|
1272
|
-
case 1:
|
|
1273
|
-
_b.sent();
|
|
1274
|
-
this.notifyEventCreation();
|
|
1275
|
-
return [2 /*return*/];
|
|
1276
|
-
}
|
|
1277
|
-
});
|
|
1278
|
-
});
|
|
1279
|
-
};
|
|
1280
|
-
/**
|
|
1281
|
-
* Destrói a chave do *storage* que contém a fila de dados que estão esperando para serem enviados ao
|
|
1282
|
-
* servidor *(EventSourcing)*.
|
|
1283
|
-
*
|
|
1284
|
-
* @returns {Promise<void>} Promessa que é resolvida quando a chave referente a fila de *EventSourcing* for destruída.
|
|
1285
|
-
*/
|
|
1286
|
-
PoEventSourcingService.prototype.destroyEventSourcingQueue = function () {
|
|
1287
|
-
return this.poStorage.remove(PoEventSourcingService.event_sourcing_name);
|
|
1288
|
-
};
|
|
1289
|
-
PoEventSourcingService.prototype.httpCommand = function (httpOperationData, customRequestId) {
|
|
1290
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1291
|
-
var eventSourcingItem;
|
|
1292
|
-
return __generator(this, function (_b) {
|
|
1293
|
-
switch (_b.label) {
|
|
1294
|
-
case 0: return [4 /*yield*/, this.serializeBody(httpOperationData)];
|
|
1295
|
-
case 1:
|
|
1296
|
-
httpOperationData = _b.sent();
|
|
1297
|
-
eventSourcingItem = this.createEventSourcingItem(PoEventSourcingOperation.Http, httpOperationData, undefined, customRequestId);
|
|
1298
|
-
return [4 /*yield*/, this.insertEventSourcingQueue(eventSourcingItem)];
|
|
1299
|
-
case 2:
|
|
1300
|
-
_b.sent();
|
|
1301
|
-
return [2 /*return*/, eventSourcingItem.id];
|
|
1302
|
-
}
|
|
1303
|
-
});
|
|
1304
|
-
});
|
|
1305
|
-
};
|
|
1306
|
-
PoEventSourcingService.prototype.responsesSubject = function () {
|
|
1307
|
-
return this.responseSubject.asObservable();
|
|
1308
|
-
};
|
|
1309
|
-
PoEventSourcingService.prototype.onSaveData = function () {
|
|
1310
|
-
var _this = this;
|
|
1311
|
-
if (!this.eventSub) {
|
|
1312
|
-
this.eventSub = rxjs.Observable.create(function (subscriber) { return (_this.emitter = subscriber); });
|
|
1313
|
-
}
|
|
1314
|
-
return this.eventSub;
|
|
1315
|
-
};
|
|
1316
|
-
PoEventSourcingService.prototype.remove = function (schemaName, itemToDelete, customRequestId) {
|
|
1317
|
-
var eventSourcingItem = this.createEventSourcingItem(PoEventSourcingOperation.Delete, itemToDelete, schemaName, customRequestId);
|
|
1318
|
-
return this.insertEventSourcingQueue(eventSourcingItem);
|
|
1319
|
-
};
|
|
1320
|
-
PoEventSourcingService.prototype.removeEventSourcingItem = function (idEventSourcingItem) {
|
|
1321
|
-
return this.poStorage.removeItemFromArray(PoEventSourcingService.event_sourcing_name, 'id', idEventSourcingItem);
|
|
1322
|
-
};
|
|
1323
|
-
PoEventSourcingService.prototype.syncGet = function () {
|
|
1324
|
-
var _this = this;
|
|
1325
|
-
var syncGetFunction = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1326
|
-
var _this = this;
|
|
1327
|
-
return __generator(this, function (_b) {
|
|
1328
|
-
return [2 /*return*/, this.poSchemaDefinition.getAll().then(function (schemas) {
|
|
1329
|
-
var schemaPromises = _this.updateStorageSchemas(schemas);
|
|
1330
|
-
return Promise.all(schemaPromises);
|
|
1331
|
-
})];
|
|
1332
|
-
});
|
|
1333
|
-
}); };
|
|
1334
|
-
return this.poSchemaService.limitedCallWrap(syncGetFunction);
|
|
1335
|
-
};
|
|
1336
|
-
PoEventSourcingService.prototype.syncSend = function () {
|
|
1337
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1338
|
-
var syncSendFunction;
|
|
1339
|
-
var _this = this;
|
|
1340
|
-
return __generator(this, function (_b) {
|
|
1341
|
-
syncSendFunction = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1342
|
-
var itemOfQueue;
|
|
1343
|
-
return __generator(this, function (_b) {
|
|
1344
|
-
switch (_b.label) {
|
|
1345
|
-
case 0: return [4 /*yield*/, this.poStorage.getFirstItem(PoEventSourcingService.event_sourcing_name)];
|
|
1346
|
-
case 1:
|
|
1347
|
-
itemOfQueue = _b.sent();
|
|
1348
|
-
if (!itemOfQueue) return [3 /*break*/, 3];
|
|
1349
|
-
return [4 /*yield*/, this.selectOperation(itemOfQueue)];
|
|
1350
|
-
case 2:
|
|
1351
|
-
_b.sent();
|
|
1352
|
-
_b.label = 3;
|
|
1353
|
-
case 3:
|
|
1354
|
-
if (this.stoppedQueueEventSourcing || !itemOfQueue) {
|
|
1355
|
-
this.stoppedQueueEventSourcing = false;
|
|
1356
|
-
return [2 /*return*/, Promise.resolve()];
|
|
1357
|
-
}
|
|
1358
|
-
return [2 /*return*/, syncSendFunction()];
|
|
1359
|
-
}
|
|
1360
|
-
});
|
|
1361
|
-
}); };
|
|
1362
|
-
return [2 /*return*/, this.poSchemaService.limitedCallWrap(syncSendFunction)];
|
|
1363
|
-
});
|
|
1364
|
-
});
|
|
1365
|
-
};
|
|
1366
|
-
PoEventSourcingService.prototype.update = function (schemaName, itemUpdated, customRequestId) {
|
|
1367
|
-
var eventSourcingItem = this.createEventSourcingItem(PoEventSourcingOperation.Update, itemUpdated, schemaName, customRequestId);
|
|
1368
|
-
return this.insertEventSourcingQueue(eventSourcingItem);
|
|
1369
|
-
};
|
|
1370
|
-
/* Avalia se o body é do tipo File e se for converte para base64 */
|
|
1371
|
-
PoEventSourcingService.prototype.serializeBody = function (requestData) {
|
|
1372
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1373
|
-
var body, mimeType, bodyType, fileName;
|
|
1374
|
-
return __generator(this, function (_b) {
|
|
1375
|
-
switch (_b.label) {
|
|
1376
|
-
case 0:
|
|
1377
|
-
body = requestData.body, mimeType = requestData.mimeType, bodyType = requestData.bodyType, fileName = requestData.fileName;
|
|
1378
|
-
if (!(body instanceof File)) return [3 /*break*/, 2];
|
|
1379
|
-
bodyType = 'File';
|
|
1380
|
-
mimeType = body.type;
|
|
1381
|
-
fileName = body.name;
|
|
1382
|
-
return [4 /*yield*/, toBase64(body)];
|
|
1383
|
-
case 1:
|
|
1384
|
-
body = _b.sent();
|
|
1385
|
-
_b.label = 2;
|
|
1386
|
-
case 2: return [2 /*return*/, Object.assign(Object.assign({}, requestData), { body: body, mimeType: mimeType, bodyType: bodyType, fileName: fileName })];
|
|
1387
|
-
}
|
|
1388
|
-
});
|
|
1389
|
-
});
|
|
1390
|
-
};
|
|
1391
|
-
PoEventSourcingService.prototype.buildUrlParams = function (schema, baseUrl, pageNumber) {
|
|
1392
|
-
var params = [];
|
|
1393
|
-
params.push(this.config.dataTransform.getPageSizeParamName() + "=" + schema.pageSize);
|
|
1394
|
-
params.push(this.config.dataTransform.getPageParamName() + "=" + pageNumber);
|
|
1395
|
-
return baseUrl + "?" + params.join('&');
|
|
1396
|
-
};
|
|
1397
|
-
PoEventSourcingService.prototype.checkRecordIdExists = function (recordId, operation) {
|
|
1398
|
-
if (!recordId) {
|
|
1399
|
-
var error = {
|
|
1400
|
-
message: 'Identifier not defined',
|
|
1401
|
-
operation: operation
|
|
1402
|
-
};
|
|
1403
|
-
throw new PoEventSourcingErrorResponse(error);
|
|
1404
|
-
}
|
|
1405
|
-
};
|
|
1406
|
-
PoEventSourcingService.prototype.concatPageItems = function (pageAcumulator, requestBody) {
|
|
1407
|
-
if (requestBody[this.config.dataTransform.getItemsFieldName()]) {
|
|
1408
|
-
pageAcumulator.data = __spreadArray(__spreadArray([], __read(pageAcumulator.data)), __read(requestBody[this.config.dataTransform.getItemsFieldName()]));
|
|
1409
|
-
}
|
|
1410
|
-
return pageAcumulator;
|
|
1411
|
-
};
|
|
1412
|
-
PoEventSourcingService.prototype.createEventSourcingItem = function (operation, newItem, schemaName, customRequestId, id) {
|
|
1413
|
-
if (!schemaName && operation !== PoEventSourcingOperation.Http) {
|
|
1414
|
-
throw new Error('PoSyncSchema is not defined.');
|
|
1415
|
-
}
|
|
1416
|
-
return {
|
|
1417
|
-
id: id ? id : new Date().getTime(),
|
|
1418
|
-
dateTime: new Date().getTime(),
|
|
1419
|
-
schema: schemaName,
|
|
1420
|
-
operation: operation,
|
|
1421
|
-
record: newItem,
|
|
1422
|
-
customRequestId: customRequestId
|
|
1423
|
-
};
|
|
1424
|
-
};
|
|
1425
|
-
PoEventSourcingService.prototype.createEventSourcingList = function (schemaName, eventList) {
|
|
1426
|
-
var _this = this;
|
|
1427
|
-
return eventList.map(function (eventItem, index) {
|
|
1428
|
-
var id = new Date().getTime() + index;
|
|
1429
|
-
return _this.createEventSourcingItem(eventItem.operation, eventItem.record, schemaName, eventItem.customRequestId, id);
|
|
1430
|
-
});
|
|
1431
|
-
};
|
|
1432
|
-
PoEventSourcingService.prototype.createSchemaSyncConfig = function (schemaName) {
|
|
1433
|
-
this.schemasSyncConfig[schemaName] = {
|
|
1434
|
-
page: undefined,
|
|
1435
|
-
currentUrlDiff: undefined,
|
|
1436
|
-
responseDate: undefined
|
|
1437
|
-
};
|
|
1438
|
-
};
|
|
1439
|
-
PoEventSourcingService.prototype.deleteOperation = function (eventSourcingItem) {
|
|
1440
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1441
|
-
var schema, recordId, url, response, errorResponse_1;
|
|
1442
|
-
return __generator(this, function (_b) {
|
|
1443
|
-
switch (_b.label) {
|
|
1444
|
-
case 0:
|
|
1445
|
-
_b.trys.push([0, 5, , 6]);
|
|
1446
|
-
return [4 /*yield*/, this.poSchemaDefinition.get(eventSourcingItem.schema)];
|
|
1447
|
-
case 1:
|
|
1448
|
-
schema = _b.sent();
|
|
1449
|
-
recordId = eventSourcingItem.record[schema.idField];
|
|
1450
|
-
this.checkRecordIdExists(recordId, PoEventSourcingOperation.Delete);
|
|
1451
|
-
url = PoEventSourcingService.getUrl(eventSourcingItem, schema, PoRequestType.DELETE);
|
|
1452
|
-
return [4 /*yield*/, this.sendServerItem(url, exports.PoHttpRequestType.DELETE)];
|
|
1453
|
-
case 2:
|
|
1454
|
-
response = _b.sent();
|
|
1455
|
-
return [4 /*yield*/, this.removeEventSourcingValidItem(response.status, eventSourcingItem)];
|
|
1456
|
-
case 3:
|
|
1457
|
-
_b.sent();
|
|
1458
|
-
return [4 /*yield*/, this.sendResponseSubject(eventSourcingItem, response)];
|
|
1459
|
-
case 4: return [2 /*return*/, _b.sent()];
|
|
1460
|
-
case 5:
|
|
1461
|
-
errorResponse_1 = _b.sent();
|
|
1462
|
-
return [2 /*return*/, this.sendResponseSubject(eventSourcingItem, errorResponse_1, true)];
|
|
1463
|
-
case 6: return [2 /*return*/];
|
|
1464
|
-
}
|
|
1465
|
-
});
|
|
1466
|
-
});
|
|
1467
|
-
};
|
|
1468
|
-
PoEventSourcingService.prototype.diffServerItems = function (currentUrlDiff) {
|
|
1469
|
-
return this.poHttpClient.get(currentUrlDiff);
|
|
1470
|
-
};
|
|
1471
|
-
PoEventSourcingService.prototype.getBodyAndDate = function (schemaName, response) {
|
|
1472
|
-
var getDateFieldName = this.config.dataTransform.getDateFieldName();
|
|
1473
|
-
var responseSyncDate = response.body[getDateFieldName];
|
|
1474
|
-
this.schemasSyncConfig[schemaName]['responseDate'] = responseSyncDate;
|
|
1475
|
-
return response.body;
|
|
1476
|
-
};
|
|
1477
|
-
PoEventSourcingService.prototype.getServerDiffRecords = function (schema, baseUrl) {
|
|
1478
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1479
|
-
var initialAcumulatorPage, diffUrl, serverResponse;
|
|
1480
|
-
var _this = this;
|
|
1481
|
-
return __generator(this, function (_b) {
|
|
1482
|
-
switch (_b.label) {
|
|
1483
|
-
case 0:
|
|
1484
|
-
initialAcumulatorPage = { entity: schema.name, data: [] };
|
|
1485
|
-
diffUrl = this.schemasSyncConfig[schema.name]['currentUrlDiff'];
|
|
1486
|
-
return [4 /*yield*/, this.diffServerItems(diffUrl)
|
|
1487
|
-
.pipe(operators.map(function (response) { return _this.getBodyAndDate(schema.name, response); }), operators.expand(function (data) { return _this.paginateSchemaData(data, schema, baseUrl); }), operators.reduce(function (pageAcumulator, requestBody) { return _this.concatPageItems(pageAcumulator, requestBody); }, initialAcumulatorPage))
|
|
1488
|
-
.toPromise()];
|
|
1489
|
-
case 1:
|
|
1490
|
-
serverResponse = _b.sent();
|
|
1491
|
-
return [2 /*return*/, serverResponse.data];
|
|
1492
|
-
}
|
|
1493
|
-
});
|
|
1494
|
-
});
|
|
1495
|
-
};
|
|
1496
|
-
PoEventSourcingService.prototype.httpOperation = function (eventSourcingItem) {
|
|
1497
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1498
|
-
var requestData, response, poHttpCommandResponse, errorHttpClient_1;
|
|
1499
|
-
return __generator(this, function (_b) {
|
|
1500
|
-
switch (_b.label) {
|
|
1501
|
-
case 0:
|
|
1502
|
-
_b.trys.push([0, 3, , 4]);
|
|
1503
|
-
return [4 /*yield*/, this.createPoHttpRequestData(eventSourcingItem.record.url, eventSourcingItem.record.method, eventSourcingItem.record, eventSourcingItem.record.headers)];
|
|
1504
|
-
case 1:
|
|
1505
|
-
requestData = _b.sent();
|
|
1506
|
-
return [4 /*yield*/, this.poHttpClient.createRequest(requestData).toPromise()];
|
|
1507
|
-
case 2:
|
|
1508
|
-
response = _b.sent();
|
|
1509
|
-
poHttpCommandResponse = {
|
|
1510
|
-
id: eventSourcingItem.id,
|
|
1511
|
-
customRequestId: eventSourcingItem.customRequestId,
|
|
1512
|
-
request: eventSourcingItem.record,
|
|
1513
|
-
response: response
|
|
1514
|
-
};
|
|
1515
|
-
this.responseSubject.next(poHttpCommandResponse);
|
|
1516
|
-
return [2 /*return*/, this.removeEventSourcingValidItem(response.status, eventSourcingItem)];
|
|
1517
|
-
case 3:
|
|
1518
|
-
errorHttpClient_1 = _b.sent();
|
|
1519
|
-
return [2 /*return*/, this.sendResponseSubject(eventSourcingItem, errorHttpClient_1, true)];
|
|
1520
|
-
case 4: return [2 /*return*/];
|
|
1521
|
-
}
|
|
1522
|
-
});
|
|
1523
|
-
});
|
|
1524
|
-
};
|
|
1525
|
-
PoEventSourcingService.prototype.insertEventSourcingQueue = function (eventSourcingItem) {
|
|
1526
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1527
|
-
var eventSourcingUpdatedQueue;
|
|
1528
|
-
return __generator(this, function (_b) {
|
|
1529
|
-
switch (_b.label) {
|
|
1530
|
-
case 0: return [4 /*yield*/, this.poStorage.appendItemToArray(PoEventSourcingService.event_sourcing_name, eventSourcingItem)];
|
|
1531
|
-
case 1:
|
|
1532
|
-
eventSourcingUpdatedQueue = _b.sent();
|
|
1533
|
-
this.notifyEventCreation();
|
|
1534
|
-
return [2 /*return*/, Promise.resolve(eventSourcingUpdatedQueue)];
|
|
1535
|
-
}
|
|
1536
|
-
});
|
|
1537
|
-
});
|
|
1538
|
-
};
|
|
1539
|
-
PoEventSourcingService.prototype.insertOperation = function (currentEventSourcingItem) {
|
|
1540
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1541
|
-
var schema, url, response, recordUpdatedByServer, id, eventSourcingItems, errorHttpClient_2;
|
|
1542
|
-
return __generator(this, function (_b) {
|
|
1543
|
-
switch (_b.label) {
|
|
1544
|
-
case 0: return [4 /*yield*/, this.poSchemaDefinition.get(currentEventSourcingItem.schema)];
|
|
1545
|
-
case 1:
|
|
1546
|
-
schema = _b.sent();
|
|
1547
|
-
url = PoEventSourcingService.getUrl(currentEventSourcingItem, schema, PoRequestType.POST);
|
|
1548
|
-
_b.label = 2;
|
|
1549
|
-
case 2:
|
|
1550
|
-
_b.trys.push([2, 8, , 9]);
|
|
1551
|
-
return [4 /*yield*/, this.sendServerItem(url, exports.PoHttpRequestType.POST, currentEventSourcingItem.record)];
|
|
1552
|
-
case 3:
|
|
1553
|
-
response = _b.sent();
|
|
1554
|
-
recordUpdatedByServer = response.body;
|
|
1555
|
-
return [4 /*yield*/, this.removeEventSourcingValidItem(response.status, currentEventSourcingItem)];
|
|
1556
|
-
case 4:
|
|
1557
|
-
_b.sent();
|
|
1558
|
-
id = currentEventSourcingItem.record[PoSchemaUtil.syncInternalIdFieldName];
|
|
1559
|
-
return [4 /*yield*/, this.poSchemaService.update(schema, recordUpdatedByServer, id)];
|
|
1560
|
-
case 5:
|
|
1561
|
-
_b.sent();
|
|
1562
|
-
return [4 /*yield*/, this.poStorage.get(PoEventSourcingService.event_sourcing_name)];
|
|
1563
|
-
case 6:
|
|
1564
|
-
eventSourcingItems = _b.sent();
|
|
1565
|
-
return [4 /*yield*/, this.updatePendingEventSourcing(currentEventSourcingItem, schema.idField, recordUpdatedByServer, eventSourcingItems)];
|
|
1566
|
-
case 7:
|
|
1567
|
-
_b.sent();
|
|
1568
|
-
return [2 /*return*/, this.sendResponseSubject(currentEventSourcingItem, response)];
|
|
1569
|
-
case 8:
|
|
1570
|
-
errorHttpClient_2 = _b.sent();
|
|
1571
|
-
return [2 /*return*/, this.sendResponseSubject(currentEventSourcingItem, errorHttpClient_2, true)];
|
|
1572
|
-
case 9: return [2 /*return*/];
|
|
1573
|
-
}
|
|
1574
|
-
});
|
|
1575
|
-
});
|
|
1576
|
-
};
|
|
1577
|
-
PoEventSourcingService.prototype.isValidStatus = function (status) {
|
|
1578
|
-
return PoEventSourcingService.VALID_HTTP_STATUS_CODES.includes(status);
|
|
1579
|
-
};
|
|
1580
|
-
PoEventSourcingService.prototype.notifyEventCreation = function () {
|
|
1581
|
-
if (this.emitter) {
|
|
1582
|
-
this.emitter.next();
|
|
1583
|
-
}
|
|
1584
|
-
};
|
|
1585
|
-
PoEventSourcingService.prototype.paginateSchemaData = function (data, schema, baseUrl) {
|
|
1586
|
-
var _this = this;
|
|
1587
|
-
this.config.dataTransform.transform(data);
|
|
1588
|
-
if (this.config.dataTransform.hasNext()) {
|
|
1589
|
-
this.schemasSyncConfig[schema.name]['currentUrlDiff'] = this.buildUrlParams(schema, baseUrl, ++this.schemasSyncConfig[schema.name]['page']);
|
|
1590
|
-
return this.diffServerItems(this.schemasSyncConfig[schema.name]['currentUrlDiff']).pipe(operators.map(function (response) { return _this.getBodyAndDate(schema.name, response); }));
|
|
1591
|
-
}
|
|
1592
|
-
return rxjs.of();
|
|
1593
|
-
};
|
|
1594
|
-
PoEventSourcingService.prototype.removeEventSourcingValidItem = function (status, eventSourcingItem) {
|
|
1595
|
-
if (this.isValidStatus(status) || eventSourcingItem.operation === PoEventSourcingOperation.Http) {
|
|
1596
|
-
return this.removeEventSourcingItem(eventSourcingItem.id);
|
|
1597
|
-
}
|
|
1598
|
-
};
|
|
1599
|
-
PoEventSourcingService.prototype.selectOperation = function (eventSourcingItem) {
|
|
1600
|
-
switch (eventSourcingItem.operation) {
|
|
1601
|
-
case PoEventSourcingOperation.Insert:
|
|
1602
|
-
return this.insertOperation(eventSourcingItem);
|
|
1603
|
-
case PoEventSourcingOperation.Update:
|
|
1604
|
-
return this.updateOperation(eventSourcingItem);
|
|
1605
|
-
case PoEventSourcingOperation.Delete:
|
|
1606
|
-
return this.deleteOperation(eventSourcingItem);
|
|
1607
|
-
case PoEventSourcingOperation.Http:
|
|
1608
|
-
return this.httpOperation(eventSourcingItem);
|
|
1609
|
-
}
|
|
1610
|
-
};
|
|
1611
|
-
PoEventSourcingService.prototype.sendResponseSubject = function (eventSourcingItem, response, isSubjectError) {
|
|
1612
|
-
if (isSubjectError === void 0) { isSubjectError = false; }
|
|
1613
|
-
var poSyncResponse = {
|
|
1614
|
-
id: eventSourcingItem.id,
|
|
1615
|
-
customRequestId: eventSourcingItem.customRequestId,
|
|
1616
|
-
request: eventSourcingItem.record,
|
|
1617
|
-
response: response
|
|
1618
|
-
};
|
|
1619
|
-
this.stoppedQueueEventSourcing = isSubjectError;
|
|
1620
|
-
this.responseSubject.next(poSyncResponse);
|
|
1621
|
-
return Promise.resolve();
|
|
1622
|
-
};
|
|
1623
|
-
PoEventSourcingService.prototype.sendServerItem = function (url, method, body) {
|
|
1624
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1625
|
-
var requestData;
|
|
1626
|
-
return __generator(this, function (_b) {
|
|
1627
|
-
switch (_b.label) {
|
|
1628
|
-
case 0: return [4 /*yield*/, this.createPoHttpRequestData(url, method, body)];
|
|
1629
|
-
case 1:
|
|
1630
|
-
requestData = _b.sent();
|
|
1631
|
-
return [2 /*return*/, this.poHttpClient.createRequest(requestData).toPromise()];
|
|
1632
|
-
}
|
|
1633
|
-
});
|
|
1634
|
-
});
|
|
1635
|
-
};
|
|
1636
|
-
PoEventSourcingService.prototype.createPoHttpRequestData = function (url, method, record, headers) {
|
|
1637
|
-
var _a;
|
|
1638
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1639
|
-
var body;
|
|
1640
|
-
return __generator(this, function (_b) {
|
|
1641
|
-
switch (_b.label) {
|
|
1642
|
-
case 0:
|
|
1643
|
-
body = (_a = record.body) !== null && _a !== void 0 ? _a : record;
|
|
1644
|
-
if (!(record.bodyType === 'File')) return [3 /*break*/, 2];
|
|
1645
|
-
return [4 /*yield*/, this.createFormData(body, record.fileName, record.mimeType, record.formField)];
|
|
1646
|
-
case 1:
|
|
1647
|
-
body = _b.sent();
|
|
1648
|
-
_b.label = 2;
|
|
1649
|
-
case 2: return [2 /*return*/, { url: url, method: method, body: body, headers: headers }];
|
|
1650
|
-
}
|
|
1651
|
-
});
|
|
1652
|
-
});
|
|
1653
|
-
};
|
|
1654
|
-
PoEventSourcingService.prototype.createFormData = function (body, fileName, mimeType, formField) {
|
|
1655
|
-
if (formField === void 0) { formField = 'file'; }
|
|
1656
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1657
|
-
var file, formData;
|
|
1658
|
-
return __generator(this, function (_b) {
|
|
1659
|
-
switch (_b.label) {
|
|
1660
|
-
case 0: return [4 /*yield*/, toFile(body, fileName, mimeType)];
|
|
1661
|
-
case 1:
|
|
1662
|
-
file = _b.sent();
|
|
1663
|
-
formData = new FormData();
|
|
1664
|
-
formData.append(formField, file, fileName);
|
|
1665
|
-
return [2 /*return*/, formData];
|
|
1666
|
-
}
|
|
1667
|
-
});
|
|
1668
|
-
});
|
|
1669
|
-
};
|
|
1670
|
-
PoEventSourcingService.prototype.updateOperation = function (eventSourcingItem) {
|
|
1671
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1672
|
-
var schema, url, recordId, response, errorHttpClient_3;
|
|
1673
|
-
return __generator(this, function (_b) {
|
|
1674
|
-
switch (_b.label) {
|
|
1675
|
-
case 0: return [4 /*yield*/, this.poSchemaDefinition.get(eventSourcingItem.schema)];
|
|
1676
|
-
case 1:
|
|
1677
|
-
schema = _b.sent();
|
|
1678
|
-
url = PoEventSourcingService.getUrl(eventSourcingItem, schema, PoRequestType.PATCH);
|
|
1679
|
-
_b.label = 2;
|
|
1680
|
-
case 2:
|
|
1681
|
-
_b.trys.push([2, 6, , 7]);
|
|
1682
|
-
recordId = eventSourcingItem.record[schema.idField];
|
|
1683
|
-
this.checkRecordIdExists(recordId, PoEventSourcingOperation.Update);
|
|
1684
|
-
return [4 /*yield*/, this.sendServerItem(url, exports.PoHttpRequestType.PUT, eventSourcingItem.record)];
|
|
1685
|
-
case 3:
|
|
1686
|
-
response = _b.sent();
|
|
1687
|
-
return [4 /*yield*/, this.removeEventSourcingValidItem(response.status, eventSourcingItem)];
|
|
1688
|
-
case 4:
|
|
1689
|
-
_b.sent();
|
|
1690
|
-
return [4 /*yield*/, this.sendResponseSubject(eventSourcingItem, response)];
|
|
1691
|
-
case 5: return [2 /*return*/, _b.sent()];
|
|
1692
|
-
case 6:
|
|
1693
|
-
errorHttpClient_3 = _b.sent();
|
|
1694
|
-
return [2 /*return*/, this.sendResponseSubject(eventSourcingItem, errorHttpClient_3, true)];
|
|
1695
|
-
case 7: return [2 /*return*/];
|
|
1696
|
-
}
|
|
1697
|
-
});
|
|
1698
|
-
});
|
|
1699
|
-
};
|
|
1700
|
-
PoEventSourcingService.prototype.updatePendingEventSourcing = function (currentEventSourcingItem, idFieldSchema, inserted, eventSourcingItems) {
|
|
1701
|
-
if (currentEventSourcingItem.record[PoSchemaUtil.syncInternalIdFieldName]) {
|
|
1702
|
-
eventSourcingItems.forEach(function (eventSourcingItem, position) {
|
|
1703
|
-
var isCurrentEventSourcingItem = !eventSourcingItem.record[idFieldSchema] &&
|
|
1704
|
-
eventSourcingItem.record[PoSchemaUtil.syncInternalIdFieldName] ===
|
|
1705
|
-
currentEventSourcingItem.record[PoSchemaUtil.syncInternalIdFieldName];
|
|
1706
|
-
if (isCurrentEventSourcingItem) {
|
|
1707
|
-
eventSourcingItems[position].record[idFieldSchema] = inserted[idFieldSchema];
|
|
1708
|
-
}
|
|
1709
|
-
});
|
|
1710
|
-
return this.poStorage.set(PoEventSourcingService.event_sourcing_name, eventSourcingItems);
|
|
1711
|
-
}
|
|
1712
|
-
else {
|
|
1713
|
-
return Promise.resolve();
|
|
1714
|
-
}
|
|
1715
|
-
};
|
|
1716
|
-
PoEventSourcingService.prototype.updateRecords = function (serverRecords, schema) {
|
|
1717
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1718
|
-
var serverRecords_1, serverRecords_1_1, serverRecord, e_1_1;
|
|
1719
|
-
var e_1, _b;
|
|
1720
|
-
return __generator(this, function (_c) {
|
|
1721
|
-
switch (_c.label) {
|
|
1722
|
-
case 0:
|
|
1723
|
-
_c.trys.push([0, 5, 6, 7]);
|
|
1724
|
-
serverRecords_1 = __values(serverRecords), serverRecords_1_1 = serverRecords_1.next();
|
|
1725
|
-
_c.label = 1;
|
|
1726
|
-
case 1:
|
|
1727
|
-
if (!!serverRecords_1_1.done) return [3 /*break*/, 4];
|
|
1728
|
-
serverRecord = serverRecords_1_1.value;
|
|
1729
|
-
return [4 /*yield*/, this.updateRecordByServerRecord(serverRecord, schema)];
|
|
1730
|
-
case 2:
|
|
1731
|
-
_c.sent();
|
|
1732
|
-
_c.label = 3;
|
|
1733
|
-
case 3:
|
|
1734
|
-
serverRecords_1_1 = serverRecords_1.next();
|
|
1735
|
-
return [3 /*break*/, 1];
|
|
1736
|
-
case 4: return [3 /*break*/, 7];
|
|
1737
|
-
case 5:
|
|
1738
|
-
e_1_1 = _c.sent();
|
|
1739
|
-
e_1 = { error: e_1_1 };
|
|
1740
|
-
return [3 /*break*/, 7];
|
|
1741
|
-
case 6:
|
|
1742
|
-
try {
|
|
1743
|
-
if (serverRecords_1_1 && !serverRecords_1_1.done && (_b = serverRecords_1.return)) _b.call(serverRecords_1);
|
|
1744
|
-
}
|
|
1745
|
-
finally { if (e_1) throw e_1.error; }
|
|
1746
|
-
return [7 /*endfinally*/];
|
|
1747
|
-
case 7: return [2 /*return*/];
|
|
1748
|
-
}
|
|
1749
|
-
});
|
|
1750
|
-
});
|
|
1751
|
-
};
|
|
1752
|
-
PoEventSourcingService.prototype.updateRecordByServerRecord = function (serverRecord, schema) {
|
|
1753
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1754
|
-
var recordId, storageRecord, existsStorageRecord;
|
|
1755
|
-
return __generator(this, function (_b) {
|
|
1756
|
-
switch (_b.label) {
|
|
1757
|
-
case 0:
|
|
1758
|
-
recordId = serverRecord[schema.idField];
|
|
1759
|
-
return [4 /*yield*/, this.poSchemaService.get(schema.name, recordId)];
|
|
1760
|
-
case 1:
|
|
1761
|
-
storageRecord = _b.sent();
|
|
1762
|
-
existsStorageRecord = !!Object.keys(storageRecord).length;
|
|
1763
|
-
if (!(existsStorageRecord && serverRecord[schema.deletedField])) return [3 /*break*/, 3];
|
|
1764
|
-
return [4 /*yield*/, this.poSchemaService.remove(schema.name, serverRecord[schema.idField])];
|
|
1765
|
-
case 2: return [2 /*return*/, _b.sent()];
|
|
1766
|
-
case 3:
|
|
1767
|
-
if (!(existsStorageRecord && !serverRecord[schema.deletedField])) return [3 /*break*/, 5];
|
|
1768
|
-
return [4 /*yield*/, this.poSchemaService.update(schema, serverRecord)];
|
|
1769
|
-
case 4: return [2 /*return*/, _b.sent()];
|
|
1770
|
-
case 5:
|
|
1771
|
-
if (!(!existsStorageRecord && !serverRecord[schema.deletedField])) return [3 /*break*/, 7];
|
|
1772
|
-
return [4 /*yield*/, this.poSchemaService.create(schema, serverRecord)];
|
|
1773
|
-
case 6: return [2 /*return*/, _b.sent()];
|
|
1774
|
-
case 7: return [2 /*return*/];
|
|
1775
|
-
}
|
|
1776
|
-
});
|
|
1777
|
-
});
|
|
1778
|
-
};
|
|
1779
|
-
PoEventSourcingService.prototype.updateStorageBySchema = function (schema) {
|
|
1780
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1781
|
-
var baseUrl, serverRecords;
|
|
1782
|
-
return __generator(this, function (_b) {
|
|
1783
|
-
switch (_b.label) {
|
|
1784
|
-
case 0:
|
|
1785
|
-
this.createSchemaSyncConfig(schema.name);
|
|
1786
|
-
this.schemasSyncConfig[schema.name]['page'] = 1;
|
|
1787
|
-
baseUrl = PoSchemaUtil.getUrl(schema, PoRequestType.DIFF) + "/" + schema.lastSync;
|
|
1788
|
-
this.schemasSyncConfig[schema.name]['currentUrlDiff'] = this.buildUrlParams(schema, baseUrl, this.schemasSyncConfig[schema.name]['page']);
|
|
1789
|
-
return [4 /*yield*/, this.getServerDiffRecords(schema, baseUrl)];
|
|
1790
|
-
case 1:
|
|
1791
|
-
serverRecords = _b.sent();
|
|
1792
|
-
return [4 /*yield*/, this.updateRecords(serverRecords, schema)];
|
|
1793
|
-
case 2:
|
|
1794
|
-
_b.sent();
|
|
1795
|
-
schema.lastSync = this.schemasSyncConfig[schema.name]['responseDate'];
|
|
1796
|
-
return [4 /*yield*/, this.poSchemaDefinition.update(schema)];
|
|
1797
|
-
case 3:
|
|
1798
|
-
_b.sent();
|
|
1799
|
-
return [2 /*return*/];
|
|
1800
|
-
}
|
|
1801
|
-
});
|
|
1802
|
-
});
|
|
1803
|
-
};
|
|
1804
|
-
PoEventSourcingService.prototype.updateStorageSchemas = function (schemas) {
|
|
1805
|
-
var _this = this;
|
|
1806
|
-
return schemas.map(function (schema) { return _this.updateStorageBySchema(schema); });
|
|
1807
|
-
};
|
|
1808
|
-
return PoEventSourcingService;
|
|
1809
|
-
}());
|
|
1810
|
-
PoEventSourcingService.event_sourcing_name = 'EventSourcing';
|
|
1811
|
-
PoEventSourcingService.VALID_HTTP_STATUS_CODES = [
|
|
1812
|
-
HttpStatus__namespace.OK,
|
|
1813
|
-
HttpStatus__namespace.CREATED,
|
|
1814
|
-
HttpStatus__namespace.ACCEPTED,
|
|
1815
|
-
HttpStatus__namespace.NON_AUTHORITATIVE_INFORMATION,
|
|
1816
|
-
HttpStatus__namespace.NO_CONTENT,
|
|
1817
|
-
HttpStatus__namespace.RESET_CONTENT,
|
|
1818
|
-
HttpStatus__namespace.PARTIAL_CONTENT,
|
|
1819
|
-
HttpStatus__namespace.MULTI_STATUS // 207
|
|
1820
|
-
];
|
|
1821
|
-
PoEventSourcingService.decorators = [
|
|
1822
|
-
{ type: core.Injectable }
|
|
1823
|
-
];
|
|
1824
|
-
PoEventSourcingService.ctorParameters = function () { return [
|
|
1825
|
-
{ type: PoSchemaDefinitionService },
|
|
1826
|
-
{ type: PoSchemaService },
|
|
1827
|
-
{ type: ngStorage.PoStorageService },
|
|
1828
|
-
{ type: PoHttpClientService }
|
|
1829
|
-
]; };
|
|
1830
|
-
|
|
1831
|
-
/**
|
|
1832
|
-
* @description
|
|
1833
|
-
*
|
|
1834
|
-
* Classe utilitária para construir consultas sobre os registros de um *schema*.
|
|
1835
|
-
*
|
|
1836
|
-
* A utilização dos métodos desta classe é feita a partir do retorno do método `PoEntity.find()`. Por exemplo,
|
|
1837
|
-
* para utilizar o método `PoQueryBuilder.page()`, é necessário:
|
|
1838
|
-
*
|
|
1839
|
-
* ``` typescript
|
|
1840
|
-
* PoSyncService.getModel('schema name').find().page(2).exec();
|
|
1841
|
-
* ```
|
|
1842
|
-
*
|
|
1843
|
-
* O `PoQueryBuilder` foi projetado para que os seus métodos sejam
|
|
1844
|
-
* chamados em cascata e ao final desse encadeamento invocar o método
|
|
1845
|
-
* `PoQueryBuilder.exec()` para que a busca seja concluída. Por exemplo:
|
|
1846
|
-
*
|
|
1847
|
-
* ``` typescript
|
|
1848
|
-
* PoSyncService
|
|
1849
|
-
* .getModel('schema name')
|
|
1850
|
-
* .find()
|
|
1851
|
-
* .page(2)
|
|
1852
|
-
* .pageSize(5)
|
|
1853
|
-
* .sort()
|
|
1854
|
-
* .exec();
|
|
1855
|
-
* ```
|
|
1856
|
-
*/
|
|
1857
|
-
var PoQueryBuilder = /** @class */ (function () {
|
|
1858
|
-
function PoQueryBuilder(poSchemaService, schema) {
|
|
1859
|
-
this.poSchemaService = poSchemaService;
|
|
1860
|
-
this.schema = schema;
|
|
1861
|
-
this._page = 1;
|
|
1862
|
-
this.filters = {};
|
|
1863
|
-
}
|
|
1864
|
-
/**
|
|
1865
|
-
* Ao final da chamada dos métodos do `PoQueryBuilder` utilizados, este método deve ser chamado para que a busca seja concluída.
|
|
1866
|
-
*
|
|
1867
|
-
* @return {Promise<PoResponseApi | object>} Registros do *schema* na qual foi aplicado a consulta.
|
|
1868
|
-
*/
|
|
1869
|
-
PoQueryBuilder.prototype.exec = function () {
|
|
1870
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1871
|
-
var storageData;
|
|
1872
|
-
return __generator(this, function (_a) {
|
|
1873
|
-
switch (_a.label) {
|
|
1874
|
-
case 0: return [4 /*yield*/, this.poSchemaService.getAll(this.schema.name)];
|
|
1875
|
-
case 1:
|
|
1876
|
-
storageData = _a.sent();
|
|
1877
|
-
if (storageData && storageData.length) {
|
|
1878
|
-
if (Object.keys(this.filters).length) {
|
|
1879
|
-
storageData = this.applyFilters(storageData);
|
|
1880
|
-
}
|
|
1881
|
-
if (this.fields) {
|
|
1882
|
-
storageData = this.applyFields(this.schema.fields, storageData);
|
|
1883
|
-
}
|
|
1884
|
-
if (this._sort) {
|
|
1885
|
-
storageData = this.order(storageData, this._sort);
|
|
1886
|
-
}
|
|
1887
|
-
if (this._limit) {
|
|
1888
|
-
return [2 /*return*/, storageData[0]];
|
|
1889
|
-
}
|
|
1890
|
-
else {
|
|
1891
|
-
return [2 /*return*/, this.paginate(storageData)];
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
else {
|
|
1895
|
-
return [2 /*return*/, {
|
|
1896
|
-
hasNext: false,
|
|
1897
|
-
items: []
|
|
1898
|
-
}];
|
|
1899
|
-
}
|
|
1900
|
-
return [2 /*return*/];
|
|
1901
|
-
}
|
|
1902
|
-
});
|
|
1903
|
-
});
|
|
1904
|
-
};
|
|
1905
|
-
/**
|
|
1906
|
-
* Aplica filtros sobre os registros, baseados nos campos e valores definidos como filtro. Por exemplo:
|
|
1907
|
-
*
|
|
1908
|
-
* ```
|
|
1909
|
-
* PoQueryBuilder.filter({ name: 'Marie', age: 24 });
|
|
1910
|
-
* ```
|
|
1911
|
-
* Retorna todos os registros que contenham a propriedade `name` igual a Marie e `age` igual a 24.
|
|
1912
|
-
*
|
|
1913
|
-
* @param {object} filter Objeto que contém os campos e valores a serem filtrados no *schema*.
|
|
1914
|
-
*
|
|
1915
|
-
* @returns {PoQueryBuilder} Objeto que possibilita encadear um novo método do `PoQueryBuilder`.
|
|
1916
|
-
*/
|
|
1917
|
-
PoQueryBuilder.prototype.filter = function (filter) {
|
|
1918
|
-
if (filter && typeof filter === 'object') {
|
|
1919
|
-
this.filters = Object.assign(Object.assign({}, this.filters), filter);
|
|
1920
|
-
}
|
|
1921
|
-
else {
|
|
1922
|
-
throw new Error('Filter must be an object');
|
|
1923
|
-
}
|
|
1924
|
-
return this;
|
|
1925
|
-
};
|
|
1926
|
-
/**
|
|
1927
|
-
* Limita o número de registros que serão retornados.
|
|
1928
|
-
*
|
|
1929
|
-
* @param {number} limit Número de registros retornados.
|
|
1930
|
-
* @returns {PoQueryBuilder} Objeto que possibilita encadear um novo método do `PoQueryBuilder`.
|
|
1931
|
-
*/
|
|
1932
|
-
PoQueryBuilder.prototype.limit = function (limit) {
|
|
1933
|
-
this._limit = limit;
|
|
1934
|
-
return this;
|
|
1935
|
-
};
|
|
1936
|
-
/**
|
|
1937
|
-
* Especifica a página de registros que se deseja retornar.
|
|
1938
|
-
*
|
|
1939
|
-
* @param {number} page Número da página.
|
|
1940
|
-
* @returns {PoQueryBuilder} Objeto que possibilita encadear um novo método do `PoQueryBuilder`.
|
|
1941
|
-
*/
|
|
1942
|
-
PoQueryBuilder.prototype.page = function (page) {
|
|
1943
|
-
validateParameter({ page: page });
|
|
1944
|
-
this._page = page;
|
|
1945
|
-
return this;
|
|
1946
|
-
};
|
|
1947
|
-
/**
|
|
1948
|
-
* Define quantos elementos serão retornados por página.
|
|
1949
|
-
*
|
|
1950
|
-
* @param {number} pageSize Número de registros por página.
|
|
1951
|
-
* @returns {PoQueryBuilder} Objeto que possibilita encadear um novo método do `PoQueryBuilder`.
|
|
1952
|
-
*/
|
|
1953
|
-
PoQueryBuilder.prototype.pageSize = function (pageSize) {
|
|
1954
|
-
validateParameter({ pageSize: pageSize });
|
|
1955
|
-
this._pageSize = pageSize;
|
|
1956
|
-
return this;
|
|
1957
|
-
};
|
|
1958
|
-
/**
|
|
1959
|
-
* Utilizado para definir quais campos do *schema* serão retornados na consulta.
|
|
1960
|
-
*
|
|
1961
|
-
* @param {string} fields Campos que serão retornados nos registros. Este campos devem estar dentro de
|
|
1962
|
-
* uma *string* separados por espaço podendo usar o caractere `-` para excluir campos.
|
|
1963
|
-
* Por exemplo, a definição abaixo:
|
|
1964
|
-
*
|
|
1965
|
-
* ```
|
|
1966
|
-
* PoQueryBuilder.select('name age address');
|
|
1967
|
-
* ```
|
|
1968
|
-
* Irá retornar apenas os campos `name`, `age` e `address`. Para não retornar um campo ou mais basta fazer:
|
|
1969
|
-
*
|
|
1970
|
-
* ```
|
|
1971
|
-
* PoQueryBuilder.select('-name -age');
|
|
1972
|
-
* ```
|
|
1973
|
-
*
|
|
1974
|
-
* @returns {PoQueryBuilder} Objeto que possibilita encadear um novo método do `PoQueryBuilder`.
|
|
1975
|
-
*/
|
|
1976
|
-
PoQueryBuilder.prototype.select = function (fields) {
|
|
1977
|
-
validateParameter({ fields: fields });
|
|
1978
|
-
this.fields = fields;
|
|
1979
|
-
return this;
|
|
1980
|
-
};
|
|
1981
|
-
/**
|
|
1982
|
-
* Ordena os registros por um campo.
|
|
1983
|
-
*
|
|
1984
|
-
* @param {string} field Campo a ser ordenado. Para ordenar de forma decrescente basta colocar o caractere `-`
|
|
1985
|
-
* na frente do campo. Por exemplo:
|
|
1986
|
-
* ```
|
|
1987
|
-
* PoQueryBuilder.sort('-name');
|
|
1988
|
-
* ```
|
|
1989
|
-
*
|
|
1990
|
-
* @returns {PoQueryBuilder} Objeto que possibilita encadear um novo método do `PoQueryBuilder`.
|
|
1991
|
-
*/
|
|
1992
|
-
PoQueryBuilder.prototype.sort = function (field) {
|
|
1993
|
-
validateParameter({ field: field });
|
|
1994
|
-
this._sort = field;
|
|
1995
|
-
return this;
|
|
1996
|
-
};
|
|
1997
|
-
/**
|
|
1998
|
-
* Essa função serve como alias para o `PoQueryBuilder.filter()`. É utilizada somente para dar maior legibilidade ao código.
|
|
1999
|
-
*
|
|
2000
|
-
* @param {object} filter Objeto que contém os campos e valores a serem filtrados no *schema*.
|
|
2001
|
-
* @returns {PoQueryBuilder} Objeto que possibilita encadear um novo método do `PoQueryBuilder`.
|
|
2002
|
-
*/
|
|
2003
|
-
PoQueryBuilder.prototype.where = function (filter) {
|
|
2004
|
-
return this.filter(filter);
|
|
2005
|
-
};
|
|
2006
|
-
PoQueryBuilder.prototype.applyFields = function (schemaFields, data) {
|
|
2007
|
-
var _a;
|
|
2008
|
-
var receivedFields = this.fields.split(' ');
|
|
2009
|
-
var restrictedFields = [];
|
|
2010
|
-
var selectedFields = [];
|
|
2011
|
-
_a = __read(this.groupFields(receivedFields), 2), selectedFields = _a[0], restrictedFields = _a[1];
|
|
2012
|
-
if (!selectedFields.length && restrictedFields.length) {
|
|
2013
|
-
selectedFields = __spreadArray([], __read(schemaFields));
|
|
2014
|
-
}
|
|
2015
|
-
if (restrictedFields.length) {
|
|
2016
|
-
selectedFields = this.removeRestrictedFields(restrictedFields, selectedFields);
|
|
2017
|
-
}
|
|
2018
|
-
selectedFields = this.removeDuplicate(selectedFields);
|
|
2019
|
-
return this.removeFieldsData(data, selectedFields);
|
|
2020
|
-
};
|
|
2021
|
-
PoQueryBuilder.prototype.applyFilters = function (data) {
|
|
2022
|
-
var _this = this;
|
|
2023
|
-
Object.keys(this.filters).forEach(function (filterKey) {
|
|
2024
|
-
data = data.filter(function (item) { return item[filterKey] === _this.filters[filterKey]; });
|
|
2025
|
-
});
|
|
2026
|
-
return data;
|
|
2027
|
-
};
|
|
2028
|
-
PoQueryBuilder.prototype.groupFields = function (receivedFields) {
|
|
2029
|
-
var restrictedFields = [];
|
|
2030
|
-
var selectedFields = [];
|
|
2031
|
-
receivedFields.forEach(function (fields) {
|
|
2032
|
-
if (fields.startsWith('-')) {
|
|
2033
|
-
restrictedFields.push(fields.substring(1));
|
|
2034
|
-
}
|
|
2035
|
-
else {
|
|
2036
|
-
selectedFields.push(fields);
|
|
2037
|
-
}
|
|
2038
|
-
});
|
|
2039
|
-
return [selectedFields, restrictedFields];
|
|
2040
|
-
};
|
|
2041
|
-
PoQueryBuilder.prototype.paginate = function (data) {
|
|
2042
|
-
var dataLength = data.length;
|
|
2043
|
-
var pageSize = this._pageSize || dataLength;
|
|
2044
|
-
var pages = Math.ceil(dataLength / pageSize);
|
|
2045
|
-
var begin = this._page * pageSize - pageSize;
|
|
2046
|
-
var end = begin + pageSize;
|
|
2047
|
-
return { hasNext: this._page < pages, items: data.slice(begin, end) };
|
|
2048
|
-
};
|
|
2049
|
-
PoQueryBuilder.prototype.order = function (data, sortingField) {
|
|
2050
|
-
var descendingOrder = sortingField.startsWith('-');
|
|
2051
|
-
sortingField = descendingOrder ? sortingField.substr(1) : sortingField;
|
|
2052
|
-
return data.sort(function (optionA, optionB) {
|
|
2053
|
-
if (optionA[sortingField] > optionB[sortingField]) {
|
|
2054
|
-
return !descendingOrder ? 1 : -1;
|
|
2055
|
-
}
|
|
2056
|
-
if (optionA[sortingField] < optionB[sortingField]) {
|
|
2057
|
-
return !descendingOrder ? -1 : 1;
|
|
2058
|
-
}
|
|
2059
|
-
return 0;
|
|
2060
|
-
});
|
|
2061
|
-
};
|
|
2062
|
-
PoQueryBuilder.prototype.removeDuplicate = function (fields) {
|
|
2063
|
-
return fields.filter(function (item, position) { return fields.indexOf(item) === position; });
|
|
2064
|
-
};
|
|
2065
|
-
PoQueryBuilder.prototype.removeFieldsData = function (data, chosenFields) {
|
|
2066
|
-
data.forEach(function (item) {
|
|
2067
|
-
Object.keys(item).forEach(function (keyItem) {
|
|
2068
|
-
if (!chosenFields.includes(keyItem)) {
|
|
2069
|
-
delete item[keyItem];
|
|
2070
|
-
}
|
|
2071
|
-
});
|
|
2072
|
-
});
|
|
2073
|
-
return data;
|
|
2074
|
-
};
|
|
2075
|
-
PoQueryBuilder.prototype.removeRestrictedFields = function (restrictedFields, fields) {
|
|
2076
|
-
return fields.filter(function (field) { return !restrictedFields.includes(field); });
|
|
2077
|
-
};
|
|
2078
|
-
return PoQueryBuilder;
|
|
2079
|
-
}());
|
|
2080
|
-
|
|
2081
|
-
/**
|
|
2082
|
-
* @description
|
|
2083
|
-
*
|
|
2084
|
-
* Uma instância `PoEntity` representa um *schema* e ela contém métodos que possibilitam manipular seus registros,
|
|
2085
|
-
* como por exemplo: buscar, criar e remover.
|
|
2086
|
-
*
|
|
2087
|
-
* Esta instância pode ser obtida a partir do retorno do método `PoSyncService.getModel('schema name')`.
|
|
2088
|
-
*/
|
|
2089
|
-
var PoEntity = /** @class */ (function () {
|
|
2090
|
-
function PoEntity(eventSourcing, schema, poSchemaService) {
|
|
2091
|
-
this.eventSourcing = eventSourcing;
|
|
2092
|
-
this.schema = schema;
|
|
2093
|
-
this.poSchemaService = poSchemaService;
|
|
2094
|
-
}
|
|
2095
|
-
/**
|
|
2096
|
-
* Busca os registros do *schema*, podendo filtrar o resultado a partir do filtro passado e retornando apenas
|
|
2097
|
-
* os campos definidos.
|
|
2098
|
-
*
|
|
2099
|
-
* Para que esta busca seja concluída é necessário utilizar o método `PoQueryBuilder.exec()`.
|
|
2100
|
-
* Veja mais em: [PoQueryBuilder](/documentation/po-query-builder).
|
|
2101
|
-
*
|
|
2102
|
-
* @param {object} filter Objeto que contém os campos e valores a serem filtrados no *schema*.
|
|
2103
|
-
* @param {string} fields Campos que serão retornados nos registros. Este campos devem estar dentro de
|
|
2104
|
-
* uma *string* separados por espaço podendo usar o caractere `-` para excluir campos.
|
|
2105
|
-
* Por exemplo, a definição abaixo:
|
|
2106
|
-
*
|
|
2107
|
-
* ```
|
|
2108
|
-
* PoQueryBuilder.select('name age address');
|
|
2109
|
-
* ```
|
|
2110
|
-
* Irá retornar apenas os campos `name`, `age` e `address`. E para não mostrar um campo ou mais basta fazer:
|
|
2111
|
-
*
|
|
2112
|
-
* ```
|
|
2113
|
-
* PoQueryBuilder.select('-name -age');
|
|
2114
|
-
* ```
|
|
2115
|
-
* @returns {PoQueryBuilder} Objeto que possibilita encadear um método do `PoQueryBuilder`.
|
|
2116
|
-
*/
|
|
2117
|
-
PoEntity.prototype.find = function (filter, fields) {
|
|
2118
|
-
var query = new PoQueryBuilder(this.poSchemaService, this.schema);
|
|
2119
|
-
if (filter) {
|
|
2120
|
-
query.filter(filter);
|
|
2121
|
-
}
|
|
2122
|
-
if (fields) {
|
|
2123
|
-
query.select(fields);
|
|
2124
|
-
}
|
|
2125
|
-
return query;
|
|
2126
|
-
};
|
|
2127
|
-
/**
|
|
2128
|
-
* Busca um registro pelo seu *id*.
|
|
2129
|
-
*
|
|
2130
|
-
* Para que esta busca seja concluída é necessário utilizar o método `PoQueryBuilder.exec()`.
|
|
2131
|
-
* Veja mais em: [PoQueryBuilder](/documentation/po-query-builder).
|
|
2132
|
-
*
|
|
2133
|
-
* @param {any} id Identificador do registro.
|
|
2134
|
-
* @param {string} fields Campos que serão retornados nos registros. Este campos devem estar dentro de
|
|
2135
|
-
* uma *string* separados por espaço podendo usar o caractere `-` para excluir campos.
|
|
2136
|
-
* Por exemplo, a definição abaixo:
|
|
2137
|
-
*
|
|
2138
|
-
* ```
|
|
2139
|
-
* PoQueryBuilder.select('name age address');
|
|
2140
|
-
* ```
|
|
2141
|
-
* Irá retornar apenas os campos `name`, `age` e `address`. E para não mostrar um campo ou mais basta fazer:
|
|
2142
|
-
*
|
|
2143
|
-
* ```
|
|
2144
|
-
* PoQueryBuilder.select('-name -age');
|
|
2145
|
-
* ```
|
|
2146
|
-
* @returns {PoQueryBuilder} Objeto que possibilita encadear um método do `PoQueryBuilder`.
|
|
2147
|
-
*/
|
|
2148
|
-
PoEntity.prototype.findById = function (id, fields) {
|
|
2149
|
-
var _a;
|
|
2150
|
-
return this.findOne((_a = {}, _a[this.schema.idField] = id, _a), fields);
|
|
2151
|
-
};
|
|
2152
|
-
/**
|
|
2153
|
-
* Semelhante ao método `PoEntity.find()`, porém retorna apenas o primeiro registro encontrado na busca.
|
|
2154
|
-
*
|
|
2155
|
-
* Para que esta busca seja concluída é necessário utilizar o método `PoQueryBuilder.exec()`.
|
|
2156
|
-
* Veja mais em: [PoQueryBuilder](/documentation/po-query-builder).
|
|
2157
|
-
*
|
|
2158
|
-
* @param {any} filter Objeto que contém os campos e valores a serem filtrados no *schema*.
|
|
2159
|
-
* @param {string} fields Campos que serão retornados nos registros. Este campos devem estar dentro de
|
|
2160
|
-
* uma *string* separados por espaço podendo usar o caractere `-` para excluir campos.
|
|
2161
|
-
* Por exemplo, a definição abaixo:
|
|
2162
|
-
*
|
|
2163
|
-
* ```
|
|
2164
|
-
* PoQueryBuilder.select('name age address');
|
|
2165
|
-
* ```
|
|
2166
|
-
* Irá retornar apenas os campos `name`, `age` e `address`. E para não mostrar um campo ou mais basta fazer:
|
|
2167
|
-
*
|
|
2168
|
-
* ```
|
|
2169
|
-
* PoQueryBuilder.select('-name -age');
|
|
2170
|
-
* ```
|
|
2171
|
-
* @returns {PoQueryBuilder} Objeto que possibilita encadear um método do `PoQueryBuilder`.
|
|
2172
|
-
*/
|
|
2173
|
-
PoEntity.prototype.findOne = function (filter, fields) {
|
|
2174
|
-
var query = this.find(filter, fields);
|
|
2175
|
-
query.limit(1);
|
|
2176
|
-
return query;
|
|
2177
|
-
};
|
|
2178
|
-
/**
|
|
2179
|
-
* Remove um registro.
|
|
2180
|
-
*
|
|
2181
|
-
* @param {object} record Registro que será removido.
|
|
2182
|
-
* @param {string} customRequestId Identificador customizado do comando.
|
|
2183
|
-
* @returns {Promise} Promessa que é concluída após o registro ser removido.
|
|
2184
|
-
*/
|
|
2185
|
-
PoEntity.prototype.remove = function (record, customRequestId) {
|
|
2186
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2187
|
-
var remove;
|
|
2188
|
-
var _this = this;
|
|
2189
|
-
return __generator(this, function (_a) {
|
|
2190
|
-
validateParameter({ record: record });
|
|
2191
|
-
remove = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2192
|
-
var idField, serverRecord;
|
|
2193
|
-
return __generator(this, function (_a) {
|
|
2194
|
-
switch (_a.label) {
|
|
2195
|
-
case 0:
|
|
2196
|
-
idField = record[this.schema.idField] ? this.schema.idField : PoSchemaUtil.syncInternalIdFieldName;
|
|
2197
|
-
serverRecord = PoSchemaUtil.separateSchemaFields(this.schema, record)['serverRecord'];
|
|
2198
|
-
return [4 /*yield*/, this.poSchemaService.remove(this.schema.name, record[idField])];
|
|
2199
|
-
case 1:
|
|
2200
|
-
_a.sent();
|
|
2201
|
-
return [4 /*yield*/, this.eventSourcing.remove(this.schema.name, serverRecord, customRequestId)];
|
|
2202
|
-
case 2:
|
|
2203
|
-
_a.sent();
|
|
2204
|
-
return [2 /*return*/];
|
|
2205
|
-
}
|
|
2206
|
-
});
|
|
2207
|
-
}); };
|
|
2208
|
-
return [2 /*return*/, this.poSchemaService.limitedCallWrap(remove)];
|
|
2209
|
-
});
|
|
2210
|
-
});
|
|
2211
|
-
};
|
|
2212
|
-
/**
|
|
2213
|
-
* Altera ou inclui um registro.
|
|
2214
|
-
*
|
|
2215
|
-
* > O registro será alterado se ele possuir um *id*, caso contrário um novo registro será criado.
|
|
2216
|
-
*
|
|
2217
|
-
* @param {object} record Registro que será persistido.
|
|
2218
|
-
* @param {string} customRequestId Identificador customizado do comando.
|
|
2219
|
-
* @returns {Promise} Promessa que é concluída após o registro ser alterado ou incluído.
|
|
2220
|
-
*/
|
|
2221
|
-
PoEntity.prototype.save = function (record, customRequestId) {
|
|
2222
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2223
|
-
return __generator(this, function (_a) {
|
|
2224
|
-
validateParameter({ record: record });
|
|
2225
|
-
return [2 /*return*/, this.poSchemaService.limitedCallWrap(this.selectSaveType.bind(this, record, true, customRequestId))];
|
|
2226
|
-
});
|
|
2227
|
-
});
|
|
2228
|
-
};
|
|
2229
|
-
/**
|
|
2230
|
-
* Salva uma lista de registros em lote.
|
|
2231
|
-
*
|
|
2232
|
-
* > Para cada registro da lista, será inserido um novo registro se o mesmo não tiver *id*, caso contrário
|
|
2233
|
-
* será contado como uma atualização de um registro existente.
|
|
2234
|
-
*
|
|
2235
|
-
* @param {Array<object>} records Lista de registros que serão persistidos.
|
|
2236
|
-
* @param {Array<string> | string} customRequestIds Identificador customizado do comando.
|
|
2237
|
-
*
|
|
2238
|
-
* Ao passar uma lista de identificadores, cada índice da lista de identificadores deverá
|
|
2239
|
-
* corresponder ao índice do registro na lista de registros.
|
|
2240
|
-
* @returns {Promise<any>} Promessa que é concluída após os registros serem alterados ou incluídos.
|
|
2241
|
-
*/
|
|
2242
|
-
PoEntity.prototype.saveAll = function (records, customRequestIds) {
|
|
2243
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2244
|
-
var saveAll;
|
|
2245
|
-
var _this = this;
|
|
2246
|
-
return __generator(this, function (_a) {
|
|
2247
|
-
validateParameter({ records: records });
|
|
2248
|
-
saveAll = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2249
|
-
var batchEvents, index, record, sendToEventSourcing, isNonLocalRecordChanged, updatedRecord, customRequestId, eventOperation;
|
|
2250
|
-
return __generator(this, function (_a) {
|
|
2251
|
-
switch (_a.label) {
|
|
2252
|
-
case 0:
|
|
2253
|
-
batchEvents = [];
|
|
2254
|
-
index = 0;
|
|
2255
|
-
_a.label = 1;
|
|
2256
|
-
case 1:
|
|
2257
|
-
if (!(index < records.length)) return [3 /*break*/, 5];
|
|
2258
|
-
record = records[index];
|
|
2259
|
-
sendToEventSourcing = false;
|
|
2260
|
-
return [4 /*yield*/, this.isNonLocalRecordChanged(record)];
|
|
2261
|
-
case 2:
|
|
2262
|
-
isNonLocalRecordChanged = _a.sent();
|
|
2263
|
-
return [4 /*yield*/, this.selectSaveType(record, sendToEventSourcing)];
|
|
2264
|
-
case 3:
|
|
2265
|
-
updatedRecord = _a.sent();
|
|
2266
|
-
if (isNonLocalRecordChanged) {
|
|
2267
|
-
customRequestId = customRequestIds instanceof Array ? customRequestIds[index] : customRequestIds;
|
|
2268
|
-
eventOperation = this.createEventOperation(record, updatedRecord, customRequestId);
|
|
2269
|
-
batchEvents.push(eventOperation);
|
|
2270
|
-
}
|
|
2271
|
-
_a.label = 4;
|
|
2272
|
-
case 4:
|
|
2273
|
-
index++;
|
|
2274
|
-
return [3 /*break*/, 1];
|
|
2275
|
-
case 5: return [4 /*yield*/, this.eventSourcing.createBatchEvents(this.schema.name, batchEvents)];
|
|
2276
|
-
case 6:
|
|
2277
|
-
_a.sent();
|
|
2278
|
-
return [2 /*return*/];
|
|
2279
|
-
}
|
|
2280
|
-
});
|
|
2281
|
-
}); };
|
|
2282
|
-
return [2 /*return*/, this.poSchemaService.limitedCallWrap(saveAll)];
|
|
2283
|
-
});
|
|
2284
|
-
});
|
|
2285
|
-
};
|
|
2286
|
-
PoEntity.prototype.create = function (newRecord, sendToEventSourcing, customRequestId) {
|
|
2287
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2288
|
-
var time, syncProperties, recordWithSyncProperties, recordedData;
|
|
2289
|
-
var _a;
|
|
2290
|
-
return __generator(this, function (_b) {
|
|
2291
|
-
switch (_b.label) {
|
|
2292
|
-
case 0:
|
|
2293
|
-
time = new Date().getTime();
|
|
2294
|
-
syncProperties = (_a = {},
|
|
2295
|
-
_a[PoSchemaUtil.syncInternalIdFieldName] = time,
|
|
2296
|
-
_a.SyncInsertedDateTime = time,
|
|
2297
|
-
_a.SyncUpdatedDateTime = null,
|
|
2298
|
-
_a.SyncExclusionDateTime = null,
|
|
2299
|
-
_a.SyncDeleted = false,
|
|
2300
|
-
_a.SyncStatus = 0,
|
|
2301
|
-
_a);
|
|
2302
|
-
recordWithSyncProperties = Object.assign(Object.assign({}, newRecord), syncProperties);
|
|
2303
|
-
return [4 /*yield*/, this.poSchemaService.create(this.schema, recordWithSyncProperties)];
|
|
2304
|
-
case 1:
|
|
2305
|
-
recordedData = _b.sent();
|
|
2306
|
-
if (!sendToEventSourcing) return [3 /*break*/, 3];
|
|
2307
|
-
return [4 /*yield*/, this.eventSourcing.create(this.schema.name, recordWithSyncProperties, customRequestId)];
|
|
2308
|
-
case 2:
|
|
2309
|
-
_b.sent();
|
|
2310
|
-
_b.label = 3;
|
|
2311
|
-
case 3: return [2 /*return*/, recordedData];
|
|
2312
|
-
}
|
|
2313
|
-
});
|
|
2314
|
-
});
|
|
2315
|
-
};
|
|
2316
|
-
PoEntity.prototype.createEventOperation = function (record, updatedRecord, customRequestId) {
|
|
2317
|
-
var operation = PoSchemaUtil.getRecordId(record, this.schema)
|
|
2318
|
-
? PoEventSourcingOperation.Update
|
|
2319
|
-
: PoEventSourcingOperation.Insert;
|
|
2320
|
-
var serverRecord = PoSchemaUtil.separateSchemaFields(this.schema, updatedRecord)['serverRecord'];
|
|
2321
|
-
return {
|
|
2322
|
-
record: serverRecord,
|
|
2323
|
-
customRequestId: customRequestId,
|
|
2324
|
-
operation: operation
|
|
2325
|
-
};
|
|
2326
|
-
};
|
|
2327
|
-
PoEntity.prototype.isNonLocalRecordChanged = function (updatedRecord) {
|
|
2328
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2329
|
-
var nonLocalFieldNames, record;
|
|
2330
|
-
return __generator(this, function (_a) {
|
|
2331
|
-
switch (_a.label) {
|
|
2332
|
-
case 0:
|
|
2333
|
-
nonLocalFieldNames = PoSchemaUtil.getNonLocalFieldNames(this.schema);
|
|
2334
|
-
return [4 /*yield*/, this.poSchemaService.get(this.schema.name, updatedRecord[this.schema.idField])];
|
|
2335
|
-
case 1:
|
|
2336
|
-
record = _a.sent();
|
|
2337
|
-
return [2 /*return*/, !PoSchemaUtil.isModelsEqual(nonLocalFieldNames, record, updatedRecord)];
|
|
2338
|
-
}
|
|
2339
|
-
});
|
|
2340
|
-
});
|
|
2341
|
-
};
|
|
2342
|
-
PoEntity.prototype.selectSaveType = function (record, sendToEventSourcing, customRequestId) {
|
|
2343
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2344
|
-
var hasId, _a;
|
|
2345
|
-
return __generator(this, function (_b) {
|
|
2346
|
-
switch (_b.label) {
|
|
2347
|
-
case 0:
|
|
2348
|
-
hasId = PoSchemaUtil.getRecordId(record, this.schema);
|
|
2349
|
-
if (!hasId) return [3 /*break*/, 2];
|
|
2350
|
-
return [4 /*yield*/, this.update(record, sendToEventSourcing, customRequestId)];
|
|
2351
|
-
case 1:
|
|
2352
|
-
_a = _b.sent();
|
|
2353
|
-
return [3 /*break*/, 4];
|
|
2354
|
-
case 2: return [4 /*yield*/, this.create(record, sendToEventSourcing, customRequestId)];
|
|
2355
|
-
case 3:
|
|
2356
|
-
_a = _b.sent();
|
|
2357
|
-
_b.label = 4;
|
|
2358
|
-
case 4: return [2 /*return*/, _a];
|
|
2359
|
-
}
|
|
2360
|
-
});
|
|
2361
|
-
});
|
|
2362
|
-
};
|
|
2363
|
-
PoEntity.prototype.update = function (updatedRecord, sendToEventSourcing, customRequestId) {
|
|
2364
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2365
|
-
var isNonLocalRecordChanged, recordedData, serverRecord;
|
|
2366
|
-
return __generator(this, function (_a) {
|
|
2367
|
-
switch (_a.label) {
|
|
2368
|
-
case 0:
|
|
2369
|
-
updatedRecord.SyncUpdatedDateTime = new Date().getTime();
|
|
2370
|
-
updatedRecord.SyncStatus = 0;
|
|
2371
|
-
return [4 /*yield*/, this.isNonLocalRecordChanged(updatedRecord)];
|
|
2372
|
-
case 1:
|
|
2373
|
-
isNonLocalRecordChanged = _a.sent();
|
|
2374
|
-
return [4 /*yield*/, this.poSchemaService.update(this.schema, updatedRecord)];
|
|
2375
|
-
case 2:
|
|
2376
|
-
recordedData = _a.sent();
|
|
2377
|
-
if (!(isNonLocalRecordChanged && sendToEventSourcing)) return [3 /*break*/, 4];
|
|
2378
|
-
serverRecord = PoSchemaUtil.separateSchemaFields(this.schema, updatedRecord)['serverRecord'];
|
|
2379
|
-
return [4 /*yield*/, this.eventSourcing.update(this.schema.name, serverRecord, customRequestId)];
|
|
2380
|
-
case 3:
|
|
2381
|
-
_a.sent();
|
|
2382
|
-
_a.label = 4;
|
|
2383
|
-
case 4: return [2 /*return*/, recordedData];
|
|
2384
|
-
}
|
|
2385
|
-
});
|
|
2386
|
-
});
|
|
2387
|
-
};
|
|
2388
|
-
return PoEntity;
|
|
2389
|
-
}());
|
|
2390
|
-
|
|
2391
|
-
/**
|
|
2392
|
-
* @usedBy PoSyncConfig, PoNetworkStatus
|
|
2393
|
-
*
|
|
2394
|
-
* @description
|
|
2395
|
-
*
|
|
2396
|
-
* Tipos de rede existentes no dispositivo.
|
|
2397
|
-
*/
|
|
2398
|
-
exports.PoNetworkType = void 0;
|
|
2399
|
-
(function (PoNetworkType) {
|
|
2400
|
-
/** Define o tipo de rede como desconhecido (`unknown`). */
|
|
2401
|
-
PoNetworkType[PoNetworkType["unknown"] = 0] = "unknown";
|
|
2402
|
-
/** Define o tipo de rede como `Ethernet`. */
|
|
2403
|
-
PoNetworkType[PoNetworkType["ethernet"] = 1] = "ethernet";
|
|
2404
|
-
/** Define o tipo de rede como `WiFi`. */
|
|
2405
|
-
PoNetworkType[PoNetworkType["wifi"] = 2] = "wifi";
|
|
2406
|
-
/** Define o tipo de rede como `2G`. */
|
|
2407
|
-
PoNetworkType[PoNetworkType["_2g"] = 3] = "_2g";
|
|
2408
|
-
/** Define o tipo de rede como `3G`. */
|
|
2409
|
-
PoNetworkType[PoNetworkType["_3g"] = 4] = "_3g";
|
|
2410
|
-
/** Define o tipo de rede como `4G`. */
|
|
2411
|
-
PoNetworkType[PoNetworkType["_4g"] = 5] = "_4g";
|
|
2412
|
-
/**
|
|
2413
|
-
* Define o tipo de rede como `cellular`. Isso acontece na utilização dos navegadores
|
|
2414
|
-
* dentro do dispositvo móvel, com exceção do *web view*.
|
|
2415
|
-
*/
|
|
2416
|
-
PoNetworkType[PoNetworkType["cellular"] = 6] = "cellular";
|
|
2417
|
-
/** Define o tipo de rede como `none`. */
|
|
2418
|
-
PoNetworkType[PoNetworkType["none"] = 7] = "none";
|
|
2419
|
-
})(exports.PoNetworkType || (exports.PoNetworkType = {}));
|
|
2420
|
-
|
|
2421
|
-
/**
|
|
2422
|
-
* @docsPrivate
|
|
2423
|
-
*
|
|
2424
|
-
* @description
|
|
2425
|
-
*
|
|
2426
|
-
* Classe responsável por implementar a classe `PoDataTransform` com os campos referentes ao padrão de
|
|
2427
|
-
* [API do PO UI](https://po-ui.io/guides/api).
|
|
2428
|
-
*/
|
|
2429
|
-
var PoDataMessage = /** @class */ (function (_super) {
|
|
2430
|
-
__extends(PoDataMessage, _super);
|
|
2431
|
-
function PoDataMessage() {
|
|
2432
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
2433
|
-
}
|
|
2434
|
-
/**
|
|
2435
|
-
* Retorna a propriedade `po_sync_date`, responsável por informar a data da última sincronização no guia de
|
|
2436
|
-
* [API do PO UI](https://po-ui.io/guides/api).
|
|
2437
|
-
*
|
|
2438
|
-
* @returns {string} Nome do campo que contém a data da última sincronização.
|
|
2439
|
-
*/
|
|
2440
|
-
PoDataMessage.prototype.getDateFieldName = function () {
|
|
2441
|
-
return 'po_sync_date';
|
|
2442
|
-
};
|
|
2443
|
-
/**
|
|
2444
|
-
* Retorna a propriedade `items`, responsável por informar a lista de registros vindos da API no guia de
|
|
2445
|
-
* [API do PO UI](https://po-ui.io/guides/api).
|
|
2446
|
-
*
|
|
2447
|
-
* @returns {string} Nome da propriedade que contém a lista de registros.
|
|
2448
|
-
*/
|
|
2449
|
-
PoDataMessage.prototype.getItemsFieldName = function () {
|
|
2450
|
-
return 'items';
|
|
2451
|
-
};
|
|
2452
|
-
/**
|
|
2453
|
-
* Retorna a propriedade `page`, responsável por informar o número da página de registros que a API retorna no guia de
|
|
2454
|
-
* [API do PO UI](https://po-ui.io/guides/api).
|
|
2455
|
-
*
|
|
2456
|
-
* @returns {string} Nome da propriedade responsável por informar o número da página de registros.
|
|
2457
|
-
*/
|
|
2458
|
-
PoDataMessage.prototype.getPageParamName = function () {
|
|
2459
|
-
return 'page';
|
|
2460
|
-
};
|
|
2461
|
-
/**
|
|
2462
|
-
* Retorna a propriedade `pageSize`, responsável pela quantidade de registros que serão exibidos por página no guia de
|
|
2463
|
-
* [API do PO UI](https://po-ui.io/guides/api).
|
|
2464
|
-
*
|
|
2465
|
-
* @returns {string} Nome do parâmetro responsável pela quantidade de registros por página.
|
|
2466
|
-
*/
|
|
2467
|
-
PoDataMessage.prototype.getPageSizeParamName = function () {
|
|
2468
|
-
return 'pageSize';
|
|
2469
|
-
};
|
|
2470
|
-
/**
|
|
2471
|
-
* Retorna um valor `boolean`, de acordo com a propriedade `hasNext` que é responsável por informar se há uma nova
|
|
2472
|
-
* página de registros disponível no guia de [API do PO UI](https://po-ui.io/guides/api).
|
|
2473
|
-
*
|
|
2474
|
-
* @returns {boolean} Informa se tem próxima página de registros.
|
|
2475
|
-
*/
|
|
2476
|
-
PoDataMessage.prototype.hasNext = function () {
|
|
2477
|
-
return this.data.hasNext;
|
|
2478
|
-
};
|
|
2479
|
-
return PoDataMessage;
|
|
2480
|
-
}(PoDataTransform));
|
|
2481
|
-
|
|
2482
|
-
/**
|
|
2483
|
-
* @description
|
|
2484
|
-
*
|
|
2485
|
-
* Classe responsável por identificar a conexão de rede disponível no dispositivo.
|
|
2486
|
-
*/
|
|
2487
|
-
var PoNetworkStatus = /** @class */ (function () {
|
|
2488
|
-
function PoNetworkStatus(networtkType) {
|
|
2489
|
-
this.setNetworkConnection(networtkType);
|
|
2490
|
-
}
|
|
2491
|
-
Object.defineProperty(PoNetworkStatus.prototype, "status", {
|
|
2492
|
-
/**
|
|
2493
|
-
* Retorna se o dispositivo está conectado na rede.
|
|
2494
|
-
*
|
|
2495
|
-
* @returns {boolean} Status da conexão com a rede.
|
|
2496
|
-
*/
|
|
2497
|
-
get: function () {
|
|
2498
|
-
return this.type !== exports.PoNetworkType.none;
|
|
2499
|
-
},
|
|
2500
|
-
enumerable: false,
|
|
2501
|
-
configurable: true
|
|
2502
|
-
});
|
|
2503
|
-
Object.defineProperty(PoNetworkStatus.prototype, "type", {
|
|
2504
|
-
/**
|
|
2505
|
-
* Retorna o tipo de conexão do dispositivo.
|
|
2506
|
-
*
|
|
2507
|
-
* @returns {PoNetworkType} Tipo da conexão com a rede.
|
|
2508
|
-
*/
|
|
2509
|
-
get: function () {
|
|
2510
|
-
return this._type;
|
|
2511
|
-
},
|
|
2512
|
-
set: function (type) {
|
|
2513
|
-
this._type = type;
|
|
2514
|
-
},
|
|
2515
|
-
enumerable: false,
|
|
2516
|
-
configurable: true
|
|
2517
|
-
});
|
|
2518
|
-
/* istanbul ignore next */
|
|
2519
|
-
PoNetworkStatus.prototype.setDefaultTypeNavigation = function () {
|
|
2520
|
-
return navigator.onLine ? exports.PoNetworkType['ethernet'] : exports.PoNetworkType.none;
|
|
2521
|
-
};
|
|
2522
|
-
PoNetworkStatus.prototype.setNetworkConnection = function (networtkType) {
|
|
2523
|
-
if (!networtkType) {
|
|
2524
|
-
this.type = this.setDefaultTypeNavigation();
|
|
2525
|
-
}
|
|
2526
|
-
else {
|
|
2527
|
-
var isGenerationMobile = ['2g', '3g', '4g'].includes(networtkType);
|
|
2528
|
-
this.type = isGenerationMobile ? exports.PoNetworkType['_' + networtkType] : exports.PoNetworkType[String(networtkType)];
|
|
2529
|
-
}
|
|
2530
|
-
};
|
|
2531
|
-
return PoNetworkStatus;
|
|
2532
|
-
}());
|
|
2533
|
-
|
|
2534
|
-
/**
|
|
2535
|
-
* @description
|
|
2536
|
-
*
|
|
2537
|
-
* O `PoNetworkService` é utilizado para verificar o status e o tipo da conexão de rede do dispositivo.
|
|
2538
|
-
*/
|
|
2539
|
-
var PoNetworkService = /** @class */ (function () {
|
|
2540
|
-
function PoNetworkService(network) {
|
|
2541
|
-
this.initNetwork(network);
|
|
2542
|
-
}
|
|
2543
|
-
/**
|
|
2544
|
-
* Retorna as propriedades tipo e status da conexão do dispositivo no momento da chamada.
|
|
2545
|
-
*
|
|
2546
|
-
* @returns {PoNetworkStatus} Instância de [PoNetworkStatus](/documentation/po-network-status) com as
|
|
2547
|
-
* propriedades da conexão.
|
|
2548
|
-
*/
|
|
2549
|
-
PoNetworkService.prototype.getConnectionStatus = function () {
|
|
2550
|
-
this.poNetworkStatus = new PoNetworkStatus(this.networkType);
|
|
2551
|
-
return this.poNetworkStatus;
|
|
2552
|
-
};
|
|
2553
|
-
/**
|
|
2554
|
-
* Notifica as mudanças no tipo de conexão de rede do dispositivo.
|
|
2555
|
-
*
|
|
2556
|
-
* @returns {Observable<{ status: boolean, type: string }>} Observable com as propriedades da conexão.
|
|
2557
|
-
*/
|
|
2558
|
-
PoNetworkService.prototype.onChange = function () {
|
|
2559
|
-
return this.networkTypeNow.asObservable();
|
|
2560
|
-
};
|
|
2561
|
-
PoNetworkService.prototype.getNavigatorStatus = function () {
|
|
2562
|
-
return rxjs.merge(rxjs.fromEvent(window, 'offline').pipe(operators.mapTo(false)), rxjs.fromEvent(window, 'online').pipe(operators.mapTo(true)), rxjs.Observable.create(function (sub) {
|
|
2563
|
-
sub.next(navigator.onLine);
|
|
2564
|
-
sub.complete();
|
|
2565
|
-
}));
|
|
2566
|
-
};
|
|
2567
|
-
PoNetworkService.prototype.initNetwork = function (network) {
|
|
2568
|
-
this.networkTypeNow = new rxjs.Subject();
|
|
2569
|
-
this.initSubscriber(network);
|
|
2570
|
-
};
|
|
2571
|
-
PoNetworkService.prototype.initSubscriber = function (network) {
|
|
2572
|
-
var _this = this;
|
|
2573
|
-
if (network) {
|
|
2574
|
-
this.getNavigatorStatus().subscribe(function (status) {
|
|
2575
|
-
_this.networkType = network.type;
|
|
2576
|
-
_this.networkTypeNow.next({ status: status, type: _this.networkType });
|
|
2577
|
-
});
|
|
2578
|
-
}
|
|
2579
|
-
};
|
|
2580
|
-
return PoNetworkService;
|
|
2581
|
-
}());
|
|
2582
|
-
PoNetworkService.decorators = [
|
|
2583
|
-
{ type: core.Injectable }
|
|
2584
|
-
];
|
|
2585
|
-
PoNetworkService.ctorParameters = function () { return [
|
|
2586
|
-
{ type: ngx.Network }
|
|
2587
|
-
]; };
|
|
2588
|
-
|
|
2589
|
-
/**
|
|
2590
|
-
* @description
|
|
2591
|
-
*
|
|
2592
|
-
* O `PoSyncService` é utilizado para configurar toda a base de dados que receberá as informações que serão
|
|
2593
|
-
* armazenadas *offline* vindas do servidor. Nele ocorre toda a preparação dos modelos de dados retornados por
|
|
2594
|
-
* cada consulta.
|
|
2595
|
-
*/
|
|
2596
|
-
var PoSyncService = /** @class */ (function () {
|
|
2597
|
-
function PoSyncService(poEventSourcingService, poHttpClient, poNetworkService, poSchemaDefinitionService, poSchemaService) {
|
|
2598
|
-
this.poEventSourcingService = poEventSourcingService;
|
|
2599
|
-
this.poHttpClient = poHttpClient;
|
|
2600
|
-
this.poNetworkService = poNetworkService;
|
|
2601
|
-
this.poSchemaDefinitionService = poSchemaDefinitionService;
|
|
2602
|
-
this.poSchemaService = poSchemaService;
|
|
2603
|
-
this.models = [];
|
|
2604
|
-
this.finishSyncSubject = new rxjs.Subject();
|
|
2605
|
-
this.isSyncEnabled = true;
|
|
2606
|
-
this.syncing = false;
|
|
2607
|
-
}
|
|
2608
|
-
/**
|
|
2609
|
-
* Destrói todas as chaves do *storage* referentes ao `po-sync`, ou seja,
|
|
2610
|
-
* as definições dos *schemas*, os registros de cada *schema* e a fila
|
|
2611
|
-
* de eventos que estão para ser enviados ao servidor *(EventSourcing)*.
|
|
2612
|
-
*
|
|
2613
|
-
* > Para que não venham ocorrer erros em ações que dependam das definições dos *schemas*,
|
|
2614
|
-
* recomenda-se utilizar o método `prepare()` em seguida.
|
|
2615
|
-
*
|
|
2616
|
-
* > Veja mais detalhes em [Fundamentos do PO Sync - Alterando as definições dos schemas](/guides/sync-fundamentals).
|
|
2617
|
-
*
|
|
2618
|
-
* @returns {Promise<any>} Promessa que é resolvida quando as chaves referentes ao `po-sync` forem destruídas.
|
|
2619
|
-
*/
|
|
2620
|
-
PoSyncService.prototype.destroy = function () {
|
|
2621
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2622
|
-
var destroyFunction;
|
|
2623
|
-
var _this = this;
|
|
2624
|
-
return __generator(this, function (_a) {
|
|
2625
|
-
destroyFunction = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2626
|
-
return __generator(this, function (_a) {
|
|
2627
|
-
switch (_a.label) {
|
|
2628
|
-
case 0: return [4 /*yield*/, this.poSchemaService.destroySchemasRecords()];
|
|
2629
|
-
case 1:
|
|
2630
|
-
_a.sent();
|
|
2631
|
-
return [4 /*yield*/, this.poSchemaDefinitionService.destroy()];
|
|
2632
|
-
case 2:
|
|
2633
|
-
_a.sent();
|
|
2634
|
-
return [4 /*yield*/, this.poEventSourcingService.destroyEventSourcingQueue()];
|
|
2635
|
-
case 3:
|
|
2636
|
-
_a.sent();
|
|
2637
|
-
return [2 /*return*/];
|
|
2638
|
-
}
|
|
2639
|
-
});
|
|
2640
|
-
}); };
|
|
2641
|
-
return [2 /*return*/, this.poSchemaService.limitedCallWrap(destroyFunction)];
|
|
2642
|
-
});
|
|
2643
|
-
});
|
|
2644
|
-
};
|
|
2645
|
-
/**
|
|
2646
|
-
* Desabilita todos os tipos de sincronização de dados (periódica, reativa e manual).
|
|
2647
|
-
*
|
|
2648
|
-
* > Para habilitar novamente a sincronização utilize o método [`PoSyncService.enableSync()`](documentation/po-sync#enable-sync).
|
|
2649
|
-
*/
|
|
2650
|
-
PoSyncService.prototype.disableSync = function () {
|
|
2651
|
-
this.isSyncEnabled = false;
|
|
2652
|
-
if (this.timer && this.subscription) {
|
|
2653
|
-
this.subscription.unsubscribe();
|
|
2654
|
-
}
|
|
2655
|
-
};
|
|
2656
|
-
/**
|
|
2657
|
-
* <a id="enable-sync"></a>
|
|
2658
|
-
* Habilita todos os tipos de sincronização de dados (periódica, reativa e manual).
|
|
2659
|
-
*
|
|
2660
|
-
* Por padrão, sempre que se inicializa uma aplicação com PO Sync as sincronizações já estão habilitadas.
|
|
2661
|
-
*/
|
|
2662
|
-
PoSyncService.prototype.enableSync = function () {
|
|
2663
|
-
this.isSyncEnabled = true;
|
|
2664
|
-
this.createSubscribe();
|
|
2665
|
-
};
|
|
2666
|
-
/**
|
|
2667
|
-
* Método que disponibiliza a partir de sua inscrição o evento de retorno das operações da fila de eventos que
|
|
2668
|
-
* foram enviadas ao servidor. A cada operação enviada para o servidor, será disparado um evento para a inscrição
|
|
2669
|
-
* deste método.
|
|
2670
|
-
*
|
|
2671
|
-
* > Veja mais detalhes em [Fundamentos do PO Sync - Capturando respostas da sincronização](/guides/sync-fundamentals).
|
|
2672
|
-
*
|
|
2673
|
-
* @returns {Observable<PoSyncResponse>} Observable com um objeto do tipo `PoSyncResponse`.
|
|
2674
|
-
*/
|
|
2675
|
-
PoSyncService.prototype.getResponses = function () {
|
|
2676
|
-
return this.poEventSourcingService.responsesSubject();
|
|
2677
|
-
};
|
|
2678
|
-
/**
|
|
2679
|
-
* Retorna uma instância de `PoEntity` para um determinado *schema*.
|
|
2680
|
-
*
|
|
2681
|
-
* > Veja mais detalhes em [Fundamentos do PO Sync - Manipulando os registros de um schema](/guides/sync-fundamentals).
|
|
2682
|
-
*
|
|
2683
|
-
* @param {string} schemaName Nome do *schema*.
|
|
2684
|
-
* @returns {PoEntity} Objeto para efetuar consultas e alterações nos dados.
|
|
2685
|
-
*/
|
|
2686
|
-
PoSyncService.prototype.getModel = function (schemaName) {
|
|
2687
|
-
var model = this.models[schemaName];
|
|
2688
|
-
if (!model) {
|
|
2689
|
-
throw new Error('Model not found: ' + schemaName);
|
|
2690
|
-
}
|
|
2691
|
-
return model;
|
|
2692
|
-
};
|
|
2693
|
-
/**
|
|
2694
|
-
* Insere uma requisição HTTP na fila de eventos do `po-sync`.
|
|
2695
|
-
*
|
|
2696
|
-
* > Veja mais detalhes em [Fundamentos do PO Sync - Inserindo requisições HTTP na fila de eventos](/guides/sync-fundamentals).
|
|
2697
|
-
*
|
|
2698
|
-
* @param {PoHttpRequestData} poHttpRequestData Dados da requisição HTTP.
|
|
2699
|
-
* @param {string} customRequestId Identificador customizado da requisição HTTP.
|
|
2700
|
-
* @returns {Promise<number>} Promessa com o identificador da requisição HTTP criada.
|
|
2701
|
-
*/
|
|
2702
|
-
PoSyncService.prototype.insertHttpCommand = function (requestData, customRequestId) {
|
|
2703
|
-
validateParameter({ requestData: requestData });
|
|
2704
|
-
return this.poEventSourcingService.httpCommand(requestData, customRequestId);
|
|
2705
|
-
};
|
|
2706
|
-
/**
|
|
2707
|
-
* Efetua uma chamada na API do servidor para realizar a carga inicial dos dados. Deve ser chamado apenas uma vez
|
|
2708
|
-
* na aplicação, após a preparação dos *schemas* realizada através do método `PoSyncService.prepare()`.
|
|
2709
|
-
*
|
|
2710
|
-
* > Veja mais detalhes em [Fundamentos do PO Sync - Carga inicial dos dados](/guides/sync-fundamentals).
|
|
2711
|
-
*
|
|
2712
|
-
* @returns {Observable<Array<{ entity: string, data: Array<any> }>>} Observable que notificará quando a
|
|
2713
|
-
* carga inicial for concluída.
|
|
2714
|
-
*/
|
|
2715
|
-
PoSyncService.prototype.loadData = function () {
|
|
2716
|
-
var _this = this;
|
|
2717
|
-
var loads = [];
|
|
2718
|
-
this.schemas.forEach(function (el) { return loads.push(_this.loadEntityData(el)); });
|
|
2719
|
-
return rxjs.forkJoin(loads);
|
|
2720
|
-
};
|
|
2721
|
-
/**
|
|
2722
|
-
* Responsável por notificar sempre que houver sincronismo.
|
|
2723
|
-
*
|
|
2724
|
-
* > Veja mais detalhes em [Fundamentos do PO Sync - Notificação pós-sincronização](/guides/sync-fundamentals).
|
|
2725
|
-
*
|
|
2726
|
-
* @returns {Observable<any>} Observable que é disparado a cada sincronismo realizado.
|
|
2727
|
-
*/
|
|
2728
|
-
PoSyncService.prototype.onSync = function () {
|
|
2729
|
-
var _this = this;
|
|
2730
|
-
if (!this.eventSub) {
|
|
2731
|
-
this.eventSub = rxjs.Observable.create(function (e) {
|
|
2732
|
-
_this.emitter = e;
|
|
2733
|
-
});
|
|
2734
|
-
}
|
|
2735
|
-
return this.eventSub;
|
|
2736
|
-
};
|
|
2737
|
-
/**
|
|
2738
|
-
* Prepara a aplicação criando os schemas e aplica as configurações.
|
|
2739
|
-
*
|
|
2740
|
-
* > Veja mais detalhes em [Fundamentos do PO Sync - Preparando a aplicação](/guides/sync-fundamentals).
|
|
2741
|
-
*
|
|
2742
|
-
* @param {Array<PoSyncSchema>} schemas Lista de *schemas* a serem preparados.
|
|
2743
|
-
* @param {PoSyncConfig} config Configurações adicionais.
|
|
2744
|
-
* @returns {Promise<any>} Promessa que é resolvida quando a aplicação estiver preparada para a utilização do `po-sync`.
|
|
2745
|
-
*/
|
|
2746
|
-
PoSyncService.prototype.prepare = function (schemas, config) {
|
|
2747
|
-
var _this = this;
|
|
2748
|
-
validateArray({ schemas: schemas });
|
|
2749
|
-
var defaultSyncConfig = {
|
|
2750
|
-
type: this.poNetworkService.getConnectionStatus().type,
|
|
2751
|
-
period: 60,
|
|
2752
|
-
dataTransform: new PoDataMessage()
|
|
2753
|
-
};
|
|
2754
|
-
this.schemas = schemas;
|
|
2755
|
-
this.config = config || defaultSyncConfig;
|
|
2756
|
-
this.config.dataTransform = this.config.dataTransform || new PoDataMessage();
|
|
2757
|
-
this.poEventSourcingService.config = this.config;
|
|
2758
|
-
this.startTimer(this.config.period);
|
|
2759
|
-
this.reactiveSync();
|
|
2760
|
-
this.poEventSourcingService.onSaveData().subscribe(function () { return _this.sync(); });
|
|
2761
|
-
return this.saveSchemas().then(function () {
|
|
2762
|
-
_this.schemas.forEach(function (schema) {
|
|
2763
|
-
_this.models[schema.name] = new PoEntity(_this.poEventSourcingService, schema, _this.poSchemaService);
|
|
2764
|
-
});
|
|
2765
|
-
return Promise.resolve();
|
|
2766
|
-
});
|
|
2767
|
-
};
|
|
2768
|
-
/**
|
|
2769
|
-
* Remove um item da fila de eventos que espera a sincronização.
|
|
2770
|
-
*
|
|
2771
|
-
* > Veja mais detalhes em [Fundamentos do PO Sync - Capturando respostas da sincronização](/guides/sync-fundamentals).
|
|
2772
|
-
*
|
|
2773
|
-
* @param {any} idEventSourcing Identificador do item da fila de eventos.
|
|
2774
|
-
* @returns {Promise<any>} Promessa que é resolvida quando o item da fila de eventos é removido.
|
|
2775
|
-
*/
|
|
2776
|
-
PoSyncService.prototype.removeItemOfSync = function (idEventSourcing) {
|
|
2777
|
-
return this.poEventSourcingService.removeEventSourcingItem(idEventSourcing);
|
|
2778
|
-
};
|
|
2779
|
-
/**
|
|
2780
|
-
* Reenvia os comandos pendentes na fila (inclusão, alteração e exclusão) e busca novos dados do servidor.
|
|
2781
|
-
*
|
|
2782
|
-
* > Veja mais detalhes em [Fundamentos do PO Sync - Capturando respostas da sincronização](/guides/sync-fundamentals).
|
|
2783
|
-
*
|
|
2784
|
-
* @returns {Promise<any>} Promessa que resolve o sincronismo disparado.
|
|
2785
|
-
*/
|
|
2786
|
-
PoSyncService.prototype.resumeSync = function () {
|
|
2787
|
-
var _this = this;
|
|
2788
|
-
if (!this.canSync()) {
|
|
2789
|
-
var finishSyncSubscription_1 = this.finishSyncSubject.asObservable().subscribe(function () {
|
|
2790
|
-
finishSyncSubscription_1.unsubscribe();
|
|
2791
|
-
return _this.sync();
|
|
2792
|
-
});
|
|
2793
|
-
return Promise.resolve();
|
|
2794
|
-
}
|
|
2795
|
-
return this.sync();
|
|
2796
|
-
};
|
|
2797
|
-
/**
|
|
2798
|
-
* Dispara o sincronismo enviando os eventos pendentes (inclusão, alteração e exclusão) e buscando novos dados do servidor.
|
|
2799
|
-
*
|
|
2800
|
-
* O sincronismo somente será executado depois que o acesso a base de dados local do dispositivo for liberada.
|
|
2801
|
-
*
|
|
2802
|
-
* > Veja mais detalhes em [Fundamentos do PO Sync - Sincronização manual](/guides/sync-fundamentals).
|
|
2803
|
-
*
|
|
2804
|
-
* @returns {Promise<any>} Promessa que é resolvida quando o sincronismo for finalizado.
|
|
2805
|
-
*/
|
|
2806
|
-
PoSyncService.prototype.sync = function () {
|
|
2807
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2808
|
-
var error_1;
|
|
2809
|
-
return __generator(this, function (_a) {
|
|
2810
|
-
switch (_a.label) {
|
|
2811
|
-
case 0:
|
|
2812
|
-
if (!this.canSync()) return [3 /*break*/, 5];
|
|
2813
|
-
this.startSync();
|
|
2814
|
-
_a.label = 1;
|
|
2815
|
-
case 1:
|
|
2816
|
-
_a.trys.push([1, 4, , 5]);
|
|
2817
|
-
return [4 /*yield*/, this.poEventSourcingService.syncSend()];
|
|
2818
|
-
case 2:
|
|
2819
|
-
_a.sent();
|
|
2820
|
-
return [4 /*yield*/, this.poEventSourcingService.syncGet()];
|
|
2821
|
-
case 3:
|
|
2822
|
-
_a.sent();
|
|
2823
|
-
if (this.emitter) {
|
|
2824
|
-
this.emitter.next();
|
|
2825
|
-
}
|
|
2826
|
-
this.finishSync();
|
|
2827
|
-
return [3 /*break*/, 5];
|
|
2828
|
-
case 4:
|
|
2829
|
-
error_1 = _a.sent();
|
|
2830
|
-
this.syncError();
|
|
2831
|
-
return [3 /*break*/, 5];
|
|
2832
|
-
case 5: return [2 /*return*/];
|
|
2833
|
-
}
|
|
2834
|
-
});
|
|
2835
|
-
});
|
|
2836
|
-
};
|
|
2837
|
-
PoSyncService.prototype.canSync = function () {
|
|
2838
|
-
if (this.syncing || !this.isSyncEnabled) {
|
|
2839
|
-
return false;
|
|
2840
|
-
}
|
|
2841
|
-
else {
|
|
2842
|
-
var currentConnection = this.poNetworkService.getConnectionStatus();
|
|
2843
|
-
var isConfiguredConnection = this.config && currentConnection.type === this.config.type;
|
|
2844
|
-
var isConfigIncludesType = this.config && this.config.type instanceof Array && this.config.type.includes(currentConnection.type);
|
|
2845
|
-
return currentConnection.status && (!this.config || isConfiguredConnection || isConfigIncludesType);
|
|
2846
|
-
}
|
|
2847
|
-
};
|
|
2848
|
-
PoSyncService.prototype.createSubscribe = function () {
|
|
2849
|
-
var _this = this;
|
|
2850
|
-
if (this.timer) {
|
|
2851
|
-
this.subscription = this.timer.subscribe(function () {
|
|
2852
|
-
_this.sync().then(function () {
|
|
2853
|
-
_this.subscription.unsubscribe();
|
|
2854
|
-
_this.subscription = null;
|
|
2855
|
-
_this.timer = null;
|
|
2856
|
-
_this.startTimer(_this.config.period);
|
|
2857
|
-
});
|
|
2858
|
-
});
|
|
2859
|
-
}
|
|
2860
|
-
};
|
|
2861
|
-
PoSyncService.prototype.finishSync = function () {
|
|
2862
|
-
this.syncing = false;
|
|
2863
|
-
this.finishSyncSubject.next();
|
|
2864
|
-
};
|
|
2865
|
-
PoSyncService.prototype.getOnePage = function (schema, page) {
|
|
2866
|
-
var _this = this;
|
|
2867
|
-
if (page === void 0) { page = 1; }
|
|
2868
|
-
var params = [];
|
|
2869
|
-
params.push(this.config.dataTransform.getPageSizeParamName() + "=" + schema.pageSize);
|
|
2870
|
-
params.push(this.config.dataTransform.getPageParamName() + "=" + page);
|
|
2871
|
-
var url = PoSchemaUtil.getUrl(schema, PoRequestType.GET) + "?" + params.join('&');
|
|
2872
|
-
return this.poHttpClient.get(url).pipe(operators.map(function (response) { return response.body; }), operators.mergeMap(function (responseBody) {
|
|
2873
|
-
var now = new Date().getTime();
|
|
2874
|
-
responseBody[_this.config.dataTransform.getItemsFieldName()].map(function (item) {
|
|
2875
|
-
item.SyncInsertedDateTime = now;
|
|
2876
|
-
item.SyncUpdatedDateTime = null;
|
|
2877
|
-
item.SyncExclusionDateTime = null;
|
|
2878
|
-
item.SyncDeleted = false;
|
|
2879
|
-
item.SyncStatus = 2;
|
|
2880
|
-
});
|
|
2881
|
-
return _this.poSchemaService
|
|
2882
|
-
.updateAll(schema, responseBody[_this.config.dataTransform.getItemsFieldName()])
|
|
2883
|
-
.then(function () { return responseBody; });
|
|
2884
|
-
}));
|
|
2885
|
-
};
|
|
2886
|
-
PoSyncService.prototype.loadEntityData = function (schema) {
|
|
2887
|
-
var _this = this;
|
|
2888
|
-
var page = 1;
|
|
2889
|
-
return this.getOnePage(schema, page).pipe(operators.expand(function (data) {
|
|
2890
|
-
_this.config.dataTransform.transform(data);
|
|
2891
|
-
var hasNext = _this.config.dataTransform.hasNext();
|
|
2892
|
-
if (hasNext) {
|
|
2893
|
-
return _this.getOnePage(schema, ++page);
|
|
2894
|
-
}
|
|
2895
|
-
else {
|
|
2896
|
-
return rxjs.of();
|
|
2897
|
-
}
|
|
2898
|
-
}), operators.reduce(function (acc, obj) {
|
|
2899
|
-
acc.data = acc.data.concat(obj[_this.config.dataTransform.getItemsFieldName()]);
|
|
2900
|
-
return acc;
|
|
2901
|
-
}, {
|
|
2902
|
-
entity: schema.name,
|
|
2903
|
-
data: []
|
|
2904
|
-
}));
|
|
2905
|
-
};
|
|
2906
|
-
PoSyncService.prototype.reactiveSync = function () {
|
|
2907
|
-
var _this = this;
|
|
2908
|
-
this.poNetworkService.onChange().subscribe(function (networkStatus) {
|
|
2909
|
-
if (networkStatus.status) {
|
|
2910
|
-
_this.startTimer(_this.config.period);
|
|
2911
|
-
return _this.sync();
|
|
2912
|
-
}
|
|
2913
|
-
if (_this.subscription) {
|
|
2914
|
-
_this.subscription.unsubscribe();
|
|
2915
|
-
}
|
|
2916
|
-
});
|
|
2917
|
-
};
|
|
2918
|
-
PoSyncService.prototype.saveSchemas = function () {
|
|
2919
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2920
|
-
var storageSchemas;
|
|
2921
|
-
return __generator(this, function (_a) {
|
|
2922
|
-
switch (_a.label) {
|
|
2923
|
-
case 0: return [4 /*yield*/, this.poSchemaDefinitionService.getAll()];
|
|
2924
|
-
case 1:
|
|
2925
|
-
storageSchemas = _a.sent();
|
|
2926
|
-
this.schemas.forEach(function (schema) { return (schema.lastSync = PoSchemaUtil.getLastSync(storageSchemas, schema.name)); });
|
|
2927
|
-
return [2 /*return*/, this.poSchemaDefinitionService.saveAll(this.schemas)];
|
|
2928
|
-
}
|
|
2929
|
-
});
|
|
2930
|
-
});
|
|
2931
|
-
};
|
|
2932
|
-
PoSyncService.prototype.startSync = function () {
|
|
2933
|
-
this.syncing = true;
|
|
2934
|
-
};
|
|
2935
|
-
PoSyncService.prototype.startTimer = function (period) {
|
|
2936
|
-
if (period && this.isSyncEnabled) {
|
|
2937
|
-
this.timer = rxjs.timer(period * 1000);
|
|
2938
|
-
this.createSubscribe();
|
|
2939
|
-
}
|
|
2940
|
-
};
|
|
2941
|
-
PoSyncService.prototype.syncError = function () {
|
|
2942
|
-
this.finishSync();
|
|
2943
|
-
};
|
|
2944
|
-
return PoSyncService;
|
|
2945
|
-
}());
|
|
2946
|
-
PoSyncService.decorators = [
|
|
2947
|
-
{ type: core.Injectable }
|
|
2948
|
-
];
|
|
2949
|
-
PoSyncService.ctorParameters = function () { return [
|
|
2950
|
-
{ type: PoEventSourcingService },
|
|
2951
|
-
{ type: PoHttpClientService },
|
|
2952
|
-
{ type: PoNetworkService },
|
|
2953
|
-
{ type: PoSchemaDefinitionService },
|
|
2954
|
-
{ type: PoSchemaService }
|
|
2955
|
-
]; };
|
|
2956
|
-
|
|
2957
|
-
/**
|
|
2958
|
-
* @description
|
|
2959
|
-
*
|
|
2960
|
-
* Módulo do componente PoSync responsável pela sincronia de dados com backends
|
|
2961
|
-
*/
|
|
2962
|
-
var PoSyncModule = /** @class */ (function () {
|
|
2963
|
-
function PoSyncModule() {
|
|
2964
|
-
}
|
|
2965
|
-
return PoSyncModule;
|
|
2966
|
-
}());
|
|
2967
|
-
PoSyncModule.decorators = [
|
|
2968
|
-
{ type: core.NgModule, args: [{
|
|
2969
|
-
providers: [
|
|
2970
|
-
PoEventSourcingService,
|
|
2971
|
-
PoNetworkService,
|
|
2972
|
-
PoSchemaDefinitionService,
|
|
2973
|
-
PoSchemaService,
|
|
2974
|
-
PoSyncService,
|
|
2975
|
-
PoHttpClientService,
|
|
2976
|
-
ngx.Network
|
|
2977
|
-
],
|
|
2978
|
-
imports: [http.HttpClientModule]
|
|
2979
|
-
},] }
|
|
2980
|
-
];
|
|
2981
|
-
|
|
2982
|
-
/**
|
|
2983
|
-
* Generated bundle index. Do not edit.
|
|
2984
|
-
*/
|
|
2985
|
-
|
|
2986
|
-
exports.PoDataTransform = PoDataTransform;
|
|
2987
|
-
exports.PoEntity = PoEntity;
|
|
2988
|
-
exports.PoEventSourcingErrorResponse = PoEventSourcingErrorResponse;
|
|
2989
|
-
exports.PoEventSourcingService = PoEventSourcingService;
|
|
2990
|
-
exports.PoHttpClientService = PoHttpClientService;
|
|
2991
|
-
exports.PoNetworkService = PoNetworkService;
|
|
2992
|
-
exports.PoSyncModule = PoSyncModule;
|
|
2993
|
-
exports.PoSyncService = PoSyncService;
|
|
2994
|
-
exports.ɵa = PoEventSourcingService;
|
|
2995
|
-
exports.ɵb = PoSchemaService;
|
|
2996
|
-
exports.ɵc = PoSchemaDefinitionService;
|
|
2997
|
-
exports.ɵd = PoSchemaService;
|
|
2998
|
-
|
|
2999
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3000
|
-
|
|
3001
|
-
})));
|
|
3002
|
-
//# sourceMappingURL=po-ui-ng-sync.umd.js.map
|