@nokecy/qc-ui 1.0.94 → 1.0.96
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/cjs/ag-grid-plus/ag-gridPlus.js +252 -173
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +108 -20
- package/dist/cjs/ag-grid-plus/context/gridContext.js +12 -4
- package/dist/cjs/ag-grid-plus/context/useSchemeDataFlow.d.ts +88 -0
- package/dist/cjs/ag-grid-plus/context/useSchemeDataFlow.js +173 -0
- package/dist/cjs/ag-grid-plus/context/useSchemeManager.d.ts +111 -0
- package/dist/cjs/ag-grid-plus/context/useSchemeManager.js +596 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.d.ts +1 -1
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.d.ts +2 -2
- package/dist/cjs/ag-grid-plus/index.d.ts +7 -2
- package/dist/cjs/ag-grid-plus/index.js +11 -93
- package/dist/cjs/ag-grid-plus/interface.d.ts +0 -31
- package/dist/cjs/ag-grid-plus/interface.js +3 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.d.ts +0 -3
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +279 -145
- package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.d.ts +11 -0
- package/dist/cjs/ag-grid-plus/{querySchemes/components/QuerySchemesManager.js → setting/QuerySchemeManager.js} +193 -108
- package/dist/cjs/ag-grid-plus/setting/index.d.ts +2 -2
- package/dist/cjs/ag-grid-plus/setting/index.js +33 -48
- package/dist/cjs/ag-grid-plus/shared/storage/backendApiAdapter.d.ts +58 -0
- package/dist/cjs/ag-grid-plus/shared/storage/backendApiAdapter.js +446 -0
- package/dist/cjs/ag-grid-plus/shared/storage/localStorageAdapter.d.ts +57 -0
- package/dist/cjs/ag-grid-plus/{schemes → shared}/storage/localStorageAdapter.js +253 -271
- package/dist/cjs/ag-grid-plus/shared/storage/schemeStorageAdapter.d.ts +132 -0
- package/dist/cjs/array-table/index.js +167 -45
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +14 -86
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +252 -173
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +108 -20
- package/dist/esm/ag-grid-plus/context/gridContext.js +13 -4
- package/dist/esm/ag-grid-plus/context/useSchemeDataFlow.d.ts +88 -0
- package/dist/esm/ag-grid-plus/context/useSchemeDataFlow.js +165 -0
- package/dist/esm/ag-grid-plus/context/useSchemeManager.d.ts +111 -0
- package/dist/esm/ag-grid-plus/context/useSchemeManager.js +590 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.d.ts +1 -1
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.d.ts +2 -2
- package/dist/esm/ag-grid-plus/index.d.ts +7 -2
- package/dist/esm/ag-grid-plus/index.js +9 -5
- package/dist/esm/ag-grid-plus/interface.d.ts +0 -31
- package/dist/esm/ag-grid-plus/interface.js +2 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.d.ts +0 -3
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +281 -147
- package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.d.ts +11 -0
- package/dist/esm/ag-grid-plus/{querySchemes/components/QuerySchemesManager.js → setting/QuerySchemeManager.js} +192 -107
- package/dist/esm/ag-grid-plus/setting/index.d.ts +2 -2
- package/dist/esm/ag-grid-plus/setting/index.js +33 -48
- package/dist/esm/ag-grid-plus/shared/storage/backendApiAdapter.d.ts +58 -0
- package/dist/esm/ag-grid-plus/shared/storage/backendApiAdapter.js +444 -0
- package/dist/esm/ag-grid-plus/shared/storage/localStorageAdapter.d.ts +57 -0
- package/dist/esm/ag-grid-plus/{schemes → shared}/storage/localStorageAdapter.js +252 -271
- package/dist/esm/ag-grid-plus/shared/storage/schemeStorageAdapter.d.ts +132 -0
- package/dist/esm/array-table/index.js +168 -46
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +11 -11
- package/dist/esm/standardFormDialog/useStandardFormSchema.d.ts +1 -1
- package/dist/umd/qc-ui.min.css +1 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.d.ts +0 -21
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +0 -86
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.d.ts +0 -5
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.js +0 -12
- package/dist/cjs/ag-grid-plus/querySchemes/constants.d.ts +0 -17
- package/dist/cjs/ag-grid-plus/querySchemes/constants.js +0 -30
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +0 -10
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +0 -65
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +0 -6
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.js +0 -564
- package/dist/cjs/ag-grid-plus/querySchemes/index.d.ts +0 -11
- package/dist/cjs/ag-grid-plus/querySchemes/index.js +0 -113
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +0 -44
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +0 -261
- package/dist/cjs/ag-grid-plus/querySchemes/types.d.ts +0 -145
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.d.ts +0 -36
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.js +0 -155
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.d.ts +0 -16
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.js +0 -342
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.less +0 -35
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.d.ts +0 -20
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.js +0 -289
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.less +0 -39
- package/dist/cjs/ag-grid-plus/schemes/components/index.d.ts +0 -4
- package/dist/cjs/ag-grid-plus/schemes/components/index.js +0 -19
- package/dist/cjs/ag-grid-plus/schemes/constants.d.ts +0 -23
- package/dist/cjs/ag-grid-plus/schemes/constants.js +0 -39
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +0 -6
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.js +0 -617
- package/dist/cjs/ag-grid-plus/schemes/index.d.ts +0 -23
- package/dist/cjs/ag-grid-plus/schemes/index.js +0 -164
- package/dist/cjs/ag-grid-plus/schemes/storage/configMerger.d.ts +0 -10
- package/dist/cjs/ag-grid-plus/schemes/storage/configMerger.js +0 -34
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +0 -79
- package/dist/cjs/ag-grid-plus/schemes/storage/priorityStorageAdapter.d.ts +0 -122
- package/dist/cjs/ag-grid-plus/schemes/storage/priorityStorageAdapter.js +0 -476
- package/dist/cjs/ag-grid-plus/schemes/storage/remoteStorageAdapter.d.ts +0 -139
- package/dist/cjs/ag-grid-plus/schemes/storage/remoteStorageAdapter.js +0 -746
- package/dist/cjs/ag-grid-plus/schemes/storage/useRemoteStorage.d.ts +0 -29
- package/dist/cjs/ag-grid-plus/schemes/storage/useRemoteStorage.js +0 -45
- package/dist/cjs/ag-grid-plus/schemes/types.d.ts +0 -131
- package/dist/cjs/ag-grid-plus/schemes/types.js +0 -5
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.d.ts +0 -27
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.js +0 -109
- package/dist/cjs/ag-grid-plus/storage/index.d.ts +0 -13
- package/dist/cjs/ag-grid-plus/storage/index.js +0 -5
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.d.ts +0 -21
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +0 -86
- package/dist/esm/ag-grid-plus/querySchemes/components/index.d.ts +0 -5
- package/dist/esm/ag-grid-plus/querySchemes/components/index.js +0 -5
- package/dist/esm/ag-grid-plus/querySchemes/constants.d.ts +0 -17
- package/dist/esm/ag-grid-plus/querySchemes/constants.js +0 -24
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +0 -10
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +0 -60
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +0 -6
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.js +0 -559
- package/dist/esm/ag-grid-plus/querySchemes/index.d.ts +0 -11
- package/dist/esm/ag-grid-plus/querySchemes/index.js +0 -20
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +0 -44
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +0 -256
- package/dist/esm/ag-grid-plus/querySchemes/types.d.ts +0 -145
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.d.ts +0 -36
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.js +0 -144
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.d.ts +0 -16
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.js +0 -334
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.less +0 -35
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.d.ts +0 -20
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.js +0 -281
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.less +0 -39
- package/dist/esm/ag-grid-plus/schemes/components/index.d.ts +0 -4
- package/dist/esm/ag-grid-plus/schemes/components/index.js +0 -2
- package/dist/esm/ag-grid-plus/schemes/constants.d.ts +0 -23
- package/dist/esm/ag-grid-plus/schemes/constants.js +0 -33
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +0 -6
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.js +0 -612
- package/dist/esm/ag-grid-plus/schemes/index.d.ts +0 -23
- package/dist/esm/ag-grid-plus/schemes/index.js +0 -30
- package/dist/esm/ag-grid-plus/schemes/storage/configMerger.d.ts +0 -10
- package/dist/esm/ag-grid-plus/schemes/storage/configMerger.js +0 -28
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +0 -79
- package/dist/esm/ag-grid-plus/schemes/storage/priorityStorageAdapter.d.ts +0 -122
- package/dist/esm/ag-grid-plus/schemes/storage/priorityStorageAdapter.js +0 -471
- package/dist/esm/ag-grid-plus/schemes/storage/remoteStorageAdapter.d.ts +0 -139
- package/dist/esm/ag-grid-plus/schemes/storage/remoteStorageAdapter.js +0 -746
- package/dist/esm/ag-grid-plus/schemes/storage/useRemoteStorage.d.ts +0 -29
- package/dist/esm/ag-grid-plus/schemes/storage/useRemoteStorage.js +0 -40
- package/dist/esm/ag-grid-plus/schemes/types.d.ts +0 -131
- package/dist/esm/ag-grid-plus/schemes/types.js +0 -1
- package/dist/esm/ag-grid-plus/schemes/utils/validator.d.ts +0 -27
- package/dist/esm/ag-grid-plus/schemes/utils/validator.js +0 -100
- package/dist/esm/ag-grid-plus/storage/index.d.ts +0 -13
- package/dist/esm/ag-grid-plus/storage/index.js +0 -17
- /package/dist/cjs/ag-grid-plus/{querySchemes/types.js → shared/storage/schemeStorageAdapter.js} +0 -0
- /package/dist/esm/ag-grid-plus/{querySchemes/types.js → shared/storage/schemeStorageAdapter.js} +0 -0
|
@@ -1,476 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PriorityStorageAdapter = void 0;
|
|
7
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
13
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
14
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
-
/**
|
|
18
|
-
* 优先级存储适配器配置
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* 优先级存储适配器
|
|
22
|
-
* 实现远端优先、本地备用的存储策略
|
|
23
|
-
*
|
|
24
|
-
* 核心特性:
|
|
25
|
-
* 1. 主存储优先:优先使用主存储(通常是远端)
|
|
26
|
-
* 2. 自动降级:主存储连续失败时,自动切换到备用存储
|
|
27
|
-
* 3. 自动恢复:定期检测主存储状态,恢复后自动切换回主存储
|
|
28
|
-
* 4. 数据同步:可选地将主存储数据同步到备用存储
|
|
29
|
-
* 5. 完全隔离:不会混用主存储和备用存储的数据
|
|
30
|
-
*/
|
|
31
|
-
var PriorityStorageAdapter = exports.PriorityStorageAdapter = /*#__PURE__*/function () {
|
|
32
|
-
function PriorityStorageAdapter(config) {
|
|
33
|
-
var _config$enableAutoDem, _config$demotionThres, _config$recoveryCheck, _config$syncToFallbac;
|
|
34
|
-
_classCallCheck(this, PriorityStorageAdapter);
|
|
35
|
-
_defineProperty(this, "config", void 0);
|
|
36
|
-
_defineProperty(this, "failureCount", 0);
|
|
37
|
-
_defineProperty(this, "isDemoted", false);
|
|
38
|
-
_defineProperty(this, "recoveryCheckTimer", void 0);
|
|
39
|
-
this.config = {
|
|
40
|
-
primary: config.primary,
|
|
41
|
-
fallback: config.fallback,
|
|
42
|
-
enableAutoDemotion: (_config$enableAutoDem = config.enableAutoDemotion) !== null && _config$enableAutoDem !== void 0 ? _config$enableAutoDem : false,
|
|
43
|
-
demotionThreshold: (_config$demotionThres = config.demotionThreshold) !== null && _config$demotionThres !== void 0 ? _config$demotionThres : 3,
|
|
44
|
-
recoveryCheckInterval: (_config$recoveryCheck = config.recoveryCheckInterval) !== null && _config$recoveryCheck !== void 0 ? _config$recoveryCheck : 60000,
|
|
45
|
-
syncToFallback: (_config$syncToFallbac = config.syncToFallback) !== null && _config$syncToFallbac !== void 0 ? _config$syncToFallbac : false,
|
|
46
|
-
onError: config.onError,
|
|
47
|
-
onDemotion: config.onDemotion,
|
|
48
|
-
onRecovery: config.onRecovery
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// 如果启用自动降级,开始恢复检测
|
|
52
|
-
if (this.config.enableAutoDemotion && this.config.fallback) {
|
|
53
|
-
this.startRecoveryCheck();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 开始恢复检测
|
|
59
|
-
*/
|
|
60
|
-
_createClass(PriorityStorageAdapter, [{
|
|
61
|
-
key: "startRecoveryCheck",
|
|
62
|
-
value: function startRecoveryCheck() {
|
|
63
|
-
var _this = this;
|
|
64
|
-
this.recoveryCheckTimer = setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
65
|
-
var _this$config$onRecove, _this$config;
|
|
66
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
67
|
-
while (1) switch (_context.prev = _context.next) {
|
|
68
|
-
case 0:
|
|
69
|
-
if (!_this.isDemoted) {
|
|
70
|
-
_context.next = 12;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
_context.prev = 1;
|
|
74
|
-
_context.next = 4;
|
|
75
|
-
return _this.config.primary.getSchemes('__health_check__');
|
|
76
|
-
case 4:
|
|
77
|
-
// 如果成功,恢复到主存储
|
|
78
|
-
console.log('[PriorityStorageAdapter] 主存储已恢复,切换回主存储');
|
|
79
|
-
_this.isDemoted = false;
|
|
80
|
-
_this.failureCount = 0;
|
|
81
|
-
(_this$config$onRecove = (_this$config = _this.config).onRecovery) === null || _this$config$onRecove === void 0 || _this$config$onRecove.call(_this$config);
|
|
82
|
-
_context.next = 12;
|
|
83
|
-
break;
|
|
84
|
-
case 10:
|
|
85
|
-
_context.prev = 10;
|
|
86
|
-
_context.t0 = _context["catch"](1);
|
|
87
|
-
case 12:
|
|
88
|
-
case "end":
|
|
89
|
-
return _context.stop();
|
|
90
|
-
}
|
|
91
|
-
}, _callee, null, [[1, 10]]);
|
|
92
|
-
})), this.config.recoveryCheckInterval);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* 停止恢复检测
|
|
97
|
-
*/
|
|
98
|
-
}, {
|
|
99
|
-
key: "stopRecoveryCheck",
|
|
100
|
-
value: function stopRecoveryCheck() {
|
|
101
|
-
if (this.recoveryCheckTimer) {
|
|
102
|
-
clearInterval(this.recoveryCheckTimer);
|
|
103
|
-
this.recoveryCheckTimer = undefined;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* 处理主存储错误
|
|
109
|
-
*/
|
|
110
|
-
}, {
|
|
111
|
-
key: "handlePrimaryError",
|
|
112
|
-
value: function handlePrimaryError(error, operation) {
|
|
113
|
-
var _this$config$onError, _this$config2;
|
|
114
|
-
console.error("[PriorityStorageAdapter] \u4E3B\u5B58\u50A8".concat(operation, "\u5931\u8D25:"), error);
|
|
115
|
-
(_this$config$onError = (_this$config2 = this.config).onError) === null || _this$config$onError === void 0 || _this$config$onError.call(_this$config2, error, 'primary');
|
|
116
|
-
|
|
117
|
-
// 增加失败计数
|
|
118
|
-
this.failureCount++;
|
|
119
|
-
|
|
120
|
-
// 检查是否需要降级
|
|
121
|
-
if (this.config.enableAutoDemotion && this.config.fallback && !this.isDemoted && this.failureCount >= this.config.demotionThreshold) {
|
|
122
|
-
var _this$config$onDemoti, _this$config3;
|
|
123
|
-
console.warn("[PriorityStorageAdapter] \u4E3B\u5B58\u50A8\u8FDE\u7EED\u5931\u8D25".concat(this.failureCount, "\u6B21\uFF0C\u964D\u7EA7\u5230\u5907\u7528\u5B58\u50A8"));
|
|
124
|
-
this.isDemoted = true;
|
|
125
|
-
(_this$config$onDemoti = (_this$config3 = this.config).onDemotion) === null || _this$config$onDemoti === void 0 || _this$config$onDemoti.call(_this$config3);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* 执行带降级的操作
|
|
131
|
-
*/
|
|
132
|
-
}, {
|
|
133
|
-
key: "executeWithFallback",
|
|
134
|
-
value: (function () {
|
|
135
|
-
var _executeWithFallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(operation, primaryFn, fallbackFn) {
|
|
136
|
-
var _this$config$onError2, _this$config4, result, _this$config$onError3, _this$config5;
|
|
137
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
138
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
139
|
-
case 0:
|
|
140
|
-
if (!(this.isDemoted && fallbackFn)) {
|
|
141
|
-
_context2.next = 12;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
_context2.prev = 1;
|
|
145
|
-
_context2.next = 4;
|
|
146
|
-
return fallbackFn();
|
|
147
|
-
case 4:
|
|
148
|
-
return _context2.abrupt("return", _context2.sent);
|
|
149
|
-
case 7:
|
|
150
|
-
_context2.prev = 7;
|
|
151
|
-
_context2.t0 = _context2["catch"](1);
|
|
152
|
-
console.error("[PriorityStorageAdapter] \u5907\u7528\u5B58\u50A8".concat(operation, "\u5931\u8D25:"), _context2.t0);
|
|
153
|
-
(_this$config$onError2 = (_this$config4 = this.config).onError) === null || _this$config$onError2 === void 0 || _this$config$onError2.call(_this$config4, _context2.t0, 'fallback');
|
|
154
|
-
throw _context2.t0;
|
|
155
|
-
case 12:
|
|
156
|
-
_context2.prev = 12;
|
|
157
|
-
_context2.next = 15;
|
|
158
|
-
return primaryFn();
|
|
159
|
-
case 15:
|
|
160
|
-
result = _context2.sent;
|
|
161
|
-
// 操作成功,重置失败计数
|
|
162
|
-
this.failureCount = 0;
|
|
163
|
-
return _context2.abrupt("return", result);
|
|
164
|
-
case 20:
|
|
165
|
-
_context2.prev = 20;
|
|
166
|
-
_context2.t1 = _context2["catch"](12);
|
|
167
|
-
this.handlePrimaryError(_context2.t1, operation);
|
|
168
|
-
|
|
169
|
-
// 如果有备用存储,尝试使用备用存储
|
|
170
|
-
if (!fallbackFn) {
|
|
171
|
-
_context2.next = 36;
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
_context2.prev = 24;
|
|
175
|
-
console.log("[PriorityStorageAdapter] \u4F7F\u7528\u5907\u7528\u5B58\u50A8\u6267\u884C".concat(operation));
|
|
176
|
-
_context2.next = 28;
|
|
177
|
-
return fallbackFn();
|
|
178
|
-
case 28:
|
|
179
|
-
return _context2.abrupt("return", _context2.sent);
|
|
180
|
-
case 31:
|
|
181
|
-
_context2.prev = 31;
|
|
182
|
-
_context2.t2 = _context2["catch"](24);
|
|
183
|
-
console.error("[PriorityStorageAdapter] \u5907\u7528\u5B58\u50A8".concat(operation, "\u4E5F\u5931\u8D25:"), _context2.t2);
|
|
184
|
-
(_this$config$onError3 = (_this$config5 = this.config).onError) === null || _this$config$onError3 === void 0 || _this$config$onError3.call(_this$config5, _context2.t2, 'fallback');
|
|
185
|
-
throw _context2.t2;
|
|
186
|
-
case 36:
|
|
187
|
-
throw _context2.t1;
|
|
188
|
-
case 37:
|
|
189
|
-
case "end":
|
|
190
|
-
return _context2.stop();
|
|
191
|
-
}
|
|
192
|
-
}, _callee2, this, [[1, 7], [12, 20], [24, 31]]);
|
|
193
|
-
}));
|
|
194
|
-
function executeWithFallback(_x, _x2, _x3) {
|
|
195
|
-
return _executeWithFallback.apply(this, arguments);
|
|
196
|
-
}
|
|
197
|
-
return executeWithFallback;
|
|
198
|
-
}()
|
|
199
|
-
/**
|
|
200
|
-
* 获取指定表格的所有方案
|
|
201
|
-
*/
|
|
202
|
-
)
|
|
203
|
-
}, {
|
|
204
|
-
key: "getSchemes",
|
|
205
|
-
value: (function () {
|
|
206
|
-
var _getSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(gridId) {
|
|
207
|
-
var _this2 = this;
|
|
208
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
209
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
210
|
-
case 0:
|
|
211
|
-
return _context3.abrupt("return", this.executeWithFallback('获取方案列表', function () {
|
|
212
|
-
return _this2.config.primary.getSchemes(gridId);
|
|
213
|
-
}, this.config.fallback ? function () {
|
|
214
|
-
return _this2.config.fallback.getSchemes(gridId);
|
|
215
|
-
} : undefined));
|
|
216
|
-
case 1:
|
|
217
|
-
case "end":
|
|
218
|
-
return _context3.stop();
|
|
219
|
-
}
|
|
220
|
-
}, _callee3, this);
|
|
221
|
-
}));
|
|
222
|
-
function getSchemes(_x4) {
|
|
223
|
-
return _getSchemes.apply(this, arguments);
|
|
224
|
-
}
|
|
225
|
-
return getSchemes;
|
|
226
|
-
}()
|
|
227
|
-
/**
|
|
228
|
-
* 保存方案列表
|
|
229
|
-
* 只保存到主存储,确保数据一致性
|
|
230
|
-
*/
|
|
231
|
-
)
|
|
232
|
-
}, {
|
|
233
|
-
key: "saveSchemes",
|
|
234
|
-
value: (function () {
|
|
235
|
-
var _saveSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(gridId, schemes) {
|
|
236
|
-
var _this3 = this;
|
|
237
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
238
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
239
|
-
case 0:
|
|
240
|
-
_context5.next = 2;
|
|
241
|
-
return this.executeWithFallback('保存方案列表', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
242
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
243
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
244
|
-
case 0:
|
|
245
|
-
_context4.next = 2;
|
|
246
|
-
return _this3.config.primary.saveSchemes(gridId, schemes);
|
|
247
|
-
case 2:
|
|
248
|
-
if (!(_this3.config.syncToFallback && _this3.config.fallback)) {
|
|
249
|
-
_context4.next = 12;
|
|
250
|
-
break;
|
|
251
|
-
}
|
|
252
|
-
_context4.prev = 3;
|
|
253
|
-
_context4.next = 6;
|
|
254
|
-
return _this3.config.fallback.saveSchemes(gridId, schemes);
|
|
255
|
-
case 6:
|
|
256
|
-
console.log('[PriorityStorageAdapter] 已同步数据到备用存储');
|
|
257
|
-
_context4.next = 12;
|
|
258
|
-
break;
|
|
259
|
-
case 9:
|
|
260
|
-
_context4.prev = 9;
|
|
261
|
-
_context4.t0 = _context4["catch"](3);
|
|
262
|
-
console.warn('[PriorityStorageAdapter] 同步到备用存储失败,忽略该错误:', _context4.t0);
|
|
263
|
-
case 12:
|
|
264
|
-
case "end":
|
|
265
|
-
return _context4.stop();
|
|
266
|
-
}
|
|
267
|
-
}, _callee4, null, [[3, 9]]);
|
|
268
|
-
})), this.config.fallback ? function () {
|
|
269
|
-
return _this3.config.fallback.saveSchemes(gridId, schemes);
|
|
270
|
-
} : undefined);
|
|
271
|
-
case 2:
|
|
272
|
-
case "end":
|
|
273
|
-
return _context5.stop();
|
|
274
|
-
}
|
|
275
|
-
}, _callee5, this);
|
|
276
|
-
}));
|
|
277
|
-
function saveSchemes(_x5, _x6) {
|
|
278
|
-
return _saveSchemes.apply(this, arguments);
|
|
279
|
-
}
|
|
280
|
-
return saveSchemes;
|
|
281
|
-
}()
|
|
282
|
-
/**
|
|
283
|
-
* 清除指定表格的所有方案
|
|
284
|
-
*/
|
|
285
|
-
)
|
|
286
|
-
}, {
|
|
287
|
-
key: "clearSchemes",
|
|
288
|
-
value: (function () {
|
|
289
|
-
var _clearSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(gridId) {
|
|
290
|
-
var _this4 = this,
|
|
291
|
-
_this$config$fallback;
|
|
292
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
293
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
294
|
-
case 0:
|
|
295
|
-
if (this.config.primary.clearSchemes) {
|
|
296
|
-
_context7.next = 2;
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
return _context7.abrupt("return");
|
|
300
|
-
case 2:
|
|
301
|
-
_context7.next = 4;
|
|
302
|
-
return this.executeWithFallback('清除方案', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
303
|
-
var _this4$config$fallbac;
|
|
304
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
305
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
306
|
-
case 0:
|
|
307
|
-
_context6.next = 2;
|
|
308
|
-
return _this4.config.primary.clearSchemes(gridId);
|
|
309
|
-
case 2:
|
|
310
|
-
if (!(_this4.config.syncToFallback && (_this4$config$fallbac = _this4.config.fallback) !== null && _this4$config$fallbac !== void 0 && _this4$config$fallbac.clearSchemes)) {
|
|
311
|
-
_context6.next = 12;
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
_context6.prev = 3;
|
|
315
|
-
_context6.next = 6;
|
|
316
|
-
return _this4.config.fallback.clearSchemes(gridId);
|
|
317
|
-
case 6:
|
|
318
|
-
console.log('[PriorityStorageAdapter] 已同步清除操作到备用存储');
|
|
319
|
-
_context6.next = 12;
|
|
320
|
-
break;
|
|
321
|
-
case 9:
|
|
322
|
-
_context6.prev = 9;
|
|
323
|
-
_context6.t0 = _context6["catch"](3);
|
|
324
|
-
console.warn('[PriorityStorageAdapter] 同步清除操作到备用存储失败,忽略该错误:', _context6.t0);
|
|
325
|
-
case 12:
|
|
326
|
-
case "end":
|
|
327
|
-
return _context6.stop();
|
|
328
|
-
}
|
|
329
|
-
}, _callee6, null, [[3, 9]]);
|
|
330
|
-
})), (_this$config$fallback = this.config.fallback) !== null && _this$config$fallback !== void 0 && _this$config$fallback.clearSchemes ? function () {
|
|
331
|
-
return _this4.config.fallback.clearSchemes(gridId);
|
|
332
|
-
} : undefined);
|
|
333
|
-
case 4:
|
|
334
|
-
case "end":
|
|
335
|
-
return _context7.stop();
|
|
336
|
-
}
|
|
337
|
-
}, _callee7, this);
|
|
338
|
-
}));
|
|
339
|
-
function clearSchemes(_x7) {
|
|
340
|
-
return _clearSchemes.apply(this, arguments);
|
|
341
|
-
}
|
|
342
|
-
return clearSchemes;
|
|
343
|
-
}()
|
|
344
|
-
/**
|
|
345
|
-
* 获取当前激活的方案ID
|
|
346
|
-
*/
|
|
347
|
-
)
|
|
348
|
-
}, {
|
|
349
|
-
key: "getCurrentSchemeId",
|
|
350
|
-
value: (function () {
|
|
351
|
-
var _getCurrentSchemeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(gridId) {
|
|
352
|
-
var _this5 = this,
|
|
353
|
-
_this$config$fallback2;
|
|
354
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
355
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
356
|
-
case 0:
|
|
357
|
-
if (this.config.primary.getCurrentSchemeId) {
|
|
358
|
-
_context8.next = 2;
|
|
359
|
-
break;
|
|
360
|
-
}
|
|
361
|
-
return _context8.abrupt("return", null);
|
|
362
|
-
case 2:
|
|
363
|
-
return _context8.abrupt("return", this.executeWithFallback('获取当前方案ID', function () {
|
|
364
|
-
return _this5.config.primary.getCurrentSchemeId(gridId);
|
|
365
|
-
}, (_this$config$fallback2 = this.config.fallback) !== null && _this$config$fallback2 !== void 0 && _this$config$fallback2.getCurrentSchemeId ? function () {
|
|
366
|
-
return _this5.config.fallback.getCurrentSchemeId(gridId);
|
|
367
|
-
} : undefined));
|
|
368
|
-
case 3:
|
|
369
|
-
case "end":
|
|
370
|
-
return _context8.stop();
|
|
371
|
-
}
|
|
372
|
-
}, _callee8, this);
|
|
373
|
-
}));
|
|
374
|
-
function getCurrentSchemeId(_x8) {
|
|
375
|
-
return _getCurrentSchemeId.apply(this, arguments);
|
|
376
|
-
}
|
|
377
|
-
return getCurrentSchemeId;
|
|
378
|
-
}()
|
|
379
|
-
/**
|
|
380
|
-
* 保存当前激活的方案ID
|
|
381
|
-
*/
|
|
382
|
-
)
|
|
383
|
-
}, {
|
|
384
|
-
key: "saveCurrentSchemeId",
|
|
385
|
-
value: (function () {
|
|
386
|
-
var _saveCurrentSchemeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(gridId, schemeId) {
|
|
387
|
-
var _this6 = this,
|
|
388
|
-
_this$config$fallback3;
|
|
389
|
-
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
390
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
391
|
-
case 0:
|
|
392
|
-
if (this.config.primary.saveCurrentSchemeId) {
|
|
393
|
-
_context10.next = 2;
|
|
394
|
-
break;
|
|
395
|
-
}
|
|
396
|
-
return _context10.abrupt("return");
|
|
397
|
-
case 2:
|
|
398
|
-
_context10.next = 4;
|
|
399
|
-
return this.executeWithFallback('保存当前方案ID', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
400
|
-
var _this6$config$fallbac;
|
|
401
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
402
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
403
|
-
case 0:
|
|
404
|
-
_context9.next = 2;
|
|
405
|
-
return _this6.config.primary.saveCurrentSchemeId(gridId, schemeId);
|
|
406
|
-
case 2:
|
|
407
|
-
if (!(_this6.config.syncToFallback && (_this6$config$fallbac = _this6.config.fallback) !== null && _this6$config$fallbac !== void 0 && _this6$config$fallbac.saveCurrentSchemeId)) {
|
|
408
|
-
_context9.next = 12;
|
|
409
|
-
break;
|
|
410
|
-
}
|
|
411
|
-
_context9.prev = 3;
|
|
412
|
-
_context9.next = 6;
|
|
413
|
-
return _this6.config.fallback.saveCurrentSchemeId(gridId, schemeId);
|
|
414
|
-
case 6:
|
|
415
|
-
console.log('[PriorityStorageAdapter] 已同步当前方案ID到备用存储');
|
|
416
|
-
_context9.next = 12;
|
|
417
|
-
break;
|
|
418
|
-
case 9:
|
|
419
|
-
_context9.prev = 9;
|
|
420
|
-
_context9.t0 = _context9["catch"](3);
|
|
421
|
-
console.warn('[PriorityStorageAdapter] 同步当前方案ID到备用存储失败,忽略该错误:', _context9.t0);
|
|
422
|
-
case 12:
|
|
423
|
-
case "end":
|
|
424
|
-
return _context9.stop();
|
|
425
|
-
}
|
|
426
|
-
}, _callee9, null, [[3, 9]]);
|
|
427
|
-
})), (_this$config$fallback3 = this.config.fallback) !== null && _this$config$fallback3 !== void 0 && _this$config$fallback3.saveCurrentSchemeId ? function () {
|
|
428
|
-
return _this6.config.fallback.saveCurrentSchemeId(gridId, schemeId);
|
|
429
|
-
} : undefined);
|
|
430
|
-
case 4:
|
|
431
|
-
case "end":
|
|
432
|
-
return _context10.stop();
|
|
433
|
-
}
|
|
434
|
-
}, _callee10, this);
|
|
435
|
-
}));
|
|
436
|
-
function saveCurrentSchemeId(_x9, _x10) {
|
|
437
|
-
return _saveCurrentSchemeId.apply(this, arguments);
|
|
438
|
-
}
|
|
439
|
-
return saveCurrentSchemeId;
|
|
440
|
-
}()
|
|
441
|
-
/**
|
|
442
|
-
* 获取当前存储状态
|
|
443
|
-
*/
|
|
444
|
-
)
|
|
445
|
-
}, {
|
|
446
|
-
key: "getStatus",
|
|
447
|
-
value: function getStatus() {
|
|
448
|
-
return {
|
|
449
|
-
isDemoted: this.isDemoted,
|
|
450
|
-
failureCount: this.failureCount,
|
|
451
|
-
primaryAvailable: !this.isDemoted
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* 手动重置到主存储
|
|
457
|
-
*/
|
|
458
|
-
}, {
|
|
459
|
-
key: "resetToPrimary",
|
|
460
|
-
value: function resetToPrimary() {
|
|
461
|
-
this.isDemoted = false;
|
|
462
|
-
this.failureCount = 0;
|
|
463
|
-
console.log('[PriorityStorageAdapter] 已手动重置到主存储');
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* 清理资源
|
|
468
|
-
*/
|
|
469
|
-
}, {
|
|
470
|
-
key: "dispose",
|
|
471
|
-
value: function dispose() {
|
|
472
|
-
this.stopRecoveryCheck();
|
|
473
|
-
}
|
|
474
|
-
}]);
|
|
475
|
-
return PriorityStorageAdapter;
|
|
476
|
-
}();
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { ColumnScheme, StorageAdapter } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* 存储错误类型
|
|
4
|
-
*/
|
|
5
|
-
export declare enum StorageErrorType {
|
|
6
|
-
/** 网络错误 */
|
|
7
|
-
NETWORK_ERROR = "NETWORK_ERROR",
|
|
8
|
-
/** 请求超时 */
|
|
9
|
-
TIMEOUT = "TIMEOUT",
|
|
10
|
-
/** 认证失败 */
|
|
11
|
-
UNAUTHORIZED = "UNAUTHORIZED",
|
|
12
|
-
/** 资源不存在 */
|
|
13
|
-
NOT_FOUND = "NOT_FOUND",
|
|
14
|
-
/** 服务器错误 */
|
|
15
|
-
SERVER_ERROR = "SERVER_ERROR",
|
|
16
|
-
/** 未知错误 */
|
|
17
|
-
UNKNOWN = "UNKNOWN"
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* 存储错误类
|
|
21
|
-
*/
|
|
22
|
-
export declare class StorageError extends Error {
|
|
23
|
-
type: StorageErrorType;
|
|
24
|
-
originalError?: any;
|
|
25
|
-
constructor(type: StorageErrorType, message: string, originalError?: any);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* 远程存储适配器配置
|
|
29
|
-
*/
|
|
30
|
-
export interface RemoteStorageConfig {
|
|
31
|
-
/** API 基础路径 */
|
|
32
|
-
apiBaseUrl: string;
|
|
33
|
-
/** 认证令牌 */
|
|
34
|
-
getToken?: () => string | null;
|
|
35
|
-
/** 用户标识获取函数 */
|
|
36
|
-
getUserId?: () => string | null;
|
|
37
|
-
/** API 版本,默认 'v1' */
|
|
38
|
-
apiVersion?: string;
|
|
39
|
-
/** API 前缀,默认 '/api' */
|
|
40
|
-
apiPrefix?: string;
|
|
41
|
-
/** 获取方案列表的 API 路径,如不指定则使用 {apiPrefix}/{apiVersion}/schemes */
|
|
42
|
-
getSchemesPath?: string;
|
|
43
|
-
/** 保存方案列表的 API 路径,如不指定则使用 {apiPrefix}/{apiVersion}/schemes */
|
|
44
|
-
saveSchemesPath?: string;
|
|
45
|
-
/** 获取当前方案ID的 API 路径,如不指定则使用 {apiPrefix}/{apiVersion}/schemes/current */
|
|
46
|
-
getCurrentSchemePath?: string;
|
|
47
|
-
/** 保存当前方案ID的 API 路径,如不指定则使用 {apiPrefix}/{apiVersion}/schemes/current */
|
|
48
|
-
saveCurrentSchemePath?: string;
|
|
49
|
-
/** 请求超时时间(毫秒),默认 10000 */
|
|
50
|
-
timeout?: number;
|
|
51
|
-
/** 最大重试次数,默认 3 */
|
|
52
|
-
maxRetries?: number;
|
|
53
|
-
/** 重试延迟(毫秒),默认 1000 */
|
|
54
|
-
retryDelay?: number;
|
|
55
|
-
/** 启用请求缓存,默认 true */
|
|
56
|
-
enableCache?: boolean;
|
|
57
|
-
/** 缓存策略,默认 'time-based' */
|
|
58
|
-
cacheStrategy?: 'time-based' | 'none' | 'forever';
|
|
59
|
-
/** 缓存过期时间(毫秒),默认 60000 (1分钟) */
|
|
60
|
-
cacheExpiration?: number;
|
|
61
|
-
/** 缓存失效回调 */
|
|
62
|
-
onCacheInvalidate?: (gridId: string) => void;
|
|
63
|
-
}
|
|
64
|
-
export declare class RemoteStorageAdapter implements StorageAdapter {
|
|
65
|
-
private config;
|
|
66
|
-
private schemeCache;
|
|
67
|
-
private currentSchemeCache;
|
|
68
|
-
private requestControllers;
|
|
69
|
-
private saveDebouncers;
|
|
70
|
-
constructor(config: RemoteStorageConfig);
|
|
71
|
-
/**
|
|
72
|
-
* 生成请求头
|
|
73
|
-
*/
|
|
74
|
-
private getHeaders;
|
|
75
|
-
/**
|
|
76
|
-
* 生成包含用户ID的完整 URL
|
|
77
|
-
*/
|
|
78
|
-
private buildUrl;
|
|
79
|
-
/**
|
|
80
|
-
* 延迟函数
|
|
81
|
-
*/
|
|
82
|
-
private delay;
|
|
83
|
-
/**
|
|
84
|
-
* 判断错误是否可重试
|
|
85
|
-
*/
|
|
86
|
-
private isRetryable;
|
|
87
|
-
/**
|
|
88
|
-
* 发送 HTTP 请求(带重试机制)
|
|
89
|
-
*/
|
|
90
|
-
private requestWithRetry;
|
|
91
|
-
/**
|
|
92
|
-
* 发送 HTTP 请求(基础实现)
|
|
93
|
-
*/
|
|
94
|
-
private request;
|
|
95
|
-
/**
|
|
96
|
-
* 检查缓存是否有效
|
|
97
|
-
*/
|
|
98
|
-
private isCacheValid;
|
|
99
|
-
/**
|
|
100
|
-
* 智能缓存失效
|
|
101
|
-
*/
|
|
102
|
-
private invalidateCache;
|
|
103
|
-
/**
|
|
104
|
-
* 获取指定表格的所有方案
|
|
105
|
-
*/
|
|
106
|
-
getSchemes(gridId: string): Promise<ColumnScheme[]>;
|
|
107
|
-
/**
|
|
108
|
-
* 保存方案列表到远端
|
|
109
|
-
*/
|
|
110
|
-
saveSchemes(gridId: string, schemes: ColumnScheme[]): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* 清除指定表格的所有方案
|
|
113
|
-
*/
|
|
114
|
-
clearSchemes(gridId: string): Promise<void>;
|
|
115
|
-
/**
|
|
116
|
-
* 获取当前激活的方案ID
|
|
117
|
-
*/
|
|
118
|
-
getCurrentSchemeId(gridId: string): Promise<string | null>;
|
|
119
|
-
/**
|
|
120
|
-
* 保存当前激活的方案ID
|
|
121
|
-
*/
|
|
122
|
-
saveCurrentSchemeId(gridId: string, schemeId: string | null): Promise<void>;
|
|
123
|
-
/**
|
|
124
|
-
* 批量使缓存失效(例如用户登出时)
|
|
125
|
-
*/
|
|
126
|
-
invalidateAllCache(reason?: string): void;
|
|
127
|
-
/**
|
|
128
|
-
* 清除所有缓存
|
|
129
|
-
*/
|
|
130
|
-
clearCache(): void;
|
|
131
|
-
/**
|
|
132
|
-
* 清除指定 gridId 的缓存
|
|
133
|
-
*/
|
|
134
|
-
clearCacheForGrid(gridId: string): void;
|
|
135
|
-
/**
|
|
136
|
-
* 清理资源
|
|
137
|
-
*/
|
|
138
|
-
dispose(): void;
|
|
139
|
-
}
|