@ailaw/venus 0.3.13 → 0.3.17
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/dist/venus.es.js +260 -3815
- package/package.json +1 -1
package/dist/venus.es.js
CHANGED
|
@@ -17,13 +17,12 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { defineComponent, ref as ref$1, watch, computed, toRefs as toRefs$1, shallowRef
|
|
20
|
+
import { defineComponent, ref as ref$1, watch, computed, toRefs as toRefs$1, shallowRef } from "vue-demi";
|
|
21
21
|
import { Select, Modal, Form, Input, Checkbox, Divider, Button, Tag, Tooltip, Upload, Row, Col, Radio, Table, Badge, Card, message } from "ant-design-vue";
|
|
22
|
-
import { useQuery, useResult, useMutation } from "@vue/apollo-composable";
|
|
22
|
+
import { useQuery, useResult, useMutation, useApolloClient } from "@vue/apollo-composable";
|
|
23
23
|
import gql from "graphql-tag";
|
|
24
24
|
import { path, uniqBy, prop } from "ramda";
|
|
25
25
|
import "vue";
|
|
26
|
-
import { Source, visit } from "graphql";
|
|
27
26
|
var index$4 = "";
|
|
28
27
|
function __variableDynamicImportRuntime0__$1(path2) {
|
|
29
28
|
switch (path2) {
|
|
@@ -221,10 +220,10 @@ function useCreateProfile() {
|
|
|
221
220
|
const me = useMe();
|
|
222
221
|
const { mutate, loading } = useMutation(addProfileUserMutation);
|
|
223
222
|
const createProfile = async (profile) => {
|
|
224
|
-
var
|
|
223
|
+
var _a;
|
|
225
224
|
const variables = {
|
|
226
225
|
email: profile.email,
|
|
227
|
-
lawFirmId: (
|
|
226
|
+
lawFirmId: (_a = me.value) == null ? void 0 : _a.lawFirmId
|
|
228
227
|
};
|
|
229
228
|
if (profile.profileType === "USERPROFILE") {
|
|
230
229
|
variables.name = profile.profileName;
|
|
@@ -374,8 +373,8 @@ var __vue2_script$d = defineComponent({
|
|
|
374
373
|
},
|
|
375
374
|
setup(props, { emit }) {
|
|
376
375
|
const selectedId = computed(() => {
|
|
377
|
-
var
|
|
378
|
-
return (
|
|
376
|
+
var _a;
|
|
377
|
+
return (_a = props.value) == null ? void 0 : _a.id;
|
|
379
378
|
});
|
|
380
379
|
const handleSelect = (value) => emit("input", props.source.find((v) => String(v.id) == value));
|
|
381
380
|
const handleProfileCreate = () => emit("create-profile");
|
|
@@ -411,9 +410,9 @@ var ProfileSelector = /* @__PURE__ */ function() {
|
|
|
411
410
|
function useProfiles(keywords, onlyRole, profileIds) {
|
|
412
411
|
const me = useMe();
|
|
413
412
|
const { result, loading } = useQuery(profilesQuery, () => {
|
|
414
|
-
var
|
|
413
|
+
var _a;
|
|
415
414
|
return {
|
|
416
|
-
lawFirmId: (
|
|
415
|
+
lawFirmId: (_a = me.value) == null ? void 0 : _a.lawFirmId,
|
|
417
416
|
keywords: keywords.value,
|
|
418
417
|
profileType: onlyRole.value,
|
|
419
418
|
profileIds: profileIds.value
|
|
@@ -843,7 +842,7 @@ var __vue2_script$9 = defineComponent({
|
|
|
843
842
|
[k]: v
|
|
844
843
|
}));
|
|
845
844
|
};
|
|
846
|
-
const
|
|
845
|
+
const remove = (id) => {
|
|
847
846
|
emit("change", props.value.filter((v) => v.id !== id));
|
|
848
847
|
};
|
|
849
848
|
const beforeUpload = (file) => {
|
|
@@ -874,7 +873,7 @@ var __vue2_script$9 = defineComponent({
|
|
|
874
873
|
};
|
|
875
874
|
return {
|
|
876
875
|
changeVal,
|
|
877
|
-
remove
|
|
876
|
+
remove,
|
|
878
877
|
beforeUpload,
|
|
879
878
|
loading,
|
|
880
879
|
allowFiles: [
|
|
@@ -913,10 +912,10 @@ var AFileUploader = /* @__PURE__ */ function() {
|
|
|
913
912
|
return __component__$9.exports;
|
|
914
913
|
}();
|
|
915
914
|
var refactorParams = (record) => {
|
|
916
|
-
var
|
|
915
|
+
var _a;
|
|
917
916
|
return {
|
|
918
917
|
id: record.id,
|
|
919
|
-
sampleDocList: ((
|
|
918
|
+
sampleDocList: ((_a = record.sampleDocs) == null ? void 0 : _a.map(({ id }) => id)) || [],
|
|
920
919
|
taskName: record.taskName,
|
|
921
920
|
isEmployee: record.isEmployee || AssigneeTypes[AssigneeTypes.EMPTY_DEFAULT],
|
|
922
921
|
generalTaskType: record.generalTaskType,
|
|
@@ -1219,7 +1218,7 @@ function __vue2_injectStyles$6(context) {
|
|
|
1219
1218
|
var TaskTemplateFilter = /* @__PURE__ */ function() {
|
|
1220
1219
|
return __component__$6.exports;
|
|
1221
1220
|
}();
|
|
1222
|
-
var toString
|
|
1221
|
+
var toString = function(x) {
|
|
1223
1222
|
return Object.prototype.toString.call(x);
|
|
1224
1223
|
};
|
|
1225
1224
|
function isNative(Ctor) {
|
|
@@ -1229,8 +1228,8 @@ var hasSymbol = typeof Symbol !== "undefined" && isNative(Symbol) && typeof Refl
|
|
|
1229
1228
|
var noopFn = function(_) {
|
|
1230
1229
|
return _;
|
|
1231
1230
|
};
|
|
1232
|
-
function proxy(target, key,
|
|
1233
|
-
var get2 =
|
|
1231
|
+
function proxy(target, key, _a) {
|
|
1232
|
+
var get2 = _a.get, set2 = _a.set;
|
|
1234
1233
|
Object.defineProperty(target, key, {
|
|
1235
1234
|
enumerable: true,
|
|
1236
1235
|
configurable: true,
|
|
@@ -1246,7 +1245,7 @@ function def(obj, key, val, enumerable) {
|
|
|
1246
1245
|
configurable: true
|
|
1247
1246
|
});
|
|
1248
1247
|
}
|
|
1249
|
-
function hasOwn
|
|
1248
|
+
function hasOwn(obj, key) {
|
|
1250
1249
|
return Object.hasOwnProperty.call(obj, key);
|
|
1251
1250
|
}
|
|
1252
1251
|
function isArray(x) {
|
|
@@ -1261,7 +1260,7 @@ function isObject(val) {
|
|
|
1261
1260
|
return val !== null && typeof val === "object";
|
|
1262
1261
|
}
|
|
1263
1262
|
function isPlainObject(x) {
|
|
1264
|
-
return toString
|
|
1263
|
+
return toString(x) === "[object Object]";
|
|
1265
1264
|
}
|
|
1266
1265
|
function isFunction(x) {
|
|
1267
1266
|
return typeof x === "function";
|
|
@@ -1280,24 +1279,24 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
1280
1279
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1281
1280
|
PERFORMANCE OF THIS SOFTWARE.
|
|
1282
1281
|
***************************************************************************** */
|
|
1283
|
-
var extendStatics
|
|
1284
|
-
extendStatics
|
|
1282
|
+
var extendStatics = function(d, b) {
|
|
1283
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
1285
1284
|
d2.__proto__ = b2;
|
|
1286
1285
|
} || function(d2, b2) {
|
|
1287
1286
|
for (var p in b2)
|
|
1288
1287
|
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|
1289
1288
|
d2[p] = b2[p];
|
|
1290
1289
|
};
|
|
1291
|
-
return extendStatics
|
|
1290
|
+
return extendStatics(d, b);
|
|
1292
1291
|
};
|
|
1293
|
-
function __extends
|
|
1292
|
+
function __extends(d, b) {
|
|
1294
1293
|
if (typeof b !== "function" && b !== null)
|
|
1295
1294
|
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1296
|
-
extendStatics
|
|
1297
|
-
function
|
|
1295
|
+
extendStatics(d, b);
|
|
1296
|
+
function __() {
|
|
1298
1297
|
this.constructor = d;
|
|
1299
1298
|
}
|
|
1300
|
-
d.prototype = b === null ? Object.create(b) : (
|
|
1299
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1301
1300
|
}
|
|
1302
1301
|
function __values(o) {
|
|
1303
1302
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
@@ -1360,7 +1359,7 @@ var EffectScopeImpl = function() {
|
|
|
1360
1359
|
return EffectScopeImpl2;
|
|
1361
1360
|
}();
|
|
1362
1361
|
(function(_super) {
|
|
1363
|
-
__extends
|
|
1362
|
+
__extends(EffectScope, _super);
|
|
1364
1363
|
function EffectScope(detached) {
|
|
1365
1364
|
if (detached === void 0) {
|
|
1366
1365
|
detached = false;
|
|
@@ -1379,13 +1378,13 @@ var EffectScopeImpl = function() {
|
|
|
1379
1378
|
return EffectScope;
|
|
1380
1379
|
})(EffectScopeImpl);
|
|
1381
1380
|
function recordEffectScope(effect, scope) {
|
|
1382
|
-
var
|
|
1381
|
+
var _a;
|
|
1383
1382
|
scope = scope || activeEffectScope;
|
|
1384
1383
|
if (scope && scope.active) {
|
|
1385
1384
|
scope.effects.push(effect);
|
|
1386
1385
|
return;
|
|
1387
1386
|
}
|
|
1388
|
-
var vm = (
|
|
1387
|
+
var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy;
|
|
1389
1388
|
vm && vm.$on("hook:destroyed", function() {
|
|
1390
1389
|
return effect.stop();
|
|
1391
1390
|
});
|
|
@@ -1411,7 +1410,7 @@ try {
|
|
|
1411
1410
|
} else if (requiredVue && "default" in requiredVue && isVue(requiredVue.default)) {
|
|
1412
1411
|
vueDependency = requiredVue.default;
|
|
1413
1412
|
}
|
|
1414
|
-
} catch (
|
|
1413
|
+
} catch (_a) {
|
|
1415
1414
|
}
|
|
1416
1415
|
var vueConstructor = null;
|
|
1417
1416
|
var currentInstance = null;
|
|
@@ -1421,7 +1420,7 @@ function isVue(obj) {
|
|
|
1421
1420
|
return obj && isFunction(obj) && obj.name === "Vue";
|
|
1422
1421
|
}
|
|
1423
1422
|
function isVueRegistered(Vue) {
|
|
1424
|
-
return vueConstructor && hasOwn
|
|
1423
|
+
return vueConstructor && hasOwn(Vue, PluginInstalledFlag);
|
|
1425
1424
|
}
|
|
1426
1425
|
function getVueConstructor() {
|
|
1427
1426
|
return vueConstructor;
|
|
@@ -1569,12 +1568,12 @@ var accessModifiedSet = new WeakMap();
|
|
|
1569
1568
|
var readonlySet = new WeakMap();
|
|
1570
1569
|
function set$1(target, key, val) {
|
|
1571
1570
|
var Vue = getVueConstructor();
|
|
1572
|
-
var
|
|
1573
|
-
|
|
1574
|
-
var defineReactive =
|
|
1571
|
+
var _a = Vue.util;
|
|
1572
|
+
_a.warn;
|
|
1573
|
+
var defineReactive = _a.defineReactive;
|
|
1575
1574
|
var ob = target.__ob__;
|
|
1576
1575
|
function ssrMockReactivity() {
|
|
1577
|
-
if (ob && isObject(val) && !hasOwn
|
|
1576
|
+
if (ob && isObject(val) && !hasOwn(val, "__ob__")) {
|
|
1578
1577
|
mockReactivityDeep(val);
|
|
1579
1578
|
}
|
|
1580
1579
|
}
|
|
@@ -1609,8 +1608,8 @@ function set$1(target, key, val) {
|
|
|
1609
1608
|
return val;
|
|
1610
1609
|
}
|
|
1611
1610
|
var RefImpl = function() {
|
|
1612
|
-
function RefImpl2(
|
|
1613
|
-
var get2 =
|
|
1611
|
+
function RefImpl2(_a) {
|
|
1612
|
+
var get2 = _a.get, set2 = _a.set;
|
|
1614
1613
|
proxy(this, "value", {
|
|
1615
1614
|
get: get2,
|
|
1616
1615
|
set: set2
|
|
@@ -1634,11 +1633,11 @@ function createRef(options, isReadonly, isComputed) {
|
|
|
1634
1633
|
return sealed;
|
|
1635
1634
|
}
|
|
1636
1635
|
function ref(raw) {
|
|
1637
|
-
var
|
|
1636
|
+
var _a;
|
|
1638
1637
|
if (isRef(raw)) {
|
|
1639
1638
|
return raw;
|
|
1640
1639
|
}
|
|
1641
|
-
var value = reactive((
|
|
1640
|
+
var value = reactive((_a = {}, _a[RefKey] = raw, _a));
|
|
1642
1641
|
return createRef({
|
|
1643
1642
|
get: function() {
|
|
1644
1643
|
return value[RefKey];
|
|
@@ -1676,12 +1675,12 @@ function toRef(object, key) {
|
|
|
1676
1675
|
});
|
|
1677
1676
|
}
|
|
1678
1677
|
function isRaw(obj) {
|
|
1679
|
-
var
|
|
1680
|
-
return Boolean(obj && hasOwn
|
|
1678
|
+
var _a;
|
|
1679
|
+
return Boolean(obj && hasOwn(obj, "__ob__") && typeof obj.__ob__ === "object" && ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a.__raw__));
|
|
1681
1680
|
}
|
|
1682
1681
|
function isReactive(obj) {
|
|
1683
|
-
var
|
|
1684
|
-
return Boolean(obj && hasOwn
|
|
1682
|
+
var _a;
|
|
1683
|
+
return Boolean(obj && hasOwn(obj, "__ob__") && typeof obj.__ob__ === "object" && !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a.__raw__));
|
|
1685
1684
|
}
|
|
1686
1685
|
function setupAccessControl(target) {
|
|
1687
1686
|
if (!isPlainObject(target) || isRaw(target) || isArray(target) || isRef(target) || isComponentInstance(target) || accessModifiedSet.has(target))
|
|
@@ -1748,17 +1747,17 @@ function observe(obj) {
|
|
|
1748
1747
|
});
|
|
1749
1748
|
observed = vm._data.$$state;
|
|
1750
1749
|
}
|
|
1751
|
-
if (!hasOwn
|
|
1750
|
+
if (!hasOwn(observed, "__ob__")) {
|
|
1752
1751
|
mockReactivityDeep(observed);
|
|
1753
1752
|
}
|
|
1754
1753
|
return observed;
|
|
1755
1754
|
}
|
|
1756
1755
|
function mockReactivityDeep(obj, seen) {
|
|
1757
|
-
var e_1,
|
|
1756
|
+
var e_1, _a;
|
|
1758
1757
|
if (seen === void 0) {
|
|
1759
1758
|
seen = new Set();
|
|
1760
1759
|
}
|
|
1761
|
-
if (seen.has(obj) || hasOwn
|
|
1760
|
+
if (seen.has(obj) || hasOwn(obj, "__ob__") || !Object.isExtensible(obj))
|
|
1762
1761
|
return;
|
|
1763
1762
|
def(obj, "__ob__", mockObserver(obj));
|
|
1764
1763
|
seen.add(obj);
|
|
@@ -1775,8 +1774,8 @@ function mockReactivityDeep(obj, seen) {
|
|
|
1775
1774
|
e_1 = { error: e_1_1 };
|
|
1776
1775
|
} finally {
|
|
1777
1776
|
try {
|
|
1778
|
-
if (_c && !_c.done && (
|
|
1779
|
-
|
|
1777
|
+
if (_c && !_c.done && (_a = _b.return))
|
|
1778
|
+
_a.call(_b);
|
|
1780
1779
|
} finally {
|
|
1781
1780
|
if (e_1)
|
|
1782
1781
|
throw e_1.error;
|
|
@@ -1824,7 +1823,7 @@ var vmStateManager = {
|
|
|
1824
1823
|
};
|
|
1825
1824
|
function asVmProperty(vm, propName, propValue) {
|
|
1826
1825
|
var props = vm.$options.props;
|
|
1827
|
-
if (!(propName in vm) && !(props && hasOwn
|
|
1826
|
+
if (!(propName in vm) && !(props && hasOwn(props, propName))) {
|
|
1828
1827
|
if (isRef(propValue)) {
|
|
1829
1828
|
proxy(vm, propName, {
|
|
1830
1829
|
get: function() {
|
|
@@ -1875,7 +1874,7 @@ function updateTemplateRef(vm) {
|
|
|
1875
1874
|
vmStateManager.set(vm, "refs", validNewKeys);
|
|
1876
1875
|
}
|
|
1877
1876
|
function updateVmAttrs(vm, ctx) {
|
|
1878
|
-
var e_1,
|
|
1877
|
+
var e_1, _a;
|
|
1879
1878
|
if (!vm) {
|
|
1880
1879
|
return;
|
|
1881
1880
|
}
|
|
@@ -1897,7 +1896,7 @@ function updateVmAttrs(vm, ctx) {
|
|
|
1897
1896
|
}
|
|
1898
1897
|
var source = vm.$attrs;
|
|
1899
1898
|
var _loop_1 = function(attr2) {
|
|
1900
|
-
if (!hasOwn
|
|
1899
|
+
if (!hasOwn(attrBindings.data, attr2)) {
|
|
1901
1900
|
proxy(attrBindings.data, attr2, {
|
|
1902
1901
|
get: function() {
|
|
1903
1902
|
return vm.$attrs[attr2];
|
|
@@ -1914,8 +1913,8 @@ function updateVmAttrs(vm, ctx) {
|
|
|
1914
1913
|
e_1 = { error: e_1_1 };
|
|
1915
1914
|
} finally {
|
|
1916
1915
|
try {
|
|
1917
|
-
if (_c && !_c.done && (
|
|
1918
|
-
|
|
1916
|
+
if (_c && !_c.done && (_a = _b.return))
|
|
1917
|
+
_a.call(_b);
|
|
1919
1918
|
} finally {
|
|
1920
1919
|
if (e_1)
|
|
1921
1920
|
throw e_1.error;
|
|
@@ -1968,9 +1967,9 @@ function mixin(Vue) {
|
|
|
1968
1967
|
updateVmAttrs(this);
|
|
1969
1968
|
},
|
|
1970
1969
|
updated: function() {
|
|
1971
|
-
var
|
|
1970
|
+
var _a;
|
|
1972
1971
|
updateTemplateRef(this);
|
|
1973
|
-
if ((
|
|
1972
|
+
if ((_a = this.$vnode) === null || _a === void 0 ? void 0 : _a.context) {
|
|
1974
1973
|
updateTemplateRef(this.$vnode.context);
|
|
1975
1974
|
}
|
|
1976
1975
|
}
|
|
@@ -2152,7 +2151,7 @@ function mergeData(from, to) {
|
|
|
2152
2151
|
continue;
|
|
2153
2152
|
toVal = to[key];
|
|
2154
2153
|
fromVal = from[key];
|
|
2155
|
-
if (!hasOwn
|
|
2154
|
+
if (!hasOwn(to, key)) {
|
|
2156
2155
|
to[key] = fromVal;
|
|
2157
2156
|
} else if (toVal !== fromVal && isPlainObject(toVal) && !isRef(toVal) && isPlainObject(fromVal) && !isRef(fromVal)) {
|
|
2158
2157
|
mergeData(fromVal, toVal);
|
|
@@ -2160,7 +2159,7 @@ function mergeData(from, to) {
|
|
|
2160
2159
|
}
|
|
2161
2160
|
return to;
|
|
2162
2161
|
}
|
|
2163
|
-
function install
|
|
2162
|
+
function install(Vue) {
|
|
2164
2163
|
if (isVueRegistered(Vue)) {
|
|
2165
2164
|
return;
|
|
2166
2165
|
}
|
|
@@ -2174,7 +2173,7 @@ function install$1(Vue) {
|
|
|
2174
2173
|
}
|
|
2175
2174
|
var Plugin = {
|
|
2176
2175
|
install: function(Vue) {
|
|
2177
|
-
return install
|
|
2176
|
+
return install(Vue);
|
|
2178
2177
|
}
|
|
2179
2178
|
};
|
|
2180
2179
|
if (typeof window !== "undefined" && window.Vue) {
|
|
@@ -2207,12 +2206,7 @@ var __vue2_script$5 = defineComponent({
|
|
|
2207
2206
|
},
|
|
2208
2207
|
pagination: {
|
|
2209
2208
|
type: Object,
|
|
2210
|
-
required: true
|
|
2211
|
-
default: {
|
|
2212
|
-
current: 0,
|
|
2213
|
-
pageSize: 6,
|
|
2214
|
-
total: 0
|
|
2215
|
-
}
|
|
2209
|
+
required: true
|
|
2216
2210
|
},
|
|
2217
2211
|
noEdit: {
|
|
2218
2212
|
type: Boolean,
|
|
@@ -2233,18 +2227,25 @@ var __vue2_script$5 = defineComponent({
|
|
|
2233
2227
|
key: "taskName",
|
|
2234
2228
|
scopedSlots: { customRender: "taskName" }
|
|
2235
2229
|
},
|
|
2230
|
+
{
|
|
2231
|
+
title: t("message.assignee"),
|
|
2232
|
+
dataIndex: "isEmployee",
|
|
2233
|
+
key: "isEmployee",
|
|
2234
|
+
width: 120,
|
|
2235
|
+
scopedSlots: { customRender: "isEmployee" }
|
|
2236
|
+
},
|
|
2236
2237
|
{
|
|
2237
2238
|
title: t("message.tag"),
|
|
2238
2239
|
dataIndex: "tagList",
|
|
2239
2240
|
key: "tagList",
|
|
2240
|
-
width:
|
|
2241
|
+
width: 120,
|
|
2241
2242
|
scopedSlots: { customRender: "tagList" }
|
|
2242
2243
|
},
|
|
2243
2244
|
{
|
|
2244
2245
|
title: "Operation",
|
|
2245
2246
|
dataIndex: "id",
|
|
2246
2247
|
key: "id",
|
|
2247
|
-
width:
|
|
2248
|
+
width: 210,
|
|
2248
2249
|
scopedSlots: { customRender: "operation" }
|
|
2249
2250
|
}
|
|
2250
2251
|
];
|
|
@@ -2262,7 +2263,9 @@ var render$5 = function() {
|
|
|
2262
2263
|
return _c("div", [_c("ant-table", { attrs: { "dataSource": _vm.dataSource, "rowKey": "id", "columns": _vm.columns, "pagination": _vm.pagination, "loading": _vm.loading }, on: { "change": function($event) {
|
|
2263
2264
|
return _vm.$emit("changePagination", $event);
|
|
2264
2265
|
} }, scopedSlots: _vm._u([{ key: "taskName", fn: function(text, record) {
|
|
2265
|
-
return _c("span", {}, [_c("span", { staticStyle: { "display": "inline-block", "width": "250px" } }, [_vm._v(_vm._s(text))])
|
|
2266
|
+
return _c("span", {}, [_c("span", { staticStyle: { "display": "inline-block", "width": "250px" } }, [_vm._v(_vm._s(text))])]);
|
|
2267
|
+
} }, { key: "isEmployee", fn: function(isEmployee) {
|
|
2268
|
+
return _c("span", {}, [_c("assignee-tag", { attrs: { "assignee-type": isEmployee } })], 1);
|
|
2266
2269
|
} }, { key: "tagList", fn: function(tags) {
|
|
2267
2270
|
return [_c("tags-with-tooltip", { attrs: { "tags": tags } })];
|
|
2268
2271
|
} }, { key: "operation", fn: function(_, record) {
|
|
@@ -2278,7 +2281,7 @@ var render$5 = function() {
|
|
|
2278
2281
|
var staticRenderFns$5 = [];
|
|
2279
2282
|
var TaskTablePure_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
2280
2283
|
const __cssModules$5 = {};
|
|
2281
|
-
var __component__$5 = /* @__PURE__ */ normalizeComponent(__vue2_script$5, render$5, staticRenderFns$5, false, __vue2_injectStyles$5, "
|
|
2284
|
+
var __component__$5 = /* @__PURE__ */ normalizeComponent(__vue2_script$5, render$5, staticRenderFns$5, false, __vue2_injectStyles$5, "cbdc9a40", null, null);
|
|
2282
2285
|
function __vue2_injectStyles$5(context) {
|
|
2283
2286
|
for (let o in __cssModules$5) {
|
|
2284
2287
|
this[o] = __cssModules$5[o];
|
|
@@ -2290,12 +2293,18 @@ var TaskTablePure = /* @__PURE__ */ function() {
|
|
|
2290
2293
|
var useSearchTaskTemplates = (pagination, conditions = ref$1({}), lawFirmId) => {
|
|
2291
2294
|
const startIndex = computed(() => (pagination.value.current - 1) * pagination.value.pageSize);
|
|
2292
2295
|
const endIndex = computed(() => startIndex.value + pagination.value.pageSize);
|
|
2296
|
+
watch(() => conditions.value, () => {
|
|
2297
|
+
pagination.value.current = 1;
|
|
2298
|
+
pagination.value.total = 0;
|
|
2299
|
+
});
|
|
2293
2300
|
return useQuery(SearchTaskTemplatesQuery, () => ({
|
|
2294
2301
|
query: {
|
|
2295
2302
|
includeGallery: true,
|
|
2296
2303
|
keywords: conditions.value.keywords || "",
|
|
2297
2304
|
isEmployee: conditions.value.isEmployee,
|
|
2298
|
-
taskTemplateId: conditions.value.taskTemplateId
|
|
2305
|
+
taskTemplateId: conditions.value.taskTemplateId,
|
|
2306
|
+
sortBy: TaskTemplateSortBy.name,
|
|
2307
|
+
sortOrder: SortOrder.asc
|
|
2299
2308
|
},
|
|
2300
2309
|
startIndex: startIndex.value,
|
|
2301
2310
|
endIndex: endIndex.value,
|
|
@@ -2366,18 +2375,18 @@ var useSearchTaskConditions = () => ref$1({
|
|
|
2366
2375
|
var useTaskTemplateTableData = (props, emit) => {
|
|
2367
2376
|
const initialPagination = ref$1({
|
|
2368
2377
|
current: 1,
|
|
2369
|
-
pageSize:
|
|
2378
|
+
pageSize: props.pageSize || 10,
|
|
2370
2379
|
total: 0
|
|
2371
2380
|
});
|
|
2372
2381
|
const { conditions = useSearchTaskConditions(), addedTasks = ref$1([]) } = toRefs$1(props);
|
|
2373
|
-
const { result, loading, refetch } = useSearchTaskTemplates(initialPagination, conditions, props.lawFirmId);
|
|
2382
|
+
const { result, loading, refetch, variables } = useSearchTaskTemplates(initialPagination, conditions, props.lawFirmId);
|
|
2374
2383
|
const dataSource = computed(() => {
|
|
2375
|
-
var
|
|
2376
|
-
return ((
|
|
2384
|
+
var _a;
|
|
2385
|
+
return ((_a = result.value) == null ? void 0 : _a.taskTemplateSearch.taskTemplateList) || [];
|
|
2377
2386
|
});
|
|
2378
2387
|
const total = computed(() => {
|
|
2379
|
-
var
|
|
2380
|
-
return ((
|
|
2388
|
+
var _a;
|
|
2389
|
+
return ((_a = result.value) == null ? void 0 : _a.taskTemplateSearch.numResult) || 0;
|
|
2381
2390
|
});
|
|
2382
2391
|
const pagination = computed(() => __spreadProps(__spreadValues({}, initialPagination.value), {
|
|
2383
2392
|
total: total.value
|
|
@@ -2397,7 +2406,8 @@ var useTaskTemplateTableData = (props, emit) => {
|
|
|
2397
2406
|
loading,
|
|
2398
2407
|
refetch,
|
|
2399
2408
|
conditions,
|
|
2400
|
-
addedTasks
|
|
2409
|
+
addedTasks,
|
|
2410
|
+
variables
|
|
2401
2411
|
};
|
|
2402
2412
|
};
|
|
2403
2413
|
var __vue2_script$4 = defineComponent({
|
|
@@ -2417,6 +2427,9 @@ var __vue2_script$4 = defineComponent({
|
|
|
2417
2427
|
lawFirmId: {
|
|
2418
2428
|
type: Number,
|
|
2419
2429
|
required: true
|
|
2430
|
+
},
|
|
2431
|
+
pageSize: {
|
|
2432
|
+
type: Number
|
|
2420
2433
|
}
|
|
2421
2434
|
},
|
|
2422
2435
|
setup(props, { emit }) {
|
|
@@ -2425,6 +2438,7 @@ var __vue2_script$4 = defineComponent({
|
|
|
2425
2438
|
refetch,
|
|
2426
2439
|
dataSource,
|
|
2427
2440
|
pagination,
|
|
2441
|
+
variables,
|
|
2428
2442
|
changePagination,
|
|
2429
2443
|
addTask,
|
|
2430
2444
|
editTask,
|
|
@@ -2439,7 +2453,8 @@ var __vue2_script$4 = defineComponent({
|
|
|
2439
2453
|
changePagination,
|
|
2440
2454
|
addTask,
|
|
2441
2455
|
editTask,
|
|
2442
|
-
removeTask
|
|
2456
|
+
removeTask,
|
|
2457
|
+
variables
|
|
2443
2458
|
};
|
|
2444
2459
|
}
|
|
2445
2460
|
});
|
|
@@ -2454,7 +2469,7 @@ var render$4 = function() {
|
|
|
2454
2469
|
var staticRenderFns$4 = [];
|
|
2455
2470
|
var TaskTable_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
2456
2471
|
const __cssModules$4 = {};
|
|
2457
|
-
var __component__$4 = /* @__PURE__ */ normalizeComponent(__vue2_script$4, render$4, staticRenderFns$4, false, __vue2_injectStyles$4, "
|
|
2472
|
+
var __component__$4 = /* @__PURE__ */ normalizeComponent(__vue2_script$4, render$4, staticRenderFns$4, false, __vue2_injectStyles$4, "36a91f4e", null, null);
|
|
2458
2473
|
function __vue2_injectStyles$4(context) {
|
|
2459
2474
|
for (let o in __cssModules$4) {
|
|
2460
2475
|
this[o] = __cssModules$4[o];
|
|
@@ -2477,27 +2492,38 @@ var __vue2_script$3 = defineComponent({
|
|
|
2477
2492
|
default: false
|
|
2478
2493
|
},
|
|
2479
2494
|
addedTasks: {
|
|
2480
|
-
type: Array
|
|
2481
|
-
required: true
|
|
2495
|
+
type: Array
|
|
2482
2496
|
},
|
|
2483
2497
|
lawFirmId: {
|
|
2484
2498
|
type: Number,
|
|
2485
2499
|
required: true
|
|
2486
2500
|
},
|
|
2487
2501
|
taskSettingPageUrl: {
|
|
2488
|
-
type: String
|
|
2489
|
-
required: true
|
|
2502
|
+
type: String
|
|
2490
2503
|
},
|
|
2491
2504
|
showPage: {
|
|
2492
2505
|
type: Boolean,
|
|
2493
2506
|
default: false
|
|
2507
|
+
},
|
|
2508
|
+
pageSize: {
|
|
2509
|
+
type: Number
|
|
2510
|
+
},
|
|
2511
|
+
openReviewButtonText: {
|
|
2512
|
+
type: String,
|
|
2513
|
+
default: "Review and add to template"
|
|
2494
2514
|
}
|
|
2495
2515
|
},
|
|
2496
|
-
setup(props) {
|
|
2497
|
-
const taskTable = ref$1(
|
|
2516
|
+
setup(props, { emit }) {
|
|
2517
|
+
const taskTable = ref$1();
|
|
2498
2518
|
const conditions = useSearchTaskConditions();
|
|
2499
2519
|
const currentComponent = shallowRef(props.showPage ? Card : Modal);
|
|
2520
|
+
const editAction = (record) => {
|
|
2521
|
+
emit("edit", record);
|
|
2522
|
+
};
|
|
2523
|
+
const getVariables = () => taskTable.value.variables;
|
|
2500
2524
|
return {
|
|
2525
|
+
editAction,
|
|
2526
|
+
getVariables,
|
|
2501
2527
|
taskTable,
|
|
2502
2528
|
conditions,
|
|
2503
2529
|
AssigneeTypes,
|
|
@@ -2516,12 +2542,12 @@ var render$3 = function() {
|
|
|
2516
2542
|
return _vm.$emit("update:visible", false);
|
|
2517
2543
|
} } }, [_vm._v("Cancel ")]), _c("ant-badge", { attrs: { "count": _vm.addedTasks.length } }, [_c("ant-button", { attrs: { "disabled": _vm.addedTasks.length === 0, "type": "primary" }, on: { "click": function($event) {
|
|
2518
2544
|
return _vm.$emit("update:reviewModalVisible", true);
|
|
2519
|
-
} } }, [_vm._v(" " + _vm._s(_vm
|
|
2545
|
+
} } }, [_vm._v(" " + _vm._s(_vm.openReviewButtonText) + " ")])], 1)];
|
|
2520
2546
|
}, proxy: true }]) }, [_c("task-template-filter", { attrs: { "show-task-home-page-link": true, "task-setting-page-url": _vm.taskSettingPageUrl, "conditions": _vm.conditions, "inline": !!_vm.showPage }, on: { "update:conditions": function($event) {
|
|
2521
2547
|
_vm.conditions = $event;
|
|
2522
2548
|
}, "update:newTaskVisible": function($event) {
|
|
2523
2549
|
return _vm.$emit("update:newTaskVisible", true);
|
|
2524
|
-
} } }), _c("task-table", { ref: "taskTable", attrs: { "conditions": _vm.conditions, "added-tasks": _vm.addedTasks, "law-firm-id": _vm.lawFirmId }, on: { "update:addedTasks": function($event) {
|
|
2550
|
+
} } }), _c("task-table", { ref: "taskTable", attrs: { "conditions": _vm.conditions, "added-tasks": _vm.addedTasks, "law-firm-id": _vm.lawFirmId, "page-size": _vm.pageSize }, on: { "update:addedTasks": function($event) {
|
|
2525
2551
|
return _vm.$emit("update:addedTasks", $event);
|
|
2526
2552
|
}, "update:tempTask": function($event) {
|
|
2527
2553
|
return _vm.$emit("update:tempTask", $event);
|
|
@@ -2532,13 +2558,13 @@ var render$3 = function() {
|
|
|
2532
2558
|
var dataSource = ref2.dataSource;
|
|
2533
2559
|
var pagination = ref2.pagination;
|
|
2534
2560
|
var changePagination = ref2.changePagination;
|
|
2535
|
-
return [_vm._t("default", null, { "loading": loading, "dataSource": dataSource, "pagination": pagination, "changePagination": changePagination })];
|
|
2561
|
+
return [_vm._t("default", null, { "editAction": _vm.editAction, "loading": loading, "dataSource": dataSource, "pagination": pagination, "changePagination": changePagination })];
|
|
2536
2562
|
} }], null, true) })], 1);
|
|
2537
2563
|
};
|
|
2538
2564
|
var staticRenderFns$3 = [];
|
|
2539
2565
|
var MainModal_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
2540
2566
|
const __cssModules$3 = {};
|
|
2541
|
-
var __component__$3 = /* @__PURE__ */ normalizeComponent(__vue2_script$3, render$3, staticRenderFns$3, false, __vue2_injectStyles$3, "
|
|
2567
|
+
var __component__$3 = /* @__PURE__ */ normalizeComponent(__vue2_script$3, render$3, staticRenderFns$3, false, __vue2_injectStyles$3, "08dd7b2c", null, null);
|
|
2542
2568
|
function __vue2_injectStyles$3(context) {
|
|
2543
2569
|
for (let o in __cssModules$3) {
|
|
2544
2570
|
this[o] = __cssModules$3[o];
|
|
@@ -2641,14 +2667,14 @@ var ReviewModal = /* @__PURE__ */ function() {
|
|
|
2641
2667
|
const useMutateTaskTemplate = () => useMutation(UpdateTaskTemplateMutation);
|
|
2642
2668
|
const useCreateTaskTemplate = () => useMutation(CreateTaskTemplateMutation);
|
|
2643
2669
|
const submit = async (record, updateTemplate, createTemplate) => {
|
|
2644
|
-
var
|
|
2670
|
+
var _a, _b, _c, _d;
|
|
2645
2671
|
let newRecord = {};
|
|
2646
2672
|
let res;
|
|
2647
2673
|
let success;
|
|
2648
2674
|
const isUpdate = !!record.taskTemplateId;
|
|
2649
2675
|
if (isUpdate) {
|
|
2650
2676
|
res = await updateTemplate.mutate(record);
|
|
2651
|
-
newRecord = ((
|
|
2677
|
+
newRecord = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.updateTaskTemplate.updatedTaskTemplate) || {};
|
|
2652
2678
|
success = ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.updateTaskTemplate.code) === ResponseCode.success;
|
|
2653
2679
|
} else {
|
|
2654
2680
|
res = await createTemplate.mutate(record);
|
|
@@ -2708,3736 +2734,159 @@ const CreateTaskTemplateMutation = gql`
|
|
|
2708
2734
|
}
|
|
2709
2735
|
${taskTemplateFragment}
|
|
2710
2736
|
`;
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
purpose with or without fee is hereby granted.
|
|
2716
|
-
|
|
2717
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2718
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2719
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2720
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2721
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2722
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2723
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
2724
|
-
***************************************************************************** */
|
|
2725
|
-
var extendStatics = function(d, b) {
|
|
2726
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
2727
|
-
d2.__proto__ = b2;
|
|
2728
|
-
} || function(d2, b2) {
|
|
2729
|
-
for (var p in b2)
|
|
2730
|
-
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|
2731
|
-
d2[p] = b2[p];
|
|
2732
|
-
};
|
|
2733
|
-
return extendStatics(d, b);
|
|
2734
|
-
};
|
|
2735
|
-
function __extends(d, b) {
|
|
2736
|
-
if (typeof b !== "function" && b !== null)
|
|
2737
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
2738
|
-
extendStatics(d, b);
|
|
2739
|
-
function __2() {
|
|
2740
|
-
this.constructor = d;
|
|
2741
|
-
}
|
|
2742
|
-
d.prototype = b === null ? Object.create(b) : (__2.prototype = b.prototype, new __2());
|
|
2743
|
-
}
|
|
2744
|
-
var __assign = function() {
|
|
2745
|
-
__assign = Object.assign || function __assign2(t) {
|
|
2746
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2747
|
-
s = arguments[i];
|
|
2748
|
-
for (var p in s)
|
|
2749
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
2750
|
-
t[p] = s[p];
|
|
2751
|
-
}
|
|
2752
|
-
return t;
|
|
2753
|
-
};
|
|
2754
|
-
return __assign.apply(this, arguments);
|
|
2737
|
+
const defaultTaskTemplate = {
|
|
2738
|
+
taskTemplateObj: {},
|
|
2739
|
+
isAddedToTask: false,
|
|
2740
|
+
isNotified: false
|
|
2755
2741
|
};
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2742
|
+
var __vue2_script$1 = defineComponent({
|
|
2743
|
+
name: "index",
|
|
2744
|
+
components: {
|
|
2745
|
+
NewTask,
|
|
2746
|
+
MainModal,
|
|
2747
|
+
ReviewModal
|
|
2748
|
+
},
|
|
2749
|
+
props: {
|
|
2750
|
+
uploadFilesFunc: {
|
|
2751
|
+
type: Function,
|
|
2752
|
+
required: true
|
|
2753
|
+
},
|
|
2754
|
+
visible: {
|
|
2755
|
+
type: Boolean,
|
|
2756
|
+
default: false
|
|
2757
|
+
},
|
|
2758
|
+
userId: {
|
|
2759
|
+
type: String,
|
|
2760
|
+
required: true
|
|
2761
|
+
},
|
|
2762
|
+
lawFirmId: {
|
|
2763
|
+
type: Number,
|
|
2764
|
+
required: true
|
|
2765
|
+
},
|
|
2766
|
+
value: {
|
|
2767
|
+
type: Array,
|
|
2768
|
+
default: () => []
|
|
2769
|
+
},
|
|
2770
|
+
reviewText: {
|
|
2771
|
+
type: String,
|
|
2772
|
+
default: "Add"
|
|
2773
|
+
},
|
|
2774
|
+
openReviewButtonText: {
|
|
2775
|
+
type: String,
|
|
2776
|
+
default: "Review and add to template"
|
|
2777
|
+
},
|
|
2778
|
+
showSendEmail: {
|
|
2779
|
+
type: Boolean,
|
|
2780
|
+
default: false
|
|
2781
|
+
},
|
|
2782
|
+
sendEmail: {
|
|
2783
|
+
type: Boolean,
|
|
2784
|
+
default: false
|
|
2785
|
+
},
|
|
2786
|
+
taskSettingPageUrl: {
|
|
2787
|
+
type: String
|
|
2788
|
+
},
|
|
2789
|
+
allowClear: {
|
|
2790
|
+
type: Boolean,
|
|
2791
|
+
default: false
|
|
2792
|
+
},
|
|
2793
|
+
pageMode: {
|
|
2794
|
+
type: Boolean,
|
|
2795
|
+
default: false
|
|
2796
|
+
},
|
|
2797
|
+
pageSize: {
|
|
2798
|
+
type: Number
|
|
2765
2799
|
}
|
|
2766
|
-
|
|
2767
|
-
}
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2800
|
+
},
|
|
2801
|
+
setup(props, { emit }) {
|
|
2802
|
+
const { client } = useApolloClient();
|
|
2803
|
+
const mainModal = ref$1();
|
|
2804
|
+
const reviewModal = ref$1();
|
|
2805
|
+
const newTaskVisible = ref$1(false);
|
|
2806
|
+
const reviewModalVisible = ref$1(false);
|
|
2807
|
+
const tempTask = ref$1(defaultTaskTemplate);
|
|
2808
|
+
const updateTemplate = useMutateTaskTemplate();
|
|
2809
|
+
const createTemplate = useCreateTaskTemplate();
|
|
2810
|
+
const addedTasks = ref$1([]);
|
|
2811
|
+
watch(() => newTaskVisible.value, (visible) => {
|
|
2812
|
+
if (!visible) {
|
|
2813
|
+
tempTask.value = defaultTaskTemplate;
|
|
2775
2814
|
}
|
|
2776
|
-
}
|
|
2777
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2778
|
-
}
|
|
2779
|
-
var genericMessage = "Invariant Violation";
|
|
2780
|
-
var _a$3 = Object.setPrototypeOf, setPrototypeOf = _a$3 === void 0 ? function(obj, proto) {
|
|
2781
|
-
obj.__proto__ = proto;
|
|
2782
|
-
return obj;
|
|
2783
|
-
} : _a$3;
|
|
2784
|
-
var InvariantError = function(_super) {
|
|
2785
|
-
__extends(InvariantError2, _super);
|
|
2786
|
-
function InvariantError2(message2) {
|
|
2787
|
-
if (message2 === void 0) {
|
|
2788
|
-
message2 = genericMessage;
|
|
2789
|
-
}
|
|
2790
|
-
var _this = _super.call(this, typeof message2 === "number" ? genericMessage + ": " + message2 + " (see https://github.com/apollographql/invariant-packages)" : message2) || this;
|
|
2791
|
-
_this.framesToPop = 1;
|
|
2792
|
-
_this.name = genericMessage;
|
|
2793
|
-
setPrototypeOf(_this, InvariantError2.prototype);
|
|
2794
|
-
return _this;
|
|
2795
|
-
}
|
|
2796
|
-
return InvariantError2;
|
|
2797
|
-
}(Error);
|
|
2798
|
-
function invariant(condition, message2) {
|
|
2799
|
-
if (!condition) {
|
|
2800
|
-
throw new InvariantError(message2);
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
var verbosityLevels = ["debug", "log", "warn", "error", "silent"];
|
|
2804
|
-
var verbosityLevel = verbosityLevels.indexOf("log");
|
|
2805
|
-
function wrapConsoleMethod(name) {
|
|
2806
|
-
return function() {
|
|
2807
|
-
if (verbosityLevels.indexOf(name) >= verbosityLevel) {
|
|
2808
|
-
var method = console[name] || console.log;
|
|
2809
|
-
return method.apply(console, arguments);
|
|
2810
|
-
}
|
|
2811
|
-
};
|
|
2812
|
-
}
|
|
2813
|
-
(function(invariant2) {
|
|
2814
|
-
invariant2.debug = wrapConsoleMethod("debug");
|
|
2815
|
-
invariant2.log = wrapConsoleMethod("log");
|
|
2816
|
-
invariant2.warn = wrapConsoleMethod("warn");
|
|
2817
|
-
invariant2.error = wrapConsoleMethod("error");
|
|
2818
|
-
})(invariant || (invariant = {}));
|
|
2819
|
-
function maybe$1(thunk) {
|
|
2820
|
-
try {
|
|
2821
|
-
return thunk();
|
|
2822
|
-
} catch (_a2) {
|
|
2823
|
-
}
|
|
2824
|
-
}
|
|
2825
|
-
var global$1 = maybe$1(function() {
|
|
2826
|
-
return globalThis;
|
|
2827
|
-
}) || maybe$1(function() {
|
|
2828
|
-
return window;
|
|
2829
|
-
}) || maybe$1(function() {
|
|
2830
|
-
return self;
|
|
2831
|
-
}) || maybe$1(function() {
|
|
2832
|
-
return global;
|
|
2833
|
-
}) || maybe$1(function() {
|
|
2834
|
-
return maybe$1.constructor("return this")();
|
|
2835
|
-
});
|
|
2836
|
-
var __ = "__";
|
|
2837
|
-
var GLOBAL_KEY = [__, __].join("DEV");
|
|
2838
|
-
function getDEV() {
|
|
2839
|
-
try {
|
|
2840
|
-
return Boolean(__DEV__);
|
|
2841
|
-
} catch (_a2) {
|
|
2842
|
-
Object.defineProperty(global$1, GLOBAL_KEY, {
|
|
2843
|
-
value: maybe$1(function() {
|
|
2844
|
-
return "production";
|
|
2845
|
-
}) !== "production",
|
|
2846
|
-
enumerable: false,
|
|
2847
|
-
configurable: true,
|
|
2848
|
-
writable: true
|
|
2849
|
-
});
|
|
2850
|
-
return global$1[GLOBAL_KEY];
|
|
2851
|
-
}
|
|
2852
|
-
}
|
|
2853
|
-
var DEV = getDEV();
|
|
2854
|
-
function maybe(thunk) {
|
|
2855
|
-
try {
|
|
2856
|
-
return thunk();
|
|
2857
|
-
} catch (_) {
|
|
2858
|
-
}
|
|
2859
|
-
}
|
|
2860
|
-
var safeGlobal = maybe(function() {
|
|
2861
|
-
return globalThis;
|
|
2862
|
-
}) || maybe(function() {
|
|
2863
|
-
return window;
|
|
2864
|
-
}) || maybe(function() {
|
|
2865
|
-
return self;
|
|
2866
|
-
}) || maybe(function() {
|
|
2867
|
-
return global;
|
|
2868
|
-
}) || maybe(function() {
|
|
2869
|
-
return maybe.constructor("return this")();
|
|
2870
|
-
});
|
|
2871
|
-
var needToRemove = false;
|
|
2872
|
-
function install() {
|
|
2873
|
-
if (safeGlobal && !maybe(function() {
|
|
2874
|
-
return "production";
|
|
2875
|
-
}) && !maybe(function() {
|
|
2876
|
-
return process;
|
|
2877
|
-
})) {
|
|
2878
|
-
Object.defineProperty(safeGlobal, "process", {
|
|
2879
|
-
value: {
|
|
2880
|
-
env: {
|
|
2881
|
-
NODE_ENV: "production"
|
|
2882
|
-
}
|
|
2883
|
-
},
|
|
2884
|
-
configurable: true,
|
|
2885
|
-
enumerable: false,
|
|
2886
|
-
writable: true
|
|
2887
|
-
});
|
|
2888
|
-
needToRemove = true;
|
|
2889
|
-
}
|
|
2890
|
-
}
|
|
2891
|
-
install();
|
|
2892
|
-
function remove() {
|
|
2893
|
-
if (needToRemove) {
|
|
2894
|
-
delete safeGlobal.process;
|
|
2895
|
-
needToRemove = false;
|
|
2896
|
-
}
|
|
2897
|
-
}
|
|
2898
|
-
function removeTemporaryGlobals() {
|
|
2899
|
-
return typeof Source === "function" ? remove() : remove();
|
|
2900
|
-
}
|
|
2901
|
-
function checkDEV() {
|
|
2902
|
-
__DEV__ ? invariant(typeof DEV === "boolean", DEV) : invariant(typeof DEV === "boolean", 36);
|
|
2903
|
-
}
|
|
2904
|
-
removeTemporaryGlobals();
|
|
2905
|
-
checkDEV();
|
|
2906
|
-
function shouldInclude(_a2, variables) {
|
|
2907
|
-
var directives = _a2.directives;
|
|
2908
|
-
if (!directives || !directives.length) {
|
|
2909
|
-
return true;
|
|
2910
|
-
}
|
|
2911
|
-
return getInclusionDirectives(directives).every(function(_a3) {
|
|
2912
|
-
var directive = _a3.directive, ifArgument = _a3.ifArgument;
|
|
2913
|
-
var evaledValue = false;
|
|
2914
|
-
if (ifArgument.value.kind === "Variable") {
|
|
2915
|
-
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
2916
|
-
__DEV__ ? invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : invariant(evaledValue !== void 0, 37);
|
|
2917
|
-
} else {
|
|
2918
|
-
evaledValue = ifArgument.value.value;
|
|
2919
|
-
}
|
|
2920
|
-
return directive.name.value === "skip" ? !evaledValue : evaledValue;
|
|
2921
|
-
});
|
|
2922
|
-
}
|
|
2923
|
-
function isInclusionDirective(_a2) {
|
|
2924
|
-
var value = _a2.name.value;
|
|
2925
|
-
return value === "skip" || value === "include";
|
|
2926
|
-
}
|
|
2927
|
-
function getInclusionDirectives(directives) {
|
|
2928
|
-
var result = [];
|
|
2929
|
-
if (directives && directives.length) {
|
|
2930
|
-
directives.forEach(function(directive) {
|
|
2931
|
-
if (!isInclusionDirective(directive))
|
|
2932
|
-
return;
|
|
2933
|
-
var directiveArguments = directive.arguments;
|
|
2934
|
-
var directiveName = directive.name.value;
|
|
2935
|
-
__DEV__ ? invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : invariant(directiveArguments && directiveArguments.length === 1, 38);
|
|
2936
|
-
var ifArgument = directiveArguments[0];
|
|
2937
|
-
__DEV__ ? invariant(ifArgument.name && ifArgument.name.value === "if", "Invalid argument for the @".concat(directiveName, " directive.")) : invariant(ifArgument.name && ifArgument.name.value === "if", 39);
|
|
2938
|
-
var ifValue = ifArgument.value;
|
|
2939
|
-
__DEV__ ? invariant(ifValue && (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : invariant(ifValue && (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 40);
|
|
2940
|
-
result.push({ directive, ifArgument });
|
|
2941
2815
|
});
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
var fragments = [];
|
|
2948
|
-
document.definitions.forEach(function(definition) {
|
|
2949
|
-
if (definition.kind === "OperationDefinition") {
|
|
2950
|
-
throw __DEV__ ? new InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : "", ". ") + "No operations are allowed when using a fragment as a query. Only fragments are allowed.") : new InvariantError(41);
|
|
2951
|
-
}
|
|
2952
|
-
if (definition.kind === "FragmentDefinition") {
|
|
2953
|
-
fragments.push(definition);
|
|
2954
|
-
}
|
|
2955
|
-
});
|
|
2956
|
-
if (typeof actualFragmentName === "undefined") {
|
|
2957
|
-
__DEV__ ? invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : invariant(fragments.length === 1, 42);
|
|
2958
|
-
actualFragmentName = fragments[0].name.value;
|
|
2959
|
-
}
|
|
2960
|
-
var query = __assign(__assign({}, document), { definitions: __spreadArray([
|
|
2961
|
-
{
|
|
2962
|
-
kind: "OperationDefinition",
|
|
2963
|
-
operation: "query",
|
|
2964
|
-
selectionSet: {
|
|
2965
|
-
kind: "SelectionSet",
|
|
2966
|
-
selections: [
|
|
2967
|
-
{
|
|
2968
|
-
kind: "FragmentSpread",
|
|
2969
|
-
name: {
|
|
2970
|
-
kind: "Name",
|
|
2971
|
-
value: actualFragmentName
|
|
2972
|
-
}
|
|
2816
|
+
const updateReviewModalContent = (record, newRecord) => {
|
|
2817
|
+
if (reviewModalVisible.value) {
|
|
2818
|
+
const newValue = addedTasks.value.map((originTask) => {
|
|
2819
|
+
if (originTask.id === record.taskTemplateId) {
|
|
2820
|
+
return newRecord;
|
|
2973
2821
|
}
|
|
2974
|
-
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2977
|
-
], document.definitions, true) });
|
|
2978
|
-
return query;
|
|
2979
|
-
}
|
|
2980
|
-
function createFragmentMap(fragments) {
|
|
2981
|
-
if (fragments === void 0) {
|
|
2982
|
-
fragments = [];
|
|
2983
|
-
}
|
|
2984
|
-
var symTable = {};
|
|
2985
|
-
fragments.forEach(function(fragment) {
|
|
2986
|
-
symTable[fragment.name.value] = fragment;
|
|
2987
|
-
});
|
|
2988
|
-
return symTable;
|
|
2989
|
-
}
|
|
2990
|
-
function getFragmentFromSelection(selection, fragmentMap) {
|
|
2991
|
-
switch (selection.kind) {
|
|
2992
|
-
case "InlineFragment":
|
|
2993
|
-
return selection;
|
|
2994
|
-
case "FragmentSpread": {
|
|
2995
|
-
var fragment = fragmentMap && fragmentMap[selection.name.value];
|
|
2996
|
-
__DEV__ ? invariant(fragment, "No fragment named ".concat(selection.name.value, ".")) : invariant(fragment, 43);
|
|
2997
|
-
return fragment;
|
|
2998
|
-
}
|
|
2999
|
-
default:
|
|
3000
|
-
return null;
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
function isNonNullObject(obj) {
|
|
3004
|
-
return obj !== null && typeof obj === "object";
|
|
3005
|
-
}
|
|
3006
|
-
function makeReference(id) {
|
|
3007
|
-
return { __ref: String(id) };
|
|
3008
|
-
}
|
|
3009
|
-
function isReference(obj) {
|
|
3010
|
-
return Boolean(obj && typeof obj === "object" && typeof obj.__ref === "string");
|
|
3011
|
-
}
|
|
3012
|
-
function isStringValue(value) {
|
|
3013
|
-
return value.kind === "StringValue";
|
|
3014
|
-
}
|
|
3015
|
-
function isBooleanValue(value) {
|
|
3016
|
-
return value.kind === "BooleanValue";
|
|
3017
|
-
}
|
|
3018
|
-
function isIntValue(value) {
|
|
3019
|
-
return value.kind === "IntValue";
|
|
3020
|
-
}
|
|
3021
|
-
function isFloatValue(value) {
|
|
3022
|
-
return value.kind === "FloatValue";
|
|
3023
|
-
}
|
|
3024
|
-
function isVariable(value) {
|
|
3025
|
-
return value.kind === "Variable";
|
|
3026
|
-
}
|
|
3027
|
-
function isObjectValue(value) {
|
|
3028
|
-
return value.kind === "ObjectValue";
|
|
3029
|
-
}
|
|
3030
|
-
function isListValue(value) {
|
|
3031
|
-
return value.kind === "ListValue";
|
|
3032
|
-
}
|
|
3033
|
-
function isEnumValue(value) {
|
|
3034
|
-
return value.kind === "EnumValue";
|
|
3035
|
-
}
|
|
3036
|
-
function isNullValue(value) {
|
|
3037
|
-
return value.kind === "NullValue";
|
|
3038
|
-
}
|
|
3039
|
-
function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
3040
|
-
if (isIntValue(value) || isFloatValue(value)) {
|
|
3041
|
-
argObj[name.value] = Number(value.value);
|
|
3042
|
-
} else if (isBooleanValue(value) || isStringValue(value)) {
|
|
3043
|
-
argObj[name.value] = value.value;
|
|
3044
|
-
} else if (isObjectValue(value)) {
|
|
3045
|
-
var nestedArgObj_1 = {};
|
|
3046
|
-
value.fields.map(function(obj) {
|
|
3047
|
-
return valueToObjectRepresentation(nestedArgObj_1, obj.name, obj.value, variables);
|
|
3048
|
-
});
|
|
3049
|
-
argObj[name.value] = nestedArgObj_1;
|
|
3050
|
-
} else if (isVariable(value)) {
|
|
3051
|
-
var variableValue = (variables || {})[value.name.value];
|
|
3052
|
-
argObj[name.value] = variableValue;
|
|
3053
|
-
} else if (isListValue(value)) {
|
|
3054
|
-
argObj[name.value] = value.values.map(function(listValue) {
|
|
3055
|
-
var nestedArgArrayObj = {};
|
|
3056
|
-
valueToObjectRepresentation(nestedArgArrayObj, name, listValue, variables);
|
|
3057
|
-
return nestedArgArrayObj[name.value];
|
|
3058
|
-
});
|
|
3059
|
-
} else if (isEnumValue(value)) {
|
|
3060
|
-
argObj[name.value] = value.value;
|
|
3061
|
-
} else if (isNullValue(value)) {
|
|
3062
|
-
argObj[name.value] = null;
|
|
3063
|
-
} else {
|
|
3064
|
-
throw __DEV__ ? new InvariantError('The inline argument "'.concat(name.value, '" of kind "').concat(value.kind, '"') + "is not supported. Use variables instead of inline arguments to overcome this limitation.") : new InvariantError(52);
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
|
-
function storeKeyNameFromField(field, variables) {
|
|
3068
|
-
var directivesObj = null;
|
|
3069
|
-
if (field.directives) {
|
|
3070
|
-
directivesObj = {};
|
|
3071
|
-
field.directives.forEach(function(directive) {
|
|
3072
|
-
directivesObj[directive.name.value] = {};
|
|
3073
|
-
if (directive.arguments) {
|
|
3074
|
-
directive.arguments.forEach(function(_a2) {
|
|
3075
|
-
var name = _a2.name, value = _a2.value;
|
|
3076
|
-
return valueToObjectRepresentation(directivesObj[directive.name.value], name, value, variables);
|
|
2822
|
+
return originTask;
|
|
3077
2823
|
});
|
|
2824
|
+
emit("update:value", newValue.map(({ id }) => id));
|
|
3078
2825
|
}
|
|
3079
|
-
}
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
var name = _a2.name, value = _a2.value;
|
|
3086
|
-
return valueToObjectRepresentation(argObj, name, value, variables);
|
|
3087
|
-
});
|
|
3088
|
-
}
|
|
3089
|
-
return getStoreKeyName(field.name.value, argObj, directivesObj);
|
|
3090
|
-
}
|
|
3091
|
-
var KNOWN_DIRECTIVES = [
|
|
3092
|
-
"connection",
|
|
3093
|
-
"include",
|
|
3094
|
-
"skip",
|
|
3095
|
-
"client",
|
|
3096
|
-
"rest",
|
|
3097
|
-
"export"
|
|
3098
|
-
];
|
|
3099
|
-
var getStoreKeyName = Object.assign(function(fieldName, args, directives) {
|
|
3100
|
-
if (args && directives && directives["connection"] && directives["connection"]["key"]) {
|
|
3101
|
-
if (directives["connection"]["filter"] && directives["connection"]["filter"].length > 0) {
|
|
3102
|
-
var filterKeys = directives["connection"]["filter"] ? directives["connection"]["filter"] : [];
|
|
3103
|
-
filterKeys.sort();
|
|
3104
|
-
var filteredArgs_1 = {};
|
|
3105
|
-
filterKeys.forEach(function(key) {
|
|
3106
|
-
filteredArgs_1[key] = args[key];
|
|
2826
|
+
};
|
|
2827
|
+
const _submit = async (record) => {
|
|
2828
|
+
const variables = mainModal.value.getVariables();
|
|
2829
|
+
const existed = client.readQuery({
|
|
2830
|
+
query: SearchTaskTemplatesQuery,
|
|
2831
|
+
variables
|
|
3107
2832
|
});
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
2833
|
+
const {
|
|
2834
|
+
newRecord,
|
|
2835
|
+
success
|
|
2836
|
+
} = await submit(record, updateTemplate, createTemplate);
|
|
2837
|
+
if (success) {
|
|
2838
|
+
client.writeQuery({
|
|
2839
|
+
query: SearchTaskTemplatesQuery,
|
|
2840
|
+
data: {
|
|
2841
|
+
taskTemplateSearch: __spreadProps(__spreadValues({}, existed.taskTemplateSearch), {
|
|
2842
|
+
taskTemplateList: existed.taskTemplateSearch.taskTemplateList.map((record2) => {
|
|
2843
|
+
if (record2.id === newRecord.id) {
|
|
2844
|
+
return __spreadProps(__spreadValues({}, newRecord), {
|
|
2845
|
+
isGallery: record2.isGallery
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
return record2;
|
|
2849
|
+
})
|
|
2850
|
+
})
|
|
2851
|
+
},
|
|
2852
|
+
variables
|
|
2853
|
+
});
|
|
2854
|
+
newTaskVisible.value = false;
|
|
2855
|
+
updateReviewModalContent(record, newRecord);
|
|
3126
2856
|
}
|
|
3127
|
-
}
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
}
|
|
3146
|
-
}
|
|
3147
|
-
return value;
|
|
3148
|
-
}
|
|
3149
|
-
function argumentsObjectFromField(field, variables) {
|
|
3150
|
-
if (field.arguments && field.arguments.length) {
|
|
3151
|
-
var argObj_1 = {};
|
|
3152
|
-
field.arguments.forEach(function(_a2) {
|
|
3153
|
-
var name = _a2.name, value = _a2.value;
|
|
3154
|
-
return valueToObjectRepresentation(argObj_1, name, value, variables);
|
|
3155
|
-
});
|
|
3156
|
-
return argObj_1;
|
|
3157
|
-
}
|
|
3158
|
-
return null;
|
|
3159
|
-
}
|
|
3160
|
-
function resultKeyNameFromField(field) {
|
|
3161
|
-
return field.alias ? field.alias.value : field.name.value;
|
|
3162
|
-
}
|
|
3163
|
-
function getTypenameFromResult(result, selectionSet, fragmentMap) {
|
|
3164
|
-
if (typeof result.__typename === "string") {
|
|
3165
|
-
return result.__typename;
|
|
3166
|
-
}
|
|
3167
|
-
for (var _i = 0, _a2 = selectionSet.selections; _i < _a2.length; _i++) {
|
|
3168
|
-
var selection = _a2[_i];
|
|
3169
|
-
if (isField(selection)) {
|
|
3170
|
-
if (selection.name.value === "__typename") {
|
|
3171
|
-
return result[resultKeyNameFromField(selection)];
|
|
3172
|
-
}
|
|
3173
|
-
} else {
|
|
3174
|
-
var typename = getTypenameFromResult(result, getFragmentFromSelection(selection, fragmentMap).selectionSet, fragmentMap);
|
|
3175
|
-
if (typeof typename === "string") {
|
|
3176
|
-
return typename;
|
|
3177
|
-
}
|
|
3178
|
-
}
|
|
3179
|
-
}
|
|
3180
|
-
}
|
|
3181
|
-
function isField(selection) {
|
|
3182
|
-
return selection.kind === "Field";
|
|
3183
|
-
}
|
|
3184
|
-
function checkDocument(doc) {
|
|
3185
|
-
__DEV__ ? invariant(doc && doc.kind === "Document", 'Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql') : invariant(doc && doc.kind === "Document", 44);
|
|
3186
|
-
var operations = doc.definitions.filter(function(d) {
|
|
3187
|
-
return d.kind !== "FragmentDefinition";
|
|
3188
|
-
}).map(function(definition) {
|
|
3189
|
-
if (definition.kind !== "OperationDefinition") {
|
|
3190
|
-
throw __DEV__ ? new InvariantError('Schema type definitions not allowed in queries. Found: "'.concat(definition.kind, '"')) : new InvariantError(45);
|
|
3191
|
-
}
|
|
3192
|
-
return definition;
|
|
3193
|
-
});
|
|
3194
|
-
__DEV__ ? invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : invariant(operations.length <= 1, 46);
|
|
3195
|
-
return doc;
|
|
3196
|
-
}
|
|
3197
|
-
function getOperationDefinition(doc) {
|
|
3198
|
-
checkDocument(doc);
|
|
3199
|
-
return doc.definitions.filter(function(definition) {
|
|
3200
|
-
return definition.kind === "OperationDefinition";
|
|
3201
|
-
})[0];
|
|
3202
|
-
}
|
|
3203
|
-
function getFragmentDefinitions(doc) {
|
|
3204
|
-
return doc.definitions.filter(function(definition) {
|
|
3205
|
-
return definition.kind === "FragmentDefinition";
|
|
3206
|
-
});
|
|
3207
|
-
}
|
|
3208
|
-
function getQueryDefinition(doc) {
|
|
3209
|
-
var queryDef = getOperationDefinition(doc);
|
|
3210
|
-
__DEV__ ? invariant(queryDef && queryDef.operation === "query", "Must contain a query definition.") : invariant(queryDef && queryDef.operation === "query", 47);
|
|
3211
|
-
return queryDef;
|
|
3212
|
-
}
|
|
3213
|
-
function getMainDefinition(queryDoc) {
|
|
3214
|
-
checkDocument(queryDoc);
|
|
3215
|
-
var fragmentDefinition;
|
|
3216
|
-
for (var _i = 0, _a2 = queryDoc.definitions; _i < _a2.length; _i++) {
|
|
3217
|
-
var definition = _a2[_i];
|
|
3218
|
-
if (definition.kind === "OperationDefinition") {
|
|
3219
|
-
var operation = definition.operation;
|
|
3220
|
-
if (operation === "query" || operation === "mutation" || operation === "subscription") {
|
|
3221
|
-
return definition;
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
|
-
if (definition.kind === "FragmentDefinition" && !fragmentDefinition) {
|
|
3225
|
-
fragmentDefinition = definition;
|
|
3226
|
-
}
|
|
3227
|
-
}
|
|
3228
|
-
if (fragmentDefinition) {
|
|
3229
|
-
return fragmentDefinition;
|
|
3230
|
-
}
|
|
3231
|
-
throw __DEV__ ? new InvariantError("Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.") : new InvariantError(51);
|
|
3232
|
-
}
|
|
3233
|
-
function getDefaultValues(definition) {
|
|
3234
|
-
var defaultValues = Object.create(null);
|
|
3235
|
-
var defs = definition && definition.variableDefinitions;
|
|
3236
|
-
if (defs && defs.length) {
|
|
3237
|
-
defs.forEach(function(def2) {
|
|
3238
|
-
if (def2.defaultValue) {
|
|
3239
|
-
valueToObjectRepresentation(defaultValues, def2.variable.name, def2.defaultValue);
|
|
3240
|
-
}
|
|
3241
|
-
});
|
|
3242
|
-
}
|
|
3243
|
-
return defaultValues;
|
|
3244
|
-
}
|
|
3245
|
-
var TYPENAME_FIELD = {
|
|
3246
|
-
kind: "Field",
|
|
3247
|
-
name: {
|
|
3248
|
-
kind: "Name",
|
|
3249
|
-
value: "__typename"
|
|
3250
|
-
}
|
|
3251
|
-
};
|
|
3252
|
-
var addTypenameToDocument = Object.assign(function(doc) {
|
|
3253
|
-
return visit(checkDocument(doc), {
|
|
3254
|
-
SelectionSet: {
|
|
3255
|
-
enter: function(node, _key, parent) {
|
|
3256
|
-
if (parent && parent.kind === "OperationDefinition") {
|
|
3257
|
-
return;
|
|
3258
|
-
}
|
|
3259
|
-
var selections = node.selections;
|
|
3260
|
-
if (!selections) {
|
|
3261
|
-
return;
|
|
3262
|
-
}
|
|
3263
|
-
var skip = selections.some(function(selection) {
|
|
3264
|
-
return isField(selection) && (selection.name.value === "__typename" || selection.name.value.lastIndexOf("__", 0) === 0);
|
|
3265
|
-
});
|
|
3266
|
-
if (skip) {
|
|
3267
|
-
return;
|
|
3268
|
-
}
|
|
3269
|
-
var field = parent;
|
|
3270
|
-
if (isField(field) && field.directives && field.directives.some(function(d) {
|
|
3271
|
-
return d.name.value === "export";
|
|
3272
|
-
})) {
|
|
3273
|
-
return;
|
|
3274
|
-
}
|
|
3275
|
-
return __assign(__assign({}, node), { selections: __spreadArray(__spreadArray([], selections, true), [TYPENAME_FIELD], false) });
|
|
3276
|
-
}
|
|
3277
|
-
}
|
|
3278
|
-
});
|
|
3279
|
-
}, {
|
|
3280
|
-
added: function(field) {
|
|
3281
|
-
return field === TYPENAME_FIELD;
|
|
3282
|
-
}
|
|
3283
|
-
});
|
|
3284
|
-
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
3285
|
-
var defaultReconciler = function(target, source, property) {
|
|
3286
|
-
return this.merge(target[property], source[property]);
|
|
3287
|
-
};
|
|
3288
|
-
var DeepMerger = function() {
|
|
3289
|
-
function DeepMerger2(reconciler) {
|
|
3290
|
-
if (reconciler === void 0) {
|
|
3291
|
-
reconciler = defaultReconciler;
|
|
3292
|
-
}
|
|
3293
|
-
this.reconciler = reconciler;
|
|
3294
|
-
this.isObject = isNonNullObject;
|
|
3295
|
-
this.pastCopies = new Set();
|
|
3296
|
-
}
|
|
3297
|
-
DeepMerger2.prototype.merge = function(target, source) {
|
|
3298
|
-
var _this = this;
|
|
3299
|
-
var context = [];
|
|
3300
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
3301
|
-
context[_i - 2] = arguments[_i];
|
|
3302
|
-
}
|
|
3303
|
-
if (isNonNullObject(source) && isNonNullObject(target)) {
|
|
3304
|
-
Object.keys(source).forEach(function(sourceKey) {
|
|
3305
|
-
if (hasOwnProperty$2.call(target, sourceKey)) {
|
|
3306
|
-
var targetValue = target[sourceKey];
|
|
3307
|
-
if (source[sourceKey] !== targetValue) {
|
|
3308
|
-
var result = _this.reconciler.apply(_this, __spreadArray([target, source, sourceKey], context, false));
|
|
3309
|
-
if (result !== targetValue) {
|
|
3310
|
-
target = _this.shallowCopyForMerge(target);
|
|
3311
|
-
target[sourceKey] = result;
|
|
3312
|
-
}
|
|
3313
|
-
}
|
|
3314
|
-
} else {
|
|
3315
|
-
target = _this.shallowCopyForMerge(target);
|
|
3316
|
-
target[sourceKey] = source[sourceKey];
|
|
3317
|
-
}
|
|
3318
|
-
});
|
|
3319
|
-
return target;
|
|
3320
|
-
}
|
|
3321
|
-
return source;
|
|
3322
|
-
};
|
|
3323
|
-
DeepMerger2.prototype.shallowCopyForMerge = function(value) {
|
|
3324
|
-
if (isNonNullObject(value)) {
|
|
3325
|
-
if (this.pastCopies.has(value)) {
|
|
3326
|
-
if (!Object.isFrozen(value))
|
|
3327
|
-
return value;
|
|
3328
|
-
this.pastCopies.delete(value);
|
|
3329
|
-
}
|
|
3330
|
-
if (Array.isArray(value)) {
|
|
3331
|
-
value = value.slice(0);
|
|
3332
|
-
} else {
|
|
3333
|
-
value = __assign({ __proto__: Object.getPrototypeOf(value) }, value);
|
|
3334
|
-
}
|
|
3335
|
-
this.pastCopies.add(value);
|
|
3336
|
-
}
|
|
3337
|
-
return value;
|
|
3338
|
-
};
|
|
3339
|
-
return DeepMerger2;
|
|
3340
|
-
}();
|
|
3341
|
-
var toString$1 = Object.prototype.toString;
|
|
3342
|
-
function cloneDeep(value) {
|
|
3343
|
-
return cloneDeepHelper(value);
|
|
3344
|
-
}
|
|
3345
|
-
function cloneDeepHelper(val, seen) {
|
|
3346
|
-
switch (toString$1.call(val)) {
|
|
3347
|
-
case "[object Array]": {
|
|
3348
|
-
seen = seen || new Map();
|
|
3349
|
-
if (seen.has(val))
|
|
3350
|
-
return seen.get(val);
|
|
3351
|
-
var copy_1 = val.slice(0);
|
|
3352
|
-
seen.set(val, copy_1);
|
|
3353
|
-
copy_1.forEach(function(child, i) {
|
|
3354
|
-
copy_1[i] = cloneDeepHelper(child, seen);
|
|
3355
|
-
});
|
|
3356
|
-
return copy_1;
|
|
3357
|
-
}
|
|
3358
|
-
case "[object Object]": {
|
|
3359
|
-
seen = seen || new Map();
|
|
3360
|
-
if (seen.has(val))
|
|
3361
|
-
return seen.get(val);
|
|
3362
|
-
var copy_2 = Object.create(Object.getPrototypeOf(val));
|
|
3363
|
-
seen.set(val, copy_2);
|
|
3364
|
-
Object.keys(val).forEach(function(key) {
|
|
3365
|
-
copy_2[key] = cloneDeepHelper(val[key], seen);
|
|
3366
|
-
});
|
|
3367
|
-
return copy_2;
|
|
3368
|
-
}
|
|
3369
|
-
default:
|
|
3370
|
-
return val;
|
|
3371
|
-
}
|
|
3372
|
-
}
|
|
3373
|
-
function deepFreeze(value) {
|
|
3374
|
-
var workSet = new Set([value]);
|
|
3375
|
-
workSet.forEach(function(obj) {
|
|
3376
|
-
if (isNonNullObject(obj) && shallowFreeze(obj) === obj) {
|
|
3377
|
-
Object.getOwnPropertyNames(obj).forEach(function(name) {
|
|
3378
|
-
if (isNonNullObject(obj[name]))
|
|
3379
|
-
workSet.add(obj[name]);
|
|
3380
|
-
});
|
|
3381
|
-
}
|
|
3382
|
-
});
|
|
3383
|
-
return value;
|
|
3384
|
-
}
|
|
3385
|
-
function shallowFreeze(obj) {
|
|
3386
|
-
if (__DEV__ && !Object.isFrozen(obj)) {
|
|
3387
|
-
try {
|
|
3388
|
-
Object.freeze(obj);
|
|
3389
|
-
} catch (e) {
|
|
3390
|
-
if (e instanceof TypeError)
|
|
3391
|
-
return null;
|
|
3392
|
-
throw e;
|
|
3393
|
-
}
|
|
3394
|
-
}
|
|
3395
|
-
return obj;
|
|
3396
|
-
}
|
|
3397
|
-
function maybeDeepFreeze(obj) {
|
|
3398
|
-
if (__DEV__) {
|
|
3399
|
-
deepFreeze(obj);
|
|
3400
|
-
}
|
|
3401
|
-
return obj;
|
|
3402
|
-
}
|
|
3403
|
-
var canUseWeakMap = typeof WeakMap === "function" && !(typeof navigator === "object" && navigator.product === "ReactNative");
|
|
3404
|
-
var canUseWeakSet = typeof WeakSet === "function";
|
|
3405
|
-
function isNonEmptyArray(value) {
|
|
3406
|
-
return Array.isArray(value) && value.length > 0;
|
|
3407
|
-
}
|
|
3408
|
-
function compact() {
|
|
3409
|
-
var objects = [];
|
|
3410
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3411
|
-
objects[_i] = arguments[_i];
|
|
3412
|
-
}
|
|
3413
|
-
var result = Object.create(null);
|
|
3414
|
-
objects.forEach(function(obj) {
|
|
3415
|
-
if (!obj)
|
|
3416
|
-
return;
|
|
3417
|
-
Object.keys(obj).forEach(function(key) {
|
|
3418
|
-
var value = obj[key];
|
|
3419
|
-
if (value !== void 0) {
|
|
3420
|
-
result[key] = value;
|
|
3421
|
-
}
|
|
3422
|
-
});
|
|
3423
|
-
});
|
|
3424
|
-
return result;
|
|
3425
|
-
}
|
|
3426
|
-
var prefixCounts = new Map();
|
|
3427
|
-
function makeUniqueId(prefix) {
|
|
3428
|
-
var count = prefixCounts.get(prefix) || 1;
|
|
3429
|
-
prefixCounts.set(prefix, count + 1);
|
|
3430
|
-
return "".concat(prefix, ":").concat(count, ":").concat(Math.random().toString(36).slice(2));
|
|
3431
|
-
}
|
|
3432
|
-
function stringifyForDisplay(value) {
|
|
3433
|
-
var undefId = makeUniqueId("stringifyForDisplay");
|
|
3434
|
-
return JSON.stringify(value, function(key, value2) {
|
|
3435
|
-
return value2 === void 0 ? undefId : value2;
|
|
3436
|
-
}).split(JSON.stringify(undefId)).join("<undefined>");
|
|
3437
|
-
}
|
|
3438
|
-
var _a$2 = Object.prototype, toString = _a$2.toString, hasOwnProperty$1 = _a$2.hasOwnProperty;
|
|
3439
|
-
var fnToStr = Function.prototype.toString;
|
|
3440
|
-
var previousComparisons = new Map();
|
|
3441
|
-
function equal(a, b) {
|
|
3442
|
-
try {
|
|
3443
|
-
return check(a, b);
|
|
3444
|
-
} finally {
|
|
3445
|
-
previousComparisons.clear();
|
|
3446
|
-
}
|
|
3447
|
-
}
|
|
3448
|
-
function check(a, b) {
|
|
3449
|
-
if (a === b) {
|
|
3450
|
-
return true;
|
|
3451
|
-
}
|
|
3452
|
-
var aTag = toString.call(a);
|
|
3453
|
-
var bTag = toString.call(b);
|
|
3454
|
-
if (aTag !== bTag) {
|
|
3455
|
-
return false;
|
|
3456
|
-
}
|
|
3457
|
-
switch (aTag) {
|
|
3458
|
-
case "[object Array]":
|
|
3459
|
-
if (a.length !== b.length)
|
|
3460
|
-
return false;
|
|
3461
|
-
case "[object Object]": {
|
|
3462
|
-
if (previouslyCompared(a, b))
|
|
3463
|
-
return true;
|
|
3464
|
-
var aKeys = definedKeys(a);
|
|
3465
|
-
var bKeys = definedKeys(b);
|
|
3466
|
-
var keyCount = aKeys.length;
|
|
3467
|
-
if (keyCount !== bKeys.length)
|
|
3468
|
-
return false;
|
|
3469
|
-
for (var k = 0; k < keyCount; ++k) {
|
|
3470
|
-
if (!hasOwnProperty$1.call(b, aKeys[k])) {
|
|
3471
|
-
return false;
|
|
3472
|
-
}
|
|
3473
|
-
}
|
|
3474
|
-
for (var k = 0; k < keyCount; ++k) {
|
|
3475
|
-
var key = aKeys[k];
|
|
3476
|
-
if (!check(a[key], b[key])) {
|
|
3477
|
-
return false;
|
|
3478
|
-
}
|
|
3479
|
-
}
|
|
3480
|
-
return true;
|
|
3481
|
-
}
|
|
3482
|
-
case "[object Error]":
|
|
3483
|
-
return a.name === b.name && a.message === b.message;
|
|
3484
|
-
case "[object Number]":
|
|
3485
|
-
if (a !== a)
|
|
3486
|
-
return b !== b;
|
|
3487
|
-
case "[object Boolean]":
|
|
3488
|
-
case "[object Date]":
|
|
3489
|
-
return +a === +b;
|
|
3490
|
-
case "[object RegExp]":
|
|
3491
|
-
case "[object String]":
|
|
3492
|
-
return a == "" + b;
|
|
3493
|
-
case "[object Map]":
|
|
3494
|
-
case "[object Set]": {
|
|
3495
|
-
if (a.size !== b.size)
|
|
3496
|
-
return false;
|
|
3497
|
-
if (previouslyCompared(a, b))
|
|
3498
|
-
return true;
|
|
3499
|
-
var aIterator = a.entries();
|
|
3500
|
-
var isMap = aTag === "[object Map]";
|
|
3501
|
-
while (true) {
|
|
3502
|
-
var info = aIterator.next();
|
|
3503
|
-
if (info.done)
|
|
3504
|
-
break;
|
|
3505
|
-
var _a2 = info.value, aKey = _a2[0], aValue = _a2[1];
|
|
3506
|
-
if (!b.has(aKey)) {
|
|
3507
|
-
return false;
|
|
3508
|
-
}
|
|
3509
|
-
if (isMap && !check(aValue, b.get(aKey))) {
|
|
3510
|
-
return false;
|
|
3511
|
-
}
|
|
3512
|
-
}
|
|
3513
|
-
return true;
|
|
3514
|
-
}
|
|
3515
|
-
case "[object Uint16Array]":
|
|
3516
|
-
case "[object Uint8Array]":
|
|
3517
|
-
case "[object Uint32Array]":
|
|
3518
|
-
case "[object Int32Array]":
|
|
3519
|
-
case "[object Int8Array]":
|
|
3520
|
-
case "[object Int16Array]":
|
|
3521
|
-
case "[object ArrayBuffer]":
|
|
3522
|
-
a = new Uint8Array(a);
|
|
3523
|
-
b = new Uint8Array(b);
|
|
3524
|
-
case "[object DataView]": {
|
|
3525
|
-
var len = a.byteLength;
|
|
3526
|
-
if (len === b.byteLength) {
|
|
3527
|
-
while (len-- && a[len] === b[len]) {
|
|
3528
|
-
}
|
|
3529
|
-
}
|
|
3530
|
-
return len === -1;
|
|
3531
|
-
}
|
|
3532
|
-
case "[object AsyncFunction]":
|
|
3533
|
-
case "[object GeneratorFunction]":
|
|
3534
|
-
case "[object AsyncGeneratorFunction]":
|
|
3535
|
-
case "[object Function]": {
|
|
3536
|
-
var aCode = fnToStr.call(a);
|
|
3537
|
-
if (aCode !== fnToStr.call(b)) {
|
|
3538
|
-
return false;
|
|
3539
|
-
}
|
|
3540
|
-
return !endsWith(aCode, nativeCodeSuffix);
|
|
3541
|
-
}
|
|
3542
|
-
}
|
|
3543
|
-
return false;
|
|
3544
|
-
}
|
|
3545
|
-
function definedKeys(obj) {
|
|
3546
|
-
return Object.keys(obj).filter(isDefinedKey, obj);
|
|
3547
|
-
}
|
|
3548
|
-
function isDefinedKey(key) {
|
|
3549
|
-
return this[key] !== void 0;
|
|
3550
|
-
}
|
|
3551
|
-
var nativeCodeSuffix = "{ [native code] }";
|
|
3552
|
-
function endsWith(full, suffix) {
|
|
3553
|
-
var fromIndex = full.length - suffix.length;
|
|
3554
|
-
return fromIndex >= 0 && full.indexOf(suffix, fromIndex) === fromIndex;
|
|
3555
|
-
}
|
|
3556
|
-
function previouslyCompared(a, b) {
|
|
3557
|
-
var bSet = previousComparisons.get(a);
|
|
3558
|
-
if (bSet) {
|
|
3559
|
-
if (bSet.has(b))
|
|
3560
|
-
return true;
|
|
3561
|
-
} else {
|
|
3562
|
-
previousComparisons.set(a, bSet = new Set());
|
|
3563
|
-
}
|
|
3564
|
-
bSet.add(b);
|
|
3565
|
-
return false;
|
|
3566
|
-
}
|
|
3567
|
-
var defaultMakeData = function() {
|
|
3568
|
-
return Object.create(null);
|
|
3569
|
-
};
|
|
3570
|
-
var _a$1 = Array.prototype, forEach = _a$1.forEach, slice = _a$1.slice;
|
|
3571
|
-
var Trie = function() {
|
|
3572
|
-
function Trie2(weakness, makeData) {
|
|
3573
|
-
if (weakness === void 0) {
|
|
3574
|
-
weakness = true;
|
|
3575
|
-
}
|
|
3576
|
-
if (makeData === void 0) {
|
|
3577
|
-
makeData = defaultMakeData;
|
|
3578
|
-
}
|
|
3579
|
-
this.weakness = weakness;
|
|
3580
|
-
this.makeData = makeData;
|
|
3581
|
-
}
|
|
3582
|
-
Trie2.prototype.lookup = function() {
|
|
3583
|
-
var array = [];
|
|
3584
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3585
|
-
array[_i] = arguments[_i];
|
|
3586
|
-
}
|
|
3587
|
-
return this.lookupArray(array);
|
|
3588
|
-
};
|
|
3589
|
-
Trie2.prototype.lookupArray = function(array) {
|
|
3590
|
-
var node = this;
|
|
3591
|
-
forEach.call(array, function(key) {
|
|
3592
|
-
return node = node.getChildTrie(key);
|
|
3593
|
-
});
|
|
3594
|
-
return node.data || (node.data = this.makeData(slice.call(array)));
|
|
3595
|
-
};
|
|
3596
|
-
Trie2.prototype.getChildTrie = function(key) {
|
|
3597
|
-
var map = this.weakness && isObjRef(key) ? this.weak || (this.weak = new WeakMap()) : this.strong || (this.strong = new Map());
|
|
3598
|
-
var child = map.get(key);
|
|
3599
|
-
if (!child)
|
|
3600
|
-
map.set(key, child = new Trie2(this.weakness, this.makeData));
|
|
3601
|
-
return child;
|
|
3602
|
-
};
|
|
3603
|
-
return Trie2;
|
|
3604
|
-
}();
|
|
3605
|
-
function isObjRef(value) {
|
|
3606
|
-
switch (typeof value) {
|
|
3607
|
-
case "object":
|
|
3608
|
-
if (value === null)
|
|
3609
|
-
break;
|
|
3610
|
-
case "function":
|
|
3611
|
-
return true;
|
|
3612
|
-
}
|
|
3613
|
-
return false;
|
|
3614
|
-
}
|
|
3615
|
-
var currentContext = null;
|
|
3616
|
-
var MISSING_VALUE = {};
|
|
3617
|
-
var idCounter = 1;
|
|
3618
|
-
var makeSlotClass = function() {
|
|
3619
|
-
return function() {
|
|
3620
|
-
function Slot2() {
|
|
3621
|
-
this.id = [
|
|
3622
|
-
"slot",
|
|
3623
|
-
idCounter++,
|
|
3624
|
-
Date.now(),
|
|
3625
|
-
Math.random().toString(36).slice(2)
|
|
3626
|
-
].join(":");
|
|
3627
|
-
}
|
|
3628
|
-
Slot2.prototype.hasValue = function() {
|
|
3629
|
-
for (var context_1 = currentContext; context_1; context_1 = context_1.parent) {
|
|
3630
|
-
if (this.id in context_1.slots) {
|
|
3631
|
-
var value = context_1.slots[this.id];
|
|
3632
|
-
if (value === MISSING_VALUE)
|
|
3633
|
-
break;
|
|
3634
|
-
if (context_1 !== currentContext) {
|
|
3635
|
-
currentContext.slots[this.id] = value;
|
|
3636
|
-
}
|
|
3637
|
-
return true;
|
|
3638
|
-
}
|
|
3639
|
-
}
|
|
3640
|
-
if (currentContext) {
|
|
3641
|
-
currentContext.slots[this.id] = MISSING_VALUE;
|
|
3642
|
-
}
|
|
3643
|
-
return false;
|
|
3644
|
-
};
|
|
3645
|
-
Slot2.prototype.getValue = function() {
|
|
3646
|
-
if (this.hasValue()) {
|
|
3647
|
-
return currentContext.slots[this.id];
|
|
3648
|
-
}
|
|
3649
|
-
};
|
|
3650
|
-
Slot2.prototype.withValue = function(value, callback, args, thisArg) {
|
|
3651
|
-
var _a2;
|
|
3652
|
-
var slots = (_a2 = {
|
|
3653
|
-
__proto__: null
|
|
3654
|
-
}, _a2[this.id] = value, _a2);
|
|
3655
|
-
var parent = currentContext;
|
|
3656
|
-
currentContext = { parent, slots };
|
|
3657
|
-
try {
|
|
3658
|
-
return callback.apply(thisArg, args);
|
|
3659
|
-
} finally {
|
|
3660
|
-
currentContext = parent;
|
|
3661
|
-
}
|
|
3662
|
-
};
|
|
3663
|
-
Slot2.bind = function(callback) {
|
|
3664
|
-
var context = currentContext;
|
|
3665
|
-
return function() {
|
|
3666
|
-
var saved = currentContext;
|
|
3667
|
-
try {
|
|
3668
|
-
currentContext = context;
|
|
3669
|
-
return callback.apply(this, arguments);
|
|
3670
|
-
} finally {
|
|
3671
|
-
currentContext = saved;
|
|
3672
|
-
}
|
|
3673
|
-
};
|
|
3674
|
-
};
|
|
3675
|
-
Slot2.noContext = function(callback, args, thisArg) {
|
|
3676
|
-
if (currentContext) {
|
|
3677
|
-
var saved = currentContext;
|
|
3678
|
-
try {
|
|
3679
|
-
currentContext = null;
|
|
3680
|
-
return callback.apply(thisArg, args);
|
|
3681
|
-
} finally {
|
|
3682
|
-
currentContext = saved;
|
|
3683
|
-
}
|
|
3684
|
-
} else {
|
|
3685
|
-
return callback.apply(thisArg, args);
|
|
3686
|
-
}
|
|
3687
|
-
};
|
|
3688
|
-
return Slot2;
|
|
3689
|
-
}();
|
|
3690
|
-
};
|
|
3691
|
-
var globalKey = "@wry/context:Slot";
|
|
3692
|
-
var host = Array;
|
|
3693
|
-
var Slot = host[globalKey] || function() {
|
|
3694
|
-
var Slot2 = makeSlotClass();
|
|
3695
|
-
try {
|
|
3696
|
-
Object.defineProperty(host, globalKey, {
|
|
3697
|
-
value: host[globalKey] = Slot2,
|
|
3698
|
-
enumerable: false,
|
|
3699
|
-
writable: false,
|
|
3700
|
-
configurable: false
|
|
3701
|
-
});
|
|
3702
|
-
} finally {
|
|
3703
|
-
return Slot2;
|
|
3704
|
-
}
|
|
3705
|
-
}();
|
|
3706
|
-
Slot.bind;
|
|
3707
|
-
Slot.noContext;
|
|
3708
|
-
function defaultDispose() {
|
|
3709
|
-
}
|
|
3710
|
-
var Cache = function() {
|
|
3711
|
-
function Cache2(max, dispose) {
|
|
3712
|
-
if (max === void 0) {
|
|
3713
|
-
max = Infinity;
|
|
3714
|
-
}
|
|
3715
|
-
if (dispose === void 0) {
|
|
3716
|
-
dispose = defaultDispose;
|
|
3717
|
-
}
|
|
3718
|
-
this.max = max;
|
|
3719
|
-
this.dispose = dispose;
|
|
3720
|
-
this.map = new Map();
|
|
3721
|
-
this.newest = null;
|
|
3722
|
-
this.oldest = null;
|
|
3723
|
-
}
|
|
3724
|
-
Cache2.prototype.has = function(key) {
|
|
3725
|
-
return this.map.has(key);
|
|
3726
|
-
};
|
|
3727
|
-
Cache2.prototype.get = function(key) {
|
|
3728
|
-
var node = this.getNode(key);
|
|
3729
|
-
return node && node.value;
|
|
3730
|
-
};
|
|
3731
|
-
Cache2.prototype.getNode = function(key) {
|
|
3732
|
-
var node = this.map.get(key);
|
|
3733
|
-
if (node && node !== this.newest) {
|
|
3734
|
-
var older = node.older, newer = node.newer;
|
|
3735
|
-
if (newer) {
|
|
3736
|
-
newer.older = older;
|
|
3737
|
-
}
|
|
3738
|
-
if (older) {
|
|
3739
|
-
older.newer = newer;
|
|
3740
|
-
}
|
|
3741
|
-
node.older = this.newest;
|
|
3742
|
-
node.older.newer = node;
|
|
3743
|
-
node.newer = null;
|
|
3744
|
-
this.newest = node;
|
|
3745
|
-
if (node === this.oldest) {
|
|
3746
|
-
this.oldest = newer;
|
|
3747
|
-
}
|
|
3748
|
-
}
|
|
3749
|
-
return node;
|
|
3750
|
-
};
|
|
3751
|
-
Cache2.prototype.set = function(key, value) {
|
|
3752
|
-
var node = this.getNode(key);
|
|
3753
|
-
if (node) {
|
|
3754
|
-
return node.value = value;
|
|
3755
|
-
}
|
|
3756
|
-
node = {
|
|
3757
|
-
key,
|
|
3758
|
-
value,
|
|
3759
|
-
newer: null,
|
|
3760
|
-
older: this.newest
|
|
3761
|
-
};
|
|
3762
|
-
if (this.newest) {
|
|
3763
|
-
this.newest.newer = node;
|
|
3764
|
-
}
|
|
3765
|
-
this.newest = node;
|
|
3766
|
-
this.oldest = this.oldest || node;
|
|
3767
|
-
this.map.set(key, node);
|
|
3768
|
-
return node.value;
|
|
3769
|
-
};
|
|
3770
|
-
Cache2.prototype.clean = function() {
|
|
3771
|
-
while (this.oldest && this.map.size > this.max) {
|
|
3772
|
-
this.delete(this.oldest.key);
|
|
3773
|
-
}
|
|
3774
|
-
};
|
|
3775
|
-
Cache2.prototype.delete = function(key) {
|
|
3776
|
-
var node = this.map.get(key);
|
|
3777
|
-
if (node) {
|
|
3778
|
-
if (node === this.newest) {
|
|
3779
|
-
this.newest = node.older;
|
|
3780
|
-
}
|
|
3781
|
-
if (node === this.oldest) {
|
|
3782
|
-
this.oldest = node.newer;
|
|
3783
|
-
}
|
|
3784
|
-
if (node.newer) {
|
|
3785
|
-
node.newer.older = node.older;
|
|
3786
|
-
}
|
|
3787
|
-
if (node.older) {
|
|
3788
|
-
node.older.newer = node.newer;
|
|
3789
|
-
}
|
|
3790
|
-
this.map.delete(key);
|
|
3791
|
-
this.dispose(node.value, key);
|
|
3792
|
-
return true;
|
|
3793
|
-
}
|
|
3794
|
-
return false;
|
|
3795
|
-
};
|
|
3796
|
-
return Cache2;
|
|
3797
|
-
}();
|
|
3798
|
-
var parentEntrySlot = new Slot();
|
|
3799
|
-
var _a;
|
|
3800
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3801
|
-
var toArray = (_a = Array.from, _a === void 0 ? function(collection) {
|
|
3802
|
-
var array = [];
|
|
3803
|
-
collection.forEach(function(item) {
|
|
3804
|
-
return array.push(item);
|
|
3805
|
-
});
|
|
3806
|
-
return array;
|
|
3807
|
-
} : _a);
|
|
3808
|
-
function maybeUnsubscribe(entryOrDep) {
|
|
3809
|
-
var unsubscribe = entryOrDep.unsubscribe;
|
|
3810
|
-
if (typeof unsubscribe === "function") {
|
|
3811
|
-
entryOrDep.unsubscribe = void 0;
|
|
3812
|
-
unsubscribe();
|
|
3813
|
-
}
|
|
3814
|
-
}
|
|
3815
|
-
var emptySetPool = [];
|
|
3816
|
-
var POOL_TARGET_SIZE = 100;
|
|
3817
|
-
function assert(condition, optionalMessage) {
|
|
3818
|
-
if (!condition) {
|
|
3819
|
-
throw new Error(optionalMessage || "assertion failure");
|
|
3820
|
-
}
|
|
3821
|
-
}
|
|
3822
|
-
function valueIs(a, b) {
|
|
3823
|
-
var len = a.length;
|
|
3824
|
-
return len > 0 && len === b.length && a[len - 1] === b[len - 1];
|
|
3825
|
-
}
|
|
3826
|
-
function valueGet(value) {
|
|
3827
|
-
switch (value.length) {
|
|
3828
|
-
case 0:
|
|
3829
|
-
throw new Error("unknown value");
|
|
3830
|
-
case 1:
|
|
3831
|
-
return value[0];
|
|
3832
|
-
case 2:
|
|
3833
|
-
throw value[1];
|
|
3834
|
-
}
|
|
3835
|
-
}
|
|
3836
|
-
function valueCopy(value) {
|
|
3837
|
-
return value.slice(0);
|
|
3838
|
-
}
|
|
3839
|
-
var Entry = function() {
|
|
3840
|
-
function Entry2(fn) {
|
|
3841
|
-
this.fn = fn;
|
|
3842
|
-
this.parents = new Set();
|
|
3843
|
-
this.childValues = new Map();
|
|
3844
|
-
this.dirtyChildren = null;
|
|
3845
|
-
this.dirty = true;
|
|
3846
|
-
this.recomputing = false;
|
|
3847
|
-
this.value = [];
|
|
3848
|
-
this.deps = null;
|
|
3849
|
-
++Entry2.count;
|
|
3850
|
-
}
|
|
3851
|
-
Entry2.prototype.peek = function() {
|
|
3852
|
-
if (this.value.length === 1 && !mightBeDirty(this)) {
|
|
3853
|
-
rememberParent(this);
|
|
3854
|
-
return this.value[0];
|
|
3855
|
-
}
|
|
3856
|
-
};
|
|
3857
|
-
Entry2.prototype.recompute = function(args) {
|
|
3858
|
-
assert(!this.recomputing, "already recomputing");
|
|
3859
|
-
rememberParent(this);
|
|
3860
|
-
return mightBeDirty(this) ? reallyRecompute(this, args) : valueGet(this.value);
|
|
3861
|
-
};
|
|
3862
|
-
Entry2.prototype.setDirty = function() {
|
|
3863
|
-
if (this.dirty)
|
|
3864
|
-
return;
|
|
3865
|
-
this.dirty = true;
|
|
3866
|
-
this.value.length = 0;
|
|
3867
|
-
reportDirty(this);
|
|
3868
|
-
maybeUnsubscribe(this);
|
|
3869
|
-
};
|
|
3870
|
-
Entry2.prototype.dispose = function() {
|
|
3871
|
-
var _this = this;
|
|
3872
|
-
this.setDirty();
|
|
3873
|
-
forgetChildren(this);
|
|
3874
|
-
eachParent(this, function(parent, child) {
|
|
3875
|
-
parent.setDirty();
|
|
3876
|
-
forgetChild(parent, _this);
|
|
3877
|
-
});
|
|
3878
|
-
};
|
|
3879
|
-
Entry2.prototype.forget = function() {
|
|
3880
|
-
this.dispose();
|
|
3881
|
-
};
|
|
3882
|
-
Entry2.prototype.dependOn = function(dep2) {
|
|
3883
|
-
dep2.add(this);
|
|
3884
|
-
if (!this.deps) {
|
|
3885
|
-
this.deps = emptySetPool.pop() || new Set();
|
|
3886
|
-
}
|
|
3887
|
-
this.deps.add(dep2);
|
|
3888
|
-
};
|
|
3889
|
-
Entry2.prototype.forgetDeps = function() {
|
|
3890
|
-
var _this = this;
|
|
3891
|
-
if (this.deps) {
|
|
3892
|
-
toArray(this.deps).forEach(function(dep2) {
|
|
3893
|
-
return dep2.delete(_this);
|
|
3894
|
-
});
|
|
3895
|
-
this.deps.clear();
|
|
3896
|
-
emptySetPool.push(this.deps);
|
|
3897
|
-
this.deps = null;
|
|
3898
|
-
}
|
|
3899
|
-
};
|
|
3900
|
-
Entry2.count = 0;
|
|
3901
|
-
return Entry2;
|
|
3902
|
-
}();
|
|
3903
|
-
function rememberParent(child) {
|
|
3904
|
-
var parent = parentEntrySlot.getValue();
|
|
3905
|
-
if (parent) {
|
|
3906
|
-
child.parents.add(parent);
|
|
3907
|
-
if (!parent.childValues.has(child)) {
|
|
3908
|
-
parent.childValues.set(child, []);
|
|
3909
|
-
}
|
|
3910
|
-
if (mightBeDirty(child)) {
|
|
3911
|
-
reportDirtyChild(parent, child);
|
|
3912
|
-
} else {
|
|
3913
|
-
reportCleanChild(parent, child);
|
|
3914
|
-
}
|
|
3915
|
-
return parent;
|
|
3916
|
-
}
|
|
3917
|
-
}
|
|
3918
|
-
function reallyRecompute(entry, args) {
|
|
3919
|
-
forgetChildren(entry);
|
|
3920
|
-
parentEntrySlot.withValue(entry, recomputeNewValue, [entry, args]);
|
|
3921
|
-
if (maybeSubscribe(entry, args)) {
|
|
3922
|
-
setClean(entry);
|
|
3923
|
-
}
|
|
3924
|
-
return valueGet(entry.value);
|
|
3925
|
-
}
|
|
3926
|
-
function recomputeNewValue(entry, args) {
|
|
3927
|
-
entry.recomputing = true;
|
|
3928
|
-
entry.value.length = 0;
|
|
3929
|
-
try {
|
|
3930
|
-
entry.value[0] = entry.fn.apply(null, args);
|
|
3931
|
-
} catch (e) {
|
|
3932
|
-
entry.value[1] = e;
|
|
3933
|
-
}
|
|
3934
|
-
entry.recomputing = false;
|
|
3935
|
-
}
|
|
3936
|
-
function mightBeDirty(entry) {
|
|
3937
|
-
return entry.dirty || !!(entry.dirtyChildren && entry.dirtyChildren.size);
|
|
3938
|
-
}
|
|
3939
|
-
function setClean(entry) {
|
|
3940
|
-
entry.dirty = false;
|
|
3941
|
-
if (mightBeDirty(entry)) {
|
|
3942
|
-
return;
|
|
3943
|
-
}
|
|
3944
|
-
reportClean(entry);
|
|
3945
|
-
}
|
|
3946
|
-
function reportDirty(child) {
|
|
3947
|
-
eachParent(child, reportDirtyChild);
|
|
3948
|
-
}
|
|
3949
|
-
function reportClean(child) {
|
|
3950
|
-
eachParent(child, reportCleanChild);
|
|
3951
|
-
}
|
|
3952
|
-
function eachParent(child, callback) {
|
|
3953
|
-
var parentCount = child.parents.size;
|
|
3954
|
-
if (parentCount) {
|
|
3955
|
-
var parents = toArray(child.parents);
|
|
3956
|
-
for (var i = 0; i < parentCount; ++i) {
|
|
3957
|
-
callback(parents[i], child);
|
|
3958
|
-
}
|
|
3959
|
-
}
|
|
3960
|
-
}
|
|
3961
|
-
function reportDirtyChild(parent, child) {
|
|
3962
|
-
assert(parent.childValues.has(child));
|
|
3963
|
-
assert(mightBeDirty(child));
|
|
3964
|
-
var parentWasClean = !mightBeDirty(parent);
|
|
3965
|
-
if (!parent.dirtyChildren) {
|
|
3966
|
-
parent.dirtyChildren = emptySetPool.pop() || new Set();
|
|
3967
|
-
} else if (parent.dirtyChildren.has(child)) {
|
|
3968
|
-
return;
|
|
3969
|
-
}
|
|
3970
|
-
parent.dirtyChildren.add(child);
|
|
3971
|
-
if (parentWasClean) {
|
|
3972
|
-
reportDirty(parent);
|
|
3973
|
-
}
|
|
3974
|
-
}
|
|
3975
|
-
function reportCleanChild(parent, child) {
|
|
3976
|
-
assert(parent.childValues.has(child));
|
|
3977
|
-
assert(!mightBeDirty(child));
|
|
3978
|
-
var childValue = parent.childValues.get(child);
|
|
3979
|
-
if (childValue.length === 0) {
|
|
3980
|
-
parent.childValues.set(child, valueCopy(child.value));
|
|
3981
|
-
} else if (!valueIs(childValue, child.value)) {
|
|
3982
|
-
parent.setDirty();
|
|
3983
|
-
}
|
|
3984
|
-
removeDirtyChild(parent, child);
|
|
3985
|
-
if (mightBeDirty(parent)) {
|
|
3986
|
-
return;
|
|
3987
|
-
}
|
|
3988
|
-
reportClean(parent);
|
|
3989
|
-
}
|
|
3990
|
-
function removeDirtyChild(parent, child) {
|
|
3991
|
-
var dc = parent.dirtyChildren;
|
|
3992
|
-
if (dc) {
|
|
3993
|
-
dc.delete(child);
|
|
3994
|
-
if (dc.size === 0) {
|
|
3995
|
-
if (emptySetPool.length < POOL_TARGET_SIZE) {
|
|
3996
|
-
emptySetPool.push(dc);
|
|
3997
|
-
}
|
|
3998
|
-
parent.dirtyChildren = null;
|
|
3999
|
-
}
|
|
4000
|
-
}
|
|
4001
|
-
}
|
|
4002
|
-
function forgetChildren(parent) {
|
|
4003
|
-
if (parent.childValues.size > 0) {
|
|
4004
|
-
parent.childValues.forEach(function(_value, child) {
|
|
4005
|
-
forgetChild(parent, child);
|
|
4006
|
-
});
|
|
4007
|
-
}
|
|
4008
|
-
parent.forgetDeps();
|
|
4009
|
-
assert(parent.dirtyChildren === null);
|
|
4010
|
-
}
|
|
4011
|
-
function forgetChild(parent, child) {
|
|
4012
|
-
child.parents.delete(parent);
|
|
4013
|
-
parent.childValues.delete(child);
|
|
4014
|
-
removeDirtyChild(parent, child);
|
|
4015
|
-
}
|
|
4016
|
-
function maybeSubscribe(entry, args) {
|
|
4017
|
-
if (typeof entry.subscribe === "function") {
|
|
4018
|
-
try {
|
|
4019
|
-
maybeUnsubscribe(entry);
|
|
4020
|
-
entry.unsubscribe = entry.subscribe.apply(null, args);
|
|
4021
|
-
} catch (e) {
|
|
4022
|
-
entry.setDirty();
|
|
4023
|
-
return false;
|
|
4024
|
-
}
|
|
4025
|
-
}
|
|
4026
|
-
return true;
|
|
4027
|
-
}
|
|
4028
|
-
var EntryMethods = {
|
|
4029
|
-
setDirty: true,
|
|
4030
|
-
dispose: true,
|
|
4031
|
-
forget: true
|
|
4032
|
-
};
|
|
4033
|
-
function dep(options) {
|
|
4034
|
-
var depsByKey = new Map();
|
|
4035
|
-
var subscribe = options && options.subscribe;
|
|
4036
|
-
function depend(key) {
|
|
4037
|
-
var parent = parentEntrySlot.getValue();
|
|
4038
|
-
if (parent) {
|
|
4039
|
-
var dep_1 = depsByKey.get(key);
|
|
4040
|
-
if (!dep_1) {
|
|
4041
|
-
depsByKey.set(key, dep_1 = new Set());
|
|
4042
|
-
}
|
|
4043
|
-
parent.dependOn(dep_1);
|
|
4044
|
-
if (typeof subscribe === "function") {
|
|
4045
|
-
maybeUnsubscribe(dep_1);
|
|
4046
|
-
dep_1.unsubscribe = subscribe(key);
|
|
4047
|
-
}
|
|
4048
|
-
}
|
|
4049
|
-
}
|
|
4050
|
-
depend.dirty = function dirty(key, entryMethodName) {
|
|
4051
|
-
var dep2 = depsByKey.get(key);
|
|
4052
|
-
if (dep2) {
|
|
4053
|
-
var m_1 = entryMethodName && hasOwnProperty.call(EntryMethods, entryMethodName) ? entryMethodName : "setDirty";
|
|
4054
|
-
toArray(dep2).forEach(function(entry) {
|
|
4055
|
-
return entry[m_1]();
|
|
4056
|
-
});
|
|
4057
|
-
depsByKey.delete(key);
|
|
4058
|
-
maybeUnsubscribe(dep2);
|
|
4059
|
-
}
|
|
4060
|
-
};
|
|
4061
|
-
return depend;
|
|
4062
|
-
}
|
|
4063
|
-
function makeDefaultMakeCacheKeyFunction() {
|
|
4064
|
-
var keyTrie = new Trie(typeof WeakMap === "function");
|
|
4065
|
-
return function() {
|
|
4066
|
-
return keyTrie.lookupArray(arguments);
|
|
4067
|
-
};
|
|
4068
|
-
}
|
|
4069
|
-
makeDefaultMakeCacheKeyFunction();
|
|
4070
|
-
var caches = new Set();
|
|
4071
|
-
function wrap(originalFunction, options) {
|
|
4072
|
-
if (options === void 0) {
|
|
4073
|
-
options = Object.create(null);
|
|
4074
|
-
}
|
|
4075
|
-
var cache = new Cache(options.max || Math.pow(2, 16), function(entry) {
|
|
4076
|
-
return entry.dispose();
|
|
4077
|
-
});
|
|
4078
|
-
var keyArgs = options.keyArgs;
|
|
4079
|
-
var makeCacheKey = options.makeCacheKey || makeDefaultMakeCacheKeyFunction();
|
|
4080
|
-
var optimistic = function() {
|
|
4081
|
-
var key = makeCacheKey.apply(null, keyArgs ? keyArgs.apply(null, arguments) : arguments);
|
|
4082
|
-
if (key === void 0) {
|
|
4083
|
-
return originalFunction.apply(null, arguments);
|
|
4084
|
-
}
|
|
4085
|
-
var entry = cache.get(key);
|
|
4086
|
-
if (!entry) {
|
|
4087
|
-
cache.set(key, entry = new Entry(originalFunction));
|
|
4088
|
-
entry.subscribe = options.subscribe;
|
|
4089
|
-
entry.forget = function() {
|
|
4090
|
-
return cache.delete(key);
|
|
4091
|
-
};
|
|
4092
|
-
}
|
|
4093
|
-
var value = entry.recompute(Array.prototype.slice.call(arguments));
|
|
4094
|
-
cache.set(key, entry);
|
|
4095
|
-
caches.add(cache);
|
|
4096
|
-
if (!parentEntrySlot.hasValue()) {
|
|
4097
|
-
caches.forEach(function(cache2) {
|
|
4098
|
-
return cache2.clean();
|
|
4099
|
-
});
|
|
4100
|
-
caches.clear();
|
|
4101
|
-
}
|
|
4102
|
-
return value;
|
|
4103
|
-
};
|
|
4104
|
-
Object.defineProperty(optimistic, "size", {
|
|
4105
|
-
get: function() {
|
|
4106
|
-
return cache["map"].size;
|
|
4107
|
-
},
|
|
4108
|
-
configurable: false,
|
|
4109
|
-
enumerable: false
|
|
4110
|
-
});
|
|
4111
|
-
function dirtyKey(key) {
|
|
4112
|
-
var entry = cache.get(key);
|
|
4113
|
-
if (entry) {
|
|
4114
|
-
entry.setDirty();
|
|
4115
|
-
}
|
|
4116
|
-
}
|
|
4117
|
-
optimistic.dirtyKey = dirtyKey;
|
|
4118
|
-
optimistic.dirty = function dirty() {
|
|
4119
|
-
dirtyKey(makeCacheKey.apply(null, arguments));
|
|
4120
|
-
};
|
|
4121
|
-
function peekKey(key) {
|
|
4122
|
-
var entry = cache.get(key);
|
|
4123
|
-
if (entry) {
|
|
4124
|
-
return entry.peek();
|
|
4125
|
-
}
|
|
4126
|
-
}
|
|
4127
|
-
optimistic.peekKey = peekKey;
|
|
4128
|
-
optimistic.peek = function peek() {
|
|
4129
|
-
return peekKey(makeCacheKey.apply(null, arguments));
|
|
4130
|
-
};
|
|
4131
|
-
function forgetKey(key) {
|
|
4132
|
-
return cache.delete(key);
|
|
4133
|
-
}
|
|
4134
|
-
optimistic.forgetKey = forgetKey;
|
|
4135
|
-
optimistic.forget = function forget() {
|
|
4136
|
-
return forgetKey(makeCacheKey.apply(null, arguments));
|
|
4137
|
-
};
|
|
4138
|
-
optimistic.makeCacheKey = makeCacheKey;
|
|
4139
|
-
optimistic.getKey = keyArgs ? function getKey() {
|
|
4140
|
-
return makeCacheKey.apply(null, keyArgs.apply(null, arguments));
|
|
4141
|
-
} : makeCacheKey;
|
|
4142
|
-
return Object.freeze(optimistic);
|
|
4143
|
-
}
|
|
4144
|
-
var ApolloCache = function() {
|
|
4145
|
-
function ApolloCache2() {
|
|
4146
|
-
this.getFragmentDoc = wrap(getFragmentQueryDocument);
|
|
4147
|
-
}
|
|
4148
|
-
ApolloCache2.prototype.batch = function(options) {
|
|
4149
|
-
var _this = this;
|
|
4150
|
-
var optimisticId = typeof options.optimistic === "string" ? options.optimistic : options.optimistic === false ? null : void 0;
|
|
4151
|
-
var updateResult;
|
|
4152
|
-
this.performTransaction(function() {
|
|
4153
|
-
return updateResult = options.update(_this);
|
|
4154
|
-
}, optimisticId);
|
|
4155
|
-
return updateResult;
|
|
4156
|
-
};
|
|
4157
|
-
ApolloCache2.prototype.recordOptimisticTransaction = function(transaction, optimisticId) {
|
|
4158
|
-
this.performTransaction(transaction, optimisticId);
|
|
4159
|
-
};
|
|
4160
|
-
ApolloCache2.prototype.transformDocument = function(document) {
|
|
4161
|
-
return document;
|
|
4162
|
-
};
|
|
4163
|
-
ApolloCache2.prototype.identify = function(object) {
|
|
4164
|
-
return;
|
|
4165
|
-
};
|
|
4166
|
-
ApolloCache2.prototype.gc = function() {
|
|
4167
|
-
return [];
|
|
4168
|
-
};
|
|
4169
|
-
ApolloCache2.prototype.modify = function(options) {
|
|
4170
|
-
return false;
|
|
4171
|
-
};
|
|
4172
|
-
ApolloCache2.prototype.transformForLink = function(document) {
|
|
4173
|
-
return document;
|
|
4174
|
-
};
|
|
4175
|
-
ApolloCache2.prototype.readQuery = function(options, optimistic) {
|
|
4176
|
-
if (optimistic === void 0) {
|
|
4177
|
-
optimistic = !!options.optimistic;
|
|
4178
|
-
}
|
|
4179
|
-
return this.read(__assign(__assign({}, options), { rootId: options.id || "ROOT_QUERY", optimistic }));
|
|
4180
|
-
};
|
|
4181
|
-
ApolloCache2.prototype.readFragment = function(options, optimistic) {
|
|
4182
|
-
if (optimistic === void 0) {
|
|
4183
|
-
optimistic = !!options.optimistic;
|
|
4184
|
-
}
|
|
4185
|
-
return this.read(__assign(__assign({}, options), { query: this.getFragmentDoc(options.fragment, options.fragmentName), rootId: options.id, optimistic }));
|
|
4186
|
-
};
|
|
4187
|
-
ApolloCache2.prototype.writeQuery = function(_a2) {
|
|
4188
|
-
var id = _a2.id, data = _a2.data, options = __rest(_a2, ["id", "data"]);
|
|
4189
|
-
return this.write(Object.assign(options, {
|
|
4190
|
-
dataId: id || "ROOT_QUERY",
|
|
4191
|
-
result: data
|
|
4192
|
-
}));
|
|
4193
|
-
};
|
|
4194
|
-
ApolloCache2.prototype.writeFragment = function(_a2) {
|
|
4195
|
-
var id = _a2.id, data = _a2.data, fragment = _a2.fragment, fragmentName = _a2.fragmentName, options = __rest(_a2, ["id", "data", "fragment", "fragmentName"]);
|
|
4196
|
-
return this.write(Object.assign(options, {
|
|
4197
|
-
query: this.getFragmentDoc(fragment, fragmentName),
|
|
4198
|
-
dataId: id,
|
|
4199
|
-
result: data
|
|
4200
|
-
}));
|
|
4201
|
-
};
|
|
4202
|
-
ApolloCache2.prototype.updateQuery = function(options, update) {
|
|
4203
|
-
return this.batch({
|
|
4204
|
-
update: function(cache) {
|
|
4205
|
-
var value = cache.readQuery(options);
|
|
4206
|
-
var data = update(value);
|
|
4207
|
-
if (data === void 0 || data === null)
|
|
4208
|
-
return value;
|
|
4209
|
-
cache.writeQuery(__assign(__assign({}, options), { data }));
|
|
4210
|
-
return data;
|
|
4211
|
-
}
|
|
4212
|
-
});
|
|
4213
|
-
};
|
|
4214
|
-
ApolloCache2.prototype.updateFragment = function(options, update) {
|
|
4215
|
-
return this.batch({
|
|
4216
|
-
update: function(cache) {
|
|
4217
|
-
var value = cache.readFragment(options);
|
|
4218
|
-
var data = update(value);
|
|
4219
|
-
if (data === void 0 || data === null)
|
|
4220
|
-
return value;
|
|
4221
|
-
cache.writeFragment(__assign(__assign({}, options), { data }));
|
|
4222
|
-
return data;
|
|
4223
|
-
}
|
|
4224
|
-
});
|
|
4225
|
-
};
|
|
4226
|
-
return ApolloCache2;
|
|
4227
|
-
}();
|
|
4228
|
-
var MissingFieldError = function() {
|
|
4229
|
-
function MissingFieldError2(message2, path2, query, variables) {
|
|
4230
|
-
this.message = message2;
|
|
4231
|
-
this.path = path2;
|
|
4232
|
-
this.query = query;
|
|
4233
|
-
this.variables = variables;
|
|
4234
|
-
}
|
|
4235
|
-
return MissingFieldError2;
|
|
4236
|
-
}();
|
|
4237
|
-
var hasOwn = Object.prototype.hasOwnProperty;
|
|
4238
|
-
function defaultDataIdFromObject(_a2, context) {
|
|
4239
|
-
var __typename = _a2.__typename, id = _a2.id, _id = _a2._id;
|
|
4240
|
-
if (typeof __typename === "string") {
|
|
4241
|
-
if (context) {
|
|
4242
|
-
context.keyObject = id !== void 0 ? { id } : _id !== void 0 ? { _id } : void 0;
|
|
4243
|
-
}
|
|
4244
|
-
if (id === void 0)
|
|
4245
|
-
id = _id;
|
|
4246
|
-
if (id !== void 0) {
|
|
4247
|
-
return "".concat(__typename, ":").concat(typeof id === "number" || typeof id === "string" ? id : JSON.stringify(id));
|
|
4248
|
-
}
|
|
4249
|
-
}
|
|
4250
|
-
}
|
|
4251
|
-
var defaultConfig = {
|
|
4252
|
-
dataIdFromObject: defaultDataIdFromObject,
|
|
4253
|
-
addTypename: true,
|
|
4254
|
-
resultCaching: true,
|
|
4255
|
-
canonizeResults: false
|
|
4256
|
-
};
|
|
4257
|
-
function normalizeConfig(config) {
|
|
4258
|
-
return compact(defaultConfig, config);
|
|
4259
|
-
}
|
|
4260
|
-
function shouldCanonizeResults(config) {
|
|
4261
|
-
var value = config.canonizeResults;
|
|
4262
|
-
return value === void 0 ? defaultConfig.canonizeResults : value;
|
|
4263
|
-
}
|
|
4264
|
-
function getTypenameFromStoreObject(store, objectOrReference) {
|
|
4265
|
-
return isReference(objectOrReference) ? store.get(objectOrReference.__ref, "__typename") : objectOrReference && objectOrReference.__typename;
|
|
4266
|
-
}
|
|
4267
|
-
var TypeOrFieldNameRegExp = /^[_a-z][_0-9a-z]*/i;
|
|
4268
|
-
function fieldNameFromStoreName(storeFieldName) {
|
|
4269
|
-
var match = storeFieldName.match(TypeOrFieldNameRegExp);
|
|
4270
|
-
return match ? match[0] : storeFieldName;
|
|
4271
|
-
}
|
|
4272
|
-
function selectionSetMatchesResult(selectionSet, result, variables) {
|
|
4273
|
-
if (isNonNullObject(result)) {
|
|
4274
|
-
return Array.isArray(result) ? result.every(function(item) {
|
|
4275
|
-
return selectionSetMatchesResult(selectionSet, item, variables);
|
|
4276
|
-
}) : selectionSet.selections.every(function(field) {
|
|
4277
|
-
if (isField(field) && shouldInclude(field, variables)) {
|
|
4278
|
-
var key = resultKeyNameFromField(field);
|
|
4279
|
-
return hasOwn.call(result, key) && (!field.selectionSet || selectionSetMatchesResult(field.selectionSet, result[key], variables));
|
|
4280
|
-
}
|
|
4281
|
-
return true;
|
|
4282
|
-
});
|
|
4283
|
-
}
|
|
4284
|
-
return false;
|
|
4285
|
-
}
|
|
4286
|
-
function storeValueIsStoreObject(value) {
|
|
4287
|
-
return isNonNullObject(value) && !isReference(value) && !Array.isArray(value);
|
|
4288
|
-
}
|
|
4289
|
-
function makeProcessedFieldsMerger() {
|
|
4290
|
-
return new DeepMerger();
|
|
4291
|
-
}
|
|
4292
|
-
var DELETE = Object.create(null);
|
|
4293
|
-
var delModifier = function() {
|
|
4294
|
-
return DELETE;
|
|
4295
|
-
};
|
|
4296
|
-
var INVALIDATE = Object.create(null);
|
|
4297
|
-
var EntityStore = function() {
|
|
4298
|
-
function EntityStore2(policies, group) {
|
|
4299
|
-
var _this = this;
|
|
4300
|
-
this.policies = policies;
|
|
4301
|
-
this.group = group;
|
|
4302
|
-
this.data = Object.create(null);
|
|
4303
|
-
this.rootIds = Object.create(null);
|
|
4304
|
-
this.refs = Object.create(null);
|
|
4305
|
-
this.getFieldValue = function(objectOrReference, storeFieldName) {
|
|
4306
|
-
return maybeDeepFreeze(isReference(objectOrReference) ? _this.get(objectOrReference.__ref, storeFieldName) : objectOrReference && objectOrReference[storeFieldName]);
|
|
4307
|
-
};
|
|
4308
|
-
this.canRead = function(objOrRef) {
|
|
4309
|
-
return isReference(objOrRef) ? _this.has(objOrRef.__ref) : typeof objOrRef === "object";
|
|
4310
|
-
};
|
|
4311
|
-
this.toReference = function(objOrIdOrRef, mergeIntoStore) {
|
|
4312
|
-
if (typeof objOrIdOrRef === "string") {
|
|
4313
|
-
return makeReference(objOrIdOrRef);
|
|
4314
|
-
}
|
|
4315
|
-
if (isReference(objOrIdOrRef)) {
|
|
4316
|
-
return objOrIdOrRef;
|
|
4317
|
-
}
|
|
4318
|
-
var id = _this.policies.identify(objOrIdOrRef)[0];
|
|
4319
|
-
if (id) {
|
|
4320
|
-
var ref2 = makeReference(id);
|
|
4321
|
-
if (mergeIntoStore) {
|
|
4322
|
-
_this.merge(id, objOrIdOrRef);
|
|
4323
|
-
}
|
|
4324
|
-
return ref2;
|
|
4325
|
-
}
|
|
4326
|
-
};
|
|
4327
|
-
}
|
|
4328
|
-
EntityStore2.prototype.toObject = function() {
|
|
4329
|
-
return __assign({}, this.data);
|
|
4330
|
-
};
|
|
4331
|
-
EntityStore2.prototype.has = function(dataId) {
|
|
4332
|
-
return this.lookup(dataId, true) !== void 0;
|
|
4333
|
-
};
|
|
4334
|
-
EntityStore2.prototype.get = function(dataId, fieldName) {
|
|
4335
|
-
this.group.depend(dataId, fieldName);
|
|
4336
|
-
if (hasOwn.call(this.data, dataId)) {
|
|
4337
|
-
var storeObject = this.data[dataId];
|
|
4338
|
-
if (storeObject && hasOwn.call(storeObject, fieldName)) {
|
|
4339
|
-
return storeObject[fieldName];
|
|
4340
|
-
}
|
|
4341
|
-
}
|
|
4342
|
-
if (fieldName === "__typename" && hasOwn.call(this.policies.rootTypenamesById, dataId)) {
|
|
4343
|
-
return this.policies.rootTypenamesById[dataId];
|
|
4344
|
-
}
|
|
4345
|
-
if (this instanceof Layer) {
|
|
4346
|
-
return this.parent.get(dataId, fieldName);
|
|
4347
|
-
}
|
|
4348
|
-
};
|
|
4349
|
-
EntityStore2.prototype.lookup = function(dataId, dependOnExistence) {
|
|
4350
|
-
if (dependOnExistence)
|
|
4351
|
-
this.group.depend(dataId, "__exists");
|
|
4352
|
-
if (hasOwn.call(this.data, dataId)) {
|
|
4353
|
-
return this.data[dataId];
|
|
4354
|
-
}
|
|
4355
|
-
if (this instanceof Layer) {
|
|
4356
|
-
return this.parent.lookup(dataId, dependOnExistence);
|
|
4357
|
-
}
|
|
4358
|
-
if (this.policies.rootTypenamesById[dataId]) {
|
|
4359
|
-
return Object.create(null);
|
|
4360
|
-
}
|
|
4361
|
-
};
|
|
4362
|
-
EntityStore2.prototype.merge = function(older, newer) {
|
|
4363
|
-
var _this = this;
|
|
4364
|
-
var dataId;
|
|
4365
|
-
if (isReference(older))
|
|
4366
|
-
older = older.__ref;
|
|
4367
|
-
if (isReference(newer))
|
|
4368
|
-
newer = newer.__ref;
|
|
4369
|
-
var existing = typeof older === "string" ? this.lookup(dataId = older) : older;
|
|
4370
|
-
var incoming = typeof newer === "string" ? this.lookup(dataId = newer) : newer;
|
|
4371
|
-
if (!incoming)
|
|
4372
|
-
return;
|
|
4373
|
-
__DEV__ ? invariant(typeof dataId === "string", "store.merge expects a string ID") : invariant(typeof dataId === "string", 1);
|
|
4374
|
-
var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming);
|
|
4375
|
-
this.data[dataId] = merged;
|
|
4376
|
-
if (merged !== existing) {
|
|
4377
|
-
delete this.refs[dataId];
|
|
4378
|
-
if (this.group.caching) {
|
|
4379
|
-
var fieldsToDirty_1 = Object.create(null);
|
|
4380
|
-
if (!existing)
|
|
4381
|
-
fieldsToDirty_1.__exists = 1;
|
|
4382
|
-
Object.keys(incoming).forEach(function(storeFieldName) {
|
|
4383
|
-
if (!existing || existing[storeFieldName] !== merged[storeFieldName]) {
|
|
4384
|
-
fieldsToDirty_1[storeFieldName] = 1;
|
|
4385
|
-
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
4386
|
-
if (fieldName !== storeFieldName && !_this.policies.hasKeyArgs(merged.__typename, fieldName)) {
|
|
4387
|
-
fieldsToDirty_1[fieldName] = 1;
|
|
4388
|
-
}
|
|
4389
|
-
if (merged[storeFieldName] === void 0 && !(_this instanceof Layer)) {
|
|
4390
|
-
delete merged[storeFieldName];
|
|
4391
|
-
}
|
|
4392
|
-
}
|
|
4393
|
-
});
|
|
4394
|
-
if (fieldsToDirty_1.__typename && !(existing && existing.__typename) && this.policies.rootTypenamesById[dataId] === merged.__typename) {
|
|
4395
|
-
delete fieldsToDirty_1.__typename;
|
|
4396
|
-
}
|
|
4397
|
-
Object.keys(fieldsToDirty_1).forEach(function(fieldName) {
|
|
4398
|
-
return _this.group.dirty(dataId, fieldName);
|
|
4399
|
-
});
|
|
4400
|
-
}
|
|
4401
|
-
}
|
|
4402
|
-
};
|
|
4403
|
-
EntityStore2.prototype.modify = function(dataId, fields) {
|
|
4404
|
-
var _this = this;
|
|
4405
|
-
var storeObject = this.lookup(dataId);
|
|
4406
|
-
if (storeObject) {
|
|
4407
|
-
var changedFields_1 = Object.create(null);
|
|
4408
|
-
var needToMerge_1 = false;
|
|
4409
|
-
var allDeleted_1 = true;
|
|
4410
|
-
var sharedDetails_1 = {
|
|
4411
|
-
DELETE,
|
|
4412
|
-
INVALIDATE,
|
|
4413
|
-
isReference,
|
|
4414
|
-
toReference: this.toReference,
|
|
4415
|
-
canRead: this.canRead,
|
|
4416
|
-
readField: function(fieldNameOrOptions, from) {
|
|
4417
|
-
return _this.policies.readField(typeof fieldNameOrOptions === "string" ? {
|
|
4418
|
-
fieldName: fieldNameOrOptions,
|
|
4419
|
-
from: from || makeReference(dataId)
|
|
4420
|
-
} : fieldNameOrOptions, { store: _this });
|
|
4421
|
-
}
|
|
4422
|
-
};
|
|
4423
|
-
Object.keys(storeObject).forEach(function(storeFieldName) {
|
|
4424
|
-
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
4425
|
-
var fieldValue = storeObject[storeFieldName];
|
|
4426
|
-
if (fieldValue === void 0)
|
|
4427
|
-
return;
|
|
4428
|
-
var modify = typeof fields === "function" ? fields : fields[storeFieldName] || fields[fieldName];
|
|
4429
|
-
if (modify) {
|
|
4430
|
-
var newValue = modify === delModifier ? DELETE : modify(maybeDeepFreeze(fieldValue), __assign(__assign({}, sharedDetails_1), { fieldName, storeFieldName, storage: _this.getStorage(dataId, storeFieldName) }));
|
|
4431
|
-
if (newValue === INVALIDATE) {
|
|
4432
|
-
_this.group.dirty(dataId, storeFieldName);
|
|
4433
|
-
} else {
|
|
4434
|
-
if (newValue === DELETE)
|
|
4435
|
-
newValue = void 0;
|
|
4436
|
-
if (newValue !== fieldValue) {
|
|
4437
|
-
changedFields_1[storeFieldName] = newValue;
|
|
4438
|
-
needToMerge_1 = true;
|
|
4439
|
-
fieldValue = newValue;
|
|
4440
|
-
}
|
|
4441
|
-
}
|
|
4442
|
-
}
|
|
4443
|
-
if (fieldValue !== void 0) {
|
|
4444
|
-
allDeleted_1 = false;
|
|
4445
|
-
}
|
|
4446
|
-
});
|
|
4447
|
-
if (needToMerge_1) {
|
|
4448
|
-
this.merge(dataId, changedFields_1);
|
|
4449
|
-
if (allDeleted_1) {
|
|
4450
|
-
if (this instanceof Layer) {
|
|
4451
|
-
this.data[dataId] = void 0;
|
|
4452
|
-
} else {
|
|
4453
|
-
delete this.data[dataId];
|
|
4454
|
-
}
|
|
4455
|
-
this.group.dirty(dataId, "__exists");
|
|
4456
|
-
}
|
|
4457
|
-
return true;
|
|
4458
|
-
}
|
|
4459
|
-
}
|
|
4460
|
-
return false;
|
|
4461
|
-
};
|
|
4462
|
-
EntityStore2.prototype.delete = function(dataId, fieldName, args) {
|
|
4463
|
-
var _a2;
|
|
4464
|
-
var storeObject = this.lookup(dataId);
|
|
4465
|
-
if (storeObject) {
|
|
4466
|
-
var typename = this.getFieldValue(storeObject, "__typename");
|
|
4467
|
-
var storeFieldName = fieldName && args ? this.policies.getStoreFieldName({ typename, fieldName, args }) : fieldName;
|
|
4468
|
-
return this.modify(dataId, storeFieldName ? (_a2 = {}, _a2[storeFieldName] = delModifier, _a2) : delModifier);
|
|
4469
|
-
}
|
|
4470
|
-
return false;
|
|
4471
|
-
};
|
|
4472
|
-
EntityStore2.prototype.evict = function(options, limit) {
|
|
4473
|
-
var evicted = false;
|
|
4474
|
-
if (options.id) {
|
|
4475
|
-
if (hasOwn.call(this.data, options.id)) {
|
|
4476
|
-
evicted = this.delete(options.id, options.fieldName, options.args);
|
|
4477
|
-
}
|
|
4478
|
-
if (this instanceof Layer && this !== limit) {
|
|
4479
|
-
evicted = this.parent.evict(options, limit) || evicted;
|
|
4480
|
-
}
|
|
4481
|
-
if (options.fieldName || evicted) {
|
|
4482
|
-
this.group.dirty(options.id, options.fieldName || "__exists");
|
|
4483
|
-
}
|
|
4484
|
-
}
|
|
4485
|
-
return evicted;
|
|
4486
|
-
};
|
|
4487
|
-
EntityStore2.prototype.clear = function() {
|
|
4488
|
-
this.replace(null);
|
|
4489
|
-
};
|
|
4490
|
-
EntityStore2.prototype.extract = function() {
|
|
4491
|
-
var _this = this;
|
|
4492
|
-
var obj = this.toObject();
|
|
4493
|
-
var extraRootIds = [];
|
|
4494
|
-
this.getRootIdSet().forEach(function(id) {
|
|
4495
|
-
if (!hasOwn.call(_this.policies.rootTypenamesById, id)) {
|
|
4496
|
-
extraRootIds.push(id);
|
|
4497
|
-
}
|
|
4498
|
-
});
|
|
4499
|
-
if (extraRootIds.length) {
|
|
4500
|
-
obj.__META = { extraRootIds: extraRootIds.sort() };
|
|
4501
|
-
}
|
|
4502
|
-
return obj;
|
|
4503
|
-
};
|
|
4504
|
-
EntityStore2.prototype.replace = function(newData) {
|
|
4505
|
-
var _this = this;
|
|
4506
|
-
Object.keys(this.data).forEach(function(dataId) {
|
|
4507
|
-
if (!(newData && hasOwn.call(newData, dataId))) {
|
|
4508
|
-
_this.delete(dataId);
|
|
4509
|
-
}
|
|
4510
|
-
});
|
|
4511
|
-
if (newData) {
|
|
4512
|
-
var __META = newData.__META, rest_1 = __rest(newData, ["__META"]);
|
|
4513
|
-
Object.keys(rest_1).forEach(function(dataId) {
|
|
4514
|
-
_this.merge(dataId, rest_1[dataId]);
|
|
4515
|
-
});
|
|
4516
|
-
if (__META) {
|
|
4517
|
-
__META.extraRootIds.forEach(this.retain, this);
|
|
4518
|
-
}
|
|
4519
|
-
}
|
|
4520
|
-
};
|
|
4521
|
-
EntityStore2.prototype.retain = function(rootId) {
|
|
4522
|
-
return this.rootIds[rootId] = (this.rootIds[rootId] || 0) + 1;
|
|
4523
|
-
};
|
|
4524
|
-
EntityStore2.prototype.release = function(rootId) {
|
|
4525
|
-
if (this.rootIds[rootId] > 0) {
|
|
4526
|
-
var count = --this.rootIds[rootId];
|
|
4527
|
-
if (!count)
|
|
4528
|
-
delete this.rootIds[rootId];
|
|
4529
|
-
return count;
|
|
4530
|
-
}
|
|
4531
|
-
return 0;
|
|
4532
|
-
};
|
|
4533
|
-
EntityStore2.prototype.getRootIdSet = function(ids) {
|
|
4534
|
-
if (ids === void 0) {
|
|
4535
|
-
ids = new Set();
|
|
4536
|
-
}
|
|
4537
|
-
Object.keys(this.rootIds).forEach(ids.add, ids);
|
|
4538
|
-
if (this instanceof Layer) {
|
|
4539
|
-
this.parent.getRootIdSet(ids);
|
|
4540
|
-
} else {
|
|
4541
|
-
Object.keys(this.policies.rootTypenamesById).forEach(ids.add, ids);
|
|
4542
|
-
}
|
|
4543
|
-
return ids;
|
|
4544
|
-
};
|
|
4545
|
-
EntityStore2.prototype.gc = function() {
|
|
4546
|
-
var _this = this;
|
|
4547
|
-
var ids = this.getRootIdSet();
|
|
4548
|
-
var snapshot = this.toObject();
|
|
4549
|
-
ids.forEach(function(id) {
|
|
4550
|
-
if (hasOwn.call(snapshot, id)) {
|
|
4551
|
-
Object.keys(_this.findChildRefIds(id)).forEach(ids.add, ids);
|
|
4552
|
-
delete snapshot[id];
|
|
4553
|
-
}
|
|
4554
|
-
});
|
|
4555
|
-
var idsToRemove = Object.keys(snapshot);
|
|
4556
|
-
if (idsToRemove.length) {
|
|
4557
|
-
var root_1 = this;
|
|
4558
|
-
while (root_1 instanceof Layer)
|
|
4559
|
-
root_1 = root_1.parent;
|
|
4560
|
-
idsToRemove.forEach(function(id) {
|
|
4561
|
-
return root_1.delete(id);
|
|
4562
|
-
});
|
|
4563
|
-
}
|
|
4564
|
-
return idsToRemove;
|
|
4565
|
-
};
|
|
4566
|
-
EntityStore2.prototype.findChildRefIds = function(dataId) {
|
|
4567
|
-
if (!hasOwn.call(this.refs, dataId)) {
|
|
4568
|
-
var found_1 = this.refs[dataId] = Object.create(null);
|
|
4569
|
-
var root = this.data[dataId];
|
|
4570
|
-
if (!root)
|
|
4571
|
-
return found_1;
|
|
4572
|
-
var workSet_1 = new Set([root]);
|
|
4573
|
-
workSet_1.forEach(function(obj) {
|
|
4574
|
-
if (isReference(obj)) {
|
|
4575
|
-
found_1[obj.__ref] = true;
|
|
4576
|
-
}
|
|
4577
|
-
if (isNonNullObject(obj)) {
|
|
4578
|
-
Object.keys(obj).forEach(function(key) {
|
|
4579
|
-
var child = obj[key];
|
|
4580
|
-
if (isNonNullObject(child)) {
|
|
4581
|
-
workSet_1.add(child);
|
|
4582
|
-
}
|
|
4583
|
-
});
|
|
4584
|
-
}
|
|
4585
|
-
});
|
|
4586
|
-
}
|
|
4587
|
-
return this.refs[dataId];
|
|
4588
|
-
};
|
|
4589
|
-
EntityStore2.prototype.makeCacheKey = function() {
|
|
4590
|
-
return this.group.keyMaker.lookupArray(arguments);
|
|
4591
|
-
};
|
|
4592
|
-
return EntityStore2;
|
|
4593
|
-
}();
|
|
4594
|
-
var CacheGroup = function() {
|
|
4595
|
-
function CacheGroup2(caching, parent) {
|
|
4596
|
-
if (parent === void 0) {
|
|
4597
|
-
parent = null;
|
|
4598
|
-
}
|
|
4599
|
-
this.caching = caching;
|
|
4600
|
-
this.parent = parent;
|
|
4601
|
-
this.d = null;
|
|
4602
|
-
this.resetCaching();
|
|
4603
|
-
}
|
|
4604
|
-
CacheGroup2.prototype.resetCaching = function() {
|
|
4605
|
-
this.d = this.caching ? dep() : null;
|
|
4606
|
-
this.keyMaker = new Trie(canUseWeakMap);
|
|
4607
|
-
};
|
|
4608
|
-
CacheGroup2.prototype.depend = function(dataId, storeFieldName) {
|
|
4609
|
-
if (this.d) {
|
|
4610
|
-
this.d(makeDepKey(dataId, storeFieldName));
|
|
4611
|
-
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
4612
|
-
if (fieldName !== storeFieldName) {
|
|
4613
|
-
this.d(makeDepKey(dataId, fieldName));
|
|
4614
|
-
}
|
|
4615
|
-
if (this.parent) {
|
|
4616
|
-
this.parent.depend(dataId, storeFieldName);
|
|
4617
|
-
}
|
|
4618
|
-
}
|
|
4619
|
-
};
|
|
4620
|
-
CacheGroup2.prototype.dirty = function(dataId, storeFieldName) {
|
|
4621
|
-
if (this.d) {
|
|
4622
|
-
this.d.dirty(makeDepKey(dataId, storeFieldName), storeFieldName === "__exists" ? "forget" : "setDirty");
|
|
4623
|
-
}
|
|
4624
|
-
};
|
|
4625
|
-
return CacheGroup2;
|
|
4626
|
-
}();
|
|
4627
|
-
function makeDepKey(dataId, storeFieldName) {
|
|
4628
|
-
return storeFieldName + "#" + dataId;
|
|
4629
|
-
}
|
|
4630
|
-
function maybeDependOnExistenceOfEntity(store, entityId) {
|
|
4631
|
-
if (supportsResultCaching(store)) {
|
|
4632
|
-
store.group.depend(entityId, "__exists");
|
|
4633
|
-
}
|
|
4634
|
-
}
|
|
4635
|
-
(function(EntityStore2) {
|
|
4636
|
-
var Root = function(_super) {
|
|
4637
|
-
__extends(Root2, _super);
|
|
4638
|
-
function Root2(_a2) {
|
|
4639
|
-
var policies = _a2.policies, _b = _a2.resultCaching, resultCaching = _b === void 0 ? true : _b, seed = _a2.seed;
|
|
4640
|
-
var _this = _super.call(this, policies, new CacheGroup(resultCaching)) || this;
|
|
4641
|
-
_this.stump = new Stump(_this);
|
|
4642
|
-
_this.storageTrie = new Trie(canUseWeakMap);
|
|
4643
|
-
if (seed)
|
|
4644
|
-
_this.replace(seed);
|
|
4645
|
-
return _this;
|
|
4646
|
-
}
|
|
4647
|
-
Root2.prototype.addLayer = function(layerId, replay) {
|
|
4648
|
-
return this.stump.addLayer(layerId, replay);
|
|
4649
|
-
};
|
|
4650
|
-
Root2.prototype.removeLayer = function() {
|
|
4651
|
-
return this;
|
|
4652
|
-
};
|
|
4653
|
-
Root2.prototype.getStorage = function() {
|
|
4654
|
-
return this.storageTrie.lookupArray(arguments);
|
|
4655
|
-
};
|
|
4656
|
-
return Root2;
|
|
4657
|
-
}(EntityStore2);
|
|
4658
|
-
EntityStore2.Root = Root;
|
|
4659
|
-
})(EntityStore || (EntityStore = {}));
|
|
4660
|
-
var Layer = function(_super) {
|
|
4661
|
-
__extends(Layer2, _super);
|
|
4662
|
-
function Layer2(id, parent, replay, group) {
|
|
4663
|
-
var _this = _super.call(this, parent.policies, group) || this;
|
|
4664
|
-
_this.id = id;
|
|
4665
|
-
_this.parent = parent;
|
|
4666
|
-
_this.replay = replay;
|
|
4667
|
-
_this.group = group;
|
|
4668
|
-
replay(_this);
|
|
4669
|
-
return _this;
|
|
4670
|
-
}
|
|
4671
|
-
Layer2.prototype.addLayer = function(layerId, replay) {
|
|
4672
|
-
return new Layer2(layerId, this, replay, this.group);
|
|
4673
|
-
};
|
|
4674
|
-
Layer2.prototype.removeLayer = function(layerId) {
|
|
4675
|
-
var _this = this;
|
|
4676
|
-
var parent = this.parent.removeLayer(layerId);
|
|
4677
|
-
if (layerId === this.id) {
|
|
4678
|
-
if (this.group.caching) {
|
|
4679
|
-
Object.keys(this.data).forEach(function(dataId) {
|
|
4680
|
-
var ownStoreObject = _this.data[dataId];
|
|
4681
|
-
var parentStoreObject = parent["lookup"](dataId);
|
|
4682
|
-
if (!parentStoreObject) {
|
|
4683
|
-
_this.delete(dataId);
|
|
4684
|
-
} else if (!ownStoreObject) {
|
|
4685
|
-
_this.group.dirty(dataId, "__exists");
|
|
4686
|
-
Object.keys(parentStoreObject).forEach(function(storeFieldName) {
|
|
4687
|
-
_this.group.dirty(dataId, storeFieldName);
|
|
4688
|
-
});
|
|
4689
|
-
} else if (ownStoreObject !== parentStoreObject) {
|
|
4690
|
-
Object.keys(ownStoreObject).forEach(function(storeFieldName) {
|
|
4691
|
-
if (!equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
|
|
4692
|
-
_this.group.dirty(dataId, storeFieldName);
|
|
4693
|
-
}
|
|
4694
|
-
});
|
|
4695
|
-
}
|
|
4696
|
-
});
|
|
4697
|
-
}
|
|
4698
|
-
return parent;
|
|
4699
|
-
}
|
|
4700
|
-
if (parent === this.parent)
|
|
4701
|
-
return this;
|
|
4702
|
-
return parent.addLayer(this.id, this.replay);
|
|
4703
|
-
};
|
|
4704
|
-
Layer2.prototype.toObject = function() {
|
|
4705
|
-
return __assign(__assign({}, this.parent.toObject()), this.data);
|
|
4706
|
-
};
|
|
4707
|
-
Layer2.prototype.findChildRefIds = function(dataId) {
|
|
4708
|
-
var fromParent = this.parent.findChildRefIds(dataId);
|
|
4709
|
-
return hasOwn.call(this.data, dataId) ? __assign(__assign({}, fromParent), _super.prototype.findChildRefIds.call(this, dataId)) : fromParent;
|
|
4710
|
-
};
|
|
4711
|
-
Layer2.prototype.getStorage = function() {
|
|
4712
|
-
var p = this.parent;
|
|
4713
|
-
while (p.parent)
|
|
4714
|
-
p = p.parent;
|
|
4715
|
-
return p.getStorage.apply(p, arguments);
|
|
4716
|
-
};
|
|
4717
|
-
return Layer2;
|
|
4718
|
-
}(EntityStore);
|
|
4719
|
-
var Stump = function(_super) {
|
|
4720
|
-
__extends(Stump2, _super);
|
|
4721
|
-
function Stump2(root) {
|
|
4722
|
-
return _super.call(this, "EntityStore.Stump", root, function() {
|
|
4723
|
-
}, new CacheGroup(root.group.caching, root.group)) || this;
|
|
4724
|
-
}
|
|
4725
|
-
Stump2.prototype.removeLayer = function() {
|
|
4726
|
-
return this;
|
|
4727
|
-
};
|
|
4728
|
-
Stump2.prototype.merge = function() {
|
|
4729
|
-
return this.parent.merge.apply(this.parent, arguments);
|
|
4730
|
-
};
|
|
4731
|
-
return Stump2;
|
|
4732
|
-
}(Layer);
|
|
4733
|
-
function storeObjectReconciler(existingObject, incomingObject, property) {
|
|
4734
|
-
var existingValue = existingObject[property];
|
|
4735
|
-
var incomingValue = incomingObject[property];
|
|
4736
|
-
return equal(existingValue, incomingValue) ? existingValue : incomingValue;
|
|
4737
|
-
}
|
|
4738
|
-
function supportsResultCaching(store) {
|
|
4739
|
-
return !!(store instanceof EntityStore && store.group.caching);
|
|
4740
|
-
}
|
|
4741
|
-
function shallowCopy(value) {
|
|
4742
|
-
if (isNonNullObject(value)) {
|
|
4743
|
-
return Array.isArray(value) ? value.slice(0) : __assign({ __proto__: Object.getPrototypeOf(value) }, value);
|
|
4744
|
-
}
|
|
4745
|
-
return value;
|
|
4746
|
-
}
|
|
4747
|
-
var ObjectCanon = function() {
|
|
4748
|
-
function ObjectCanon2() {
|
|
4749
|
-
this.known = new (canUseWeakSet ? WeakSet : Set)();
|
|
4750
|
-
this.pool = new Trie(canUseWeakMap);
|
|
4751
|
-
this.passes = new WeakMap();
|
|
4752
|
-
this.keysByJSON = new Map();
|
|
4753
|
-
this.empty = this.admit({});
|
|
4754
|
-
}
|
|
4755
|
-
ObjectCanon2.prototype.isKnown = function(value) {
|
|
4756
|
-
return isNonNullObject(value) && this.known.has(value);
|
|
4757
|
-
};
|
|
4758
|
-
ObjectCanon2.prototype.pass = function(value) {
|
|
4759
|
-
if (isNonNullObject(value)) {
|
|
4760
|
-
var copy = shallowCopy(value);
|
|
4761
|
-
this.passes.set(copy, value);
|
|
4762
|
-
return copy;
|
|
4763
|
-
}
|
|
4764
|
-
return value;
|
|
4765
|
-
};
|
|
4766
|
-
ObjectCanon2.prototype.admit = function(value) {
|
|
4767
|
-
var _this = this;
|
|
4768
|
-
if (isNonNullObject(value)) {
|
|
4769
|
-
var original = this.passes.get(value);
|
|
4770
|
-
if (original)
|
|
4771
|
-
return original;
|
|
4772
|
-
var proto = Object.getPrototypeOf(value);
|
|
4773
|
-
switch (proto) {
|
|
4774
|
-
case Array.prototype: {
|
|
4775
|
-
if (this.known.has(value))
|
|
4776
|
-
return value;
|
|
4777
|
-
var array = value.map(this.admit, this);
|
|
4778
|
-
var node = this.pool.lookupArray(array);
|
|
4779
|
-
if (!node.array) {
|
|
4780
|
-
this.known.add(node.array = array);
|
|
4781
|
-
if (__DEV__) {
|
|
4782
|
-
Object.freeze(array);
|
|
4783
|
-
}
|
|
4784
|
-
}
|
|
4785
|
-
return node.array;
|
|
4786
|
-
}
|
|
4787
|
-
case null:
|
|
4788
|
-
case Object.prototype: {
|
|
4789
|
-
if (this.known.has(value))
|
|
4790
|
-
return value;
|
|
4791
|
-
var proto_1 = Object.getPrototypeOf(value);
|
|
4792
|
-
var array_1 = [proto_1];
|
|
4793
|
-
var keys = this.sortedKeys(value);
|
|
4794
|
-
array_1.push(keys.json);
|
|
4795
|
-
var firstValueIndex_1 = array_1.length;
|
|
4796
|
-
keys.sorted.forEach(function(key) {
|
|
4797
|
-
array_1.push(_this.admit(value[key]));
|
|
4798
|
-
});
|
|
4799
|
-
var node = this.pool.lookupArray(array_1);
|
|
4800
|
-
if (!node.object) {
|
|
4801
|
-
var obj_1 = node.object = Object.create(proto_1);
|
|
4802
|
-
this.known.add(obj_1);
|
|
4803
|
-
keys.sorted.forEach(function(key, i) {
|
|
4804
|
-
obj_1[key] = array_1[firstValueIndex_1 + i];
|
|
4805
|
-
});
|
|
4806
|
-
if (__DEV__) {
|
|
4807
|
-
Object.freeze(obj_1);
|
|
4808
|
-
}
|
|
4809
|
-
}
|
|
4810
|
-
return node.object;
|
|
4811
|
-
}
|
|
4812
|
-
}
|
|
4813
|
-
}
|
|
4814
|
-
return value;
|
|
4815
|
-
};
|
|
4816
|
-
ObjectCanon2.prototype.sortedKeys = function(obj) {
|
|
4817
|
-
var keys = Object.keys(obj);
|
|
4818
|
-
var node = this.pool.lookupArray(keys);
|
|
4819
|
-
if (!node.keys) {
|
|
4820
|
-
keys.sort();
|
|
4821
|
-
var json = JSON.stringify(keys);
|
|
4822
|
-
if (!(node.keys = this.keysByJSON.get(json))) {
|
|
4823
|
-
this.keysByJSON.set(json, node.keys = { sorted: keys, json });
|
|
4824
|
-
}
|
|
4825
|
-
}
|
|
4826
|
-
return node.keys;
|
|
4827
|
-
};
|
|
4828
|
-
return ObjectCanon2;
|
|
4829
|
-
}();
|
|
4830
|
-
var canonicalStringify = Object.assign(function(value) {
|
|
4831
|
-
if (isNonNullObject(value)) {
|
|
4832
|
-
if (stringifyCanon === void 0) {
|
|
4833
|
-
resetCanonicalStringify();
|
|
4834
|
-
}
|
|
4835
|
-
var canonical = stringifyCanon.admit(value);
|
|
4836
|
-
var json = stringifyCache.get(canonical);
|
|
4837
|
-
if (json === void 0) {
|
|
4838
|
-
stringifyCache.set(canonical, json = JSON.stringify(canonical));
|
|
4839
|
-
}
|
|
4840
|
-
return json;
|
|
4841
|
-
}
|
|
4842
|
-
return JSON.stringify(value);
|
|
4843
|
-
}, {
|
|
4844
|
-
reset: resetCanonicalStringify
|
|
4845
|
-
});
|
|
4846
|
-
var stringifyCanon;
|
|
4847
|
-
var stringifyCache;
|
|
4848
|
-
function resetCanonicalStringify() {
|
|
4849
|
-
stringifyCanon = new ObjectCanon();
|
|
4850
|
-
stringifyCache = new (canUseWeakMap ? WeakMap : Map)();
|
|
4851
|
-
}
|
|
4852
|
-
function execSelectionSetKeyArgs(options) {
|
|
4853
|
-
return [
|
|
4854
|
-
options.selectionSet,
|
|
4855
|
-
options.objectOrReference,
|
|
4856
|
-
options.context,
|
|
4857
|
-
options.context.canonizeResults
|
|
4858
|
-
];
|
|
4859
|
-
}
|
|
4860
|
-
var StoreReader = function() {
|
|
4861
|
-
function StoreReader2(config) {
|
|
4862
|
-
var _this = this;
|
|
4863
|
-
this.knownResults = new (canUseWeakMap ? WeakMap : Map)();
|
|
4864
|
-
this.config = compact(config, {
|
|
4865
|
-
addTypename: config.addTypename !== false,
|
|
4866
|
-
canonizeResults: shouldCanonizeResults(config)
|
|
4867
|
-
});
|
|
4868
|
-
this.canon = config.canon || new ObjectCanon();
|
|
4869
|
-
this.executeSelectionSet = wrap(function(options) {
|
|
4870
|
-
var _a2;
|
|
4871
|
-
var canonizeResults = options.context.canonizeResults;
|
|
4872
|
-
var peekArgs = execSelectionSetKeyArgs(options);
|
|
4873
|
-
peekArgs[3] = !canonizeResults;
|
|
4874
|
-
var other = (_a2 = _this.executeSelectionSet).peek.apply(_a2, peekArgs);
|
|
4875
|
-
if (other) {
|
|
4876
|
-
if (canonizeResults) {
|
|
4877
|
-
return __assign(__assign({}, other), { result: _this.canon.admit(other.result) });
|
|
4878
|
-
}
|
|
4879
|
-
return other;
|
|
4880
|
-
}
|
|
4881
|
-
maybeDependOnExistenceOfEntity(options.context.store, options.enclosingRef.__ref);
|
|
4882
|
-
return _this.execSelectionSetImpl(options);
|
|
4883
|
-
}, {
|
|
4884
|
-
max: this.config.resultCacheMaxSize,
|
|
4885
|
-
keyArgs: execSelectionSetKeyArgs,
|
|
4886
|
-
makeCacheKey: function(selectionSet, parent, context, canonizeResults) {
|
|
4887
|
-
if (supportsResultCaching(context.store)) {
|
|
4888
|
-
return context.store.makeCacheKey(selectionSet, isReference(parent) ? parent.__ref : parent, context.varString, canonizeResults);
|
|
4889
|
-
}
|
|
4890
|
-
}
|
|
4891
|
-
});
|
|
4892
|
-
this.executeSubSelectedArray = wrap(function(options) {
|
|
4893
|
-
maybeDependOnExistenceOfEntity(options.context.store, options.enclosingRef.__ref);
|
|
4894
|
-
return _this.execSubSelectedArrayImpl(options);
|
|
4895
|
-
}, {
|
|
4896
|
-
max: this.config.resultCacheMaxSize,
|
|
4897
|
-
makeCacheKey: function(_a2) {
|
|
4898
|
-
var field = _a2.field, array = _a2.array, context = _a2.context;
|
|
4899
|
-
if (supportsResultCaching(context.store)) {
|
|
4900
|
-
return context.store.makeCacheKey(field, array, context.varString);
|
|
4901
|
-
}
|
|
4902
|
-
}
|
|
4903
|
-
});
|
|
4904
|
-
}
|
|
4905
|
-
StoreReader2.prototype.resetCanon = function() {
|
|
4906
|
-
this.canon = new ObjectCanon();
|
|
4907
|
-
};
|
|
4908
|
-
StoreReader2.prototype.diffQueryAgainstStore = function(_a2) {
|
|
4909
|
-
var store = _a2.store, query = _a2.query, _b = _a2.rootId, rootId = _b === void 0 ? "ROOT_QUERY" : _b, variables = _a2.variables, _c = _a2.returnPartialData, returnPartialData = _c === void 0 ? true : _c, _d = _a2.canonizeResults, canonizeResults = _d === void 0 ? this.config.canonizeResults : _d;
|
|
4910
|
-
var policies = this.config.cache.policies;
|
|
4911
|
-
variables = __assign(__assign({}, getDefaultValues(getQueryDefinition(query))), variables);
|
|
4912
|
-
var rootRef = makeReference(rootId);
|
|
4913
|
-
var merger = new DeepMerger();
|
|
4914
|
-
var execResult = this.executeSelectionSet({
|
|
4915
|
-
selectionSet: getMainDefinition(query).selectionSet,
|
|
4916
|
-
objectOrReference: rootRef,
|
|
4917
|
-
enclosingRef: rootRef,
|
|
4918
|
-
context: {
|
|
4919
|
-
store,
|
|
4920
|
-
query,
|
|
4921
|
-
policies,
|
|
4922
|
-
variables,
|
|
4923
|
-
varString: canonicalStringify(variables),
|
|
4924
|
-
canonizeResults,
|
|
4925
|
-
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
4926
|
-
merge: function(a, b) {
|
|
4927
|
-
return merger.merge(a, b);
|
|
4928
|
-
}
|
|
4929
|
-
}
|
|
4930
|
-
});
|
|
4931
|
-
var missing;
|
|
4932
|
-
if (execResult.missing) {
|
|
4933
|
-
missing = [new MissingFieldError(firstMissing(execResult.missing), execResult.missing, query, variables)];
|
|
4934
|
-
if (!returnPartialData) {
|
|
4935
|
-
throw missing[0];
|
|
4936
|
-
}
|
|
4937
|
-
}
|
|
4938
|
-
return {
|
|
4939
|
-
result: execResult.result,
|
|
4940
|
-
complete: !missing,
|
|
4941
|
-
missing
|
|
4942
|
-
};
|
|
4943
|
-
};
|
|
4944
|
-
StoreReader2.prototype.isFresh = function(result, parent, selectionSet, context) {
|
|
4945
|
-
if (supportsResultCaching(context.store) && this.knownResults.get(result) === selectionSet) {
|
|
4946
|
-
var latest = this.executeSelectionSet.peek(selectionSet, parent, context, this.canon.isKnown(result));
|
|
4947
|
-
if (latest && result === latest.result) {
|
|
4948
|
-
return true;
|
|
4949
|
-
}
|
|
4950
|
-
}
|
|
4951
|
-
return false;
|
|
4952
|
-
};
|
|
4953
|
-
StoreReader2.prototype.execSelectionSetImpl = function(_a2) {
|
|
4954
|
-
var _this = this;
|
|
4955
|
-
var selectionSet = _a2.selectionSet, objectOrReference = _a2.objectOrReference, enclosingRef = _a2.enclosingRef, context = _a2.context;
|
|
4956
|
-
if (isReference(objectOrReference) && !context.policies.rootTypenamesById[objectOrReference.__ref] && !context.store.has(objectOrReference.__ref)) {
|
|
4957
|
-
return {
|
|
4958
|
-
result: this.canon.empty,
|
|
4959
|
-
missing: "Dangling reference to missing ".concat(objectOrReference.__ref, " object")
|
|
4960
|
-
};
|
|
4961
|
-
}
|
|
4962
|
-
var variables = context.variables, policies = context.policies, store = context.store;
|
|
4963
|
-
var typename = store.getFieldValue(objectOrReference, "__typename");
|
|
4964
|
-
var result = {};
|
|
4965
|
-
var missing;
|
|
4966
|
-
if (this.config.addTypename && typeof typename === "string" && !policies.rootIdsByTypename[typename]) {
|
|
4967
|
-
result = { __typename: typename };
|
|
4968
|
-
}
|
|
4969
|
-
function handleMissing(result2, resultName) {
|
|
4970
|
-
var _a3;
|
|
4971
|
-
if (result2.missing) {
|
|
4972
|
-
missing = context.merge(missing, (_a3 = {}, _a3[resultName] = result2.missing, _a3));
|
|
4973
|
-
}
|
|
4974
|
-
return result2.result;
|
|
4975
|
-
}
|
|
4976
|
-
var workSet = new Set(selectionSet.selections);
|
|
4977
|
-
workSet.forEach(function(selection) {
|
|
4978
|
-
var _a3, _b;
|
|
4979
|
-
if (!shouldInclude(selection, variables))
|
|
4980
|
-
return;
|
|
4981
|
-
if (isField(selection)) {
|
|
4982
|
-
var fieldValue = policies.readField({
|
|
4983
|
-
fieldName: selection.name.value,
|
|
4984
|
-
field: selection,
|
|
4985
|
-
variables: context.variables,
|
|
4986
|
-
from: objectOrReference
|
|
4987
|
-
}, context);
|
|
4988
|
-
var resultName = resultKeyNameFromField(selection);
|
|
4989
|
-
if (fieldValue === void 0) {
|
|
4990
|
-
if (!addTypenameToDocument.added(selection)) {
|
|
4991
|
-
missing = context.merge(missing, (_a3 = {}, _a3[resultName] = "Can't find field '".concat(selection.name.value, "' on ").concat(isReference(objectOrReference) ? objectOrReference.__ref + " object" : "object " + JSON.stringify(objectOrReference, null, 2)), _a3));
|
|
4992
|
-
}
|
|
4993
|
-
} else if (Array.isArray(fieldValue)) {
|
|
4994
|
-
fieldValue = handleMissing(_this.executeSubSelectedArray({
|
|
4995
|
-
field: selection,
|
|
4996
|
-
array: fieldValue,
|
|
4997
|
-
enclosingRef,
|
|
4998
|
-
context
|
|
4999
|
-
}), resultName);
|
|
5000
|
-
} else if (!selection.selectionSet) {
|
|
5001
|
-
if (context.canonizeResults) {
|
|
5002
|
-
fieldValue = _this.canon.pass(fieldValue);
|
|
5003
|
-
}
|
|
5004
|
-
} else if (fieldValue != null) {
|
|
5005
|
-
fieldValue = handleMissing(_this.executeSelectionSet({
|
|
5006
|
-
selectionSet: selection.selectionSet,
|
|
5007
|
-
objectOrReference: fieldValue,
|
|
5008
|
-
enclosingRef: isReference(fieldValue) ? fieldValue : enclosingRef,
|
|
5009
|
-
context
|
|
5010
|
-
}), resultName);
|
|
5011
|
-
}
|
|
5012
|
-
if (fieldValue !== void 0) {
|
|
5013
|
-
result = context.merge(result, (_b = {}, _b[resultName] = fieldValue, _b));
|
|
5014
|
-
}
|
|
5015
|
-
} else {
|
|
5016
|
-
var fragment = getFragmentFromSelection(selection, context.fragmentMap);
|
|
5017
|
-
if (fragment && policies.fragmentMatches(fragment, typename)) {
|
|
5018
|
-
fragment.selectionSet.selections.forEach(workSet.add, workSet);
|
|
5019
|
-
}
|
|
5020
|
-
}
|
|
5021
|
-
});
|
|
5022
|
-
var finalResult = { result, missing };
|
|
5023
|
-
var frozen = context.canonizeResults ? this.canon.admit(finalResult) : maybeDeepFreeze(finalResult);
|
|
5024
|
-
if (frozen.result) {
|
|
5025
|
-
this.knownResults.set(frozen.result, selectionSet);
|
|
5026
|
-
}
|
|
5027
|
-
return frozen;
|
|
5028
|
-
};
|
|
5029
|
-
StoreReader2.prototype.execSubSelectedArrayImpl = function(_a2) {
|
|
5030
|
-
var _this = this;
|
|
5031
|
-
var field = _a2.field, array = _a2.array, enclosingRef = _a2.enclosingRef, context = _a2.context;
|
|
5032
|
-
var missing;
|
|
5033
|
-
function handleMissing(childResult, i) {
|
|
5034
|
-
var _a3;
|
|
5035
|
-
if (childResult.missing) {
|
|
5036
|
-
missing = context.merge(missing, (_a3 = {}, _a3[i] = childResult.missing, _a3));
|
|
5037
|
-
}
|
|
5038
|
-
return childResult.result;
|
|
5039
|
-
}
|
|
5040
|
-
if (field.selectionSet) {
|
|
5041
|
-
array = array.filter(context.store.canRead);
|
|
5042
|
-
}
|
|
5043
|
-
array = array.map(function(item, i) {
|
|
5044
|
-
if (item === null) {
|
|
5045
|
-
return null;
|
|
5046
|
-
}
|
|
5047
|
-
if (Array.isArray(item)) {
|
|
5048
|
-
return handleMissing(_this.executeSubSelectedArray({
|
|
5049
|
-
field,
|
|
5050
|
-
array: item,
|
|
5051
|
-
enclosingRef,
|
|
5052
|
-
context
|
|
5053
|
-
}), i);
|
|
5054
|
-
}
|
|
5055
|
-
if (field.selectionSet) {
|
|
5056
|
-
return handleMissing(_this.executeSelectionSet({
|
|
5057
|
-
selectionSet: field.selectionSet,
|
|
5058
|
-
objectOrReference: item,
|
|
5059
|
-
enclosingRef: isReference(item) ? item : enclosingRef,
|
|
5060
|
-
context
|
|
5061
|
-
}), i);
|
|
5062
|
-
}
|
|
5063
|
-
if (__DEV__) {
|
|
5064
|
-
assertSelectionSetForIdValue(context.store, field, item);
|
|
5065
|
-
}
|
|
5066
|
-
return item;
|
|
5067
|
-
});
|
|
5068
|
-
return {
|
|
5069
|
-
result: context.canonizeResults ? this.canon.admit(array) : array,
|
|
5070
|
-
missing
|
|
5071
|
-
};
|
|
5072
|
-
};
|
|
5073
|
-
return StoreReader2;
|
|
5074
|
-
}();
|
|
5075
|
-
function firstMissing(tree) {
|
|
5076
|
-
try {
|
|
5077
|
-
JSON.stringify(tree, function(_, value) {
|
|
5078
|
-
if (typeof value === "string")
|
|
5079
|
-
throw value;
|
|
5080
|
-
return value;
|
|
5081
|
-
});
|
|
5082
|
-
} catch (result) {
|
|
5083
|
-
return result;
|
|
5084
|
-
}
|
|
5085
|
-
}
|
|
5086
|
-
function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
5087
|
-
if (!field.selectionSet) {
|
|
5088
|
-
var workSet_1 = new Set([fieldValue]);
|
|
5089
|
-
workSet_1.forEach(function(value) {
|
|
5090
|
-
if (isNonNullObject(value)) {
|
|
5091
|
-
__DEV__ ? invariant(!isReference(value), "Missing selection set for object of type ".concat(getTypenameFromStoreObject(store, value), " returned for query field ").concat(field.name.value)) : invariant(!isReference(value), 5);
|
|
5092
|
-
Object.values(value).forEach(workSet_1.add, workSet_1);
|
|
5093
|
-
}
|
|
5094
|
-
});
|
|
5095
|
-
}
|
|
5096
|
-
}
|
|
5097
|
-
var cacheSlot = new Slot();
|
|
5098
|
-
var cacheInfoMap = new WeakMap();
|
|
5099
|
-
function getCacheInfo(cache) {
|
|
5100
|
-
var info = cacheInfoMap.get(cache);
|
|
5101
|
-
if (!info) {
|
|
5102
|
-
cacheInfoMap.set(cache, info = {
|
|
5103
|
-
vars: new Set(),
|
|
5104
|
-
dep: dep()
|
|
5105
|
-
});
|
|
5106
|
-
}
|
|
5107
|
-
return info;
|
|
5108
|
-
}
|
|
5109
|
-
function forgetCache(cache) {
|
|
5110
|
-
getCacheInfo(cache).vars.forEach(function(rv) {
|
|
5111
|
-
return rv.forgetCache(cache);
|
|
5112
|
-
});
|
|
5113
|
-
}
|
|
5114
|
-
function recallCache(cache) {
|
|
5115
|
-
getCacheInfo(cache).vars.forEach(function(rv) {
|
|
5116
|
-
return rv.attachCache(cache);
|
|
5117
|
-
});
|
|
5118
|
-
}
|
|
5119
|
-
function makeVar(value) {
|
|
5120
|
-
var caches2 = new Set();
|
|
5121
|
-
var listeners = new Set();
|
|
5122
|
-
var rv = function(newValue) {
|
|
5123
|
-
if (arguments.length > 0) {
|
|
5124
|
-
if (value !== newValue) {
|
|
5125
|
-
value = newValue;
|
|
5126
|
-
caches2.forEach(function(cache2) {
|
|
5127
|
-
getCacheInfo(cache2).dep.dirty(rv);
|
|
5128
|
-
broadcast(cache2);
|
|
5129
|
-
});
|
|
5130
|
-
var oldListeners = Array.from(listeners);
|
|
5131
|
-
listeners.clear();
|
|
5132
|
-
oldListeners.forEach(function(listener) {
|
|
5133
|
-
return listener(value);
|
|
5134
|
-
});
|
|
5135
|
-
}
|
|
5136
|
-
} else {
|
|
5137
|
-
var cache = cacheSlot.getValue();
|
|
5138
|
-
if (cache) {
|
|
5139
|
-
attach(cache);
|
|
5140
|
-
getCacheInfo(cache).dep(rv);
|
|
5141
|
-
}
|
|
5142
|
-
}
|
|
5143
|
-
return value;
|
|
5144
|
-
};
|
|
5145
|
-
rv.onNextChange = function(listener) {
|
|
5146
|
-
listeners.add(listener);
|
|
5147
|
-
return function() {
|
|
5148
|
-
listeners.delete(listener);
|
|
5149
|
-
};
|
|
5150
|
-
};
|
|
5151
|
-
var attach = rv.attachCache = function(cache) {
|
|
5152
|
-
caches2.add(cache);
|
|
5153
|
-
getCacheInfo(cache).vars.add(rv);
|
|
5154
|
-
return rv;
|
|
5155
|
-
};
|
|
5156
|
-
rv.forgetCache = function(cache) {
|
|
5157
|
-
return caches2.delete(cache);
|
|
5158
|
-
};
|
|
5159
|
-
return rv;
|
|
5160
|
-
}
|
|
5161
|
-
function broadcast(cache) {
|
|
5162
|
-
if (cache.broadcastWatches) {
|
|
5163
|
-
cache.broadcastWatches();
|
|
5164
|
-
}
|
|
5165
|
-
}
|
|
5166
|
-
var specifierInfoCache = Object.create(null);
|
|
5167
|
-
function lookupSpecifierInfo(spec) {
|
|
5168
|
-
var cacheKey = JSON.stringify(spec);
|
|
5169
|
-
return specifierInfoCache[cacheKey] || (specifierInfoCache[cacheKey] = Object.create(null));
|
|
5170
|
-
}
|
|
5171
|
-
function keyFieldsFnFromSpecifier(specifier) {
|
|
5172
|
-
var info = lookupSpecifierInfo(specifier);
|
|
5173
|
-
return info.keyFieldsFn || (info.keyFieldsFn = function(object, context) {
|
|
5174
|
-
var extract = function(from, key) {
|
|
5175
|
-
return context.readField(key, from);
|
|
5176
|
-
};
|
|
5177
|
-
var keyObject = context.keyObject = collectSpecifierPaths(specifier, function(schemaKeyPath) {
|
|
5178
|
-
var extracted = extractKeyPath(context.storeObject, schemaKeyPath, extract);
|
|
5179
|
-
if (extracted === void 0 && object !== context.storeObject && hasOwn.call(object, schemaKeyPath[0])) {
|
|
5180
|
-
extracted = extractKeyPath(object, schemaKeyPath, extractKey);
|
|
5181
|
-
}
|
|
5182
|
-
__DEV__ ? invariant(extracted !== void 0, "Missing field '".concat(schemaKeyPath.join("."), "' while extracting keyFields from ").concat(JSON.stringify(object))) : invariant(extracted !== void 0, 2);
|
|
5183
|
-
return extracted;
|
|
5184
|
-
});
|
|
5185
|
-
return "".concat(context.typename, ":").concat(JSON.stringify(keyObject));
|
|
5186
|
-
});
|
|
5187
|
-
}
|
|
5188
|
-
function keyArgsFnFromSpecifier(specifier) {
|
|
5189
|
-
var info = lookupSpecifierInfo(specifier);
|
|
5190
|
-
return info.keyArgsFn || (info.keyArgsFn = function(args, _a2) {
|
|
5191
|
-
var field = _a2.field, variables = _a2.variables, fieldName = _a2.fieldName;
|
|
5192
|
-
var collected = collectSpecifierPaths(specifier, function(keyPath) {
|
|
5193
|
-
var firstKey = keyPath[0];
|
|
5194
|
-
var firstChar = firstKey.charAt(0);
|
|
5195
|
-
if (firstChar === "@") {
|
|
5196
|
-
if (field && isNonEmptyArray(field.directives)) {
|
|
5197
|
-
var directiveName_1 = firstKey.slice(1);
|
|
5198
|
-
var d = field.directives.find(function(d2) {
|
|
5199
|
-
return d2.name.value === directiveName_1;
|
|
5200
|
-
});
|
|
5201
|
-
var directiveArgs = d && argumentsObjectFromField(d, variables);
|
|
5202
|
-
return directiveArgs && extractKeyPath(directiveArgs, keyPath.slice(1));
|
|
5203
|
-
}
|
|
5204
|
-
return;
|
|
5205
|
-
}
|
|
5206
|
-
if (firstChar === "$") {
|
|
5207
|
-
var variableName = firstKey.slice(1);
|
|
5208
|
-
if (variables && hasOwn.call(variables, variableName)) {
|
|
5209
|
-
var varKeyPath = keyPath.slice(0);
|
|
5210
|
-
varKeyPath[0] = variableName;
|
|
5211
|
-
return extractKeyPath(variables, varKeyPath);
|
|
5212
|
-
}
|
|
5213
|
-
return;
|
|
5214
|
-
}
|
|
5215
|
-
if (args) {
|
|
5216
|
-
return extractKeyPath(args, keyPath);
|
|
5217
|
-
}
|
|
5218
|
-
});
|
|
5219
|
-
var suffix = JSON.stringify(collected);
|
|
5220
|
-
if (args || suffix !== "{}") {
|
|
5221
|
-
fieldName += ":" + suffix;
|
|
5222
|
-
}
|
|
5223
|
-
return fieldName;
|
|
5224
|
-
});
|
|
5225
|
-
}
|
|
5226
|
-
function collectSpecifierPaths(specifier, extractor) {
|
|
5227
|
-
var merger = new DeepMerger();
|
|
5228
|
-
return getSpecifierPaths(specifier).reduce(function(collected, path2) {
|
|
5229
|
-
var _a2;
|
|
5230
|
-
var toMerge = extractor(path2);
|
|
5231
|
-
if (toMerge !== void 0) {
|
|
5232
|
-
for (var i = path2.length - 1; i >= 0; --i) {
|
|
5233
|
-
toMerge = (_a2 = {}, _a2[path2[i]] = toMerge, _a2);
|
|
5234
|
-
}
|
|
5235
|
-
collected = merger.merge(collected, toMerge);
|
|
5236
|
-
}
|
|
5237
|
-
return collected;
|
|
5238
|
-
}, Object.create(null));
|
|
5239
|
-
}
|
|
5240
|
-
function getSpecifierPaths(spec) {
|
|
5241
|
-
var info = lookupSpecifierInfo(spec);
|
|
5242
|
-
if (!info.paths) {
|
|
5243
|
-
var paths_1 = info.paths = [];
|
|
5244
|
-
var currentPath_1 = [];
|
|
5245
|
-
spec.forEach(function(s, i) {
|
|
5246
|
-
if (Array.isArray(s)) {
|
|
5247
|
-
getSpecifierPaths(s).forEach(function(p) {
|
|
5248
|
-
return paths_1.push(currentPath_1.concat(p));
|
|
5249
|
-
});
|
|
5250
|
-
currentPath_1.length = 0;
|
|
5251
|
-
} else {
|
|
5252
|
-
currentPath_1.push(s);
|
|
5253
|
-
if (!Array.isArray(spec[i + 1])) {
|
|
5254
|
-
paths_1.push(currentPath_1.slice(0));
|
|
5255
|
-
currentPath_1.length = 0;
|
|
5256
|
-
}
|
|
5257
|
-
}
|
|
5258
|
-
});
|
|
5259
|
-
}
|
|
5260
|
-
return info.paths;
|
|
5261
|
-
}
|
|
5262
|
-
function extractKey(object, key) {
|
|
5263
|
-
return object[key];
|
|
5264
|
-
}
|
|
5265
|
-
function extractKeyPath(object, path2, extract) {
|
|
5266
|
-
extract = extract || extractKey;
|
|
5267
|
-
return normalize(path2.reduce(function reducer(obj, key) {
|
|
5268
|
-
return Array.isArray(obj) ? obj.map(function(child) {
|
|
5269
|
-
return reducer(child, key);
|
|
5270
|
-
}) : obj && extract(obj, key);
|
|
5271
|
-
}, object));
|
|
5272
|
-
}
|
|
5273
|
-
function normalize(value) {
|
|
5274
|
-
if (isNonNullObject(value)) {
|
|
5275
|
-
if (Array.isArray(value)) {
|
|
5276
|
-
return value.map(normalize);
|
|
5277
|
-
}
|
|
5278
|
-
return collectSpecifierPaths(Object.keys(value).sort(), function(path2) {
|
|
5279
|
-
return extractKeyPath(value, path2);
|
|
5280
|
-
});
|
|
5281
|
-
}
|
|
5282
|
-
return value;
|
|
5283
|
-
}
|
|
5284
|
-
getStoreKeyName.setStringify(canonicalStringify);
|
|
5285
|
-
function argsFromFieldSpecifier(spec) {
|
|
5286
|
-
return spec.args !== void 0 ? spec.args : spec.field ? argumentsObjectFromField(spec.field, spec.variables) : null;
|
|
5287
|
-
}
|
|
5288
|
-
var nullKeyFieldsFn = function() {
|
|
5289
|
-
return void 0;
|
|
5290
|
-
};
|
|
5291
|
-
var simpleKeyArgsFn = function(_args, context) {
|
|
5292
|
-
return context.fieldName;
|
|
5293
|
-
};
|
|
5294
|
-
var mergeTrueFn = function(existing, incoming, _a2) {
|
|
5295
|
-
var mergeObjects = _a2.mergeObjects;
|
|
5296
|
-
return mergeObjects(existing, incoming);
|
|
5297
|
-
};
|
|
5298
|
-
var mergeFalseFn = function(_, incoming) {
|
|
5299
|
-
return incoming;
|
|
5300
|
-
};
|
|
5301
|
-
var Policies = function() {
|
|
5302
|
-
function Policies2(config) {
|
|
5303
|
-
this.config = config;
|
|
5304
|
-
this.typePolicies = Object.create(null);
|
|
5305
|
-
this.toBeAdded = Object.create(null);
|
|
5306
|
-
this.supertypeMap = new Map();
|
|
5307
|
-
this.fuzzySubtypes = new Map();
|
|
5308
|
-
this.rootIdsByTypename = Object.create(null);
|
|
5309
|
-
this.rootTypenamesById = Object.create(null);
|
|
5310
|
-
this.usingPossibleTypes = false;
|
|
5311
|
-
this.config = __assign({ dataIdFromObject: defaultDataIdFromObject }, config);
|
|
5312
|
-
this.cache = this.config.cache;
|
|
5313
|
-
this.setRootTypename("Query");
|
|
5314
|
-
this.setRootTypename("Mutation");
|
|
5315
|
-
this.setRootTypename("Subscription");
|
|
5316
|
-
if (config.possibleTypes) {
|
|
5317
|
-
this.addPossibleTypes(config.possibleTypes);
|
|
5318
|
-
}
|
|
5319
|
-
if (config.typePolicies) {
|
|
5320
|
-
this.addTypePolicies(config.typePolicies);
|
|
5321
|
-
}
|
|
5322
|
-
}
|
|
5323
|
-
Policies2.prototype.identify = function(object, partialContext) {
|
|
5324
|
-
var _a2;
|
|
5325
|
-
var policies = this;
|
|
5326
|
-
var typename = partialContext && (partialContext.typename || ((_a2 = partialContext.storeObject) === null || _a2 === void 0 ? void 0 : _a2.__typename)) || object.__typename;
|
|
5327
|
-
if (typename === this.rootTypenamesById.ROOT_QUERY) {
|
|
5328
|
-
return ["ROOT_QUERY"];
|
|
5329
|
-
}
|
|
5330
|
-
var storeObject = partialContext && partialContext.storeObject || object;
|
|
5331
|
-
var context = __assign(__assign({}, partialContext), { typename, storeObject, readField: partialContext && partialContext.readField || function() {
|
|
5332
|
-
var options = normalizeReadFieldOptions(arguments, storeObject);
|
|
5333
|
-
return policies.readField(options, {
|
|
5334
|
-
store: policies.cache["data"],
|
|
5335
|
-
variables: options.variables
|
|
5336
|
-
});
|
|
5337
|
-
} });
|
|
5338
|
-
var id;
|
|
5339
|
-
var policy = typename && this.getTypePolicy(typename);
|
|
5340
|
-
var keyFn = policy && policy.keyFn || this.config.dataIdFromObject;
|
|
5341
|
-
while (keyFn) {
|
|
5342
|
-
var specifierOrId = keyFn(object, context);
|
|
5343
|
-
if (Array.isArray(specifierOrId)) {
|
|
5344
|
-
keyFn = keyFieldsFnFromSpecifier(specifierOrId);
|
|
5345
|
-
} else {
|
|
5346
|
-
id = specifierOrId;
|
|
5347
|
-
break;
|
|
5348
|
-
}
|
|
5349
|
-
}
|
|
5350
|
-
id = id ? String(id) : void 0;
|
|
5351
|
-
return context.keyObject ? [id, context.keyObject] : [id];
|
|
5352
|
-
};
|
|
5353
|
-
Policies2.prototype.addTypePolicies = function(typePolicies) {
|
|
5354
|
-
var _this = this;
|
|
5355
|
-
Object.keys(typePolicies).forEach(function(typename) {
|
|
5356
|
-
var _a2 = typePolicies[typename], queryType = _a2.queryType, mutationType = _a2.mutationType, subscriptionType = _a2.subscriptionType, incoming = __rest(_a2, ["queryType", "mutationType", "subscriptionType"]);
|
|
5357
|
-
if (queryType)
|
|
5358
|
-
_this.setRootTypename("Query", typename);
|
|
5359
|
-
if (mutationType)
|
|
5360
|
-
_this.setRootTypename("Mutation", typename);
|
|
5361
|
-
if (subscriptionType)
|
|
5362
|
-
_this.setRootTypename("Subscription", typename);
|
|
5363
|
-
if (hasOwn.call(_this.toBeAdded, typename)) {
|
|
5364
|
-
_this.toBeAdded[typename].push(incoming);
|
|
5365
|
-
} else {
|
|
5366
|
-
_this.toBeAdded[typename] = [incoming];
|
|
5367
|
-
}
|
|
5368
|
-
});
|
|
5369
|
-
};
|
|
5370
|
-
Policies2.prototype.updateTypePolicy = function(typename, incoming) {
|
|
5371
|
-
var _this = this;
|
|
5372
|
-
var existing = this.getTypePolicy(typename);
|
|
5373
|
-
var keyFields = incoming.keyFields, fields = incoming.fields;
|
|
5374
|
-
function setMerge(existing2, merge) {
|
|
5375
|
-
existing2.merge = typeof merge === "function" ? merge : merge === true ? mergeTrueFn : merge === false ? mergeFalseFn : existing2.merge;
|
|
5376
|
-
}
|
|
5377
|
-
setMerge(existing, incoming.merge);
|
|
5378
|
-
existing.keyFn = keyFields === false ? nullKeyFieldsFn : Array.isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields) : typeof keyFields === "function" ? keyFields : existing.keyFn;
|
|
5379
|
-
if (fields) {
|
|
5380
|
-
Object.keys(fields).forEach(function(fieldName) {
|
|
5381
|
-
var existing2 = _this.getFieldPolicy(typename, fieldName, true);
|
|
5382
|
-
var incoming2 = fields[fieldName];
|
|
5383
|
-
if (typeof incoming2 === "function") {
|
|
5384
|
-
existing2.read = incoming2;
|
|
5385
|
-
} else {
|
|
5386
|
-
var keyArgs = incoming2.keyArgs, read = incoming2.read, merge = incoming2.merge;
|
|
5387
|
-
existing2.keyFn = keyArgs === false ? simpleKeyArgsFn : Array.isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs) : typeof keyArgs === "function" ? keyArgs : existing2.keyFn;
|
|
5388
|
-
if (typeof read === "function") {
|
|
5389
|
-
existing2.read = read;
|
|
5390
|
-
}
|
|
5391
|
-
setMerge(existing2, merge);
|
|
5392
|
-
}
|
|
5393
|
-
if (existing2.read && existing2.merge) {
|
|
5394
|
-
existing2.keyFn = existing2.keyFn || simpleKeyArgsFn;
|
|
5395
|
-
}
|
|
5396
|
-
});
|
|
5397
|
-
}
|
|
5398
|
-
};
|
|
5399
|
-
Policies2.prototype.setRootTypename = function(which, typename) {
|
|
5400
|
-
if (typename === void 0) {
|
|
5401
|
-
typename = which;
|
|
5402
|
-
}
|
|
5403
|
-
var rootId = "ROOT_" + which.toUpperCase();
|
|
5404
|
-
var old = this.rootTypenamesById[rootId];
|
|
5405
|
-
if (typename !== old) {
|
|
5406
|
-
__DEV__ ? invariant(!old || old === which, "Cannot change root ".concat(which, " __typename more than once")) : invariant(!old || old === which, 3);
|
|
5407
|
-
if (old)
|
|
5408
|
-
delete this.rootIdsByTypename[old];
|
|
5409
|
-
this.rootIdsByTypename[typename] = rootId;
|
|
5410
|
-
this.rootTypenamesById[rootId] = typename;
|
|
5411
|
-
}
|
|
5412
|
-
};
|
|
5413
|
-
Policies2.prototype.addPossibleTypes = function(possibleTypes) {
|
|
5414
|
-
var _this = this;
|
|
5415
|
-
this.usingPossibleTypes = true;
|
|
5416
|
-
Object.keys(possibleTypes).forEach(function(supertype) {
|
|
5417
|
-
_this.getSupertypeSet(supertype, true);
|
|
5418
|
-
possibleTypes[supertype].forEach(function(subtype) {
|
|
5419
|
-
_this.getSupertypeSet(subtype, true).add(supertype);
|
|
5420
|
-
var match = subtype.match(TypeOrFieldNameRegExp);
|
|
5421
|
-
if (!match || match[0] !== subtype) {
|
|
5422
|
-
_this.fuzzySubtypes.set(subtype, new RegExp(subtype));
|
|
5423
|
-
}
|
|
5424
|
-
});
|
|
5425
|
-
});
|
|
5426
|
-
};
|
|
5427
|
-
Policies2.prototype.getTypePolicy = function(typename) {
|
|
5428
|
-
var _this = this;
|
|
5429
|
-
if (!hasOwn.call(this.typePolicies, typename)) {
|
|
5430
|
-
var policy_1 = this.typePolicies[typename] = Object.create(null);
|
|
5431
|
-
policy_1.fields = Object.create(null);
|
|
5432
|
-
var supertypes = this.supertypeMap.get(typename);
|
|
5433
|
-
if (supertypes && supertypes.size) {
|
|
5434
|
-
supertypes.forEach(function(supertype) {
|
|
5435
|
-
var _a2 = _this.getTypePolicy(supertype), fields = _a2.fields, rest = __rest(_a2, ["fields"]);
|
|
5436
|
-
Object.assign(policy_1, rest);
|
|
5437
|
-
Object.assign(policy_1.fields, fields);
|
|
5438
|
-
});
|
|
5439
|
-
}
|
|
5440
|
-
}
|
|
5441
|
-
var inbox = this.toBeAdded[typename];
|
|
5442
|
-
if (inbox && inbox.length) {
|
|
5443
|
-
inbox.splice(0).forEach(function(policy) {
|
|
5444
|
-
_this.updateTypePolicy(typename, policy);
|
|
5445
|
-
});
|
|
5446
|
-
}
|
|
5447
|
-
return this.typePolicies[typename];
|
|
5448
|
-
};
|
|
5449
|
-
Policies2.prototype.getFieldPolicy = function(typename, fieldName, createIfMissing) {
|
|
5450
|
-
if (typename) {
|
|
5451
|
-
var fieldPolicies = this.getTypePolicy(typename).fields;
|
|
5452
|
-
return fieldPolicies[fieldName] || createIfMissing && (fieldPolicies[fieldName] = Object.create(null));
|
|
5453
|
-
}
|
|
5454
|
-
};
|
|
5455
|
-
Policies2.prototype.getSupertypeSet = function(subtype, createIfMissing) {
|
|
5456
|
-
var supertypeSet = this.supertypeMap.get(subtype);
|
|
5457
|
-
if (!supertypeSet && createIfMissing) {
|
|
5458
|
-
this.supertypeMap.set(subtype, supertypeSet = new Set());
|
|
5459
|
-
}
|
|
5460
|
-
return supertypeSet;
|
|
5461
|
-
};
|
|
5462
|
-
Policies2.prototype.fragmentMatches = function(fragment, typename, result, variables) {
|
|
5463
|
-
var _this = this;
|
|
5464
|
-
if (!fragment.typeCondition)
|
|
5465
|
-
return true;
|
|
5466
|
-
if (!typename)
|
|
5467
|
-
return false;
|
|
5468
|
-
var supertype = fragment.typeCondition.name.value;
|
|
5469
|
-
if (typename === supertype)
|
|
5470
|
-
return true;
|
|
5471
|
-
if (this.usingPossibleTypes && this.supertypeMap.has(supertype)) {
|
|
5472
|
-
var typenameSupertypeSet = this.getSupertypeSet(typename, true);
|
|
5473
|
-
var workQueue_1 = [typenameSupertypeSet];
|
|
5474
|
-
var maybeEnqueue_1 = function(subtype) {
|
|
5475
|
-
var supertypeSet2 = _this.getSupertypeSet(subtype, false);
|
|
5476
|
-
if (supertypeSet2 && supertypeSet2.size && workQueue_1.indexOf(supertypeSet2) < 0) {
|
|
5477
|
-
workQueue_1.push(supertypeSet2);
|
|
5478
|
-
}
|
|
5479
|
-
};
|
|
5480
|
-
var needToCheckFuzzySubtypes = !!(result && this.fuzzySubtypes.size);
|
|
5481
|
-
var checkingFuzzySubtypes = false;
|
|
5482
|
-
for (var i = 0; i < workQueue_1.length; ++i) {
|
|
5483
|
-
var supertypeSet = workQueue_1[i];
|
|
5484
|
-
if (supertypeSet.has(supertype)) {
|
|
5485
|
-
if (!typenameSupertypeSet.has(supertype)) {
|
|
5486
|
-
if (checkingFuzzySubtypes) {
|
|
5487
|
-
__DEV__ && invariant.warn("Inferring subtype ".concat(typename, " of supertype ").concat(supertype));
|
|
5488
|
-
}
|
|
5489
|
-
typenameSupertypeSet.add(supertype);
|
|
5490
|
-
}
|
|
5491
|
-
return true;
|
|
5492
|
-
}
|
|
5493
|
-
supertypeSet.forEach(maybeEnqueue_1);
|
|
5494
|
-
if (needToCheckFuzzySubtypes && i === workQueue_1.length - 1 && selectionSetMatchesResult(fragment.selectionSet, result, variables)) {
|
|
5495
|
-
needToCheckFuzzySubtypes = false;
|
|
5496
|
-
checkingFuzzySubtypes = true;
|
|
5497
|
-
this.fuzzySubtypes.forEach(function(regExp, fuzzyString) {
|
|
5498
|
-
var match = typename.match(regExp);
|
|
5499
|
-
if (match && match[0] === typename) {
|
|
5500
|
-
maybeEnqueue_1(fuzzyString);
|
|
5501
|
-
}
|
|
5502
|
-
});
|
|
5503
|
-
}
|
|
5504
|
-
}
|
|
5505
|
-
}
|
|
5506
|
-
return false;
|
|
5507
|
-
};
|
|
5508
|
-
Policies2.prototype.hasKeyArgs = function(typename, fieldName) {
|
|
5509
|
-
var policy = this.getFieldPolicy(typename, fieldName, false);
|
|
5510
|
-
return !!(policy && policy.keyFn);
|
|
5511
|
-
};
|
|
5512
|
-
Policies2.prototype.getStoreFieldName = function(fieldSpec) {
|
|
5513
|
-
var typename = fieldSpec.typename, fieldName = fieldSpec.fieldName;
|
|
5514
|
-
var policy = this.getFieldPolicy(typename, fieldName, false);
|
|
5515
|
-
var storeFieldName;
|
|
5516
|
-
var keyFn = policy && policy.keyFn;
|
|
5517
|
-
if (keyFn && typename) {
|
|
5518
|
-
var context = {
|
|
5519
|
-
typename,
|
|
5520
|
-
fieldName,
|
|
5521
|
-
field: fieldSpec.field || null,
|
|
5522
|
-
variables: fieldSpec.variables
|
|
5523
|
-
};
|
|
5524
|
-
var args = argsFromFieldSpecifier(fieldSpec);
|
|
5525
|
-
while (keyFn) {
|
|
5526
|
-
var specifierOrString = keyFn(args, context);
|
|
5527
|
-
if (Array.isArray(specifierOrString)) {
|
|
5528
|
-
keyFn = keyArgsFnFromSpecifier(specifierOrString);
|
|
5529
|
-
} else {
|
|
5530
|
-
storeFieldName = specifierOrString || fieldName;
|
|
5531
|
-
break;
|
|
5532
|
-
}
|
|
5533
|
-
}
|
|
5534
|
-
}
|
|
5535
|
-
if (storeFieldName === void 0) {
|
|
5536
|
-
storeFieldName = fieldSpec.field ? storeKeyNameFromField(fieldSpec.field, fieldSpec.variables) : getStoreKeyName(fieldName, argsFromFieldSpecifier(fieldSpec));
|
|
5537
|
-
}
|
|
5538
|
-
if (storeFieldName === false) {
|
|
5539
|
-
return fieldName;
|
|
5540
|
-
}
|
|
5541
|
-
return fieldName === fieldNameFromStoreName(storeFieldName) ? storeFieldName : fieldName + ":" + storeFieldName;
|
|
5542
|
-
};
|
|
5543
|
-
Policies2.prototype.readField = function(options, context) {
|
|
5544
|
-
var objectOrReference = options.from;
|
|
5545
|
-
if (!objectOrReference)
|
|
5546
|
-
return;
|
|
5547
|
-
var nameOrField = options.field || options.fieldName;
|
|
5548
|
-
if (!nameOrField)
|
|
5549
|
-
return;
|
|
5550
|
-
if (options.typename === void 0) {
|
|
5551
|
-
var typename = context.store.getFieldValue(objectOrReference, "__typename");
|
|
5552
|
-
if (typename)
|
|
5553
|
-
options.typename = typename;
|
|
5554
|
-
}
|
|
5555
|
-
var storeFieldName = this.getStoreFieldName(options);
|
|
5556
|
-
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
5557
|
-
var existing = context.store.getFieldValue(objectOrReference, storeFieldName);
|
|
5558
|
-
var policy = this.getFieldPolicy(options.typename, fieldName, false);
|
|
5559
|
-
var read = policy && policy.read;
|
|
5560
|
-
if (read) {
|
|
5561
|
-
var readOptions = makeFieldFunctionOptions(this, objectOrReference, options, context, context.store.getStorage(isReference(objectOrReference) ? objectOrReference.__ref : objectOrReference, storeFieldName));
|
|
5562
|
-
return cacheSlot.withValue(this.cache, read, [existing, readOptions]);
|
|
5563
|
-
}
|
|
5564
|
-
return existing;
|
|
5565
|
-
};
|
|
5566
|
-
Policies2.prototype.getReadFunction = function(typename, fieldName) {
|
|
5567
|
-
var policy = this.getFieldPolicy(typename, fieldName, false);
|
|
5568
|
-
return policy && policy.read;
|
|
5569
|
-
};
|
|
5570
|
-
Policies2.prototype.getMergeFunction = function(parentTypename, fieldName, childTypename) {
|
|
5571
|
-
var policy = this.getFieldPolicy(parentTypename, fieldName, false);
|
|
5572
|
-
var merge = policy && policy.merge;
|
|
5573
|
-
if (!merge && childTypename) {
|
|
5574
|
-
policy = this.getTypePolicy(childTypename);
|
|
5575
|
-
merge = policy && policy.merge;
|
|
5576
|
-
}
|
|
5577
|
-
return merge;
|
|
5578
|
-
};
|
|
5579
|
-
Policies2.prototype.runMergeFunction = function(existing, incoming, _a2, context, storage) {
|
|
5580
|
-
var field = _a2.field, typename = _a2.typename, merge = _a2.merge;
|
|
5581
|
-
if (merge === mergeTrueFn) {
|
|
5582
|
-
return makeMergeObjectsFunction(context.store)(existing, incoming);
|
|
5583
|
-
}
|
|
5584
|
-
if (merge === mergeFalseFn) {
|
|
5585
|
-
return incoming;
|
|
5586
|
-
}
|
|
5587
|
-
if (context.overwrite) {
|
|
5588
|
-
existing = void 0;
|
|
5589
|
-
}
|
|
5590
|
-
return merge(existing, incoming, makeFieldFunctionOptions(this, void 0, { typename, fieldName: field.name.value, field, variables: context.variables }, context, storage || Object.create(null)));
|
|
5591
|
-
};
|
|
5592
|
-
return Policies2;
|
|
5593
|
-
}();
|
|
5594
|
-
function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, context, storage) {
|
|
5595
|
-
var storeFieldName = policies.getStoreFieldName(fieldSpec);
|
|
5596
|
-
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
5597
|
-
var variables = fieldSpec.variables || context.variables;
|
|
5598
|
-
var _a2 = context.store, toReference = _a2.toReference, canRead = _a2.canRead;
|
|
5599
|
-
return {
|
|
5600
|
-
args: argsFromFieldSpecifier(fieldSpec),
|
|
5601
|
-
field: fieldSpec.field || null,
|
|
5602
|
-
fieldName,
|
|
5603
|
-
storeFieldName,
|
|
5604
|
-
variables,
|
|
5605
|
-
isReference,
|
|
5606
|
-
toReference,
|
|
5607
|
-
storage,
|
|
5608
|
-
cache: policies.cache,
|
|
5609
|
-
canRead,
|
|
5610
|
-
readField: function() {
|
|
5611
|
-
return policies.readField(normalizeReadFieldOptions(arguments, objectOrReference, context), context);
|
|
5612
|
-
},
|
|
5613
|
-
mergeObjects: makeMergeObjectsFunction(context.store)
|
|
5614
|
-
};
|
|
5615
|
-
}
|
|
5616
|
-
function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables) {
|
|
5617
|
-
var fieldNameOrOptions = readFieldArgs[0], from = readFieldArgs[1], argc = readFieldArgs.length;
|
|
5618
|
-
var options;
|
|
5619
|
-
if (typeof fieldNameOrOptions === "string") {
|
|
5620
|
-
options = {
|
|
5621
|
-
fieldName: fieldNameOrOptions,
|
|
5622
|
-
from: argc > 1 ? from : objectOrReference
|
|
5623
|
-
};
|
|
5624
|
-
} else {
|
|
5625
|
-
options = __assign({}, fieldNameOrOptions);
|
|
5626
|
-
if (!hasOwn.call(options, "from")) {
|
|
5627
|
-
options.from = objectOrReference;
|
|
5628
|
-
}
|
|
5629
|
-
}
|
|
5630
|
-
if (__DEV__ && options.from === void 0) {
|
|
5631
|
-
__DEV__ && invariant.warn("Undefined 'from' passed to readField with arguments ".concat(stringifyForDisplay(Array.from(readFieldArgs))));
|
|
5632
|
-
}
|
|
5633
|
-
if (options.variables === void 0) {
|
|
5634
|
-
options.variables = variables;
|
|
5635
|
-
}
|
|
5636
|
-
return options;
|
|
5637
|
-
}
|
|
5638
|
-
function makeMergeObjectsFunction(store) {
|
|
5639
|
-
return function mergeObjects(existing, incoming) {
|
|
5640
|
-
if (Array.isArray(existing) || Array.isArray(incoming)) {
|
|
5641
|
-
throw __DEV__ ? new InvariantError("Cannot automatically merge arrays") : new InvariantError(4);
|
|
5642
|
-
}
|
|
5643
|
-
if (isNonNullObject(existing) && isNonNullObject(incoming)) {
|
|
5644
|
-
var eType = store.getFieldValue(existing, "__typename");
|
|
5645
|
-
var iType = store.getFieldValue(incoming, "__typename");
|
|
5646
|
-
var typesDiffer = eType && iType && eType !== iType;
|
|
5647
|
-
if (typesDiffer) {
|
|
5648
|
-
return incoming;
|
|
5649
|
-
}
|
|
5650
|
-
if (isReference(existing) && storeValueIsStoreObject(incoming)) {
|
|
5651
|
-
store.merge(existing.__ref, incoming);
|
|
5652
|
-
return existing;
|
|
5653
|
-
}
|
|
5654
|
-
if (storeValueIsStoreObject(existing) && isReference(incoming)) {
|
|
5655
|
-
store.merge(existing, incoming.__ref);
|
|
5656
|
-
return incoming;
|
|
5657
|
-
}
|
|
5658
|
-
if (storeValueIsStoreObject(existing) && storeValueIsStoreObject(incoming)) {
|
|
5659
|
-
return __assign(__assign({}, existing), incoming);
|
|
5660
|
-
}
|
|
5661
|
-
}
|
|
5662
|
-
return incoming;
|
|
5663
|
-
};
|
|
5664
|
-
}
|
|
5665
|
-
function getContextFlavor(context, clientOnly, deferred) {
|
|
5666
|
-
var key = "".concat(clientOnly).concat(deferred);
|
|
5667
|
-
var flavored = context.flavors.get(key);
|
|
5668
|
-
if (!flavored) {
|
|
5669
|
-
context.flavors.set(key, flavored = context.clientOnly === clientOnly && context.deferred === deferred ? context : __assign(__assign({}, context), { clientOnly, deferred }));
|
|
5670
|
-
}
|
|
5671
|
-
return flavored;
|
|
5672
|
-
}
|
|
5673
|
-
var StoreWriter = function() {
|
|
5674
|
-
function StoreWriter2(cache, reader) {
|
|
5675
|
-
this.cache = cache;
|
|
5676
|
-
this.reader = reader;
|
|
5677
|
-
}
|
|
5678
|
-
StoreWriter2.prototype.writeToStore = function(store, _a2) {
|
|
5679
|
-
var _this = this;
|
|
5680
|
-
var query = _a2.query, result = _a2.result, dataId = _a2.dataId, variables = _a2.variables, overwrite = _a2.overwrite;
|
|
5681
|
-
var operationDefinition = getOperationDefinition(query);
|
|
5682
|
-
var merger = makeProcessedFieldsMerger();
|
|
5683
|
-
variables = __assign(__assign({}, getDefaultValues(operationDefinition)), variables);
|
|
5684
|
-
var context = {
|
|
5685
|
-
store,
|
|
5686
|
-
written: Object.create(null),
|
|
5687
|
-
merge: function(existing, incoming) {
|
|
5688
|
-
return merger.merge(existing, incoming);
|
|
5689
|
-
},
|
|
5690
|
-
variables,
|
|
5691
|
-
varString: canonicalStringify(variables),
|
|
5692
|
-
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
5693
|
-
overwrite: !!overwrite,
|
|
5694
|
-
incomingById: new Map(),
|
|
5695
|
-
clientOnly: false,
|
|
5696
|
-
deferred: false,
|
|
5697
|
-
flavors: new Map()
|
|
5698
|
-
};
|
|
5699
|
-
var ref2 = this.processSelectionSet({
|
|
5700
|
-
result: result || Object.create(null),
|
|
5701
|
-
dataId,
|
|
5702
|
-
selectionSet: operationDefinition.selectionSet,
|
|
5703
|
-
mergeTree: { map: new Map() },
|
|
5704
|
-
context
|
|
5705
|
-
});
|
|
5706
|
-
if (!isReference(ref2)) {
|
|
5707
|
-
throw __DEV__ ? new InvariantError("Could not identify object ".concat(JSON.stringify(result))) : new InvariantError(6);
|
|
5708
|
-
}
|
|
5709
|
-
context.incomingById.forEach(function(_a3, dataId2) {
|
|
5710
|
-
var storeObject = _a3.storeObject, mergeTree = _a3.mergeTree, fieldNodeSet = _a3.fieldNodeSet;
|
|
5711
|
-
var entityRef = makeReference(dataId2);
|
|
5712
|
-
if (mergeTree && mergeTree.map.size) {
|
|
5713
|
-
var applied = _this.applyMerges(mergeTree, entityRef, storeObject, context);
|
|
5714
|
-
if (isReference(applied)) {
|
|
5715
|
-
return;
|
|
5716
|
-
}
|
|
5717
|
-
storeObject = applied;
|
|
5718
|
-
}
|
|
5719
|
-
if (__DEV__ && !context.overwrite) {
|
|
5720
|
-
var fieldsWithSelectionSets_1 = Object.create(null);
|
|
5721
|
-
fieldNodeSet.forEach(function(field) {
|
|
5722
|
-
if (field.selectionSet) {
|
|
5723
|
-
fieldsWithSelectionSets_1[field.name.value] = true;
|
|
5724
|
-
}
|
|
5725
|
-
});
|
|
5726
|
-
var hasSelectionSet_1 = function(storeFieldName) {
|
|
5727
|
-
return fieldsWithSelectionSets_1[fieldNameFromStoreName(storeFieldName)] === true;
|
|
5728
|
-
};
|
|
5729
|
-
var hasMergeFunction_1 = function(storeFieldName) {
|
|
5730
|
-
var childTree = mergeTree && mergeTree.map.get(storeFieldName);
|
|
5731
|
-
return Boolean(childTree && childTree.info && childTree.info.merge);
|
|
5732
|
-
};
|
|
5733
|
-
Object.keys(storeObject).forEach(function(storeFieldName) {
|
|
5734
|
-
if (hasSelectionSet_1(storeFieldName) && !hasMergeFunction_1(storeFieldName)) {
|
|
5735
|
-
warnAboutDataLoss(entityRef, storeObject, storeFieldName, context.store);
|
|
5736
|
-
}
|
|
5737
|
-
});
|
|
5738
|
-
}
|
|
5739
|
-
store.merge(dataId2, storeObject);
|
|
5740
|
-
});
|
|
5741
|
-
store.retain(ref2.__ref);
|
|
5742
|
-
return ref2;
|
|
5743
|
-
};
|
|
5744
|
-
StoreWriter2.prototype.processSelectionSet = function(_a2) {
|
|
5745
|
-
var _this = this;
|
|
5746
|
-
var dataId = _a2.dataId, result = _a2.result, selectionSet = _a2.selectionSet, context = _a2.context, mergeTree = _a2.mergeTree;
|
|
5747
|
-
var policies = this.cache.policies;
|
|
5748
|
-
var incoming = Object.create(null);
|
|
5749
|
-
var typename = dataId && policies.rootTypenamesById[dataId] || getTypenameFromResult(result, selectionSet, context.fragmentMap) || dataId && context.store.get(dataId, "__typename");
|
|
5750
|
-
if (typeof typename === "string") {
|
|
5751
|
-
incoming.__typename = typename;
|
|
5752
|
-
}
|
|
5753
|
-
var readField = function() {
|
|
5754
|
-
var options = normalizeReadFieldOptions(arguments, incoming, context.variables);
|
|
5755
|
-
if (isReference(options.from)) {
|
|
5756
|
-
var info = context.incomingById.get(options.from.__ref);
|
|
5757
|
-
if (info) {
|
|
5758
|
-
var result_1 = policies.readField(__assign(__assign({}, options), { from: info.storeObject }), context);
|
|
5759
|
-
if (result_1 !== void 0) {
|
|
5760
|
-
return result_1;
|
|
5761
|
-
}
|
|
5762
|
-
}
|
|
5763
|
-
}
|
|
5764
|
-
return policies.readField(options, context);
|
|
5765
|
-
};
|
|
5766
|
-
var fieldNodeSet = new Set();
|
|
5767
|
-
this.flattenFields(selectionSet, result, context, typename).forEach(function(context2, field) {
|
|
5768
|
-
var _a3;
|
|
5769
|
-
var resultFieldKey = resultKeyNameFromField(field);
|
|
5770
|
-
var value = result[resultFieldKey];
|
|
5771
|
-
fieldNodeSet.add(field);
|
|
5772
|
-
if (value !== void 0) {
|
|
5773
|
-
var storeFieldName = policies.getStoreFieldName({
|
|
5774
|
-
typename,
|
|
5775
|
-
fieldName: field.name.value,
|
|
5776
|
-
field,
|
|
5777
|
-
variables: context2.variables
|
|
5778
|
-
});
|
|
5779
|
-
var childTree = getChildMergeTree(mergeTree, storeFieldName);
|
|
5780
|
-
var incomingValue = _this.processFieldValue(value, field, field.selectionSet ? getContextFlavor(context2, false, false) : context2, childTree);
|
|
5781
|
-
var childTypename = void 0;
|
|
5782
|
-
if (field.selectionSet && (isReference(incomingValue) || storeValueIsStoreObject(incomingValue))) {
|
|
5783
|
-
childTypename = readField("__typename", incomingValue);
|
|
5784
|
-
}
|
|
5785
|
-
var merge = policies.getMergeFunction(typename, field.name.value, childTypename);
|
|
5786
|
-
if (merge) {
|
|
5787
|
-
childTree.info = {
|
|
5788
|
-
field,
|
|
5789
|
-
typename,
|
|
5790
|
-
merge
|
|
5791
|
-
};
|
|
5792
|
-
} else {
|
|
5793
|
-
maybeRecycleChildMergeTree(mergeTree, storeFieldName);
|
|
5794
|
-
}
|
|
5795
|
-
incoming = context2.merge(incoming, (_a3 = {}, _a3[storeFieldName] = incomingValue, _a3));
|
|
5796
|
-
} else if (__DEV__ && !context2.clientOnly && !context2.deferred && !addTypenameToDocument.added(field) && !policies.getReadFunction(typename, field.name.value)) {
|
|
5797
|
-
__DEV__ && invariant.error("Missing field '".concat(resultKeyNameFromField(field), "' while writing result ").concat(JSON.stringify(result, null, 2)).substring(0, 1e3));
|
|
5798
|
-
}
|
|
5799
|
-
});
|
|
5800
|
-
try {
|
|
5801
|
-
var _b = policies.identify(result, {
|
|
5802
|
-
typename,
|
|
5803
|
-
selectionSet,
|
|
5804
|
-
fragmentMap: context.fragmentMap,
|
|
5805
|
-
storeObject: incoming,
|
|
5806
|
-
readField
|
|
5807
|
-
}), id = _b[0], keyObject = _b[1];
|
|
5808
|
-
dataId = dataId || id;
|
|
5809
|
-
if (keyObject) {
|
|
5810
|
-
incoming = context.merge(incoming, keyObject);
|
|
5811
|
-
}
|
|
5812
|
-
} catch (e) {
|
|
5813
|
-
if (!dataId)
|
|
5814
|
-
throw e;
|
|
5815
|
-
}
|
|
5816
|
-
if (typeof dataId === "string") {
|
|
5817
|
-
var dataRef = makeReference(dataId);
|
|
5818
|
-
var sets = context.written[dataId] || (context.written[dataId] = []);
|
|
5819
|
-
if (sets.indexOf(selectionSet) >= 0)
|
|
5820
|
-
return dataRef;
|
|
5821
|
-
sets.push(selectionSet);
|
|
5822
|
-
if (this.reader && this.reader.isFresh(result, dataRef, selectionSet, context)) {
|
|
5823
|
-
return dataRef;
|
|
5824
|
-
}
|
|
5825
|
-
var previous_1 = context.incomingById.get(dataId);
|
|
5826
|
-
if (previous_1) {
|
|
5827
|
-
previous_1.storeObject = context.merge(previous_1.storeObject, incoming);
|
|
5828
|
-
previous_1.mergeTree = mergeMergeTrees(previous_1.mergeTree, mergeTree);
|
|
5829
|
-
fieldNodeSet.forEach(function(field) {
|
|
5830
|
-
return previous_1.fieldNodeSet.add(field);
|
|
5831
|
-
});
|
|
5832
|
-
} else {
|
|
5833
|
-
context.incomingById.set(dataId, {
|
|
5834
|
-
storeObject: incoming,
|
|
5835
|
-
mergeTree: mergeTreeIsEmpty(mergeTree) ? void 0 : mergeTree,
|
|
5836
|
-
fieldNodeSet
|
|
5837
|
-
});
|
|
5838
|
-
}
|
|
5839
|
-
return dataRef;
|
|
5840
|
-
}
|
|
5841
|
-
return incoming;
|
|
5842
|
-
};
|
|
5843
|
-
StoreWriter2.prototype.processFieldValue = function(value, field, context, mergeTree) {
|
|
5844
|
-
var _this = this;
|
|
5845
|
-
if (!field.selectionSet || value === null) {
|
|
5846
|
-
return __DEV__ ? cloneDeep(value) : value;
|
|
5847
|
-
}
|
|
5848
|
-
if (Array.isArray(value)) {
|
|
5849
|
-
return value.map(function(item, i) {
|
|
5850
|
-
var value2 = _this.processFieldValue(item, field, context, getChildMergeTree(mergeTree, i));
|
|
5851
|
-
maybeRecycleChildMergeTree(mergeTree, i);
|
|
5852
|
-
return value2;
|
|
5853
|
-
});
|
|
5854
|
-
}
|
|
5855
|
-
return this.processSelectionSet({
|
|
5856
|
-
result: value,
|
|
5857
|
-
selectionSet: field.selectionSet,
|
|
5858
|
-
context,
|
|
5859
|
-
mergeTree
|
|
5860
|
-
});
|
|
5861
|
-
};
|
|
5862
|
-
StoreWriter2.prototype.flattenFields = function(selectionSet, result, context, typename) {
|
|
5863
|
-
if (typename === void 0) {
|
|
5864
|
-
typename = getTypenameFromResult(result, selectionSet, context.fragmentMap);
|
|
5865
|
-
}
|
|
5866
|
-
var fieldMap = new Map();
|
|
5867
|
-
var policies = this.cache.policies;
|
|
5868
|
-
var limitingTrie = new Trie(false);
|
|
5869
|
-
(function flatten(selectionSet2, inheritedContext) {
|
|
5870
|
-
var visitedNode = limitingTrie.lookup(selectionSet2, inheritedContext.clientOnly, inheritedContext.deferred);
|
|
5871
|
-
if (visitedNode.visited)
|
|
5872
|
-
return;
|
|
5873
|
-
visitedNode.visited = true;
|
|
5874
|
-
selectionSet2.selections.forEach(function(selection) {
|
|
5875
|
-
if (!shouldInclude(selection, context.variables))
|
|
5876
|
-
return;
|
|
5877
|
-
var clientOnly = inheritedContext.clientOnly, deferred = inheritedContext.deferred;
|
|
5878
|
-
if (!(clientOnly && deferred) && isNonEmptyArray(selection.directives)) {
|
|
5879
|
-
selection.directives.forEach(function(dir) {
|
|
5880
|
-
var name = dir.name.value;
|
|
5881
|
-
if (name === "client")
|
|
5882
|
-
clientOnly = true;
|
|
5883
|
-
if (name === "defer") {
|
|
5884
|
-
var args = argumentsObjectFromField(dir, context.variables);
|
|
5885
|
-
if (!args || args.if !== false) {
|
|
5886
|
-
deferred = true;
|
|
5887
|
-
}
|
|
5888
|
-
}
|
|
5889
|
-
});
|
|
5890
|
-
}
|
|
5891
|
-
if (isField(selection)) {
|
|
5892
|
-
var existing = fieldMap.get(selection);
|
|
5893
|
-
if (existing) {
|
|
5894
|
-
clientOnly = clientOnly && existing.clientOnly;
|
|
5895
|
-
deferred = deferred && existing.deferred;
|
|
5896
|
-
}
|
|
5897
|
-
fieldMap.set(selection, getContextFlavor(context, clientOnly, deferred));
|
|
5898
|
-
} else {
|
|
5899
|
-
var fragment = getFragmentFromSelection(selection, context.fragmentMap);
|
|
5900
|
-
if (fragment && policies.fragmentMatches(fragment, typename, result, context.variables)) {
|
|
5901
|
-
flatten(fragment.selectionSet, getContextFlavor(context, clientOnly, deferred));
|
|
5902
|
-
}
|
|
5903
|
-
}
|
|
5904
|
-
});
|
|
5905
|
-
})(selectionSet, context);
|
|
5906
|
-
return fieldMap;
|
|
5907
|
-
};
|
|
5908
|
-
StoreWriter2.prototype.applyMerges = function(mergeTree, existing, incoming, context, getStorageArgs) {
|
|
5909
|
-
var _a2;
|
|
5910
|
-
var _this = this;
|
|
5911
|
-
if (mergeTree.map.size && !isReference(incoming)) {
|
|
5912
|
-
var e_1 = !Array.isArray(incoming) && (isReference(existing) || storeValueIsStoreObject(existing)) ? existing : void 0;
|
|
5913
|
-
var i_1 = incoming;
|
|
5914
|
-
if (e_1 && !getStorageArgs) {
|
|
5915
|
-
getStorageArgs = [isReference(e_1) ? e_1.__ref : e_1];
|
|
5916
|
-
}
|
|
5917
|
-
var changedFields_1;
|
|
5918
|
-
var getValue_1 = function(from, name) {
|
|
5919
|
-
return Array.isArray(from) ? typeof name === "number" ? from[name] : void 0 : context.store.getFieldValue(from, String(name));
|
|
5920
|
-
};
|
|
5921
|
-
mergeTree.map.forEach(function(childTree, storeFieldName) {
|
|
5922
|
-
var eVal = getValue_1(e_1, storeFieldName);
|
|
5923
|
-
var iVal = getValue_1(i_1, storeFieldName);
|
|
5924
|
-
if (iVal === void 0)
|
|
5925
|
-
return;
|
|
5926
|
-
if (getStorageArgs) {
|
|
5927
|
-
getStorageArgs.push(storeFieldName);
|
|
5928
|
-
}
|
|
5929
|
-
var aVal = _this.applyMerges(childTree, eVal, iVal, context, getStorageArgs);
|
|
5930
|
-
if (aVal !== iVal) {
|
|
5931
|
-
changedFields_1 = changedFields_1 || new Map();
|
|
5932
|
-
changedFields_1.set(storeFieldName, aVal);
|
|
5933
|
-
}
|
|
5934
|
-
if (getStorageArgs) {
|
|
5935
|
-
invariant(getStorageArgs.pop() === storeFieldName);
|
|
5936
|
-
}
|
|
5937
|
-
});
|
|
5938
|
-
if (changedFields_1) {
|
|
5939
|
-
incoming = Array.isArray(i_1) ? i_1.slice(0) : __assign({}, i_1);
|
|
5940
|
-
changedFields_1.forEach(function(value, name) {
|
|
5941
|
-
incoming[name] = value;
|
|
5942
|
-
});
|
|
5943
|
-
}
|
|
5944
|
-
}
|
|
5945
|
-
if (mergeTree.info) {
|
|
5946
|
-
return this.cache.policies.runMergeFunction(existing, incoming, mergeTree.info, context, getStorageArgs && (_a2 = context.store).getStorage.apply(_a2, getStorageArgs));
|
|
5947
|
-
}
|
|
5948
|
-
return incoming;
|
|
5949
|
-
};
|
|
5950
|
-
return StoreWriter2;
|
|
5951
|
-
}();
|
|
5952
|
-
var emptyMergeTreePool = [];
|
|
5953
|
-
function getChildMergeTree(_a2, name) {
|
|
5954
|
-
var map = _a2.map;
|
|
5955
|
-
if (!map.has(name)) {
|
|
5956
|
-
map.set(name, emptyMergeTreePool.pop() || { map: new Map() });
|
|
5957
|
-
}
|
|
5958
|
-
return map.get(name);
|
|
5959
|
-
}
|
|
5960
|
-
function mergeMergeTrees(left, right) {
|
|
5961
|
-
if (left === right || !right || mergeTreeIsEmpty(right))
|
|
5962
|
-
return left;
|
|
5963
|
-
if (!left || mergeTreeIsEmpty(left))
|
|
5964
|
-
return right;
|
|
5965
|
-
var info = left.info && right.info ? __assign(__assign({}, left.info), right.info) : left.info || right.info;
|
|
5966
|
-
var needToMergeMaps = left.map.size && right.map.size;
|
|
5967
|
-
var map = needToMergeMaps ? new Map() : left.map.size ? left.map : right.map;
|
|
5968
|
-
var merged = { info, map };
|
|
5969
|
-
if (needToMergeMaps) {
|
|
5970
|
-
var remainingRightKeys_1 = new Set(right.map.keys());
|
|
5971
|
-
left.map.forEach(function(leftTree, key) {
|
|
5972
|
-
merged.map.set(key, mergeMergeTrees(leftTree, right.map.get(key)));
|
|
5973
|
-
remainingRightKeys_1.delete(key);
|
|
5974
|
-
});
|
|
5975
|
-
remainingRightKeys_1.forEach(function(key) {
|
|
5976
|
-
merged.map.set(key, mergeMergeTrees(right.map.get(key), left.map.get(key)));
|
|
5977
|
-
});
|
|
5978
|
-
}
|
|
5979
|
-
return merged;
|
|
5980
|
-
}
|
|
5981
|
-
function mergeTreeIsEmpty(tree) {
|
|
5982
|
-
return !tree || !(tree.info || tree.map.size);
|
|
5983
|
-
}
|
|
5984
|
-
function maybeRecycleChildMergeTree(_a2, name) {
|
|
5985
|
-
var map = _a2.map;
|
|
5986
|
-
var childTree = map.get(name);
|
|
5987
|
-
if (childTree && mergeTreeIsEmpty(childTree)) {
|
|
5988
|
-
emptyMergeTreePool.push(childTree);
|
|
5989
|
-
map.delete(name);
|
|
5990
|
-
}
|
|
5991
|
-
}
|
|
5992
|
-
var warnings = new Set();
|
|
5993
|
-
function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
5994
|
-
var getChild = function(objOrRef) {
|
|
5995
|
-
var child = store.getFieldValue(objOrRef, storeFieldName);
|
|
5996
|
-
return typeof child === "object" && child;
|
|
5997
|
-
};
|
|
5998
|
-
var existing = getChild(existingRef);
|
|
5999
|
-
if (!existing)
|
|
6000
|
-
return;
|
|
6001
|
-
var incoming = getChild(incomingObj);
|
|
6002
|
-
if (!incoming)
|
|
6003
|
-
return;
|
|
6004
|
-
if (isReference(existing))
|
|
6005
|
-
return;
|
|
6006
|
-
if (equal(existing, incoming))
|
|
6007
|
-
return;
|
|
6008
|
-
if (Object.keys(existing).every(function(key) {
|
|
6009
|
-
return store.getFieldValue(incoming, key) !== void 0;
|
|
6010
|
-
})) {
|
|
6011
|
-
return;
|
|
6012
|
-
}
|
|
6013
|
-
var parentType = store.getFieldValue(existingRef, "__typename") || store.getFieldValue(incomingObj, "__typename");
|
|
6014
|
-
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
6015
|
-
var typeDotName = "".concat(parentType, ".").concat(fieldName);
|
|
6016
|
-
if (warnings.has(typeDotName))
|
|
6017
|
-
return;
|
|
6018
|
-
warnings.add(typeDotName);
|
|
6019
|
-
var childTypenames = [];
|
|
6020
|
-
if (!Array.isArray(existing) && !Array.isArray(incoming)) {
|
|
6021
|
-
[existing, incoming].forEach(function(child) {
|
|
6022
|
-
var typename = store.getFieldValue(child, "__typename");
|
|
6023
|
-
if (typeof typename === "string" && !childTypenames.includes(typename)) {
|
|
6024
|
-
childTypenames.push(typename);
|
|
6025
|
-
}
|
|
6026
|
-
});
|
|
6027
|
-
}
|
|
6028
|
-
__DEV__ && invariant.warn("Cache data may be lost when replacing the ".concat(fieldName, " field of a ").concat(parentType, " object.\n\nTo address this problem (which is not a bug in Apollo Client), ").concat(childTypenames.length ? "either ensure all objects of type " + childTypenames.join(" and ") + " have an ID or a custom merge function, or " : "", "define a custom merge function for the ").concat(typeDotName, " field, so InMemoryCache can safely merge these objects:\n\n existing: ").concat(JSON.stringify(existing).slice(0, 1e3), "\n incoming: ").concat(JSON.stringify(incoming).slice(0, 1e3), "\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n"));
|
|
6029
|
-
}
|
|
6030
|
-
var InMemoryCache = function(_super) {
|
|
6031
|
-
__extends(InMemoryCache2, _super);
|
|
6032
|
-
function InMemoryCache2(config) {
|
|
6033
|
-
if (config === void 0) {
|
|
6034
|
-
config = {};
|
|
6035
|
-
}
|
|
6036
|
-
var _this = _super.call(this) || this;
|
|
6037
|
-
_this.watches = new Set();
|
|
6038
|
-
_this.typenameDocumentCache = new Map();
|
|
6039
|
-
_this.makeVar = makeVar;
|
|
6040
|
-
_this.txCount = 0;
|
|
6041
|
-
_this.config = normalizeConfig(config);
|
|
6042
|
-
_this.addTypename = !!_this.config.addTypename;
|
|
6043
|
-
_this.policies = new Policies({
|
|
6044
|
-
cache: _this,
|
|
6045
|
-
dataIdFromObject: _this.config.dataIdFromObject,
|
|
6046
|
-
possibleTypes: _this.config.possibleTypes,
|
|
6047
|
-
typePolicies: _this.config.typePolicies
|
|
6048
|
-
});
|
|
6049
|
-
_this.init();
|
|
6050
|
-
return _this;
|
|
6051
|
-
}
|
|
6052
|
-
InMemoryCache2.prototype.init = function() {
|
|
6053
|
-
var rootStore = this.data = new EntityStore.Root({
|
|
6054
|
-
policies: this.policies,
|
|
6055
|
-
resultCaching: this.config.resultCaching
|
|
6056
|
-
});
|
|
6057
|
-
this.optimisticData = rootStore.stump;
|
|
6058
|
-
this.resetResultCache();
|
|
6059
|
-
};
|
|
6060
|
-
InMemoryCache2.prototype.resetResultCache = function(resetResultIdentities) {
|
|
6061
|
-
var _this = this;
|
|
6062
|
-
var previousReader = this.storeReader;
|
|
6063
|
-
this.storeWriter = new StoreWriter(this, this.storeReader = new StoreReader({
|
|
6064
|
-
cache: this,
|
|
6065
|
-
addTypename: this.addTypename,
|
|
6066
|
-
resultCacheMaxSize: this.config.resultCacheMaxSize,
|
|
6067
|
-
canonizeResults: shouldCanonizeResults(this.config),
|
|
6068
|
-
canon: resetResultIdentities ? void 0 : previousReader && previousReader.canon
|
|
6069
|
-
}));
|
|
6070
|
-
this.maybeBroadcastWatch = wrap(function(c, options) {
|
|
6071
|
-
return _this.broadcastWatch(c, options);
|
|
6072
|
-
}, {
|
|
6073
|
-
max: this.config.resultCacheMaxSize,
|
|
6074
|
-
makeCacheKey: function(c) {
|
|
6075
|
-
var store = c.optimistic ? _this.optimisticData : _this.data;
|
|
6076
|
-
if (supportsResultCaching(store)) {
|
|
6077
|
-
var optimistic = c.optimistic, rootId = c.rootId, variables = c.variables;
|
|
6078
|
-
return store.makeCacheKey(c.query, c.callback, canonicalStringify({ optimistic, rootId, variables }));
|
|
6079
|
-
}
|
|
6080
|
-
}
|
|
6081
|
-
});
|
|
6082
|
-
new Set([
|
|
6083
|
-
this.data.group,
|
|
6084
|
-
this.optimisticData.group
|
|
6085
|
-
]).forEach(function(group) {
|
|
6086
|
-
return group.resetCaching();
|
|
6087
|
-
});
|
|
6088
|
-
};
|
|
6089
|
-
InMemoryCache2.prototype.restore = function(data) {
|
|
6090
|
-
this.init();
|
|
6091
|
-
if (data)
|
|
6092
|
-
this.data.replace(data);
|
|
6093
|
-
return this;
|
|
6094
|
-
};
|
|
6095
|
-
InMemoryCache2.prototype.extract = function(optimistic) {
|
|
6096
|
-
if (optimistic === void 0) {
|
|
6097
|
-
optimistic = false;
|
|
6098
|
-
}
|
|
6099
|
-
return (optimistic ? this.optimisticData : this.data).extract();
|
|
6100
|
-
};
|
|
6101
|
-
InMemoryCache2.prototype.read = function(options) {
|
|
6102
|
-
var _a2 = options.returnPartialData, returnPartialData = _a2 === void 0 ? false : _a2;
|
|
6103
|
-
try {
|
|
6104
|
-
return this.storeReader.diffQueryAgainstStore(__assign(__assign({}, options), { store: options.optimistic ? this.optimisticData : this.data, config: this.config, returnPartialData })).result || null;
|
|
6105
|
-
} catch (e) {
|
|
6106
|
-
if (e instanceof MissingFieldError) {
|
|
6107
|
-
return null;
|
|
6108
|
-
}
|
|
6109
|
-
throw e;
|
|
6110
|
-
}
|
|
6111
|
-
};
|
|
6112
|
-
InMemoryCache2.prototype.write = function(options) {
|
|
6113
|
-
try {
|
|
6114
|
-
++this.txCount;
|
|
6115
|
-
return this.storeWriter.writeToStore(this.data, options);
|
|
6116
|
-
} finally {
|
|
6117
|
-
if (!--this.txCount && options.broadcast !== false) {
|
|
6118
|
-
this.broadcastWatches();
|
|
6119
|
-
}
|
|
6120
|
-
}
|
|
6121
|
-
};
|
|
6122
|
-
InMemoryCache2.prototype.modify = function(options) {
|
|
6123
|
-
if (hasOwn.call(options, "id") && !options.id) {
|
|
6124
|
-
return false;
|
|
6125
|
-
}
|
|
6126
|
-
var store = options.optimistic ? this.optimisticData : this.data;
|
|
6127
|
-
try {
|
|
6128
|
-
++this.txCount;
|
|
6129
|
-
return store.modify(options.id || "ROOT_QUERY", options.fields);
|
|
6130
|
-
} finally {
|
|
6131
|
-
if (!--this.txCount && options.broadcast !== false) {
|
|
6132
|
-
this.broadcastWatches();
|
|
6133
|
-
}
|
|
6134
|
-
}
|
|
6135
|
-
};
|
|
6136
|
-
InMemoryCache2.prototype.diff = function(options) {
|
|
6137
|
-
return this.storeReader.diffQueryAgainstStore(__assign(__assign({}, options), { store: options.optimistic ? this.optimisticData : this.data, rootId: options.id || "ROOT_QUERY", config: this.config }));
|
|
6138
|
-
};
|
|
6139
|
-
InMemoryCache2.prototype.watch = function(watch2) {
|
|
6140
|
-
var _this = this;
|
|
6141
|
-
if (!this.watches.size) {
|
|
6142
|
-
recallCache(this);
|
|
6143
|
-
}
|
|
6144
|
-
this.watches.add(watch2);
|
|
6145
|
-
if (watch2.immediate) {
|
|
6146
|
-
this.maybeBroadcastWatch(watch2);
|
|
6147
|
-
}
|
|
6148
|
-
return function() {
|
|
6149
|
-
if (_this.watches.delete(watch2) && !_this.watches.size) {
|
|
6150
|
-
forgetCache(_this);
|
|
6151
|
-
}
|
|
6152
|
-
_this.maybeBroadcastWatch.forget(watch2);
|
|
6153
|
-
};
|
|
6154
|
-
};
|
|
6155
|
-
InMemoryCache2.prototype.gc = function(options) {
|
|
6156
|
-
canonicalStringify.reset();
|
|
6157
|
-
var ids = this.optimisticData.gc();
|
|
6158
|
-
if (options && !this.txCount) {
|
|
6159
|
-
if (options.resetResultCache) {
|
|
6160
|
-
this.resetResultCache(options.resetResultIdentities);
|
|
6161
|
-
} else if (options.resetResultIdentities) {
|
|
6162
|
-
this.storeReader.resetCanon();
|
|
6163
|
-
}
|
|
6164
|
-
}
|
|
6165
|
-
return ids;
|
|
6166
|
-
};
|
|
6167
|
-
InMemoryCache2.prototype.retain = function(rootId, optimistic) {
|
|
6168
|
-
return (optimistic ? this.optimisticData : this.data).retain(rootId);
|
|
6169
|
-
};
|
|
6170
|
-
InMemoryCache2.prototype.release = function(rootId, optimistic) {
|
|
6171
|
-
return (optimistic ? this.optimisticData : this.data).release(rootId);
|
|
6172
|
-
};
|
|
6173
|
-
InMemoryCache2.prototype.identify = function(object) {
|
|
6174
|
-
if (isReference(object))
|
|
6175
|
-
return object.__ref;
|
|
6176
|
-
try {
|
|
6177
|
-
return this.policies.identify(object)[0];
|
|
6178
|
-
} catch (e) {
|
|
6179
|
-
__DEV__ && invariant.warn(e);
|
|
6180
|
-
}
|
|
6181
|
-
};
|
|
6182
|
-
InMemoryCache2.prototype.evict = function(options) {
|
|
6183
|
-
if (!options.id) {
|
|
6184
|
-
if (hasOwn.call(options, "id")) {
|
|
6185
|
-
return false;
|
|
6186
|
-
}
|
|
6187
|
-
options = __assign(__assign({}, options), { id: "ROOT_QUERY" });
|
|
6188
|
-
}
|
|
6189
|
-
try {
|
|
6190
|
-
++this.txCount;
|
|
6191
|
-
return this.optimisticData.evict(options, this.data);
|
|
6192
|
-
} finally {
|
|
6193
|
-
if (!--this.txCount && options.broadcast !== false) {
|
|
6194
|
-
this.broadcastWatches();
|
|
6195
|
-
}
|
|
6196
|
-
}
|
|
6197
|
-
};
|
|
6198
|
-
InMemoryCache2.prototype.reset = function(options) {
|
|
6199
|
-
var _this = this;
|
|
6200
|
-
this.init();
|
|
6201
|
-
canonicalStringify.reset();
|
|
6202
|
-
if (options && options.discardWatches) {
|
|
6203
|
-
this.watches.forEach(function(watch2) {
|
|
6204
|
-
return _this.maybeBroadcastWatch.forget(watch2);
|
|
6205
|
-
});
|
|
6206
|
-
this.watches.clear();
|
|
6207
|
-
forgetCache(this);
|
|
6208
|
-
} else {
|
|
6209
|
-
this.broadcastWatches();
|
|
6210
|
-
}
|
|
6211
|
-
return Promise.resolve();
|
|
6212
|
-
};
|
|
6213
|
-
InMemoryCache2.prototype.removeOptimistic = function(idToRemove) {
|
|
6214
|
-
var newOptimisticData = this.optimisticData.removeLayer(idToRemove);
|
|
6215
|
-
if (newOptimisticData !== this.optimisticData) {
|
|
6216
|
-
this.optimisticData = newOptimisticData;
|
|
6217
|
-
this.broadcastWatches();
|
|
6218
|
-
}
|
|
6219
|
-
};
|
|
6220
|
-
InMemoryCache2.prototype.batch = function(options) {
|
|
6221
|
-
var _this = this;
|
|
6222
|
-
var update = options.update, _a2 = options.optimistic, optimistic = _a2 === void 0 ? true : _a2, removeOptimistic = options.removeOptimistic, onWatchUpdated = options.onWatchUpdated;
|
|
6223
|
-
var updateResult;
|
|
6224
|
-
var perform = function(layer) {
|
|
6225
|
-
var _a3 = _this, data = _a3.data, optimisticData = _a3.optimisticData;
|
|
6226
|
-
++_this.txCount;
|
|
6227
|
-
if (layer) {
|
|
6228
|
-
_this.data = _this.optimisticData = layer;
|
|
6229
|
-
}
|
|
6230
|
-
try {
|
|
6231
|
-
return updateResult = update(_this);
|
|
6232
|
-
} finally {
|
|
6233
|
-
--_this.txCount;
|
|
6234
|
-
_this.data = data;
|
|
6235
|
-
_this.optimisticData = optimisticData;
|
|
6236
|
-
}
|
|
6237
|
-
};
|
|
6238
|
-
var alreadyDirty = new Set();
|
|
6239
|
-
if (onWatchUpdated && !this.txCount) {
|
|
6240
|
-
this.broadcastWatches(__assign(__assign({}, options), { onWatchUpdated: function(watch2) {
|
|
6241
|
-
alreadyDirty.add(watch2);
|
|
6242
|
-
return false;
|
|
6243
|
-
} }));
|
|
6244
|
-
}
|
|
6245
|
-
if (typeof optimistic === "string") {
|
|
6246
|
-
this.optimisticData = this.optimisticData.addLayer(optimistic, perform);
|
|
6247
|
-
} else if (optimistic === false) {
|
|
6248
|
-
perform(this.data);
|
|
6249
|
-
} else {
|
|
6250
|
-
perform();
|
|
6251
|
-
}
|
|
6252
|
-
if (typeof removeOptimistic === "string") {
|
|
6253
|
-
this.optimisticData = this.optimisticData.removeLayer(removeOptimistic);
|
|
6254
|
-
}
|
|
6255
|
-
if (onWatchUpdated && alreadyDirty.size) {
|
|
6256
|
-
this.broadcastWatches(__assign(__assign({}, options), { onWatchUpdated: function(watch2, diff) {
|
|
6257
|
-
var result = onWatchUpdated.call(this, watch2, diff);
|
|
6258
|
-
if (result !== false) {
|
|
6259
|
-
alreadyDirty.delete(watch2);
|
|
6260
|
-
}
|
|
6261
|
-
return result;
|
|
6262
|
-
} }));
|
|
6263
|
-
if (alreadyDirty.size) {
|
|
6264
|
-
alreadyDirty.forEach(function(watch2) {
|
|
6265
|
-
return _this.maybeBroadcastWatch.dirty(watch2);
|
|
6266
|
-
});
|
|
6267
|
-
}
|
|
6268
|
-
} else {
|
|
6269
|
-
this.broadcastWatches(options);
|
|
6270
|
-
}
|
|
6271
|
-
return updateResult;
|
|
6272
|
-
};
|
|
6273
|
-
InMemoryCache2.prototype.performTransaction = function(update, optimisticId) {
|
|
6274
|
-
return this.batch({
|
|
6275
|
-
update,
|
|
6276
|
-
optimistic: optimisticId || optimisticId !== null
|
|
6277
|
-
});
|
|
6278
|
-
};
|
|
6279
|
-
InMemoryCache2.prototype.transformDocument = function(document) {
|
|
6280
|
-
if (this.addTypename) {
|
|
6281
|
-
var result = this.typenameDocumentCache.get(document);
|
|
6282
|
-
if (!result) {
|
|
6283
|
-
result = addTypenameToDocument(document);
|
|
6284
|
-
this.typenameDocumentCache.set(document, result);
|
|
6285
|
-
this.typenameDocumentCache.set(result, result);
|
|
6286
|
-
}
|
|
6287
|
-
return result;
|
|
6288
|
-
}
|
|
6289
|
-
return document;
|
|
6290
|
-
};
|
|
6291
|
-
InMemoryCache2.prototype.broadcastWatches = function(options) {
|
|
6292
|
-
var _this = this;
|
|
6293
|
-
if (!this.txCount) {
|
|
6294
|
-
this.watches.forEach(function(c) {
|
|
6295
|
-
return _this.maybeBroadcastWatch(c, options);
|
|
6296
|
-
});
|
|
6297
|
-
}
|
|
6298
|
-
};
|
|
6299
|
-
InMemoryCache2.prototype.broadcastWatch = function(c, options) {
|
|
6300
|
-
var lastDiff = c.lastDiff;
|
|
6301
|
-
var diff = this.diff(c);
|
|
6302
|
-
if (options) {
|
|
6303
|
-
if (c.optimistic && typeof options.optimistic === "string") {
|
|
6304
|
-
diff.fromOptimisticTransaction = true;
|
|
6305
|
-
}
|
|
6306
|
-
if (options.onWatchUpdated && options.onWatchUpdated.call(this, c, diff, lastDiff) === false) {
|
|
6307
|
-
return;
|
|
6308
|
-
}
|
|
6309
|
-
}
|
|
6310
|
-
if (!lastDiff || !equal(lastDiff.result, diff.result)) {
|
|
6311
|
-
c.callback(c.lastDiff = diff, lastDiff);
|
|
6312
|
-
}
|
|
6313
|
-
};
|
|
6314
|
-
return InMemoryCache2;
|
|
6315
|
-
}(ApolloCache);
|
|
6316
|
-
const defaultTaskTemplate = {
|
|
6317
|
-
taskTemplateObj: {},
|
|
6318
|
-
isAddedToTask: false,
|
|
6319
|
-
isNotified: false
|
|
6320
|
-
};
|
|
6321
|
-
var __vue2_script$1 = defineComponent({
|
|
6322
|
-
name: "index",
|
|
6323
|
-
components: {
|
|
6324
|
-
NewTask,
|
|
6325
|
-
MainModal,
|
|
6326
|
-
ReviewModal
|
|
6327
|
-
},
|
|
6328
|
-
props: {
|
|
6329
|
-
uploadFilesFunc: {
|
|
6330
|
-
type: Function,
|
|
6331
|
-
required: true
|
|
6332
|
-
},
|
|
6333
|
-
visible: {
|
|
6334
|
-
type: Boolean,
|
|
6335
|
-
default: false
|
|
6336
|
-
},
|
|
6337
|
-
userId: {
|
|
6338
|
-
type: String,
|
|
6339
|
-
required: true
|
|
6340
|
-
},
|
|
6341
|
-
lawFirmId: {
|
|
6342
|
-
type: Number,
|
|
6343
|
-
required: true
|
|
6344
|
-
},
|
|
6345
|
-
value: {
|
|
6346
|
-
type: Array,
|
|
6347
|
-
default: () => []
|
|
6348
|
-
},
|
|
6349
|
-
reviewText: {
|
|
6350
|
-
type: String,
|
|
6351
|
-
default: "Add"
|
|
6352
|
-
},
|
|
6353
|
-
showSendEmail: {
|
|
6354
|
-
type: Boolean,
|
|
6355
|
-
default: false
|
|
6356
|
-
},
|
|
6357
|
-
sendEmail: {
|
|
6358
|
-
type: Boolean,
|
|
6359
|
-
default: false
|
|
6360
|
-
},
|
|
6361
|
-
taskSettingPageUrl: {
|
|
6362
|
-
type: String
|
|
6363
|
-
},
|
|
6364
|
-
allowClear: {
|
|
6365
|
-
type: Boolean,
|
|
6366
|
-
default: false
|
|
6367
|
-
},
|
|
6368
|
-
pageMode: {
|
|
6369
|
-
type: Boolean,
|
|
6370
|
-
default: false
|
|
6371
|
-
}
|
|
6372
|
-
},
|
|
6373
|
-
setup(props, { emit }) {
|
|
6374
|
-
const mainModal = ref$1();
|
|
6375
|
-
const reviewModal = ref$1();
|
|
6376
|
-
const newTaskVisible = ref$1(false);
|
|
6377
|
-
const reviewModalVisible = ref$1(false);
|
|
6378
|
-
const tempTask = ref$1(defaultTaskTemplate);
|
|
6379
|
-
const updateTemplate = useMutateTaskTemplate();
|
|
6380
|
-
const createTemplate = useCreateTaskTemplate();
|
|
6381
|
-
const addedTasks = ref$1([]);
|
|
6382
|
-
new InMemoryCache();
|
|
6383
|
-
onMounted(() => {
|
|
6384
|
-
const { value, lawFirmId } = props;
|
|
6385
|
-
if (!value.length)
|
|
6386
|
-
return;
|
|
6387
|
-
const conditions = ref$1({
|
|
6388
|
-
taskTemplateId: value
|
|
6389
|
-
});
|
|
6390
|
-
const { result } = useSearchTaskTemplates(ref$1({ current: 1, pageSize: 1e3, total: 0 }), conditions, lawFirmId);
|
|
6391
|
-
watch(() => result.value, () => {
|
|
6392
|
-
var _a2, _b;
|
|
6393
|
-
addedTasks.value = ((_b = (_a2 = result.value) == null ? void 0 : _a2.taskTemplateSearch) == null ? void 0 : _b.taskTemplateList) || [];
|
|
6394
|
-
});
|
|
6395
|
-
});
|
|
6396
|
-
watch(() => newTaskVisible.value, (visible) => {
|
|
6397
|
-
if (!visible) {
|
|
6398
|
-
tempTask.value = defaultTaskTemplate;
|
|
6399
|
-
}
|
|
6400
|
-
});
|
|
6401
|
-
const _submit = async (record) => {
|
|
6402
|
-
const {
|
|
6403
|
-
newRecord,
|
|
6404
|
-
success
|
|
6405
|
-
} = await submit(record, updateTemplate, createTemplate);
|
|
6406
|
-
if (success) {
|
|
6407
|
-
newTaskVisible.value = false;
|
|
6408
|
-
mainModal.value.taskTable.refetch();
|
|
6409
|
-
if (reviewModalVisible.value) {
|
|
6410
|
-
const newValue = addedTasks.value.map((originTask) => {
|
|
6411
|
-
if (originTask.id === record.taskTemplateId) {
|
|
6412
|
-
return newRecord;
|
|
6413
|
-
}
|
|
6414
|
-
return originTask;
|
|
6415
|
-
});
|
|
6416
|
-
emit("update:value", newValue.map(({ id }) => id));
|
|
6417
|
-
}
|
|
6418
|
-
}
|
|
6419
|
-
};
|
|
6420
|
-
const submitting = computed(() => updateTemplate.loading.value || createTemplate.loading.value);
|
|
6421
|
-
return {
|
|
6422
|
-
mainModal,
|
|
6423
|
-
reviewModal,
|
|
6424
|
-
_submit,
|
|
6425
|
-
newTaskVisible,
|
|
6426
|
-
tempTask,
|
|
6427
|
-
reviewModalVisible,
|
|
6428
|
-
submitting,
|
|
6429
|
-
addedTasks
|
|
6430
|
-
};
|
|
2857
|
+
};
|
|
2858
|
+
const submitting = computed(() => updateTemplate.loading.value || createTemplate.loading.value);
|
|
2859
|
+
const showEdit = (record) => {
|
|
2860
|
+
newTaskVisible.value = true;
|
|
2861
|
+
tempTask.value = {
|
|
2862
|
+
taskTemplateObj: __spreadValues({}, record)
|
|
2863
|
+
};
|
|
2864
|
+
};
|
|
2865
|
+
return {
|
|
2866
|
+
showEdit,
|
|
2867
|
+
mainModal,
|
|
2868
|
+
reviewModal,
|
|
2869
|
+
_submit,
|
|
2870
|
+
newTaskVisible,
|
|
2871
|
+
tempTask,
|
|
2872
|
+
reviewModalVisible,
|
|
2873
|
+
submitting,
|
|
2874
|
+
addedTasks
|
|
2875
|
+
};
|
|
6431
2876
|
}
|
|
6432
2877
|
});
|
|
6433
2878
|
var render$1 = function() {
|
|
6434
2879
|
var _vm = this;
|
|
6435
2880
|
var _h = _vm.$createElement;
|
|
6436
2881
|
var _c = _vm._self._c || _h;
|
|
6437
|
-
return _c("div", { attrs: { "id": "venus-component-task-cart" } }, [_c("main-modal", { ref: "mainModal", attrs: { "
|
|
2882
|
+
return _c("div", { attrs: { "id": "venus-component-task-cart" } }, [_c("main-modal", { ref: "mainModal", attrs: { "visible": _vm.visible, "show-page": _vm.pageMode, "page-size": _vm.pageSize, "law-firm-id": _vm.lawFirmId, "tempTask": _vm.tempTask, "added-tasks": _vm.addedTasks, "newTaskVisible": _vm.newTaskVisible, "task-setting-page-url": _vm.taskSettingPageUrl, "reviewModalVisible": _vm.reviewModalVisible, "open-review-button-text": _vm.openReviewButtonText }, on: { "update:tempTask": function($event) {
|
|
6438
2883
|
_vm.tempTask = $event;
|
|
6439
2884
|
}, "update:temp-task": function($event) {
|
|
6440
2885
|
_vm.tempTask = $event;
|
|
2886
|
+
}, "update:addedTasks": function($event) {
|
|
2887
|
+
_vm.addedTasks = $event;
|
|
2888
|
+
}, "update:added-tasks": function($event) {
|
|
2889
|
+
_vm.addedTasks = $event;
|
|
6441
2890
|
}, "update:newTaskVisible": function($event) {
|
|
6442
2891
|
_vm.newTaskVisible = $event;
|
|
6443
2892
|
}, "update:new-task-visible": function($event) {
|
|
@@ -6446,11 +2895,7 @@ var render$1 = function() {
|
|
|
6446
2895
|
_vm.reviewModalVisible = $event;
|
|
6447
2896
|
}, "update:review-modal-visible": function($event) {
|
|
6448
2897
|
_vm.reviewModalVisible = $event;
|
|
6449
|
-
}, "update:
|
|
6450
|
-
_vm.addedTasks = $event;
|
|
6451
|
-
}, "update:added-tasks": function($event) {
|
|
6452
|
-
_vm.addedTasks = $event;
|
|
6453
|
-
}, "update:visible": function($event) {
|
|
2898
|
+
}, "edit": _vm.showEdit, "update:visible": function($event) {
|
|
6454
2899
|
return _vm.$emit("update:visible", $event);
|
|
6455
2900
|
} }, scopedSlots: _vm._u([{ key: "default", fn: function(ref2) {
|
|
6456
2901
|
var loading = ref2.loading;
|
|
@@ -6458,25 +2903,25 @@ var render$1 = function() {
|
|
|
6458
2903
|
var pagination = ref2.pagination;
|
|
6459
2904
|
var changePagination = ref2.changePagination;
|
|
6460
2905
|
return [_vm._t("table", null, { "loading": loading, "dataSource": dataSource, "pagination": pagination, "changePagination": changePagination })];
|
|
6461
|
-
} }], null, true) }), _c("review-modal", { ref: "reviewModal", attrs: { "
|
|
2906
|
+
} }], null, true) }), _c("review-modal", { ref: "reviewModal", attrs: { "sendEmail": _vm.sendEmail, "allow-clear": _vm.allowClear, "tempTask": _vm.tempTask, "review-text": _vm.reviewText, "added-tasks": _vm.addedTasks, "showSendEmail": _vm.showSendEmail, "visible": _vm.reviewModalVisible, "newTaskVisible": _vm.newTaskVisible }, on: { "update:tempTask": function($event) {
|
|
6462
2907
|
_vm.tempTask = $event;
|
|
6463
2908
|
}, "update:temp-task": function($event) {
|
|
6464
2909
|
_vm.tempTask = $event;
|
|
2910
|
+
}, "update:addedTasks": function($event) {
|
|
2911
|
+
_vm.addedTasks = $event;
|
|
2912
|
+
}, "update:added-tasks": function($event) {
|
|
2913
|
+
_vm.addedTasks = $event;
|
|
6465
2914
|
}, "update:visible": function($event) {
|
|
6466
2915
|
_vm.reviewModalVisible = $event;
|
|
6467
2916
|
}, "update:newTaskVisible": function($event) {
|
|
6468
2917
|
_vm.newTaskVisible = $event;
|
|
6469
2918
|
}, "update:new-task-visible": function($event) {
|
|
6470
2919
|
_vm.newTaskVisible = $event;
|
|
6471
|
-
}, "update:addedTasks": function($event) {
|
|
6472
|
-
_vm.addedTasks = $event;
|
|
6473
|
-
}, "update:added-tasks": function($event) {
|
|
6474
|
-
_vm.addedTasks = $event;
|
|
6475
|
-
}, "update:sendEmail": function($event) {
|
|
6476
|
-
return _vm.$emit("update:sendEmail", $event);
|
|
6477
2920
|
}, "submit": function($event) {
|
|
6478
2921
|
return _vm.$emit("submit", $event);
|
|
6479
|
-
}
|
|
2922
|
+
}, "update:sendEmail": function($event) {
|
|
2923
|
+
return _vm.$emit("update:sendEmail", $event);
|
|
2924
|
+
} } }), _c("new-task", { attrs: { "user-id": _vm.userId, "loading": _vm.submitting, "value": _vm.tempTask, "law-firm-id": _vm.lawFirmId, "visible": _vm.newTaskVisible, "upload-files-func": _vm.uploadFilesFunc }, on: { "update:value": function($event) {
|
|
6480
2925
|
_vm.tempTask = $event;
|
|
6481
2926
|
}, "update:visible": function($event) {
|
|
6482
2927
|
_vm.newTaskVisible = $event;
|
|
@@ -6485,7 +2930,7 @@ var render$1 = function() {
|
|
|
6485
2930
|
var staticRenderFns$1 = [];
|
|
6486
2931
|
var index_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
6487
2932
|
const __cssModules$1 = {};
|
|
6488
|
-
var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script$1, render$1, staticRenderFns$1, false, __vue2_injectStyles$1, "
|
|
2933
|
+
var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script$1, render$1, staticRenderFns$1, false, __vue2_injectStyles$1, "21942322", null, null);
|
|
6489
2934
|
function __vue2_injectStyles$1(context) {
|
|
6490
2935
|
for (let o in __cssModules$1) {
|
|
6491
2936
|
this[o] = __cssModules$1[o];
|