@ngrx-traits/core 0.0.1
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 +24 -0
- package/bundles/ngrx-traits-core-testing.umd.js +52 -0
- package/bundles/ngrx-traits-core-testing.umd.js.map +1 -0
- package/bundles/ngrx-traits-core.umd.js +1212 -0
- package/bundles/ngrx-traits-core.umd.js.map +1 -0
- package/cache/cache.actions.d.ts +29 -0
- package/cache/cache.models.d.ts +20 -0
- package/cache/cache.module.d.ts +7 -0
- package/cache/cache.reducer.d.ts +3 -0
- package/cache/cache.selectors.d.ts +3 -0
- package/cache/cache.service.d.ts +65 -0
- package/cache/index.d.ts +17 -0
- package/create-entity-feature.d.ts +59 -0
- package/esm2015/cache/cache.actions.js +6 -0
- package/esm2015/cache/cache.actions.js.map +1 -0
- package/esm2015/cache/cache.models.js +31 -0
- package/esm2015/cache/cache.models.js.map +1 -0
- package/esm2015/cache/cache.module.js +18 -0
- package/esm2015/cache/cache.module.js.map +1 -0
- package/esm2015/cache/cache.reducer.js +141 -0
- package/esm2015/cache/cache.reducer.js.map +1 -0
- package/esm2015/cache/cache.selectors.js +5 -0
- package/esm2015/cache/cache.selectors.js.map +1 -0
- package/esm2015/cache/cache.service.js +72 -0
- package/esm2015/cache/cache.service.js.map +1 -0
- package/esm2015/cache/index.js +7 -0
- package/esm2015/cache/index.js.map +1 -0
- package/esm2015/create-entity-feature.js +283 -0
- package/esm2015/create-entity-feature.js.map +1 -0
- package/esm2015/index.js +7 -0
- package/esm2015/index.js.map +1 -0
- package/esm2015/local-store/disable-local-trait-effects.token.js +6 -0
- package/esm2015/local-store/disable-local-trait-effects.token.js.map +1 -0
- package/esm2015/local-store/index.js +3 -0
- package/esm2015/local-store/index.js.map +1 -0
- package/esm2015/local-store/traits-local-store.js +75 -0
- package/esm2015/local-store/traits-local-store.js.map +1 -0
- package/esm2015/model.js +28 -0
- package/esm2015/model.js.map +1 -0
- package/esm2015/ngrx-traits-core.js +5 -0
- package/esm2015/ngrx-traits-core.js.map +1 -0
- package/esm2015/public_api.js +2 -0
- package/esm2015/public_api.js.map +1 -0
- package/esm2015/testing/index.js +2 -0
- package/esm2015/testing/index.js.map +1 -0
- package/esm2015/testing/ngrx-traits-core-testing.js +5 -0
- package/esm2015/testing/ngrx-traits-core-testing.js.map +1 -0
- package/esm2015/testing/provide-mock-local-traits.js +39 -0
- package/esm2015/testing/provide-mock-local-traits.js.map +1 -0
- package/esm2015/testing/public_api.js +2 -0
- package/esm2015/testing/public_api.js.map +1 -0
- package/esm2015/trait-effect.js +32 -0
- package/esm2015/trait-effect.js.map +1 -0
- package/esm2015/util.js +17 -0
- package/esm2015/util.js.map +1 -0
- package/fesm2015/ngrx-traits-core-testing.js +46 -0
- package/fesm2015/ngrx-traits-core-testing.js.map +1 -0
- package/fesm2015/ngrx-traits-core.js +699 -0
- package/fesm2015/ngrx-traits-core.js.map +1 -0
- package/index.d.ts +6 -0
- package/local-store/disable-local-trait-effects.token.d.ts +5 -0
- package/local-store/index.d.ts +2 -0
- package/local-store/traits-local-store.d.ts +33 -0
- package/model.d.ts +103 -0
- package/ngrx-traits-core.d.ts +5 -0
- package/package.json +29 -0
- package/public_api.d.ts +1 -0
- package/testing/index.d.ts +1 -0
- package/testing/ngrx-traits-core-testing.d.ts +5 -0
- package/testing/package.json +10 -0
- package/testing/provide-mock-local-traits.d.ts +8 -0
- package/testing/public_api.d.ts +1 -0
- package/trait-effect.d.ts +16 -0
- package/util.d.ts +8 -0
|
@@ -0,0 +1,1212 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@ngrx/store'), require('@angular/core'), require('@ngrx/effects'), require('rxjs/operators'), require('rxjs')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@ngrx-traits/core', ['exports', '@ngrx/store', '@angular/core', '@ngrx/effects', 'rxjs/operators', 'rxjs'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['ngrx-traits'] = global['ngrx-traits'] || {}, global['ngrx-traits'].core = {}), global.i2, global.ng.core, global.i1, global.rxjs.operators, global.rxjs));
|
|
5
|
+
}(this, (function (exports, i2, i0, i1, operators, rxjs) { '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 i2__namespace = /*#__PURE__*/_interopNamespace(i2);
|
|
28
|
+
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
29
|
+
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
30
|
+
|
|
31
|
+
/*! *****************************************************************************
|
|
32
|
+
Copyright (c) Microsoft Corporation.
|
|
33
|
+
|
|
34
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
35
|
+
purpose with or without fee is hereby granted.
|
|
36
|
+
|
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
38
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
39
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
40
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
41
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
42
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
43
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
44
|
+
***************************************************************************** */
|
|
45
|
+
/* global Reflect, Promise */
|
|
46
|
+
var extendStatics = function (d, b) {
|
|
47
|
+
extendStatics = Object.setPrototypeOf ||
|
|
48
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
49
|
+
function (d, b) { for (var p in b)
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
51
|
+
d[p] = b[p]; };
|
|
52
|
+
return extendStatics(d, b);
|
|
53
|
+
};
|
|
54
|
+
function __extends(d, b) {
|
|
55
|
+
if (typeof b !== "function" && b !== null)
|
|
56
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
57
|
+
extendStatics(d, b);
|
|
58
|
+
function __() { this.constructor = d; }
|
|
59
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
60
|
+
}
|
|
61
|
+
var __assign = function () {
|
|
62
|
+
__assign = Object.assign || function __assign(t) {
|
|
63
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
64
|
+
s = arguments[i];
|
|
65
|
+
for (var p in s)
|
|
66
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
67
|
+
t[p] = s[p];
|
|
68
|
+
}
|
|
69
|
+
return t;
|
|
70
|
+
};
|
|
71
|
+
return __assign.apply(this, arguments);
|
|
72
|
+
};
|
|
73
|
+
function __rest(s, e) {
|
|
74
|
+
var t = {};
|
|
75
|
+
for (var p in s)
|
|
76
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
77
|
+
t[p] = s[p];
|
|
78
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
79
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
80
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
81
|
+
t[p[i]] = s[p[i]];
|
|
82
|
+
}
|
|
83
|
+
return t;
|
|
84
|
+
}
|
|
85
|
+
function __decorate(decorators, target, key, desc) {
|
|
86
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
87
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
88
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
89
|
+
else
|
|
90
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
91
|
+
if (d = decorators[i])
|
|
92
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
93
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
94
|
+
}
|
|
95
|
+
function __param(paramIndex, decorator) {
|
|
96
|
+
return function (target, key) { decorator(target, key, paramIndex); };
|
|
97
|
+
}
|
|
98
|
+
function __metadata(metadataKey, metadataValue) {
|
|
99
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
100
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
101
|
+
}
|
|
102
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
103
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
104
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
105
|
+
function fulfilled(value) { try {
|
|
106
|
+
step(generator.next(value));
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
reject(e);
|
|
110
|
+
} }
|
|
111
|
+
function rejected(value) { try {
|
|
112
|
+
step(generator["throw"](value));
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
reject(e);
|
|
116
|
+
} }
|
|
117
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
118
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function __generator(thisArg, body) {
|
|
122
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
123
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
124
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
125
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
126
|
+
function step(op) {
|
|
127
|
+
if (f)
|
|
128
|
+
throw new TypeError("Generator is already executing.");
|
|
129
|
+
while (_)
|
|
130
|
+
try {
|
|
131
|
+
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)
|
|
132
|
+
return t;
|
|
133
|
+
if (y = 0, t)
|
|
134
|
+
op = [op[0] & 2, t.value];
|
|
135
|
+
switch (op[0]) {
|
|
136
|
+
case 0:
|
|
137
|
+
case 1:
|
|
138
|
+
t = op;
|
|
139
|
+
break;
|
|
140
|
+
case 4:
|
|
141
|
+
_.label++;
|
|
142
|
+
return { value: op[1], done: false };
|
|
143
|
+
case 5:
|
|
144
|
+
_.label++;
|
|
145
|
+
y = op[1];
|
|
146
|
+
op = [0];
|
|
147
|
+
continue;
|
|
148
|
+
case 7:
|
|
149
|
+
op = _.ops.pop();
|
|
150
|
+
_.trys.pop();
|
|
151
|
+
continue;
|
|
152
|
+
default:
|
|
153
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
154
|
+
_ = 0;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
158
|
+
_.label = op[1];
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
162
|
+
_.label = t[1];
|
|
163
|
+
t = op;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
if (t && _.label < t[2]) {
|
|
167
|
+
_.label = t[2];
|
|
168
|
+
_.ops.push(op);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
if (t[2])
|
|
172
|
+
_.ops.pop();
|
|
173
|
+
_.trys.pop();
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
op = body.call(thisArg, _);
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
179
|
+
op = [6, e];
|
|
180
|
+
y = 0;
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
f = t = 0;
|
|
184
|
+
}
|
|
185
|
+
if (op[0] & 5)
|
|
186
|
+
throw op[1];
|
|
187
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
191
|
+
if (k2 === undefined)
|
|
192
|
+
k2 = k;
|
|
193
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
194
|
+
}) : (function (o, m, k, k2) {
|
|
195
|
+
if (k2 === undefined)
|
|
196
|
+
k2 = k;
|
|
197
|
+
o[k2] = m[k];
|
|
198
|
+
});
|
|
199
|
+
function __exportStar(m, o) {
|
|
200
|
+
for (var p in m)
|
|
201
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
202
|
+
__createBinding(o, m, p);
|
|
203
|
+
}
|
|
204
|
+
function __values(o) {
|
|
205
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
206
|
+
if (m)
|
|
207
|
+
return m.call(o);
|
|
208
|
+
if (o && typeof o.length === "number")
|
|
209
|
+
return {
|
|
210
|
+
next: function () {
|
|
211
|
+
if (o && i >= o.length)
|
|
212
|
+
o = void 0;
|
|
213
|
+
return { value: o && o[i++], done: !o };
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
217
|
+
}
|
|
218
|
+
function __read(o, n) {
|
|
219
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
220
|
+
if (!m)
|
|
221
|
+
return o;
|
|
222
|
+
var i = m.call(o), r, ar = [], e;
|
|
223
|
+
try {
|
|
224
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
225
|
+
ar.push(r.value);
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
e = { error: error };
|
|
229
|
+
}
|
|
230
|
+
finally {
|
|
231
|
+
try {
|
|
232
|
+
if (r && !r.done && (m = i["return"]))
|
|
233
|
+
m.call(i);
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
if (e)
|
|
237
|
+
throw e.error;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return ar;
|
|
241
|
+
}
|
|
242
|
+
/** @deprecated */
|
|
243
|
+
function __spread() {
|
|
244
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
245
|
+
ar = ar.concat(__read(arguments[i]));
|
|
246
|
+
return ar;
|
|
247
|
+
}
|
|
248
|
+
/** @deprecated */
|
|
249
|
+
function __spreadArrays() {
|
|
250
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
251
|
+
s += arguments[i].length;
|
|
252
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
253
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
254
|
+
r[k] = a[j];
|
|
255
|
+
return r;
|
|
256
|
+
}
|
|
257
|
+
function __spreadArray(to, from, pack) {
|
|
258
|
+
if (pack || arguments.length === 2)
|
|
259
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
260
|
+
if (ar || !(i in from)) {
|
|
261
|
+
if (!ar)
|
|
262
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
263
|
+
ar[i] = from[i];
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return to.concat(ar || from);
|
|
267
|
+
}
|
|
268
|
+
function __await(v) {
|
|
269
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
270
|
+
}
|
|
271
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
272
|
+
if (!Symbol.asyncIterator)
|
|
273
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
274
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
275
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
276
|
+
function verb(n) { if (g[n])
|
|
277
|
+
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
278
|
+
function resume(n, v) { try {
|
|
279
|
+
step(g[n](v));
|
|
280
|
+
}
|
|
281
|
+
catch (e) {
|
|
282
|
+
settle(q[0][3], e);
|
|
283
|
+
} }
|
|
284
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
285
|
+
function fulfill(value) { resume("next", value); }
|
|
286
|
+
function reject(value) { resume("throw", value); }
|
|
287
|
+
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
288
|
+
resume(q[0][0], q[0][1]); }
|
|
289
|
+
}
|
|
290
|
+
function __asyncDelegator(o) {
|
|
291
|
+
var i, p;
|
|
292
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
293
|
+
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; }
|
|
294
|
+
}
|
|
295
|
+
function __asyncValues(o) {
|
|
296
|
+
if (!Symbol.asyncIterator)
|
|
297
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
298
|
+
var m = o[Symbol.asyncIterator], i;
|
|
299
|
+
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);
|
|
300
|
+
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); }); }; }
|
|
301
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
302
|
+
}
|
|
303
|
+
function __makeTemplateObject(cooked, raw) {
|
|
304
|
+
if (Object.defineProperty) {
|
|
305
|
+
Object.defineProperty(cooked, "raw", { value: raw });
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
cooked.raw = raw;
|
|
309
|
+
}
|
|
310
|
+
return cooked;
|
|
311
|
+
}
|
|
312
|
+
;
|
|
313
|
+
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
314
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
315
|
+
}) : function (o, v) {
|
|
316
|
+
o["default"] = v;
|
|
317
|
+
};
|
|
318
|
+
function __importStar(mod) {
|
|
319
|
+
if (mod && mod.__esModule)
|
|
320
|
+
return mod;
|
|
321
|
+
var result = {};
|
|
322
|
+
if (mod != null)
|
|
323
|
+
for (var k in mod)
|
|
324
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
325
|
+
__createBinding(result, mod, k);
|
|
326
|
+
__setModuleDefault(result, mod);
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
329
|
+
function __importDefault(mod) {
|
|
330
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
331
|
+
}
|
|
332
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
333
|
+
if (kind === "a" && !f)
|
|
334
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
335
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
336
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
337
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
338
|
+
}
|
|
339
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
340
|
+
if (kind === "m")
|
|
341
|
+
throw new TypeError("Private method is not writable");
|
|
342
|
+
if (kind === "a" && !f)
|
|
343
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
344
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
345
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
346
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function insertIf(condition, getElement) {
|
|
350
|
+
return condition ? [getElement()] : [];
|
|
351
|
+
}
|
|
352
|
+
function toMap(a) {
|
|
353
|
+
return a.reduce(function (acum, value) {
|
|
354
|
+
acum[value] = true;
|
|
355
|
+
return acum;
|
|
356
|
+
}, {});
|
|
357
|
+
}
|
|
358
|
+
function capitalize(name) {
|
|
359
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
360
|
+
}
|
|
361
|
+
function camelCaseToSentence(text) {
|
|
362
|
+
var result = text.replace(/([A-Z])/g, ' $1');
|
|
363
|
+
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function createTraitFactory(f) {
|
|
367
|
+
return f;
|
|
368
|
+
}
|
|
369
|
+
function createEntityFeatureFactory(namesOrFactory) {
|
|
370
|
+
var traits = [];
|
|
371
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
372
|
+
traits[_i - 1] = arguments[_i];
|
|
373
|
+
}
|
|
374
|
+
return (function (config) {
|
|
375
|
+
var _d = 'entityName' in namesOrFactory
|
|
376
|
+
? namesOrFactory
|
|
377
|
+
: { entityName: 'Entity', entitiesName: 'Entities' }, entityName = _d.entityName, entitiesName = _d.entitiesName;
|
|
378
|
+
var singular = capitalize(entityName);
|
|
379
|
+
var plural = entitiesName
|
|
380
|
+
? capitalize(entitiesName)
|
|
381
|
+
: capitalize(entityName + 's');
|
|
382
|
+
var sortedTraits = sortTraits('entityName' in namesOrFactory ? __spreadArray([], __read(traits)) : __spreadArray([namesOrFactory], __read(traits)));
|
|
383
|
+
var allConfigs = buildAllConfigs(sortedTraits);
|
|
384
|
+
var allActions = buildAllActions(sortedTraits, config.actionsGroupKey, singular, plural, allConfigs);
|
|
385
|
+
var allSelectors = buildAllSelectors(sortedTraits, allConfigs);
|
|
386
|
+
var allMutators = buildAllMutators(sortedTraits, allSelectors, allConfigs);
|
|
387
|
+
var initialState = buildInitialState(sortedTraits, allConfigs);
|
|
388
|
+
var reducer = buildReducer(sortedTraits, initialState, allActions, allSelectors, allMutators, allConfigs);
|
|
389
|
+
var featureSelector = typeof config.featureSelector === 'string'
|
|
390
|
+
? i2.createFeatureSelector(config.featureSelector)
|
|
391
|
+
: config.featureSelector;
|
|
392
|
+
var allFeatureSelectors = allSelectors && getSelectorsForFeature(featureSelector, allSelectors);
|
|
393
|
+
var allEffects = buildAllEffects(sortedTraits, allActions, allFeatureSelectors, allConfigs);
|
|
394
|
+
return {
|
|
395
|
+
actions: entityName
|
|
396
|
+
? renameProps(allActions, singular, plural)
|
|
397
|
+
: allActions,
|
|
398
|
+
selectors: entityName
|
|
399
|
+
? renameProps(allFeatureSelectors, singular, plural)
|
|
400
|
+
: allSelectors,
|
|
401
|
+
initialState: initialState,
|
|
402
|
+
reducer: reducer !== null && reducer !== void 0 ? reducer : i2.createReducer(initialState),
|
|
403
|
+
effects: allEffects,
|
|
404
|
+
};
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
function renameProps(target, entityName, entitiesName) {
|
|
408
|
+
var e_1, _d;
|
|
409
|
+
var result = {};
|
|
410
|
+
try {
|
|
411
|
+
for (var _e = __values(Object.entries(target)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
412
|
+
var _g = __read(_f.value, 2), key = _g[0], value = _g[1];
|
|
413
|
+
var newKey = key
|
|
414
|
+
.replace('Entities', entitiesName)
|
|
415
|
+
.replace('Entity', entityName);
|
|
416
|
+
result[newKey] = value;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
420
|
+
finally {
|
|
421
|
+
try {
|
|
422
|
+
if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
|
|
423
|
+
}
|
|
424
|
+
finally { if (e_1) throw e_1.error; }
|
|
425
|
+
}
|
|
426
|
+
return result;
|
|
427
|
+
}
|
|
428
|
+
function sortTraits(traits) {
|
|
429
|
+
var _a;
|
|
430
|
+
var sortedTraits = [];
|
|
431
|
+
var _loop_1 = function (i) {
|
|
432
|
+
var e_2, _d;
|
|
433
|
+
var trait = traits[i];
|
|
434
|
+
if (!((_a = trait.depends) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
435
|
+
sortedTraits.push(trait);
|
|
436
|
+
return "continue";
|
|
437
|
+
}
|
|
438
|
+
if (trait.depends.length > 1) {
|
|
439
|
+
var _loop_2 = function (d) {
|
|
440
|
+
var isTraitPresent = traits.some(function (tr) { return tr.key === d; });
|
|
441
|
+
if (isTraitPresent) {
|
|
442
|
+
trait.depends = [d];
|
|
443
|
+
return "break";
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
try {
|
|
447
|
+
for (var _e = (e_2 = void 0, __values(trait.depends)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
448
|
+
var d = _f.value;
|
|
449
|
+
var state_1 = _loop_2(d);
|
|
450
|
+
if (state_1 === "break")
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
455
|
+
finally {
|
|
456
|
+
try {
|
|
457
|
+
if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
|
|
458
|
+
}
|
|
459
|
+
finally { if (e_2) throw e_2.error; }
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (trait.depends.length > 1)
|
|
463
|
+
throw Error('could not find dependencies ' + trait.depends.join(' '));
|
|
464
|
+
var isDependencyAlreadyAdded = sortedTraits.some(function (tr) { var _a; return tr.key === ((_a = trait === null || trait === void 0 ? void 0 : trait.depends) === null || _a === void 0 ? void 0 : _a[0]); });
|
|
465
|
+
if (isDependencyAlreadyAdded)
|
|
466
|
+
sortedTraits.push(trait);
|
|
467
|
+
else {
|
|
468
|
+
// move trait to the end
|
|
469
|
+
delete traits[i];
|
|
470
|
+
traits.push(trait);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
for (var i = 0; i < traits.length; i++) {
|
|
474
|
+
_loop_1(i);
|
|
475
|
+
}
|
|
476
|
+
return sortedTraits;
|
|
477
|
+
}
|
|
478
|
+
function buildAllConfigs(sortedTraits) {
|
|
479
|
+
return sortedTraits.reduce(function (acc, factory) {
|
|
480
|
+
acc[factory.key] = factory.config;
|
|
481
|
+
return acc;
|
|
482
|
+
}, {});
|
|
483
|
+
}
|
|
484
|
+
function buildAllActions(sortedTraits, actionsGroupKey, entityName, entitiesName, allConfigs) {
|
|
485
|
+
return sortedTraits.reduce(function (previousResult, factory) {
|
|
486
|
+
var _a, _b;
|
|
487
|
+
var result = (_b = (_a = factory === null || factory === void 0 ? void 0 : factory.actions) === null || _a === void 0 ? void 0 : _a.call(factory, {
|
|
488
|
+
actionsGroupKey: actionsGroupKey,
|
|
489
|
+
entityName: entityName,
|
|
490
|
+
entitiesName: entitiesName,
|
|
491
|
+
allConfigs: allConfigs,
|
|
492
|
+
})) !== null && _b !== void 0 ? _b : {};
|
|
493
|
+
result = previousResult ? Object.assign(Object.assign({}, previousResult), result) : result;
|
|
494
|
+
return result;
|
|
495
|
+
}, {});
|
|
496
|
+
}
|
|
497
|
+
function buildAllSelectors(sortedTraits, allConfigs) {
|
|
498
|
+
return sortedTraits.reduce(function (previousResult, factory) {
|
|
499
|
+
var _a, _b;
|
|
500
|
+
var result = (_b = (_a = factory === null || factory === void 0 ? void 0 : factory.selectors) === null || _a === void 0 ? void 0 : _a.call(factory, {
|
|
501
|
+
previousSelectors: previousResult,
|
|
502
|
+
allConfigs: allConfigs,
|
|
503
|
+
})) !== null && _b !== void 0 ? _b : {};
|
|
504
|
+
result = previousResult ? Object.assign(Object.assign({}, previousResult), result) : result;
|
|
505
|
+
return result;
|
|
506
|
+
}, {});
|
|
507
|
+
}
|
|
508
|
+
function buildAllMutators(sortedTraits, allSelectors, allConfigs) {
|
|
509
|
+
return (sortedTraits.reduce(function (previousResult, factory) {
|
|
510
|
+
var _a, _b;
|
|
511
|
+
var result = (_b = (_a = factory === null || factory === void 0 ? void 0 : factory.mutators) === null || _a === void 0 ? void 0 : _a.call(factory, {
|
|
512
|
+
allSelectors: allSelectors,
|
|
513
|
+
previousMutators: previousResult,
|
|
514
|
+
allConfigs: allConfigs,
|
|
515
|
+
})) !== null && _b !== void 0 ? _b : {};
|
|
516
|
+
result = previousResult ? Object.assign(Object.assign({}, previousResult), result) : result;
|
|
517
|
+
return result;
|
|
518
|
+
}, {}) || {});
|
|
519
|
+
}
|
|
520
|
+
function buildInitialState(sortedTraits, allConfigs) {
|
|
521
|
+
return sortedTraits.reduce(function (previousResult, factory) {
|
|
522
|
+
var _a, _b, _c;
|
|
523
|
+
var result = (_c = (_b = (_a = factory === null || factory === void 0 ? void 0 : factory.initialState) === null || _a === void 0 ? void 0 : _a.call(factory, {
|
|
524
|
+
previousInitialState: previousResult,
|
|
525
|
+
allConfigs: allConfigs,
|
|
526
|
+
})) !== null && _b !== void 0 ? _b : previousResult) !== null && _c !== void 0 ? _c : {};
|
|
527
|
+
return result;
|
|
528
|
+
}, {});
|
|
529
|
+
}
|
|
530
|
+
function buildReducer(sortedTraits, initialState, allActions, allSelectors, allMutators, allConfigs) {
|
|
531
|
+
return sortedTraits.reduce(function (previousResult, factory) {
|
|
532
|
+
var _a;
|
|
533
|
+
var result = (_a = factory === null || factory === void 0 ? void 0 : factory.reducer) === null || _a === void 0 ? void 0 : _a.call(factory, {
|
|
534
|
+
initialState: initialState,
|
|
535
|
+
allActions: allActions,
|
|
536
|
+
allSelectors: allSelectors,
|
|
537
|
+
allMutators: allMutators,
|
|
538
|
+
allConfigs: allConfigs,
|
|
539
|
+
});
|
|
540
|
+
return result && previousResult
|
|
541
|
+
? function (state, action) {
|
|
542
|
+
if (state === void 0) { state = initialState; }
|
|
543
|
+
var aState = previousResult(state, action);
|
|
544
|
+
return result(aState, action);
|
|
545
|
+
}
|
|
546
|
+
: result !== null && result !== void 0 ? result : previousResult;
|
|
547
|
+
}, undefined);
|
|
548
|
+
}
|
|
549
|
+
function buildAllEffects(sortedTraits, allActions, allFeatureSelectors, allConfigs) {
|
|
550
|
+
return sortedTraits.reduce(function (previousResult, factory) {
|
|
551
|
+
var _a, _b;
|
|
552
|
+
var result = (_b = (_a = factory === null || factory === void 0 ? void 0 : factory.effects) === null || _a === void 0 ? void 0 : _a.call(factory, {
|
|
553
|
+
allActions: allActions,
|
|
554
|
+
allSelectors: allFeatureSelectors,
|
|
555
|
+
allConfigs: allConfigs,
|
|
556
|
+
})) !== null && _b !== void 0 ? _b : [];
|
|
557
|
+
result = previousResult ? __spreadArray(__spreadArray([], __read(previousResult)), __read(result)) : result;
|
|
558
|
+
return result;
|
|
559
|
+
}, []);
|
|
560
|
+
}
|
|
561
|
+
function getSelectorsForFeature(featureSelect, selectors) {
|
|
562
|
+
var ss = {};
|
|
563
|
+
for (var prop in selectors) {
|
|
564
|
+
ss[prop] = i2.createSelector(featureSelect, selectors[prop]);
|
|
565
|
+
}
|
|
566
|
+
return ss;
|
|
567
|
+
}
|
|
568
|
+
function setPropertyReducer(sourceReducer, property, propertyReducer) {
|
|
569
|
+
return function reducer(state, action) {
|
|
570
|
+
var _d;
|
|
571
|
+
var sourceState = sourceReducer(state, action);
|
|
572
|
+
return Object.assign(Object.assign({}, sourceState), (_d = {}, _d[property] = propertyReducer(sourceState[property], action), _d));
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
function setPropertiesReducer(sourceReducer, propertiesReducers) {
|
|
576
|
+
return function reducer(state, action) {
|
|
577
|
+
var newState = Object.assign({}, sourceReducer(state, action));
|
|
578
|
+
for (var property in propertiesReducers) {
|
|
579
|
+
newState[property] = propertiesReducers[property](newState[property], action);
|
|
580
|
+
}
|
|
581
|
+
return newState;
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function joinReducers(firstReducer, secondReducer) {
|
|
585
|
+
return function reducer(state, action) {
|
|
586
|
+
var sourceState = firstReducer(state, action);
|
|
587
|
+
return secondReducer(sourceState, action);
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function combineEntityFeatures(traitFactoriesMap) {
|
|
591
|
+
return (function (config) {
|
|
592
|
+
var e_3, _d;
|
|
593
|
+
var featureSelector = typeof config.featureSelector === 'string'
|
|
594
|
+
? i2.createFeatureSelector(config.featureSelector)
|
|
595
|
+
: config.featureSelector;
|
|
596
|
+
var actions = {};
|
|
597
|
+
var selectors = {};
|
|
598
|
+
var reducers = {};
|
|
599
|
+
var effects = [];
|
|
600
|
+
var _loop_3 = function (key, entityFeatureFactory) {
|
|
601
|
+
var selector = i2.createSelector(featureSelector, function (state) { return state[key]; });
|
|
602
|
+
var featureTraits = entityFeatureFactory({
|
|
603
|
+
actionsGroupKey: config.actionsGroupKey,
|
|
604
|
+
featureSelector: selector,
|
|
605
|
+
});
|
|
606
|
+
actions[key] = featureTraits.actions;
|
|
607
|
+
selectors[key] = featureTraits.selectors;
|
|
608
|
+
reducers[key] = featureTraits.reducer;
|
|
609
|
+
effects = __spreadArray(__spreadArray([], __read(effects)), __read(featureTraits.effects));
|
|
610
|
+
};
|
|
611
|
+
try {
|
|
612
|
+
for (var _e = __values(Object.entries(traitFactoriesMap)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
613
|
+
var _g = __read(_f.value, 2), key = _g[0], entityFeatureFactory = _g[1];
|
|
614
|
+
_loop_3(key, entityFeatureFactory);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
618
|
+
finally {
|
|
619
|
+
try {
|
|
620
|
+
if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
|
|
621
|
+
}
|
|
622
|
+
finally { if (e_3) throw e_3.error; }
|
|
623
|
+
}
|
|
624
|
+
return {
|
|
625
|
+
actions: actions,
|
|
626
|
+
selectors: selectors,
|
|
627
|
+
reducer: i2.combineReducers(reducers),
|
|
628
|
+
effects: effects,
|
|
629
|
+
};
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
function mixEntityFeatures(traitFactoriesMap) {
|
|
633
|
+
return (function (config) {
|
|
634
|
+
var e_4, _d;
|
|
635
|
+
var featureSelector = typeof config.featureSelector === 'string'
|
|
636
|
+
? i2.createFeatureSelector(config.featureSelector)
|
|
637
|
+
: config.featureSelector;
|
|
638
|
+
var actions = {};
|
|
639
|
+
var selectors = {};
|
|
640
|
+
var reducers = {};
|
|
641
|
+
var effects = [];
|
|
642
|
+
var _loop_4 = function (key, entityFeatureFactory) {
|
|
643
|
+
var selector = i2.createSelector(featureSelector, function (state) { return state[key]; });
|
|
644
|
+
var featureTraits = entityFeatureFactory({
|
|
645
|
+
actionsGroupKey: config.actionsGroupKey,
|
|
646
|
+
featureSelector: selector,
|
|
647
|
+
});
|
|
648
|
+
actions = Object.assign(Object.assign({}, actions), featureTraits.actions);
|
|
649
|
+
selectors = Object.assign(Object.assign({}, selectors), featureTraits.selectors);
|
|
650
|
+
reducers[key] = featureTraits.reducer;
|
|
651
|
+
effects = __spreadArray(__spreadArray([], __read(effects)), __read(featureTraits.effects));
|
|
652
|
+
};
|
|
653
|
+
try {
|
|
654
|
+
for (var _e = __values(Object.entries(traitFactoriesMap)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
655
|
+
var _g = __read(_f.value, 2), key = _g[0], entityFeatureFactory = _g[1];
|
|
656
|
+
_loop_4(key, entityFeatureFactory);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
660
|
+
finally {
|
|
661
|
+
try {
|
|
662
|
+
if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
|
|
663
|
+
}
|
|
664
|
+
finally { if (e_4) throw e_4.error; }
|
|
665
|
+
}
|
|
666
|
+
return {
|
|
667
|
+
actions: actions,
|
|
668
|
+
selectors: selectors,
|
|
669
|
+
reducer: i2.combineReducers(reducers),
|
|
670
|
+
effects: effects,
|
|
671
|
+
};
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
function addEntityFeaturesProperties(targetTraitFactory, traitFactoriesMap) {
|
|
675
|
+
return (function (config) {
|
|
676
|
+
var e_5, _d;
|
|
677
|
+
var featureSelector = typeof config.featureSelector === 'string'
|
|
678
|
+
? i2.createFeatureSelector(config.featureSelector)
|
|
679
|
+
: config.featureSelector;
|
|
680
|
+
var targetFeatureTraits = targetTraitFactory({
|
|
681
|
+
actionsGroupKey: config.actionsGroupKey,
|
|
682
|
+
featureSelector: featureSelector,
|
|
683
|
+
});
|
|
684
|
+
var actions = Object.assign({}, targetFeatureTraits.actions);
|
|
685
|
+
var selectors = Object.assign({}, targetFeatureTraits.selectors);
|
|
686
|
+
var reducers = {};
|
|
687
|
+
var effects = __spreadArray([], __read(targetFeatureTraits.effects));
|
|
688
|
+
var _loop_5 = function (key, entityFeatureFactory) {
|
|
689
|
+
var selector = i2.createSelector(featureSelector, function (state) { return state[key]; });
|
|
690
|
+
var featureTraits = entityFeatureFactory({
|
|
691
|
+
actionsGroupKey: config.actionsGroupKey,
|
|
692
|
+
featureSelector: selector,
|
|
693
|
+
});
|
|
694
|
+
actions[key] = featureTraits.actions;
|
|
695
|
+
selectors[key] = featureTraits.selectors;
|
|
696
|
+
reducers[key] = featureTraits.reducer;
|
|
697
|
+
effects = __spreadArray(__spreadArray([], __read(effects)), __read(featureTraits.effects));
|
|
698
|
+
};
|
|
699
|
+
try {
|
|
700
|
+
for (var _e = __values(Object.entries(traitFactoriesMap)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
701
|
+
var _g = __read(_f.value, 2), key = _g[0], entityFeatureFactory = _g[1];
|
|
702
|
+
_loop_5(key, entityFeatureFactory);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
706
|
+
finally {
|
|
707
|
+
try {
|
|
708
|
+
if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
|
|
709
|
+
}
|
|
710
|
+
finally { if (e_5) throw e_5.error; }
|
|
711
|
+
}
|
|
712
|
+
return {
|
|
713
|
+
actions: actions,
|
|
714
|
+
selectors: selectors,
|
|
715
|
+
reducer: setPropertiesReducer(targetFeatureTraits.reducer, reducers),
|
|
716
|
+
effects: effects,
|
|
717
|
+
};
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
// export
|
|
721
|
+
/// products:{actions, selectors, }, orders: {actions,slectors}
|
|
722
|
+
/// { actions: {ProductActions, OrderActions}, selectors: {ProductSelectors, OrderSelectors}
|
|
723
|
+
// TODO finish implementing combineTrais and addPropertiesTraits
|
|
724
|
+
// TODO finish renaming traits
|
|
725
|
+
|
|
726
|
+
// type G = ReplaceProps<
|
|
727
|
+
// ReplaceProps<
|
|
728
|
+
// {
|
|
729
|
+
// loadEntities: 1;
|
|
730
|
+
// loadEntitiesSuccess: 2;
|
|
731
|
+
// selectEntities: 3;
|
|
732
|
+
// selectEntity: 4;
|
|
733
|
+
// },
|
|
734
|
+
// 'Entities',
|
|
735
|
+
// 'products'
|
|
736
|
+
// >,
|
|
737
|
+
// 'Entity',
|
|
738
|
+
// 'product'
|
|
739
|
+
// >;
|
|
740
|
+
//
|
|
741
|
+
// const g: G = {};
|
|
742
|
+
// // g.
|
|
743
|
+
// type F= ReplaceEntityNames<{
|
|
744
|
+
// loadEntities: 1;
|
|
745
|
+
// loadEntitiesSuccess: 2;
|
|
746
|
+
// selectEntities: 3;
|
|
747
|
+
// selectEntity: 4;
|
|
748
|
+
// }, 'product','products'>;
|
|
749
|
+
// const f: F = {};
|
|
750
|
+
// f.
|
|
751
|
+
// TODO clean up file
|
|
752
|
+
|
|
753
|
+
var TraitEffect = /** @class */ (function () {
|
|
754
|
+
function TraitEffect(actions$, store) {
|
|
755
|
+
this.actions$ = actions$;
|
|
756
|
+
this.store = store;
|
|
757
|
+
this.name = this.constructor.name;
|
|
758
|
+
this.componentId = '';
|
|
759
|
+
}
|
|
760
|
+
TraitEffect.prototype.ngrxOnIdentifyEffects = function () {
|
|
761
|
+
return this.componentId ? this.name + this.componentId : '';
|
|
762
|
+
};
|
|
763
|
+
TraitEffect.prototype.ngrxOnRunEffects = function (resolvedEffects$) {
|
|
764
|
+
return this.componentId
|
|
765
|
+
? resolvedEffects$.pipe(operators.takeUntil(this.actions$.pipe(i1.ofType(getDestroyActionName(this.componentId)))))
|
|
766
|
+
: resolvedEffects$;
|
|
767
|
+
};
|
|
768
|
+
return TraitEffect;
|
|
769
|
+
}());
|
|
770
|
+
TraitEffect.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: TraitEffect, deps: [{ token: i1__namespace.Actions }, { token: i2__namespace.Store }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
771
|
+
TraitEffect.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: TraitEffect });
|
|
772
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: TraitEffect, decorators: [{
|
|
773
|
+
type: i0.Injectable
|
|
774
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.Actions }, { type: i2__namespace.Store }]; } });
|
|
775
|
+
function getDestroyActionName(id) {
|
|
776
|
+
return "[" + id + "] Destroyed";
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* @internal
|
|
781
|
+
*/
|
|
782
|
+
var DISABLE_LOCAL_TRAIT_EFFECTS = new i0.InjectionToken('disableLocalTraitEffects');
|
|
783
|
+
|
|
784
|
+
var id = 0;
|
|
785
|
+
function uniqueComponentId() {
|
|
786
|
+
return id++;
|
|
787
|
+
}
|
|
788
|
+
function buildLocalTraits(injector, componentName, traitFactory) {
|
|
789
|
+
var _a;
|
|
790
|
+
var reducers = injector.get(i2.ReducerManager);
|
|
791
|
+
var effects = injector.get(i1.EffectSources);
|
|
792
|
+
var store = injector.get(i2.Store);
|
|
793
|
+
var componentId = componentName + "_" + uniqueComponentId();
|
|
794
|
+
var traits = traitFactory({
|
|
795
|
+
featureSelector: i2.createFeatureSelector(componentId),
|
|
796
|
+
actionsGroupKey: "[" + componentId + "]",
|
|
797
|
+
});
|
|
798
|
+
traits.reducer && reducers.addReducer(componentId, traits.reducer);
|
|
799
|
+
var providers = (traits.effects && __spreadArray([], __read(traits.effects.map(function (e) { return ({ provide: e }); })))) || [];
|
|
800
|
+
var disableLocalTraitsEffects = injector.get(DISABLE_LOCAL_TRAIT_EFFECTS, false);
|
|
801
|
+
if (!disableLocalTraitsEffects) {
|
|
802
|
+
var i_1 = i0.Injector.create({
|
|
803
|
+
providers: providers,
|
|
804
|
+
parent: injector,
|
|
805
|
+
});
|
|
806
|
+
(_a = traits.effects) === null || _a === void 0 ? void 0 : _a.forEach(function (e) {
|
|
807
|
+
var effect = i_1.get(e);
|
|
808
|
+
effect.componentId = componentId;
|
|
809
|
+
effects.addEffects(effect);
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
function destroy() {
|
|
813
|
+
store.dispatch({ type: getDestroyActionName(componentId) });
|
|
814
|
+
/**
|
|
815
|
+
* A service that extends TraitsLocalStore and other component service are destroyed
|
|
816
|
+
* before the component that depends on them, this causes that any subscriptions
|
|
817
|
+
* to selectors of the TraitsLocalStore could fail because the store state is removed before
|
|
818
|
+
* they are unsubscribe by the onDestroy of the component. Executing reducers.removeReducer
|
|
819
|
+
* inside setTimeout ensures the state is remove after the component onDestroy was called,
|
|
820
|
+
* avoiding the before mentioned possible issues.
|
|
821
|
+
*/
|
|
822
|
+
setTimeout(function () { return reducers.removeReducer(componentId); });
|
|
823
|
+
}
|
|
824
|
+
return {
|
|
825
|
+
destroy: destroy,
|
|
826
|
+
actions: traits.actions,
|
|
827
|
+
selectors: traits.selectors,
|
|
828
|
+
addEffects: function (localEffect) {
|
|
829
|
+
localEffect.componentId = componentId;
|
|
830
|
+
effects.addEffects(localEffect);
|
|
831
|
+
},
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
var TraitsLocalStore = /** @class */ (function (_super) {
|
|
835
|
+
__extends(TraitsLocalStore, _super);
|
|
836
|
+
function TraitsLocalStore(injector) {
|
|
837
|
+
var _this = _super.call(this, injector.get(i1.Actions), injector.get(i2.Store)) || this;
|
|
838
|
+
_this.injector = injector;
|
|
839
|
+
var config = _this.setup();
|
|
840
|
+
_this.traits = buildLocalTraits(_this.injector, config.componentName, config.traitsFactory);
|
|
841
|
+
_this.localActions = _this.traits.actions;
|
|
842
|
+
_this.localSelectors = _this.traits.selectors;
|
|
843
|
+
return _this;
|
|
844
|
+
}
|
|
845
|
+
TraitsLocalStore.prototype.ngOnDestroy = function () {
|
|
846
|
+
this.traits.destroy();
|
|
847
|
+
};
|
|
848
|
+
return TraitsLocalStore;
|
|
849
|
+
}(TraitEffect));
|
|
850
|
+
TraitsLocalStore.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: TraitsLocalStore, deps: [{ token: i0__namespace.Injector }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
851
|
+
TraitsLocalStore.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: TraitsLocalStore });
|
|
852
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: TraitsLocalStore, decorators: [{
|
|
853
|
+
type: i0.Injectable
|
|
854
|
+
}], ctorParameters: function () { return [{ type: i0__namespace.Injector }]; } });
|
|
855
|
+
|
|
856
|
+
function hash(key) {
|
|
857
|
+
return JSON.stringify(key, function (_, val) { return typeof val == 'object'
|
|
858
|
+
? Object.keys(val)
|
|
859
|
+
.sort()
|
|
860
|
+
.reduce(function (result, k) {
|
|
861
|
+
result[k] = val[k];
|
|
862
|
+
return result;
|
|
863
|
+
}, {})
|
|
864
|
+
: val; });
|
|
865
|
+
}
|
|
866
|
+
function hashKey(key) {
|
|
867
|
+
return typeof key === 'string'
|
|
868
|
+
? [key]
|
|
869
|
+
: key.map(function (k) {
|
|
870
|
+
return typeof k === 'string' ? k : hash(k);
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
function getCacheValue(keys, state) {
|
|
874
|
+
var e_1, _b;
|
|
875
|
+
var _a;
|
|
876
|
+
var parent = state;
|
|
877
|
+
try {
|
|
878
|
+
for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
|
|
879
|
+
var key = keys_1_1.value;
|
|
880
|
+
parent = (_a = parent === null || parent === void 0 ? void 0 : parent.keys) === null || _a === void 0 ? void 0 : _a[key];
|
|
881
|
+
if (!parent)
|
|
882
|
+
return undefined;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
886
|
+
finally {
|
|
887
|
+
try {
|
|
888
|
+
if (keys_1_1 && !keys_1_1.done && (_b = keys_1.return)) _b.call(keys_1);
|
|
889
|
+
}
|
|
890
|
+
finally { if (e_1) throw e_1.error; }
|
|
891
|
+
}
|
|
892
|
+
return parent === null || parent === void 0 ? void 0 : parent.data;
|
|
893
|
+
}
|
|
894
|
+
function isCacheValid(cache, exp) {
|
|
895
|
+
return !cache.invalid && Date.now() <= cache.date + exp;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
var cacheStateSelector = i2.createFeatureSelector('cache');
|
|
899
|
+
var selectCache = function (key) { return i2.createSelector(cacheStateSelector, function (state) { return getCacheValue(hashKey(key), state); }); };
|
|
900
|
+
|
|
901
|
+
var cache$1 = i2.createAction('[Cache] Cache', i2.props());
|
|
902
|
+
var hitCache = i2.createAction('[Cache] Hit Cache', i2.props());
|
|
903
|
+
var invalidateCache$1 = i2.createAction('[Cache] Invalidate Cache', i2.props());
|
|
904
|
+
var deleteCache = i2.createAction('[Cache] Delete Cache', i2.props());
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Cache the result of source parameter using the provided key, when call
|
|
908
|
+
* again if the cache is valid (exist and is not expired or invalidated)
|
|
909
|
+
* it will return the cache value without calling again source
|
|
910
|
+
* @example
|
|
911
|
+
* // cache for 3 min
|
|
912
|
+
* loadStores$ = createEffect(() => {
|
|
913
|
+
* return this.actions$.pipe(
|
|
914
|
+
* ofType(ProductStoreActions.loadStores),
|
|
915
|
+
* exhaustMap(() =>
|
|
916
|
+
* cache({
|
|
917
|
+
* key: ['stores'],
|
|
918
|
+
* store: this.store,
|
|
919
|
+
* source: this.storeService.getStores(),
|
|
920
|
+
* expire: 1000 * 60 * 3 // optional param , cache forever if not present
|
|
921
|
+
* }).pipe(
|
|
922
|
+
* map((res) => ProductStoreActions.loadStoresSuccess({ entities: res })),
|
|
923
|
+
* catchError(() => of(ProductStoreActions.loadStoresFail()))
|
|
924
|
+
* )
|
|
925
|
+
* )
|
|
926
|
+
* );
|
|
927
|
+
* });
|
|
928
|
+
* // cache top 10, for 3 mins
|
|
929
|
+
* loadDepartments$ = createEffect(() => {
|
|
930
|
+
* return this.actions$.pipe(
|
|
931
|
+
* ofType(this.localActions.loadDepartments),
|
|
932
|
+
* concatLatestFrom(() =>
|
|
933
|
+
* this.store.select(this.localSelectors.selectDepartmentsFilter)
|
|
934
|
+
* ),
|
|
935
|
+
* exhaustMap(([_, filters]) =>
|
|
936
|
+
* cache({
|
|
937
|
+
* key: ['stores','departments',{ storeId: filters!.storeId },
|
|
938
|
+
* store: this.store,
|
|
939
|
+
* source: this.storeService.getStoreDepartments(filters!.storeId),
|
|
940
|
+
* expires: 1000 * 60 * 3,
|
|
941
|
+
* maxCacheSize: 10,
|
|
942
|
+
* }).pipe(
|
|
943
|
+
* map((res) =>
|
|
944
|
+
* this.localActions.loadDepartmentsSuccess({
|
|
945
|
+
* entities: res,
|
|
946
|
+
* })
|
|
947
|
+
* ),
|
|
948
|
+
* catchError(() => of(this.localActions.loadDepartmentsFail()))
|
|
949
|
+
* )
|
|
950
|
+
* )
|
|
951
|
+
* );
|
|
952
|
+
* });
|
|
953
|
+
*
|
|
954
|
+
* @param options - configuration
|
|
955
|
+
* @param options.store - required ngrx store
|
|
956
|
+
* @param options.key - key can be string, array of string or array of string with plain objects
|
|
957
|
+
* @param options.source - called when cache is invalid
|
|
958
|
+
* @param options.expires - time to expire the cache valued, if not present is infinite
|
|
959
|
+
* @param options.maxCacheSize - max number of keys to store , only works if last key is variable
|
|
960
|
+
*/
|
|
961
|
+
function cache(_a) {
|
|
962
|
+
var store = _a.store, key = _a.key, source = _a.source, expires = _a.expires, maxCacheSize = _a.maxCacheSize;
|
|
963
|
+
var exp = expires !== null && expires !== void 0 ? expires : Infinity;
|
|
964
|
+
return store.select(selectCache(key)).pipe(operators.first(), operators.concatMap(function (cache) { return cache && isCacheValid(cache, exp)
|
|
965
|
+
? rxjs.of(cache.value).pipe(operators.tap(function () { return store.dispatch(hitCache({ key: key })); }))
|
|
966
|
+
: source.pipe(operators.tap(function (value) { return store.dispatch(cache$1({
|
|
967
|
+
key: key,
|
|
968
|
+
date: Date.now(),
|
|
969
|
+
value: value,
|
|
970
|
+
maxCacheSize: maxCacheSize,
|
|
971
|
+
})); })); }));
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
var initialState = {
|
|
975
|
+
keys: {},
|
|
976
|
+
};
|
|
977
|
+
var cacheReducer = i2.createReducer(initialState, i2.on(cache$1, function (state, _j) {
|
|
978
|
+
var key = _j.key, value = _j.value, date = _j.date, maxCacheSize = _j.maxCacheSize;
|
|
979
|
+
return setCacheValue(hashKey(key), { value: value, date: date, invalid: false }, state, maxCacheSize);
|
|
980
|
+
}), i2.on(invalidateCache$1, function (state, _j) {
|
|
981
|
+
var key = _j.key;
|
|
982
|
+
var k = hashKey(key);
|
|
983
|
+
return invalidateCache(k, state);
|
|
984
|
+
}), i2.on(deleteCache, function (state, _j) {
|
|
985
|
+
var key = _j.key;
|
|
986
|
+
var k = hashKey(key);
|
|
987
|
+
return deleteCacheValue(k, state);
|
|
988
|
+
}), i2.on(hitCache, function (state, _j) {
|
|
989
|
+
var key = _j.key;
|
|
990
|
+
var k = hashKey(key);
|
|
991
|
+
return increaseCacheHitCount(k, state);
|
|
992
|
+
}));
|
|
993
|
+
function setCacheValue(keys, value, state, maxCacheSize, expires) {
|
|
994
|
+
var e_1, _j;
|
|
995
|
+
var newState = Object.assign({}, state);
|
|
996
|
+
var cache = newState;
|
|
997
|
+
var lastCache = undefined;
|
|
998
|
+
for (var i = 0; i < keys.length; i++) {
|
|
999
|
+
var key = keys[i];
|
|
1000
|
+
cache.keys = (cache === null || cache === void 0 ? void 0 : cache.keys) ? Object.assign({}, cache === null || cache === void 0 ? void 0 : cache.keys) : {};
|
|
1001
|
+
var v = cache.keys[key];
|
|
1002
|
+
v = v ? Object.assign({}, v) : {};
|
|
1003
|
+
cache.keys[key] = v;
|
|
1004
|
+
lastCache = cache;
|
|
1005
|
+
cache = v;
|
|
1006
|
+
}
|
|
1007
|
+
cache.data = cache.data
|
|
1008
|
+
? Object.assign(Object.assign({}, value), { hitCount: cache.data.hitCount + 1 }) : Object.assign(Object.assign({}, value), { hitCount: 1 });
|
|
1009
|
+
if (maxCacheSize &&
|
|
1010
|
+
(lastCache === null || lastCache === void 0 ? void 0 : lastCache.keys) &&
|
|
1011
|
+
Object.keys(lastCache.keys).length > maxCacheSize) {
|
|
1012
|
+
var entries = findLessHitOrOldestCacheEntries(lastCache, expires !== null && expires !== void 0 ? expires : Infinity, maxCacheSize);
|
|
1013
|
+
if (entries && entries.length) {
|
|
1014
|
+
try {
|
|
1015
|
+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
1016
|
+
var _k = __read(entries_1_1.value, 1), key = _k[0];
|
|
1017
|
+
delete lastCache.keys[key];
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1021
|
+
finally {
|
|
1022
|
+
try {
|
|
1023
|
+
if (entries_1_1 && !entries_1_1.done && (_j = entries_1.return)) _j.call(entries_1);
|
|
1024
|
+
}
|
|
1025
|
+
finally { if (e_1) throw e_1.error; }
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
return newState;
|
|
1030
|
+
}
|
|
1031
|
+
function findLessHitOrOldestCacheEntries(state, expires, maxCacheSize) {
|
|
1032
|
+
if (!state.keys)
|
|
1033
|
+
return undefined;
|
|
1034
|
+
var entries = Object.entries(state.keys);
|
|
1035
|
+
// find the newest key;
|
|
1036
|
+
var _j = __read(entries.reduce(function (a, b) {
|
|
1037
|
+
var _a, _b, _c, _d;
|
|
1038
|
+
var aDate = (_b = (_a = a[1].data) === null || _a === void 0 ? void 0 : _a.date) !== null && _b !== void 0 ? _b : 0;
|
|
1039
|
+
var bDate = (_d = (_c = b[1].data) === null || _c === void 0 ? void 0 : _c.date) !== null && _d !== void 0 ? _d : 0;
|
|
1040
|
+
return aDate > bDate ? a : b;
|
|
1041
|
+
}), 1), newestKey = _j[0];
|
|
1042
|
+
var sorted = entries.sort(function (_j, _k) {
|
|
1043
|
+
var _l = __read(_j, 2), aKey = _l[0], aValue = _l[1];
|
|
1044
|
+
var _m = __read(_k, 2), bKey = _m[0], bValue = _m[1];
|
|
1045
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1046
|
+
// ensures the newest key always wins
|
|
1047
|
+
if (aKey === newestKey)
|
|
1048
|
+
return -1;
|
|
1049
|
+
if (bKey === newestKey)
|
|
1050
|
+
return 1;
|
|
1051
|
+
var aValid = aValue.data && isCacheValid(aValue.data, expires) ? 1 : 0;
|
|
1052
|
+
var bValid = bValue.data && isCacheValid(bValue.data, expires) ? 1 : 0;
|
|
1053
|
+
var diffValid = aValid - bValid;
|
|
1054
|
+
var diffHit = ((_b = (_a = aValue.data) === null || _a === void 0 ? void 0 : _a.hitCount) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = bValue.data) === null || _c === void 0 ? void 0 : _c.hitCount) !== null && _d !== void 0 ? _d : 0);
|
|
1055
|
+
var diffDate = ((_f = (_e = aValue.data) === null || _e === void 0 ? void 0 : _e.date) !== null && _f !== void 0 ? _f : 0) - ((_h = (_g = bValue.data) === null || _g === void 0 ? void 0 : _g.date) !== null && _h !== void 0 ? _h : 0);
|
|
1056
|
+
return (-1 * (diffValid === 0 ? (diffHit === 0 ? diffDate : diffHit) : diffValid));
|
|
1057
|
+
});
|
|
1058
|
+
return sorted.slice(maxCacheSize);
|
|
1059
|
+
}
|
|
1060
|
+
function deleteCacheValue(keys, state) {
|
|
1061
|
+
var e_2, _j;
|
|
1062
|
+
var newState = Object.assign({}, state);
|
|
1063
|
+
var cache = newState;
|
|
1064
|
+
try {
|
|
1065
|
+
for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
|
|
1066
|
+
var key = keys_1_1.value;
|
|
1067
|
+
if (!cache.keys)
|
|
1068
|
+
return state;
|
|
1069
|
+
cache.keys = Object.assign({}, cache === null || cache === void 0 ? void 0 : cache.keys);
|
|
1070
|
+
var v = cache.keys[key];
|
|
1071
|
+
if (!v)
|
|
1072
|
+
return state;
|
|
1073
|
+
v = Object.assign({}, v);
|
|
1074
|
+
cache.keys[key] = v;
|
|
1075
|
+
cache = v;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1079
|
+
finally {
|
|
1080
|
+
try {
|
|
1081
|
+
if (keys_1_1 && !keys_1_1.done && (_j = keys_1.return)) _j.call(keys_1);
|
|
1082
|
+
}
|
|
1083
|
+
finally { if (e_2) throw e_2.error; }
|
|
1084
|
+
}
|
|
1085
|
+
if (cache.data)
|
|
1086
|
+
delete cache.data;
|
|
1087
|
+
else if (cache.keys)
|
|
1088
|
+
delete cache.keys;
|
|
1089
|
+
return newState;
|
|
1090
|
+
}
|
|
1091
|
+
function invalidateCache(keys, state) {
|
|
1092
|
+
var e_3, _j;
|
|
1093
|
+
var _a;
|
|
1094
|
+
var newState = Object.assign({}, state);
|
|
1095
|
+
var cache = newState;
|
|
1096
|
+
try {
|
|
1097
|
+
for (var keys_2 = __values(keys), keys_2_1 = keys_2.next(); !keys_2_1.done; keys_2_1 = keys_2.next()) {
|
|
1098
|
+
var key = keys_2_1.value;
|
|
1099
|
+
if (!(cache === null || cache === void 0 ? void 0 : cache.keys))
|
|
1100
|
+
return state;
|
|
1101
|
+
cache.keys = Object.assign({}, cache === null || cache === void 0 ? void 0 : cache.keys);
|
|
1102
|
+
var v = (_a = cache === null || cache === void 0 ? void 0 : cache.keys) === null || _a === void 0 ? void 0 : _a[key];
|
|
1103
|
+
if (!v)
|
|
1104
|
+
return state;
|
|
1105
|
+
v = Object.assign({}, v);
|
|
1106
|
+
cache.keys[key] = v;
|
|
1107
|
+
cache = v;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1111
|
+
finally {
|
|
1112
|
+
try {
|
|
1113
|
+
if (keys_2_1 && !keys_2_1.done && (_j = keys_2.return)) _j.call(keys_2);
|
|
1114
|
+
}
|
|
1115
|
+
finally { if (e_3) throw e_3.error; }
|
|
1116
|
+
}
|
|
1117
|
+
cache && invalidaSubKeys(cache);
|
|
1118
|
+
return newState;
|
|
1119
|
+
}
|
|
1120
|
+
function increaseCacheHitCount(keys, state) {
|
|
1121
|
+
var e_4, _j;
|
|
1122
|
+
var _a;
|
|
1123
|
+
var newState = Object.assign({}, state);
|
|
1124
|
+
var cache = newState;
|
|
1125
|
+
try {
|
|
1126
|
+
for (var keys_3 = __values(keys), keys_3_1 = keys_3.next(); !keys_3_1.done; keys_3_1 = keys_3.next()) {
|
|
1127
|
+
var key = keys_3_1.value;
|
|
1128
|
+
if (!(cache === null || cache === void 0 ? void 0 : cache.keys))
|
|
1129
|
+
return state;
|
|
1130
|
+
cache.keys = Object.assign({}, cache === null || cache === void 0 ? void 0 : cache.keys);
|
|
1131
|
+
var v = (_a = cache === null || cache === void 0 ? void 0 : cache.keys) === null || _a === void 0 ? void 0 : _a[key];
|
|
1132
|
+
if (!v)
|
|
1133
|
+
return state;
|
|
1134
|
+
v = Object.assign({}, v);
|
|
1135
|
+
cache.keys[key] = v;
|
|
1136
|
+
cache = v;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1140
|
+
finally {
|
|
1141
|
+
try {
|
|
1142
|
+
if (keys_3_1 && !keys_3_1.done && (_j = keys_3.return)) _j.call(keys_3);
|
|
1143
|
+
}
|
|
1144
|
+
finally { if (e_4) throw e_4.error; }
|
|
1145
|
+
}
|
|
1146
|
+
if (!cache.data)
|
|
1147
|
+
return state;
|
|
1148
|
+
cache.data = Object.assign(Object.assign({}, cache.data), { hitCount: cache.data.hitCount + 1 });
|
|
1149
|
+
return newState;
|
|
1150
|
+
}
|
|
1151
|
+
function invalidaSubKeys(state) {
|
|
1152
|
+
if (state.data) {
|
|
1153
|
+
state.data = Object.assign(Object.assign({}, state.data), { invalid: true });
|
|
1154
|
+
}
|
|
1155
|
+
if (state.keys) {
|
|
1156
|
+
state.keys = Object.assign({}, state.keys);
|
|
1157
|
+
for (var key in state.keys) {
|
|
1158
|
+
state.keys[key] = invalidaSubKeys(Object.assign({}, state.keys[key]));
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
return state;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
var CacheModule = /** @class */ (function () {
|
|
1165
|
+
function CacheModule() {
|
|
1166
|
+
}
|
|
1167
|
+
return CacheModule;
|
|
1168
|
+
}());
|
|
1169
|
+
CacheModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: CacheModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
1170
|
+
CacheModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: CacheModule, imports: [i2__namespace.StoreFeatureModule] });
|
|
1171
|
+
CacheModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: CacheModule, providers: [], imports: [[i2.StoreModule.forFeature('cache', cacheReducer)]] });
|
|
1172
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0__namespace, type: CacheModule, decorators: [{
|
|
1173
|
+
type: i0.NgModule,
|
|
1174
|
+
args: [{
|
|
1175
|
+
imports: [i2.StoreModule.forFeature('cache', cacheReducer)],
|
|
1176
|
+
providers: [],
|
|
1177
|
+
}]
|
|
1178
|
+
}] });
|
|
1179
|
+
|
|
1180
|
+
var CacheActions = { invalidateCache: invalidateCache$1, deleteCache: deleteCache };
|
|
1181
|
+
var CacheSelectors = { getCache: selectCache };
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Generated bundle index. Do not edit.
|
|
1185
|
+
*/
|
|
1186
|
+
|
|
1187
|
+
exports.CacheActions = CacheActions;
|
|
1188
|
+
exports.CacheModule = CacheModule;
|
|
1189
|
+
exports.CacheSelectors = CacheSelectors;
|
|
1190
|
+
exports.DISABLE_LOCAL_TRAIT_EFFECTS = DISABLE_LOCAL_TRAIT_EFFECTS;
|
|
1191
|
+
exports.TraitEffect = TraitEffect;
|
|
1192
|
+
exports.TraitsLocalStore = TraitsLocalStore;
|
|
1193
|
+
exports.addEntityFeaturesProperties = addEntityFeaturesProperties;
|
|
1194
|
+
exports.buildLocalTraits = buildLocalTraits;
|
|
1195
|
+
exports.cache = cache;
|
|
1196
|
+
exports.camelCaseToSentence = camelCaseToSentence;
|
|
1197
|
+
exports.capitalize = capitalize;
|
|
1198
|
+
exports.combineEntityFeatures = combineEntityFeatures;
|
|
1199
|
+
exports.createEntityFeatureFactory = createEntityFeatureFactory;
|
|
1200
|
+
exports.createTraitFactory = createTraitFactory;
|
|
1201
|
+
exports.getDestroyActionName = getDestroyActionName;
|
|
1202
|
+
exports.insertIf = insertIf;
|
|
1203
|
+
exports.joinReducers = joinReducers;
|
|
1204
|
+
exports.mixEntityFeatures = mixEntityFeatures;
|
|
1205
|
+
exports.setPropertiesReducer = setPropertiesReducer;
|
|
1206
|
+
exports.setPropertyReducer = setPropertyReducer;
|
|
1207
|
+
exports.toMap = toMap;
|
|
1208
|
+
|
|
1209
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1210
|
+
|
|
1211
|
+
})));
|
|
1212
|
+
//# sourceMappingURL=ngrx-traits-core.umd.js.map
|