@lls/store 24.1.57-3bf4faf5 → 24.1.57-4e182f7c
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 +6 -0
- package/lib/index.js +1023 -65
- package/package.json +7 -4
package/README.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,26 +1,802 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
|
|
30
|
+
// <define:import.meta>
|
|
31
|
+
var init_define_import_meta = __esm({
|
|
32
|
+
"<define:import.meta>"() {
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/.pnpm/reselect@4.1.8/node_modules/reselect/lib/defaultMemoize.js
|
|
37
|
+
var require_defaultMemoize = __commonJS({
|
|
38
|
+
"../../node_modules/.pnpm/reselect@4.1.8/node_modules/reselect/lib/defaultMemoize.js"(exports) {
|
|
39
|
+
"use strict";
|
|
40
|
+
init_define_import_meta();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", {
|
|
42
|
+
value: true
|
|
43
|
+
});
|
|
44
|
+
exports.createCacheKeyComparator = createCacheKeyComparator;
|
|
45
|
+
exports.defaultEqualityCheck = void 0;
|
|
46
|
+
exports.defaultMemoize = defaultMemoize;
|
|
47
|
+
var NOT_FOUND = "NOT_FOUND";
|
|
48
|
+
function createSingletonCache(equals) {
|
|
49
|
+
var entry;
|
|
50
|
+
return {
|
|
51
|
+
get: function get(key) {
|
|
52
|
+
if (entry && equals(entry.key, key)) {
|
|
53
|
+
return entry.value;
|
|
54
|
+
}
|
|
55
|
+
return NOT_FOUND;
|
|
56
|
+
},
|
|
57
|
+
put: function put(key, value) {
|
|
58
|
+
entry = {
|
|
59
|
+
key,
|
|
60
|
+
value
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
getEntries: function getEntries() {
|
|
64
|
+
return entry ? [entry] : [];
|
|
65
|
+
},
|
|
66
|
+
clear: function clear() {
|
|
67
|
+
entry = void 0;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function createLruCache(maxSize, equals) {
|
|
72
|
+
var entries = [];
|
|
73
|
+
function get(key) {
|
|
74
|
+
var cacheIndex = entries.findIndex(function(entry2) {
|
|
75
|
+
return equals(key, entry2.key);
|
|
76
|
+
});
|
|
77
|
+
if (cacheIndex > -1) {
|
|
78
|
+
var entry = entries[cacheIndex];
|
|
79
|
+
if (cacheIndex > 0) {
|
|
80
|
+
entries.splice(cacheIndex, 1);
|
|
81
|
+
entries.unshift(entry);
|
|
82
|
+
}
|
|
83
|
+
return entry.value;
|
|
84
|
+
}
|
|
85
|
+
return NOT_FOUND;
|
|
86
|
+
}
|
|
87
|
+
function put(key, value) {
|
|
88
|
+
if (get(key) === NOT_FOUND) {
|
|
89
|
+
entries.unshift({
|
|
90
|
+
key,
|
|
91
|
+
value
|
|
92
|
+
});
|
|
93
|
+
if (entries.length > maxSize) {
|
|
94
|
+
entries.pop();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function getEntries() {
|
|
99
|
+
return entries;
|
|
100
|
+
}
|
|
101
|
+
function clear() {
|
|
102
|
+
entries = [];
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
get,
|
|
106
|
+
put,
|
|
107
|
+
getEntries,
|
|
108
|
+
clear
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
var defaultEqualityCheck = function defaultEqualityCheck2(a, b) {
|
|
112
|
+
return a === b;
|
|
113
|
+
};
|
|
114
|
+
exports.defaultEqualityCheck = defaultEqualityCheck;
|
|
115
|
+
function createCacheKeyComparator(equalityCheck) {
|
|
116
|
+
return function areArgumentsShallowlyEqual(prev, next) {
|
|
117
|
+
if (prev === null || next === null || prev.length !== next.length) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
var length = prev.length;
|
|
121
|
+
for (var i = 0; i < length; i++) {
|
|
122
|
+
if (!equalityCheck(prev[i], next[i])) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function defaultMemoize(func, equalityCheckOrOptions) {
|
|
130
|
+
var providedOptions = typeof equalityCheckOrOptions === "object" ? equalityCheckOrOptions : {
|
|
131
|
+
equalityCheck: equalityCheckOrOptions
|
|
132
|
+
};
|
|
133
|
+
var _providedOptions$equa = providedOptions.equalityCheck, equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa, _providedOptions$maxS = providedOptions.maxSize, maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS, resultEqualityCheck = providedOptions.resultEqualityCheck;
|
|
134
|
+
var comparator = createCacheKeyComparator(equalityCheck);
|
|
135
|
+
var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator);
|
|
136
|
+
function memoized() {
|
|
137
|
+
var value = cache.get(arguments);
|
|
138
|
+
if (value === NOT_FOUND) {
|
|
139
|
+
value = func.apply(null, arguments);
|
|
140
|
+
if (resultEqualityCheck) {
|
|
141
|
+
var entries = cache.getEntries();
|
|
142
|
+
var matchingEntry = entries.find(function(entry) {
|
|
143
|
+
return resultEqualityCheck(entry.value, value);
|
|
144
|
+
});
|
|
145
|
+
if (matchingEntry) {
|
|
146
|
+
value = matchingEntry.value;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
cache.put(arguments, value);
|
|
150
|
+
}
|
|
151
|
+
return value;
|
|
152
|
+
}
|
|
153
|
+
memoized.clearCache = function() {
|
|
154
|
+
return cache.clear();
|
|
155
|
+
};
|
|
156
|
+
return memoized;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// ../../node_modules/.pnpm/reselect@4.1.8/node_modules/reselect/lib/index.js
|
|
162
|
+
var require_lib = __commonJS({
|
|
163
|
+
"../../node_modules/.pnpm/reselect@4.1.8/node_modules/reselect/lib/index.js"(exports) {
|
|
164
|
+
"use strict";
|
|
165
|
+
init_define_import_meta();
|
|
166
|
+
Object.defineProperty(exports, "__esModule", {
|
|
167
|
+
value: true
|
|
168
|
+
});
|
|
169
|
+
exports.createSelector = void 0;
|
|
170
|
+
exports.createSelectorCreator = createSelectorCreator;
|
|
171
|
+
exports.createStructuredSelector = void 0;
|
|
172
|
+
Object.defineProperty(exports, "defaultEqualityCheck", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
get: function get() {
|
|
175
|
+
return _defaultMemoize.defaultEqualityCheck;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(exports, "defaultMemoize", {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
get: function get() {
|
|
181
|
+
return _defaultMemoize.defaultMemoize;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
var _defaultMemoize = require_defaultMemoize();
|
|
185
|
+
function getDependencies(funcs) {
|
|
186
|
+
var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
|
|
187
|
+
if (!dependencies.every(function(dep) {
|
|
188
|
+
return typeof dep === "function";
|
|
189
|
+
})) {
|
|
190
|
+
var dependencyTypes = dependencies.map(function(dep) {
|
|
191
|
+
return typeof dep === "function" ? "function " + (dep.name || "unnamed") + "()" : typeof dep;
|
|
192
|
+
}).join(", ");
|
|
193
|
+
throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
|
|
194
|
+
}
|
|
195
|
+
return dependencies;
|
|
196
|
+
}
|
|
197
|
+
function createSelectorCreator(memoize) {
|
|
198
|
+
for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
199
|
+
memoizeOptionsFromArgs[_key - 1] = arguments[_key];
|
|
200
|
+
}
|
|
201
|
+
var createSelector3 = function createSelector4() {
|
|
202
|
+
for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
203
|
+
funcs[_key2] = arguments[_key2];
|
|
204
|
+
}
|
|
205
|
+
var _recomputations = 0;
|
|
206
|
+
var _lastResult;
|
|
207
|
+
var directlyPassedOptions = {
|
|
208
|
+
memoizeOptions: void 0
|
|
209
|
+
};
|
|
210
|
+
var resultFunc = funcs.pop();
|
|
211
|
+
if (typeof resultFunc === "object") {
|
|
212
|
+
directlyPassedOptions = resultFunc;
|
|
213
|
+
resultFunc = funcs.pop();
|
|
214
|
+
}
|
|
215
|
+
if (typeof resultFunc !== "function") {
|
|
216
|
+
throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
|
|
217
|
+
}
|
|
218
|
+
var _directlyPassedOption = directlyPassedOptions, _directlyPassedOption2 = _directlyPassedOption.memoizeOptions, memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2;
|
|
219
|
+
var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
|
|
220
|
+
var dependencies = getDependencies(funcs);
|
|
221
|
+
var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
|
|
222
|
+
_recomputations++;
|
|
223
|
+
return resultFunc.apply(null, arguments);
|
|
224
|
+
}].concat(finalMemoizeOptions));
|
|
225
|
+
var selector = memoize(function dependenciesChecker() {
|
|
226
|
+
var params = [];
|
|
227
|
+
var length = dependencies.length;
|
|
228
|
+
for (var i = 0; i < length; i++) {
|
|
229
|
+
params.push(dependencies[i].apply(null, arguments));
|
|
230
|
+
}
|
|
231
|
+
_lastResult = memoizedResultFunc.apply(null, params);
|
|
232
|
+
return _lastResult;
|
|
233
|
+
});
|
|
234
|
+
Object.assign(selector, {
|
|
235
|
+
resultFunc,
|
|
236
|
+
memoizedResultFunc,
|
|
237
|
+
dependencies,
|
|
238
|
+
lastResult: function lastResult() {
|
|
239
|
+
return _lastResult;
|
|
240
|
+
},
|
|
241
|
+
recomputations: function recomputations() {
|
|
242
|
+
return _recomputations;
|
|
243
|
+
},
|
|
244
|
+
resetRecomputations: function resetRecomputations() {
|
|
245
|
+
return _recomputations = 0;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
return selector;
|
|
249
|
+
};
|
|
250
|
+
return createSelector3;
|
|
251
|
+
}
|
|
252
|
+
var createSelector2 = /* @__PURE__ */ createSelectorCreator(_defaultMemoize.defaultMemoize);
|
|
253
|
+
exports.createSelector = createSelector2;
|
|
254
|
+
var createStructuredSelector = function createStructuredSelector2(selectors, selectorCreator) {
|
|
255
|
+
if (selectorCreator === void 0) {
|
|
256
|
+
selectorCreator = createSelector2;
|
|
257
|
+
}
|
|
258
|
+
if (typeof selectors !== "object") {
|
|
259
|
+
throw new Error("createStructuredSelector expects first argument to be an object " + ("where each property is a selector, instead received a " + typeof selectors));
|
|
260
|
+
}
|
|
261
|
+
var objectKeys = Object.keys(selectors);
|
|
262
|
+
var resultSelector = selectorCreator(
|
|
263
|
+
// @ts-ignore
|
|
264
|
+
objectKeys.map(function(key) {
|
|
265
|
+
return selectors[key];
|
|
266
|
+
}),
|
|
267
|
+
function() {
|
|
268
|
+
for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
269
|
+
values[_key3] = arguments[_key3];
|
|
270
|
+
}
|
|
271
|
+
return values.reduce(function(composition, value, index) {
|
|
272
|
+
composition[objectKeys[index]] = value;
|
|
273
|
+
return composition;
|
|
274
|
+
}, {});
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
return resultSelector;
|
|
278
|
+
};
|
|
279
|
+
exports.createStructuredSelector = createStructuredSelector;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// ../../node_modules/.pnpm/normalizr@3.6.2/node_modules/normalizr/dist/normalizr.js
|
|
284
|
+
var require_normalizr = __commonJS({
|
|
285
|
+
"../../node_modules/.pnpm/normalizr@3.6.2/node_modules/normalizr/dist/normalizr.js"(exports) {
|
|
286
|
+
"use strict";
|
|
287
|
+
init_define_import_meta();
|
|
288
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
289
|
+
function _defineProperties(target, props) {
|
|
290
|
+
for (var i = 0; i < props.length; i++) {
|
|
291
|
+
var descriptor = props[i];
|
|
292
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
293
|
+
descriptor.configurable = true;
|
|
294
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
295
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
299
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
300
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
301
|
+
return Constructor;
|
|
302
|
+
}
|
|
303
|
+
function _extends() {
|
|
304
|
+
_extends = Object.assign || function(target) {
|
|
305
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
306
|
+
var source = arguments[i];
|
|
307
|
+
for (var key in source) {
|
|
308
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
309
|
+
target[key] = source[key];
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return target;
|
|
314
|
+
};
|
|
315
|
+
return _extends.apply(this, arguments);
|
|
316
|
+
}
|
|
317
|
+
function _inheritsLoose(subClass, superClass) {
|
|
318
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
319
|
+
subClass.prototype.constructor = subClass;
|
|
320
|
+
subClass.__proto__ = superClass;
|
|
321
|
+
}
|
|
322
|
+
function isImmutable(object) {
|
|
323
|
+
return !!(object && typeof object.hasOwnProperty === "function" && (object.hasOwnProperty("__ownerID") || // Immutable.Map
|
|
324
|
+
object._map && object._map.hasOwnProperty("__ownerID")));
|
|
325
|
+
}
|
|
326
|
+
function denormalizeImmutable(schema3, input, unvisit) {
|
|
327
|
+
return Object.keys(schema3).reduce(function(object, key) {
|
|
328
|
+
var stringKey = "" + key;
|
|
329
|
+
if (object.has(stringKey)) {
|
|
330
|
+
return object.set(stringKey, unvisit(object.get(stringKey), schema3[stringKey]));
|
|
331
|
+
} else {
|
|
332
|
+
return object;
|
|
333
|
+
}
|
|
334
|
+
}, input);
|
|
335
|
+
}
|
|
336
|
+
var getDefaultGetId = function getDefaultGetId2(idAttribute) {
|
|
337
|
+
return function(input) {
|
|
338
|
+
return isImmutable(input) ? input.get(idAttribute) : input[idAttribute];
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
var EntitySchema = /* @__PURE__ */ function() {
|
|
342
|
+
function EntitySchema2(key, definition, options) {
|
|
343
|
+
if (definition === void 0) {
|
|
344
|
+
definition = {};
|
|
345
|
+
}
|
|
346
|
+
if (options === void 0) {
|
|
347
|
+
options = {};
|
|
348
|
+
}
|
|
349
|
+
if (!key || typeof key !== "string") {
|
|
350
|
+
throw new Error("Expected a string key for Entity, but found " + key + ".");
|
|
351
|
+
}
|
|
352
|
+
var _options = options, _options$idAttribute = _options.idAttribute, idAttribute = _options$idAttribute === void 0 ? "id" : _options$idAttribute, _options$mergeStrateg = _options.mergeStrategy, mergeStrategy = _options$mergeStrateg === void 0 ? function(entityA, entityB) {
|
|
353
|
+
return _extends({}, entityA, entityB);
|
|
354
|
+
} : _options$mergeStrateg, _options$processStrat = _options.processStrategy, processStrategy = _options$processStrat === void 0 ? function(input) {
|
|
355
|
+
return _extends({}, input);
|
|
356
|
+
} : _options$processStrat, _options$fallbackStra = _options.fallbackStrategy, fallbackStrategy = _options$fallbackStra === void 0 ? function(key2, schema3) {
|
|
357
|
+
return void 0;
|
|
358
|
+
} : _options$fallbackStra;
|
|
359
|
+
this._key = key;
|
|
360
|
+
this._getId = typeof idAttribute === "function" ? idAttribute : getDefaultGetId(idAttribute);
|
|
361
|
+
this._idAttribute = idAttribute;
|
|
362
|
+
this._mergeStrategy = mergeStrategy;
|
|
363
|
+
this._processStrategy = processStrategy;
|
|
364
|
+
this._fallbackStrategy = fallbackStrategy;
|
|
365
|
+
this.define(definition);
|
|
366
|
+
}
|
|
367
|
+
var _proto = EntitySchema2.prototype;
|
|
368
|
+
_proto.define = function define2(definition) {
|
|
369
|
+
this.schema = Object.keys(definition).reduce(function(entitySchema, key) {
|
|
370
|
+
var _extends2;
|
|
371
|
+
var schema3 = definition[key];
|
|
372
|
+
return _extends({}, entitySchema, (_extends2 = {}, _extends2[key] = schema3, _extends2));
|
|
373
|
+
}, this.schema || {});
|
|
374
|
+
};
|
|
375
|
+
_proto.getId = function getId(input, parent, key) {
|
|
376
|
+
return this._getId(input, parent, key);
|
|
377
|
+
};
|
|
378
|
+
_proto.merge = function merge(entityA, entityB) {
|
|
379
|
+
return this._mergeStrategy(entityA, entityB);
|
|
380
|
+
};
|
|
381
|
+
_proto.fallback = function fallback(id, schema3) {
|
|
382
|
+
return this._fallbackStrategy(id, schema3);
|
|
383
|
+
};
|
|
384
|
+
_proto.normalize = function normalize3(input, parent, key, visit2, addEntity, visitedEntities) {
|
|
385
|
+
var _this = this;
|
|
386
|
+
var id = this.getId(input, parent, key);
|
|
387
|
+
var entityType = this.key;
|
|
388
|
+
if (!(entityType in visitedEntities)) {
|
|
389
|
+
visitedEntities[entityType] = {};
|
|
390
|
+
}
|
|
391
|
+
if (!(id in visitedEntities[entityType])) {
|
|
392
|
+
visitedEntities[entityType][id] = [];
|
|
393
|
+
}
|
|
394
|
+
if (visitedEntities[entityType][id].some(function(entity) {
|
|
395
|
+
return entity === input;
|
|
396
|
+
})) {
|
|
397
|
+
return id;
|
|
398
|
+
}
|
|
399
|
+
visitedEntities[entityType][id].push(input);
|
|
400
|
+
var processedEntity = this._processStrategy(input, parent, key);
|
|
401
|
+
Object.keys(this.schema).forEach(function(key2) {
|
|
402
|
+
if (processedEntity.hasOwnProperty(key2) && typeof processedEntity[key2] === "object") {
|
|
403
|
+
var schema3 = _this.schema[key2];
|
|
404
|
+
var resolvedSchema = typeof schema3 === "function" ? schema3(input) : schema3;
|
|
405
|
+
processedEntity[key2] = visit2(processedEntity[key2], processedEntity, key2, resolvedSchema, addEntity, visitedEntities);
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
addEntity(this, processedEntity, input, parent, key);
|
|
409
|
+
return id;
|
|
410
|
+
};
|
|
411
|
+
_proto.denormalize = function denormalize2(entity, unvisit) {
|
|
412
|
+
var _this2 = this;
|
|
413
|
+
if (isImmutable(entity)) {
|
|
414
|
+
return denormalizeImmutable(this.schema, entity, unvisit);
|
|
415
|
+
}
|
|
416
|
+
Object.keys(this.schema).forEach(function(key) {
|
|
417
|
+
if (entity.hasOwnProperty(key)) {
|
|
418
|
+
var schema3 = _this2.schema[key];
|
|
419
|
+
entity[key] = unvisit(entity[key], schema3);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
return entity;
|
|
423
|
+
};
|
|
424
|
+
_createClass(EntitySchema2, [{
|
|
425
|
+
key: "key",
|
|
426
|
+
get: function get() {
|
|
427
|
+
return this._key;
|
|
428
|
+
}
|
|
429
|
+
}, {
|
|
430
|
+
key: "idAttribute",
|
|
431
|
+
get: function get() {
|
|
432
|
+
return this._idAttribute;
|
|
433
|
+
}
|
|
434
|
+
}]);
|
|
435
|
+
return EntitySchema2;
|
|
436
|
+
}();
|
|
437
|
+
var PolymorphicSchema = /* @__PURE__ */ function() {
|
|
438
|
+
function PolymorphicSchema2(definition, schemaAttribute) {
|
|
439
|
+
if (schemaAttribute) {
|
|
440
|
+
this._schemaAttribute = typeof schemaAttribute === "string" ? function(input) {
|
|
441
|
+
return input[schemaAttribute];
|
|
442
|
+
} : schemaAttribute;
|
|
443
|
+
}
|
|
444
|
+
this.define(definition);
|
|
445
|
+
}
|
|
446
|
+
var _proto = PolymorphicSchema2.prototype;
|
|
447
|
+
_proto.define = function define2(definition) {
|
|
448
|
+
this.schema = definition;
|
|
449
|
+
};
|
|
450
|
+
_proto.getSchemaAttribute = function getSchemaAttribute(input, parent, key) {
|
|
451
|
+
return !this.isSingleSchema && this._schemaAttribute(input, parent, key);
|
|
452
|
+
};
|
|
453
|
+
_proto.inferSchema = function inferSchema(input, parent, key) {
|
|
454
|
+
if (this.isSingleSchema) {
|
|
455
|
+
return this.schema;
|
|
456
|
+
}
|
|
457
|
+
var attr = this.getSchemaAttribute(input, parent, key);
|
|
458
|
+
return this.schema[attr];
|
|
459
|
+
};
|
|
460
|
+
_proto.normalizeValue = function normalizeValue(value, parent, key, visit2, addEntity, visitedEntities) {
|
|
461
|
+
var schema3 = this.inferSchema(value, parent, key);
|
|
462
|
+
if (!schema3) {
|
|
463
|
+
return value;
|
|
464
|
+
}
|
|
465
|
+
var normalizedValue = visit2(value, parent, key, schema3, addEntity, visitedEntities);
|
|
466
|
+
return this.isSingleSchema || normalizedValue === void 0 || normalizedValue === null ? normalizedValue : {
|
|
467
|
+
id: normalizedValue,
|
|
468
|
+
schema: this.getSchemaAttribute(value, parent, key)
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
_proto.denormalizeValue = function denormalizeValue(value, unvisit) {
|
|
472
|
+
var schemaKey = isImmutable(value) ? value.get("schema") : value.schema;
|
|
473
|
+
if (!this.isSingleSchema && !schemaKey) {
|
|
474
|
+
return value;
|
|
475
|
+
}
|
|
476
|
+
var id = this.isSingleSchema ? void 0 : isImmutable(value) ? value.get("id") : value.id;
|
|
477
|
+
var schema3 = this.isSingleSchema ? this.schema : this.schema[schemaKey];
|
|
478
|
+
return unvisit(id || value, schema3);
|
|
479
|
+
};
|
|
480
|
+
_createClass(PolymorphicSchema2, [{
|
|
481
|
+
key: "isSingleSchema",
|
|
482
|
+
get: function get() {
|
|
483
|
+
return !this._schemaAttribute;
|
|
484
|
+
}
|
|
485
|
+
}]);
|
|
486
|
+
return PolymorphicSchema2;
|
|
487
|
+
}();
|
|
488
|
+
var UnionSchema = /* @__PURE__ */ function(_PolymorphicSchema) {
|
|
489
|
+
_inheritsLoose(UnionSchema2, _PolymorphicSchema);
|
|
490
|
+
function UnionSchema2(definition, schemaAttribute) {
|
|
491
|
+
if (!schemaAttribute) {
|
|
492
|
+
throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');
|
|
493
|
+
}
|
|
494
|
+
return _PolymorphicSchema.call(this, definition, schemaAttribute) || this;
|
|
495
|
+
}
|
|
496
|
+
var _proto = UnionSchema2.prototype;
|
|
497
|
+
_proto.normalize = function normalize3(input, parent, key, visit2, addEntity, visitedEntities) {
|
|
498
|
+
return this.normalizeValue(input, parent, key, visit2, addEntity, visitedEntities);
|
|
499
|
+
};
|
|
500
|
+
_proto.denormalize = function denormalize2(input, unvisit) {
|
|
501
|
+
return this.denormalizeValue(input, unvisit);
|
|
502
|
+
};
|
|
503
|
+
return UnionSchema2;
|
|
504
|
+
}(PolymorphicSchema);
|
|
505
|
+
var ValuesSchema = /* @__PURE__ */ function(_PolymorphicSchema) {
|
|
506
|
+
_inheritsLoose(ValuesSchema2, _PolymorphicSchema);
|
|
507
|
+
function ValuesSchema2() {
|
|
508
|
+
return _PolymorphicSchema.apply(this, arguments) || this;
|
|
509
|
+
}
|
|
510
|
+
var _proto = ValuesSchema2.prototype;
|
|
511
|
+
_proto.normalize = function normalize3(input, parent, key, visit2, addEntity, visitedEntities) {
|
|
512
|
+
var _this = this;
|
|
513
|
+
return Object.keys(input).reduce(function(output, key2, index) {
|
|
514
|
+
var _extends2;
|
|
515
|
+
var value = input[key2];
|
|
516
|
+
return value !== void 0 && value !== null ? _extends({}, output, (_extends2 = {}, _extends2[key2] = _this.normalizeValue(value, input, key2, visit2, addEntity, visitedEntities), _extends2)) : output;
|
|
517
|
+
}, {});
|
|
518
|
+
};
|
|
519
|
+
_proto.denormalize = function denormalize2(input, unvisit) {
|
|
520
|
+
var _this2 = this;
|
|
521
|
+
return Object.keys(input).reduce(function(output, key) {
|
|
522
|
+
var _extends3;
|
|
523
|
+
var entityOrId = input[key];
|
|
524
|
+
return _extends({}, output, (_extends3 = {}, _extends3[key] = _this2.denormalizeValue(entityOrId, unvisit), _extends3));
|
|
525
|
+
}, {});
|
|
526
|
+
};
|
|
527
|
+
return ValuesSchema2;
|
|
528
|
+
}(PolymorphicSchema);
|
|
529
|
+
var validateSchema = function validateSchema2(definition) {
|
|
530
|
+
var isArray = Array.isArray(definition);
|
|
531
|
+
if (isArray && definition.length > 1) {
|
|
532
|
+
throw new Error("Expected schema definition to be a single schema, but found " + definition.length + ".");
|
|
533
|
+
}
|
|
534
|
+
return definition[0];
|
|
535
|
+
};
|
|
536
|
+
var getValues = function getValues2(input) {
|
|
537
|
+
return Array.isArray(input) ? input : Object.keys(input).map(function(key) {
|
|
538
|
+
return input[key];
|
|
539
|
+
});
|
|
540
|
+
};
|
|
541
|
+
var normalize2 = function normalize3(schema3, input, parent, key, visit2, addEntity, visitedEntities) {
|
|
542
|
+
schema3 = validateSchema(schema3);
|
|
543
|
+
var values = getValues(input);
|
|
544
|
+
return values.map(function(value, index) {
|
|
545
|
+
return visit2(value, parent, key, schema3, addEntity, visitedEntities);
|
|
546
|
+
});
|
|
547
|
+
};
|
|
548
|
+
var denormalize = function denormalize2(schema3, input, unvisit) {
|
|
549
|
+
schema3 = validateSchema(schema3);
|
|
550
|
+
return input && input.map ? input.map(function(entityOrId) {
|
|
551
|
+
return unvisit(entityOrId, schema3);
|
|
552
|
+
}) : input;
|
|
553
|
+
};
|
|
554
|
+
var ArraySchema = /* @__PURE__ */ function(_PolymorphicSchema) {
|
|
555
|
+
_inheritsLoose(ArraySchema2, _PolymorphicSchema);
|
|
556
|
+
function ArraySchema2() {
|
|
557
|
+
return _PolymorphicSchema.apply(this, arguments) || this;
|
|
558
|
+
}
|
|
559
|
+
var _proto = ArraySchema2.prototype;
|
|
560
|
+
_proto.normalize = function normalize3(input, parent, key, visit2, addEntity, visitedEntities) {
|
|
561
|
+
var _this = this;
|
|
562
|
+
var values = getValues(input);
|
|
563
|
+
return values.map(function(value, index) {
|
|
564
|
+
return _this.normalizeValue(value, parent, key, visit2, addEntity, visitedEntities);
|
|
565
|
+
}).filter(function(value) {
|
|
566
|
+
return value !== void 0 && value !== null;
|
|
567
|
+
});
|
|
568
|
+
};
|
|
569
|
+
_proto.denormalize = function denormalize2(input, unvisit) {
|
|
570
|
+
var _this2 = this;
|
|
571
|
+
return input && input.map ? input.map(function(value) {
|
|
572
|
+
return _this2.denormalizeValue(value, unvisit);
|
|
573
|
+
}) : input;
|
|
574
|
+
};
|
|
575
|
+
return ArraySchema2;
|
|
576
|
+
}(PolymorphicSchema);
|
|
577
|
+
var _normalize = function normalize3(schema3, input, parent, key, visit2, addEntity, visitedEntities) {
|
|
578
|
+
var object = _extends({}, input);
|
|
579
|
+
Object.keys(schema3).forEach(function(key2) {
|
|
580
|
+
var localSchema = schema3[key2];
|
|
581
|
+
var resolvedLocalSchema = typeof localSchema === "function" ? localSchema(input) : localSchema;
|
|
582
|
+
var value = visit2(input[key2], input, key2, resolvedLocalSchema, addEntity, visitedEntities);
|
|
583
|
+
if (value === void 0 || value === null) {
|
|
584
|
+
delete object[key2];
|
|
585
|
+
} else {
|
|
586
|
+
object[key2] = value;
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
return object;
|
|
590
|
+
};
|
|
591
|
+
var _denormalize = function denormalize2(schema3, input, unvisit) {
|
|
592
|
+
if (isImmutable(input)) {
|
|
593
|
+
return denormalizeImmutable(schema3, input, unvisit);
|
|
594
|
+
}
|
|
595
|
+
var object = _extends({}, input);
|
|
596
|
+
Object.keys(schema3).forEach(function(key) {
|
|
597
|
+
if (object[key] != null) {
|
|
598
|
+
object[key] = unvisit(object[key], schema3[key]);
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
return object;
|
|
602
|
+
};
|
|
603
|
+
var ObjectSchema = /* @__PURE__ */ function() {
|
|
604
|
+
function ObjectSchema2(definition) {
|
|
605
|
+
this.define(definition);
|
|
606
|
+
}
|
|
607
|
+
var _proto = ObjectSchema2.prototype;
|
|
608
|
+
_proto.define = function define2(definition) {
|
|
609
|
+
this.schema = Object.keys(definition).reduce(function(entitySchema, key) {
|
|
610
|
+
var _extends2;
|
|
611
|
+
var schema3 = definition[key];
|
|
612
|
+
return _extends({}, entitySchema, (_extends2 = {}, _extends2[key] = schema3, _extends2));
|
|
613
|
+
}, this.schema || {});
|
|
614
|
+
};
|
|
615
|
+
_proto.normalize = function normalize3() {
|
|
616
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
617
|
+
args[_key] = arguments[_key];
|
|
618
|
+
}
|
|
619
|
+
return _normalize.apply(void 0, [this.schema].concat(args));
|
|
620
|
+
};
|
|
621
|
+
_proto.denormalize = function denormalize2() {
|
|
622
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
623
|
+
args[_key2] = arguments[_key2];
|
|
624
|
+
}
|
|
625
|
+
return _denormalize.apply(void 0, [this.schema].concat(args));
|
|
626
|
+
};
|
|
627
|
+
return ObjectSchema2;
|
|
628
|
+
}();
|
|
629
|
+
var visit = function visit2(value, parent, key, schema3, addEntity, visitedEntities) {
|
|
630
|
+
if (typeof value !== "object" || !value) {
|
|
631
|
+
return value;
|
|
632
|
+
}
|
|
633
|
+
if (typeof schema3 === "object" && (!schema3.normalize || typeof schema3.normalize !== "function")) {
|
|
634
|
+
var method = Array.isArray(schema3) ? normalize2 : _normalize;
|
|
635
|
+
return method(schema3, value, parent, key, visit2, addEntity, visitedEntities);
|
|
636
|
+
}
|
|
637
|
+
return schema3.normalize(value, parent, key, visit2, addEntity, visitedEntities);
|
|
638
|
+
};
|
|
639
|
+
var addEntities = function addEntities2(entities2) {
|
|
640
|
+
return function(schema3, processedEntity, value, parent, key) {
|
|
641
|
+
var schemaKey = schema3.key;
|
|
642
|
+
var id = schema3.getId(value, parent, key);
|
|
643
|
+
if (!(schemaKey in entities2)) {
|
|
644
|
+
entities2[schemaKey] = {};
|
|
645
|
+
}
|
|
646
|
+
var existingEntity = entities2[schemaKey][id];
|
|
647
|
+
if (existingEntity) {
|
|
648
|
+
entities2[schemaKey][id] = schema3.merge(existingEntity, processedEntity);
|
|
649
|
+
} else {
|
|
650
|
+
entities2[schemaKey][id] = processedEntity;
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
};
|
|
654
|
+
var schema2 = {
|
|
655
|
+
Array: ArraySchema,
|
|
656
|
+
Entity: EntitySchema,
|
|
657
|
+
Object: ObjectSchema,
|
|
658
|
+
Union: UnionSchema,
|
|
659
|
+
Values: ValuesSchema
|
|
660
|
+
};
|
|
661
|
+
var normalize$1 = function normalize3(input, schema3) {
|
|
662
|
+
if (!input || typeof input !== "object") {
|
|
663
|
+
throw new Error('Unexpected input given to normalize. Expected type to be "object", found "' + (input === null ? "null" : typeof input) + '".');
|
|
664
|
+
}
|
|
665
|
+
var entities2 = {};
|
|
666
|
+
var addEntity = addEntities(entities2);
|
|
667
|
+
var visitedEntities = {};
|
|
668
|
+
var result = visit(input, input, null, schema3, addEntity, visitedEntities);
|
|
669
|
+
return {
|
|
670
|
+
entities: entities2,
|
|
671
|
+
result
|
|
672
|
+
};
|
|
673
|
+
};
|
|
674
|
+
var unvisitEntity = function unvisitEntity2(id, schema3, unvisit, getEntity, cache) {
|
|
675
|
+
var entity = getEntity(id, schema3);
|
|
676
|
+
if (entity === void 0 && schema3 instanceof EntitySchema) {
|
|
677
|
+
entity = schema3.fallback(id, schema3);
|
|
678
|
+
}
|
|
679
|
+
if (typeof entity !== "object" || entity === null) {
|
|
680
|
+
return entity;
|
|
681
|
+
}
|
|
682
|
+
if (!cache[schema3.key]) {
|
|
683
|
+
cache[schema3.key] = {};
|
|
684
|
+
}
|
|
685
|
+
if (!cache[schema3.key][id]) {
|
|
686
|
+
var entityCopy = isImmutable(entity) ? entity : _extends({}, entity);
|
|
687
|
+
cache[schema3.key][id] = entityCopy;
|
|
688
|
+
cache[schema3.key][id] = schema3.denormalize(entityCopy, unvisit);
|
|
689
|
+
}
|
|
690
|
+
return cache[schema3.key][id];
|
|
691
|
+
};
|
|
692
|
+
var getUnvisit = function getUnvisit2(entities2) {
|
|
693
|
+
var cache = {};
|
|
694
|
+
var getEntity = getEntities(entities2);
|
|
695
|
+
return function unvisit(input, schema3) {
|
|
696
|
+
if (typeof schema3 === "object" && (!schema3.denormalize || typeof schema3.denormalize !== "function")) {
|
|
697
|
+
var method = Array.isArray(schema3) ? denormalize : _denormalize;
|
|
698
|
+
return method(schema3, input, unvisit);
|
|
699
|
+
}
|
|
700
|
+
if (input === void 0 || input === null) {
|
|
701
|
+
return input;
|
|
702
|
+
}
|
|
703
|
+
if (schema3 instanceof EntitySchema) {
|
|
704
|
+
return unvisitEntity(input, schema3, unvisit, getEntity, cache);
|
|
705
|
+
}
|
|
706
|
+
return schema3.denormalize(input, unvisit);
|
|
707
|
+
};
|
|
708
|
+
};
|
|
709
|
+
var getEntities = function getEntities2(entities2) {
|
|
710
|
+
var isImmutable$1 = isImmutable(entities2);
|
|
711
|
+
return function(entityOrId, schema3) {
|
|
712
|
+
var schemaKey = schema3.key;
|
|
713
|
+
if (typeof entityOrId === "object") {
|
|
714
|
+
return entityOrId;
|
|
715
|
+
}
|
|
716
|
+
if (isImmutable$1) {
|
|
717
|
+
return entities2.getIn([schemaKey, entityOrId.toString()]);
|
|
718
|
+
}
|
|
719
|
+
return entities2[schemaKey] && entities2[schemaKey][entityOrId];
|
|
720
|
+
};
|
|
721
|
+
};
|
|
722
|
+
var denormalize$1 = function denormalize2(input, schema3, entities2) {
|
|
723
|
+
if (typeof input !== "undefined") {
|
|
724
|
+
return getUnvisit(entities2)(input, schema3);
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
exports.denormalize = denormalize$1;
|
|
728
|
+
exports.normalize = normalize$1;
|
|
729
|
+
exports.schema = schema2;
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
// src/index.ts
|
|
734
|
+
init_define_import_meta();
|
|
735
|
+
|
|
1
736
|
// src/selectors/school.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
737
|
+
init_define_import_meta();
|
|
738
|
+
import { filterEntitiesSimpleFieldByValues } from "@lls/utils";
|
|
739
|
+
import _2 from "lodash/fp.js";
|
|
740
|
+
|
|
741
|
+
// src/selectors/crud.ts
|
|
742
|
+
init_define_import_meta();
|
|
743
|
+
import { createSearchSelector, makeGetAllEntities, makeGetEntityById } from "@lls/utils";
|
|
8
744
|
import _ from "lodash/fp.js";
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
745
|
+
var crud = (entityName, { search: search3 }) => {
|
|
746
|
+
const getElements = makeGetAllEntities(entityName);
|
|
747
|
+
const makeSearchElements = () => createSearchSelector(
|
|
748
|
+
getElements,
|
|
749
|
+
(_state, params) => params,
|
|
750
|
+
(elements, params) => search3(params)(elements)
|
|
751
|
+
);
|
|
752
|
+
const methodName = _.capitalize(entityName);
|
|
753
|
+
const getElementById = makeGetEntityById(entityName);
|
|
754
|
+
const back = {
|
|
755
|
+
[`get${methodName}`]: getElements,
|
|
756
|
+
[`search${methodName}`]: makeSearchElements(),
|
|
757
|
+
[`get${methodName.replace(/s$/, "")}`]: getElementById,
|
|
758
|
+
[`makeSearch${methodName}`]: makeSearchElements
|
|
759
|
+
};
|
|
760
|
+
return back;
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
// src/selectors/school.ts
|
|
764
|
+
var search = ({ ids }) => _2.flow(filterEntitiesSimpleFieldByValues("id", ids));
|
|
765
|
+
var { getSchools, getSchool, searchSchools, makeSearchSchools } = crud("schools", {
|
|
766
|
+
search
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
// src/selectors/user.ts
|
|
770
|
+
init_define_import_meta();
|
|
771
|
+
var import_reselect = __toESM(require_lib(), 1);
|
|
772
|
+
import { filterEntitiesArrayFieldByValues, filterEntitiesSimpleFieldByValues as filterEntitiesSimpleFieldByValues2 } from "@lls/utils";
|
|
773
|
+
import _4 from "lodash/fp.js";
|
|
774
|
+
|
|
775
|
+
// src/selectors/auth.ts
|
|
776
|
+
init_define_import_meta();
|
|
777
|
+
import _3 from "lodash/fp.js";
|
|
778
|
+
var getAuth = _3.get("auth");
|
|
779
|
+
var getIsLogged = _3.flow(_3.get("auth.id"), _3.negate(_3.isNil));
|
|
780
|
+
var getToken = _3.get("auth.token");
|
|
781
|
+
|
|
782
|
+
// src/selectors/user.ts
|
|
783
|
+
var search2 = ({ ids, schoolIds }) => _4.flow(filterEntitiesArrayFieldByValues("schools", schoolIds), filterEntitiesSimpleFieldByValues2("id", ids));
|
|
784
|
+
var { getUsers, getUser, searchUsers, makeSearchUsers } = crud("users", {
|
|
785
|
+
search: search2
|
|
786
|
+
});
|
|
787
|
+
var getCurrentUser = (0, import_reselect.createSelector)(
|
|
788
|
+
getAuth,
|
|
789
|
+
getUsers,
|
|
790
|
+
(auth2, users) => users?.find((user2) => user2?.id === auth2?.id)
|
|
17
791
|
);
|
|
18
792
|
|
|
19
793
|
// src/reducers/entities.ts
|
|
794
|
+
init_define_import_meta();
|
|
20
795
|
import { makeReducer } from "@lls/utils";
|
|
21
|
-
import
|
|
796
|
+
import _5 from "lodash/fp.js";
|
|
22
797
|
|
|
23
|
-
//
|
|
798
|
+
// src/actions/index.ts
|
|
799
|
+
init_define_import_meta();
|
|
24
800
|
import { makeActionCreator } from "@lls/utils";
|
|
25
801
|
var actionTypes = {
|
|
26
802
|
DELETE_ENTITY: "DELETE_ENTITY",
|
|
@@ -28,24 +804,7 @@ var actionTypes = {
|
|
|
28
804
|
SET_ENTITY: "SET_ENTITY",
|
|
29
805
|
SET_ENTITIES: "SET_ENTITIES",
|
|
30
806
|
RESET_AUTH: "RESET_AUTH",
|
|
31
|
-
SET_AUTH: "SET_AUTH"
|
|
32
|
-
SET_LOADING_SCREEN: "SET_LOADING_SCREEN",
|
|
33
|
-
SET_MODAL: "SET_MODAL",
|
|
34
|
-
ADD_NOTIFICATION: "ADD_NOTIFICATION",
|
|
35
|
-
REMOVE_NOTIFICATION: "REMOVE_NOTIFICATION",
|
|
36
|
-
SET_SHOWN_CONTEXTUAL_ACTIONS: "SET_SHOW_CONTEXTUAL_ACTIONS",
|
|
37
|
-
SET_IS_DRAWER_OPEN: "SET_IS_DRAWER_OPEN",
|
|
38
|
-
SET_DRAWER_EXPANDED_ID: "SET_DRAWER_EXPANDED_ID",
|
|
39
|
-
SET_IS_OPEN_SAVE_MODAL: "SET_IS_OPEN_SAVE_MODAL",
|
|
40
|
-
SET_IS_VIEWER_READY: "SET_IS_VIEWER_READY",
|
|
41
|
-
SET_CURRENT_TOUR_ID: "SET_CURRENT_TOUR_ID",
|
|
42
|
-
SET_CURRENT_TOUR_STEP: "SET_CURRENT_TOUR_STEP",
|
|
43
|
-
RESET_TOUR: "RESET_TOUR",
|
|
44
|
-
SET_IS_TOUR_PANEL_OPEN: "SET_IS_TOUR_PANEL_OPEN",
|
|
45
|
-
SET_TOUR_PANEL_MODE: "SET_TOUR_PANEL_MODE",
|
|
46
|
-
SET_IS_STUDENT_VIEW_ACTIVATED: "SET_IS_STUDENT_VIEW_ACTIVATED",
|
|
47
|
-
SET_SCENARIO_ID: "SET_SCENARIO_ID",
|
|
48
|
-
SET_SSR_FAKE_PAGE_ID: "SET_SSR_FAKE_PAGE_ID"
|
|
807
|
+
SET_AUTH: "SET_AUTH"
|
|
49
808
|
};
|
|
50
809
|
var deleteEntity = makeActionCreator(actionTypes.DELETE_ENTITY);
|
|
51
810
|
var updateEntity = makeActionCreator(actionTypes.UPDATE_ENTITY);
|
|
@@ -53,44 +812,27 @@ var setEntity = makeActionCreator(actionTypes.SET_ENTITY);
|
|
|
53
812
|
var setEntities = makeActionCreator(actionTypes.SET_ENTITIES);
|
|
54
813
|
var setAuth = makeActionCreator(actionTypes.SET_AUTH);
|
|
55
814
|
var resetAuth = makeActionCreator(actionTypes.RESET_AUTH);
|
|
56
|
-
var setLoadingScreen = makeActionCreator(actionTypes.SET_LOADING_SCREEN);
|
|
57
|
-
var setModal = makeActionCreator(actionTypes.SET_MODAL);
|
|
58
|
-
var addNotification = makeActionCreator(actionTypes.ADD_NOTIFICATION);
|
|
59
|
-
var removeNotification = makeActionCreator(actionTypes.REMOVE_NOTIFICATION);
|
|
60
|
-
var setShownContextualActions = makeActionCreator(actionTypes.SET_SHOWN_CONTEXTUAL_ACTIONS);
|
|
61
|
-
var setIsDrawerOpen = makeActionCreator(actionTypes.SET_IS_DRAWER_OPEN);
|
|
62
|
-
var setIsViewerReady = makeActionCreator(actionTypes.SET_IS_VIEWER_READY);
|
|
63
|
-
var setDrawerExpandedId = makeActionCreator(actionTypes.SET_DRAWER_EXPANDED_ID);
|
|
64
|
-
var setIsOpenSaveModal = makeActionCreator(actionTypes.SET_IS_OPEN_SAVE_MODAL);
|
|
65
|
-
var setCurrentTourId = makeActionCreator(actionTypes.SET_CURRENT_TOUR_ID);
|
|
66
|
-
var setCurrentTourStep = makeActionCreator(actionTypes.SET_CURRENT_TOUR_STEP);
|
|
67
|
-
var resetTour = makeActionCreator(actionTypes.RESET_TOUR);
|
|
68
|
-
var setIsTourPanelOpen = makeActionCreator(actionTypes.SET_IS_TOUR_PANEL_OPEN);
|
|
69
|
-
var setTourPanelMode = makeActionCreator(actionTypes.SET_TOUR_PANEL_MODE);
|
|
70
|
-
var setScenarioId = makeActionCreator(actionTypes.SET_SCENARIO_ID);
|
|
71
|
-
var setIsStudentViewActivated = makeActionCreator(actionTypes.SET_IS_STUDENT_VIEW_ACTIVATED);
|
|
72
|
-
var setSsrFakePageId = makeActionCreator(actionTypes.SET_SSR_FAKE_PAGE_ID);
|
|
73
815
|
|
|
74
816
|
// src/reducers/entities.ts
|
|
75
817
|
var deleteEntityReducer = (state, payload) => {
|
|
76
818
|
const { path } = payload;
|
|
77
|
-
return
|
|
819
|
+
return _5.omit(path, state);
|
|
78
820
|
};
|
|
79
821
|
var updateEntityReducer = (state, payload) => {
|
|
80
822
|
const { path, entity } = payload;
|
|
81
|
-
const currentEntity =
|
|
82
|
-
return
|
|
823
|
+
const currentEntity = _5.get(path, state);
|
|
824
|
+
return _5.set(path, _5.merge(currentEntity, entity), state);
|
|
83
825
|
};
|
|
84
826
|
var setEntityReducer = (state, payload) => {
|
|
85
827
|
const { path, entity } = payload;
|
|
86
|
-
return
|
|
828
|
+
return _5.set(path, entity, state);
|
|
87
829
|
};
|
|
88
830
|
var shallowAssign = (old, next, transform) => {
|
|
89
831
|
let updated = false;
|
|
90
|
-
const merged =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (
|
|
832
|
+
const merged = _5.flow(
|
|
833
|
+
_5.toPairs,
|
|
834
|
+
_5.reduce((memo, [key, val]) => {
|
|
835
|
+
if (_5.isEmpty(val)) return memo;
|
|
94
836
|
if (!old[key]) {
|
|
95
837
|
updated = true;
|
|
96
838
|
memo[key] = val;
|
|
@@ -103,7 +845,7 @@ var shallowAssign = (old, next, transform) => {
|
|
|
103
845
|
return memo;
|
|
104
846
|
}
|
|
105
847
|
return memo;
|
|
106
|
-
},
|
|
848
|
+
}, _5.clone(old))
|
|
107
849
|
)(next);
|
|
108
850
|
return updated ? merged : old;
|
|
109
851
|
};
|
|
@@ -112,7 +854,7 @@ var setEntitiesReducer = (state, payload) => {
|
|
|
112
854
|
return shallowAssign(
|
|
113
855
|
entityKind,
|
|
114
856
|
nextEntityKind,
|
|
115
|
-
(oldEntity, nextEntity) =>
|
|
857
|
+
(oldEntity, nextEntity) => _5.isEqual(oldEntity, nextEntity) ? oldEntity : _5.assign(oldEntity, nextEntity)
|
|
116
858
|
);
|
|
117
859
|
});
|
|
118
860
|
};
|
|
@@ -127,13 +869,229 @@ var entities = makeReducer(
|
|
|
127
869
|
);
|
|
128
870
|
var entities_default = entities;
|
|
129
871
|
|
|
872
|
+
// src/reducers/auth.ts
|
|
873
|
+
init_define_import_meta();
|
|
874
|
+
import { makeReducer as makeReducer2 } from "@lls/utils";
|
|
875
|
+
import _6 from "lodash/fp.js";
|
|
876
|
+
var initialState = {
|
|
877
|
+
id: void 0,
|
|
878
|
+
role: null,
|
|
879
|
+
token: null,
|
|
880
|
+
isStudent: null,
|
|
881
|
+
isTeacher: null,
|
|
882
|
+
isPremium: null,
|
|
883
|
+
userPages: null,
|
|
884
|
+
username: null,
|
|
885
|
+
llsUserId: null
|
|
886
|
+
};
|
|
887
|
+
var auth = makeReducer2(initialState, {
|
|
888
|
+
[actionTypes.SET_AUTH]: _6.assign,
|
|
889
|
+
[actionTypes.RESET_AUTH]: _6.constant(initialState)
|
|
890
|
+
});
|
|
891
|
+
var auth_default = auth;
|
|
892
|
+
|
|
130
893
|
// src/schema/index.ts
|
|
131
|
-
|
|
132
|
-
var
|
|
894
|
+
init_define_import_meta();
|
|
895
|
+
var import_normalizr = __toESM(require_normalizr(), 1);
|
|
896
|
+
import _7 from "lodash/fp.js";
|
|
897
|
+
var document = new import_normalizr.schema.Entity("documents", {}, { idAttribute: "resourceId" });
|
|
898
|
+
var subject = new import_normalizr.schema.Entity("subjects");
|
|
899
|
+
var level = new import_normalizr.schema.Entity("levels");
|
|
900
|
+
var book = new import_normalizr.schema.Entity("books");
|
|
901
|
+
var tool = new import_normalizr.schema.Entity("tools");
|
|
902
|
+
var chapter = new import_normalizr.schema.Entity("chapters");
|
|
903
|
+
var page = new import_normalizr.schema.Entity("pages");
|
|
904
|
+
var resource = new import_normalizr.schema.Entity("resources");
|
|
905
|
+
var user = new import_normalizr.schema.Entity("users");
|
|
906
|
+
var school = new import_normalizr.schema.Entity("schools");
|
|
907
|
+
var teacher = new import_normalizr.schema.Entity("teachers");
|
|
908
|
+
var faq = new import_normalizr.schema.Entity("faq");
|
|
909
|
+
var product = new import_normalizr.schema.Entity("products");
|
|
910
|
+
var communityProjects = new import_normalizr.schema.Entity("communityProjects");
|
|
911
|
+
var grammarRule = new import_normalizr.schema.Entity("grammarRules", {}, { idAttribute: "objectID" });
|
|
912
|
+
var mainNotification = new import_normalizr.schema.Entity("mainNotifications");
|
|
913
|
+
var explorerResult = new import_normalizr.schema.Entity("explorerResults", {}, { idAttribute: "resourceId" });
|
|
914
|
+
var drawerNotification = new import_normalizr.schema.Entity("drawerNotifications");
|
|
915
|
+
var copyNotification = new import_normalizr.schema.Entity("copyNotifications");
|
|
916
|
+
var quote = new import_normalizr.schema.Entity("quotes");
|
|
917
|
+
var group = new import_normalizr.schema.Entity("groups");
|
|
918
|
+
var analytic = new import_normalizr.schema.Entity("analytics");
|
|
919
|
+
var contact = new import_normalizr.schema.Entity("contact");
|
|
920
|
+
var collection = new import_normalizr.schema.Entity("collections");
|
|
921
|
+
var sharedPage = new import_normalizr.schema.Entity("sharedPages");
|
|
922
|
+
var student = new import_normalizr.schema.Entity("students");
|
|
923
|
+
var news = new import_normalizr.schema.Entity("news");
|
|
924
|
+
var schoolType = new import_normalizr.schema.Entity("schoolTypes");
|
|
925
|
+
var panorama = new import_normalizr.schema.Entity("panoramas");
|
|
926
|
+
var premiumResource = new import_normalizr.schema.Entity("premiumResources");
|
|
927
|
+
var garDivision = new import_normalizr.schema.Entity("garDivisions");
|
|
928
|
+
var define = (el, scheme) => {
|
|
929
|
+
el.define(scheme);
|
|
930
|
+
return scheme;
|
|
931
|
+
};
|
|
932
|
+
var bookSchema = define(book, {
|
|
933
|
+
chapters: [chapter],
|
|
934
|
+
collection,
|
|
935
|
+
firstValidPage: page,
|
|
936
|
+
levels: [level],
|
|
937
|
+
news: [news],
|
|
938
|
+
oldBook: book,
|
|
939
|
+
premiumResources: [premiumResource],
|
|
940
|
+
revisionPages: [page],
|
|
941
|
+
subjects: [subject],
|
|
942
|
+
textbooks: [book],
|
|
943
|
+
tools: [tool],
|
|
944
|
+
workbooks: [book],
|
|
945
|
+
workplans: [book]
|
|
946
|
+
});
|
|
947
|
+
var garDivisionSchema = define(garDivision, {
|
|
948
|
+
students: [user],
|
|
949
|
+
school
|
|
950
|
+
});
|
|
951
|
+
var chapterSchema = define(chapter, {
|
|
952
|
+
book,
|
|
953
|
+
oldBook: book,
|
|
954
|
+
oldChapter: chapter,
|
|
955
|
+
pages: [page],
|
|
956
|
+
resources: [resource]
|
|
957
|
+
});
|
|
958
|
+
var pageSchema = define(page, {
|
|
959
|
+
book,
|
|
960
|
+
chapter,
|
|
961
|
+
oldBook: book,
|
|
962
|
+
oldChapter: chapter,
|
|
963
|
+
oldLesson: page,
|
|
964
|
+
originalPage: page,
|
|
965
|
+
parent: page,
|
|
966
|
+
sharedGroups: [group],
|
|
967
|
+
sharedTeacher: user,
|
|
968
|
+
sharedUsers: [user],
|
|
969
|
+
user
|
|
970
|
+
});
|
|
971
|
+
var userSchema = define(user, {
|
|
972
|
+
books: [book],
|
|
973
|
+
booksV2: [book],
|
|
974
|
+
contacts: [contact],
|
|
975
|
+
copies: [page],
|
|
976
|
+
copyNotifications: [copyNotification],
|
|
977
|
+
drawerNotifications: [drawerNotification],
|
|
978
|
+
garDivisions: [garDivision],
|
|
979
|
+
groups: [group],
|
|
980
|
+
lastBooksViewed: [book],
|
|
981
|
+
lastPagesViewed: [page],
|
|
982
|
+
levels: [level],
|
|
983
|
+
mainNotifications: [mainNotification],
|
|
984
|
+
pages: [page],
|
|
985
|
+
schools: [school],
|
|
986
|
+
sharedPages: [sharedPage],
|
|
987
|
+
students: [student],
|
|
988
|
+
subjects: [subject],
|
|
989
|
+
teachers: [teacher],
|
|
990
|
+
userPages: [page]
|
|
991
|
+
});
|
|
992
|
+
var notificationSchema = define(mainNotification, { page });
|
|
993
|
+
drawerNotification.define({ page });
|
|
994
|
+
copyNotification.define({ page });
|
|
995
|
+
var resourceSchema = define(resource, {
|
|
996
|
+
chapter,
|
|
997
|
+
page
|
|
998
|
+
});
|
|
999
|
+
var toolSchema = define(tool, {
|
|
1000
|
+
books: [book]
|
|
1001
|
+
});
|
|
1002
|
+
var sharedPageSchema = define(sharedPage, {
|
|
1003
|
+
user,
|
|
1004
|
+
chapter,
|
|
1005
|
+
parent: page,
|
|
1006
|
+
book,
|
|
1007
|
+
originalPage: page
|
|
1008
|
+
});
|
|
1009
|
+
var studentSchema = define(student, {
|
|
1010
|
+
levels: [level]
|
|
1011
|
+
});
|
|
1012
|
+
var teacherSchema = define(teacher, {
|
|
1013
|
+
schools: [school],
|
|
1014
|
+
subjects: [subject]
|
|
1015
|
+
});
|
|
1016
|
+
var productSchema = define(product, {
|
|
1017
|
+
books: [book]
|
|
1018
|
+
});
|
|
1019
|
+
var groupSchema = define(group, {
|
|
1020
|
+
owner: teacher,
|
|
1021
|
+
students: [student]
|
|
1022
|
+
});
|
|
1023
|
+
var newsSchema = define(news, {
|
|
1024
|
+
books: [book],
|
|
1025
|
+
subjects: [subject],
|
|
1026
|
+
levels: [level]
|
|
1027
|
+
});
|
|
1028
|
+
var premiumResourceSchema = define(premiumResource, {
|
|
1029
|
+
book
|
|
1030
|
+
});
|
|
1031
|
+
var querySchema = {
|
|
1032
|
+
viewer: {
|
|
1033
|
+
addCorrectionsToGroup: group,
|
|
1034
|
+
addCorrectionsToStudents: page,
|
|
1035
|
+
addPageAppreciation: page,
|
|
1036
|
+
addStudentToGroup: group,
|
|
1037
|
+
books: { hits: [book] },
|
|
1038
|
+
chapters: { hits: [chapter] },
|
|
1039
|
+
createEstimate: quote,
|
|
1040
|
+
createGroup: group,
|
|
1041
|
+
createPage: page,
|
|
1042
|
+
createUser: user,
|
|
1043
|
+
documents: { hits: [document] },
|
|
1044
|
+
explorerResults: [explorerResult],
|
|
1045
|
+
levels: [level],
|
|
1046
|
+
me: user,
|
|
1047
|
+
// mutations
|
|
1048
|
+
pages: { hits: [page] },
|
|
1049
|
+
panoramas: [panorama],
|
|
1050
|
+
parents: { hits: [page] },
|
|
1051
|
+
//pages alias
|
|
1052
|
+
product: { hits: [product] },
|
|
1053
|
+
schoolTypes: { hits: [schoolType] },
|
|
1054
|
+
sharePageToGroup: page,
|
|
1055
|
+
sharePageToUsers: page,
|
|
1056
|
+
subjects: { hits: [subject] },
|
|
1057
|
+
updateCopyNotification: copyNotification,
|
|
1058
|
+
updateDrawerNotification: drawerNotification,
|
|
1059
|
+
updateGroup: group,
|
|
1060
|
+
updateMainNotification: mainNotification,
|
|
1061
|
+
updatePage: page,
|
|
1062
|
+
updateTrialUser: user,
|
|
1063
|
+
updateUserLastActivitySeenAt: user,
|
|
1064
|
+
updateUser: user
|
|
1065
|
+
},
|
|
1066
|
+
auth: {
|
|
1067
|
+
user
|
|
1068
|
+
},
|
|
1069
|
+
marketing: {
|
|
1070
|
+
addLikeFaq: faq,
|
|
1071
|
+
communityProjects: [communityProjects],
|
|
1072
|
+
createAnalytics: analytic,
|
|
1073
|
+
faq: [faq]
|
|
1074
|
+
},
|
|
1075
|
+
static: {
|
|
1076
|
+
projetVoltaire: {
|
|
1077
|
+
grammarRules: [grammarRule]
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
var normalizeData = _7.flow((data) => (0, import_normalizr.normalize)(data, querySchema));
|
|
133
1082
|
export {
|
|
1083
|
+
auth_default as authReducer,
|
|
134
1084
|
entities_default as entitiesReducer,
|
|
1085
|
+
getCurrentUser,
|
|
135
1086
|
getSchool,
|
|
136
1087
|
getSchools,
|
|
137
|
-
|
|
138
|
-
|
|
1088
|
+
getUser,
|
|
1089
|
+
getUsers,
|
|
1090
|
+
makeSearchSchools,
|
|
1091
|
+
makeSearchUsers,
|
|
1092
|
+
normalizeData,
|
|
1093
|
+
querySchema,
|
|
1094
|
+
searchSchools,
|
|
1095
|
+
searchUsers,
|
|
1096
|
+
setEntitiesReducer
|
|
139
1097
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@lls/store",
|
|
3
3
|
"description": "model de donnée et selecteurs",
|
|
4
4
|
"homepage": "https://github.com/lelivrescolaire/monorepo/tree/dev/libs/store",
|
|
5
|
-
"version": "24.1.57-
|
|
5
|
+
"version": "24.1.57-4e182f7c",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./lib/builttypes/store/src/index.d.ts",
|
|
8
8
|
"exports": {
|
|
@@ -37,14 +37,17 @@
|
|
|
37
37
|
"lodash": "4.17.21",
|
|
38
38
|
"react": "18.3.1",
|
|
39
39
|
"reselect": "4.1.8",
|
|
40
|
-
"typescript": "5.5.
|
|
40
|
+
"typescript": "5.5.4",
|
|
41
41
|
"vite": "5.3.3",
|
|
42
42
|
"vite-tsconfig-paths": "4.3.2",
|
|
43
43
|
"vitest": "2.0.0",
|
|
44
|
-
"@lls/utils": "24.1.57-
|
|
45
|
-
"@lls/vitescripts": "24.1.57-
|
|
44
|
+
"@lls/utils": "24.1.57-4e182f7c",
|
|
45
|
+
"@lls/vitescripts": "24.1.57-4e182f7c"
|
|
46
46
|
},
|
|
47
47
|
"license": "ISC",
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"normalizr": "3.6.2"
|
|
50
|
+
},
|
|
48
51
|
"scripts": {
|
|
49
52
|
"build": "node build.mjs",
|
|
50
53
|
"lint": "pnpm biome check --apply src __tests__",
|