@pisell/pisellos 2.2.97 → 2.2.99

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.
Files changed (44) hide show
  1. package/dist/model/strategy/adapter/walletPass/type.d.ts +2 -2
  2. package/dist/model/strategy/adapter/walletPass/utils.js +70 -57
  3. package/dist/modules/Order/index.d.ts +1 -1
  4. package/dist/server/index.d.ts +30 -0
  5. package/dist/server/index.js +660 -330
  6. package/dist/server/modules/floor-plan/index.d.ts +39 -0
  7. package/dist/server/modules/floor-plan/index.js +595 -0
  8. package/dist/server/modules/floor-plan/types.d.ts +43 -0
  9. package/dist/server/modules/floor-plan/types.js +13 -0
  10. package/dist/server/modules/index.d.ts +3 -0
  11. package/dist/server/modules/index.js +4 -0
  12. package/dist/server/modules/order/types.d.ts +13 -1
  13. package/dist/server/modules/order/types.js +2 -1
  14. package/dist/server/modules/order/utils/filterBookings.d.ts +7 -1
  15. package/dist/server/modules/order/utils/filterBookings.js +64 -4
  16. package/dist/server/modules/resource/index.d.ts +0 -5
  17. package/dist/server/modules/resource/index.js +186 -269
  18. package/dist/server/types.d.ts +2 -0
  19. package/dist/solution/BookingByStep/index.d.ts +1 -1
  20. package/dist/solution/Sales/index.d.ts +2 -1
  21. package/dist/solution/Sales/index.js +23 -10
  22. package/dist/solution/Sales/types.d.ts +1 -1
  23. package/lib/model/strategy/adapter/walletPass/type.d.ts +2 -2
  24. package/lib/model/strategy/adapter/walletPass/utils.js +58 -51
  25. package/lib/modules/Order/index.d.ts +1 -1
  26. package/lib/server/index.d.ts +30 -0
  27. package/lib/server/index.js +202 -9
  28. package/lib/server/modules/floor-plan/index.d.ts +39 -0
  29. package/lib/server/modules/floor-plan/index.js +327 -0
  30. package/lib/server/modules/floor-plan/types.d.ts +43 -0
  31. package/lib/server/modules/floor-plan/types.js +34 -0
  32. package/lib/server/modules/index.d.ts +3 -0
  33. package/lib/server/modules/index.js +6 -0
  34. package/lib/server/modules/order/types.d.ts +13 -1
  35. package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
  36. package/lib/server/modules/order/utils/filterBookings.js +69 -3
  37. package/lib/server/modules/resource/index.d.ts +0 -5
  38. package/lib/server/modules/resource/index.js +60 -73
  39. package/lib/server/types.d.ts +2 -0
  40. package/lib/solution/BookingByStep/index.d.ts +1 -1
  41. package/lib/solution/Sales/index.d.ts +2 -1
  42. package/lib/solution/Sales/index.js +11 -4
  43. package/lib/solution/Sales/types.d.ts +1 -1
  44. package/package.json +1 -1
@@ -0,0 +1,39 @@
1
+ import { Module, PisellCore } from '../../../types';
2
+ import { BaseModule } from '../../../modules/BaseModule';
3
+ import { type FloorPlanItem } from './types';
4
+ /**
5
+ * 平面图模块:预加载列表、pubsub 同步、供 OS Server 路由读本地 store
6
+ */
7
+ export declare class FloorPlanModule extends BaseModule implements Module {
8
+ protected defaultName: string;
9
+ protected defaultVersion: string;
10
+ private store;
11
+ private request;
12
+ private logger;
13
+ private floorPlanDataSource;
14
+ private pendingSyncMessages;
15
+ private syncTimer?;
16
+ constructor(name?: string, version?: string);
17
+ initialize(core: PisellCore, options: any): Promise<void>;
18
+ private logInfo;
19
+ private logWarning;
20
+ private logError;
21
+ private idKey;
22
+ private syncMaps;
23
+ /** 与接口约定一致:sort 升序,id 降序 */
24
+ getSortedList(): FloorPlanItem[];
25
+ getById(id: number | string): FloorPlanItem | undefined;
26
+ getByCode(code: string): FloorPlanItem | undefined;
27
+ private replaceStore;
28
+ private mergeItems;
29
+ private removeByIds;
30
+ private loadListFromServer;
31
+ fetchByIdFromServer(id: number | string): Promise<FloorPlanItem | null>;
32
+ fetchByCodeFromServer(code: string): Promise<FloorPlanItem | null>;
33
+ preload(): Promise<void>;
34
+ private initFloorPlanDataSource;
35
+ private setupFloorPlanSync;
36
+ private processFloorPlanSyncMessages;
37
+ clear(): Promise<void>;
38
+ destroy(): void;
39
+ }
@@ -0,0 +1,595 @@
1
+ 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); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ 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; }
12
+ 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); } }
13
+ 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); }); }; }
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+ 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); } }
16
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
18
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
19
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
20
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
22
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
23
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
24
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
25
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
+ 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; }
27
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
28
+ 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); }
29
+ import { BaseModule } from "../../../modules/BaseModule";
30
+ import { FloorPlanHooks } from "./types";
31
+ var FLOOR_PLAN_SYNC_DEBOUNCE_MS = 3000;
32
+
33
+ /**
34
+ * 平面图模块:预加载列表、pubsub 同步、供 OS Server 路由读本地 store
35
+ */
36
+ export var FloorPlanModule = /*#__PURE__*/function (_BaseModule) {
37
+ _inherits(FloorPlanModule, _BaseModule);
38
+ var _super = _createSuper(FloorPlanModule);
39
+ function FloorPlanModule(name, version) {
40
+ var _this;
41
+ _classCallCheck(this, FloorPlanModule);
42
+ _this = _super.call(this, name, version);
43
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'floor_plan');
44
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
45
+ _defineProperty(_assertThisInitialized(_this), "store", void 0);
46
+ _defineProperty(_assertThisInitialized(_this), "request", void 0);
47
+ _defineProperty(_assertThisInitialized(_this), "logger", void 0);
48
+ _defineProperty(_assertThisInitialized(_this), "floorPlanDataSource", void 0);
49
+ _defineProperty(_assertThisInitialized(_this), "pendingSyncMessages", []);
50
+ _defineProperty(_assertThisInitialized(_this), "syncTimer", void 0);
51
+ return _this;
52
+ }
53
+ _createClass(FloorPlanModule, [{
54
+ key: "initialize",
55
+ value: function () {
56
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
57
+ var _options$initialState;
58
+ var appPlugin, app;
59
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
60
+ while (1) switch (_context.prev = _context.next) {
61
+ case 0:
62
+ this.core = core;
63
+ this.store = options.store;
64
+ if (Array.isArray(options === null || options === void 0 || (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list) && options.initialState.list.length > 0) {
65
+ this.store.list = options.initialState.list;
66
+ this.syncMaps();
67
+ this.core.effects.emit(FloorPlanHooks.onFloorPlansChanged, this.store.list);
68
+ } else {
69
+ this.store.list = [];
70
+ this.store.map = new Map();
71
+ this.store.codeMap = new Map();
72
+ }
73
+ this.request = core.getPlugin('request');
74
+ appPlugin = core.getPlugin('app');
75
+ if (appPlugin) {
76
+ app = appPlugin.getApp();
77
+ this.logger = app.logger;
78
+ }
79
+ this.initFloorPlanDataSource();
80
+ this.setupFloorPlanSync();
81
+ case 8:
82
+ case "end":
83
+ return _context.stop();
84
+ }
85
+ }, _callee, this);
86
+ }));
87
+ function initialize(_x, _x2) {
88
+ return _initialize.apply(this, arguments);
89
+ }
90
+ return initialize;
91
+ }()
92
+ }, {
93
+ key: "logInfo",
94
+ value: function logInfo(title, metadata) {
95
+ try {
96
+ var _this$logger, _this$logger$addLog;
97
+ (_this$logger = this.logger) === null || _this$logger === void 0 || (_this$logger$addLog = _this$logger.addLog) === null || _this$logger$addLog === void 0 || _this$logger$addLog.call(_this$logger, {
98
+ type: 'info',
99
+ title: "[FloorPlanModule] ".concat(title),
100
+ metadata: metadata || {}
101
+ });
102
+ } catch (_unused) {
103
+ // ignore
104
+ }
105
+ }
106
+ }, {
107
+ key: "logWarning",
108
+ value: function logWarning(title, metadata) {
109
+ try {
110
+ var _this$logger2, _this$logger2$addLog;
111
+ (_this$logger2 = this.logger) === null || _this$logger2 === void 0 || (_this$logger2$addLog = _this$logger2.addLog) === null || _this$logger2$addLog === void 0 || _this$logger2$addLog.call(_this$logger2, {
112
+ type: 'warning',
113
+ title: "[FloorPlanModule] ".concat(title),
114
+ metadata: metadata || {}
115
+ });
116
+ } catch (_unused2) {
117
+ // ignore
118
+ }
119
+ }
120
+ }, {
121
+ key: "logError",
122
+ value: function logError(title, metadata) {
123
+ try {
124
+ var _this$logger3, _this$logger3$addLog;
125
+ (_this$logger3 = this.logger) === null || _this$logger3 === void 0 || (_this$logger3$addLog = _this$logger3.addLog) === null || _this$logger3$addLog === void 0 || _this$logger3$addLog.call(_this$logger3, {
126
+ type: 'error',
127
+ title: "[FloorPlanModule] ".concat(title),
128
+ metadata: metadata || {}
129
+ });
130
+ } catch (_unused3) {
131
+ // ignore
132
+ }
133
+ }
134
+ }, {
135
+ key: "idKey",
136
+ value: function idKey(id) {
137
+ return String(id);
138
+ }
139
+ }, {
140
+ key: "syncMaps",
141
+ value: function syncMaps() {
142
+ this.store.map = new Map();
143
+ this.store.codeMap = new Map();
144
+ var _iterator = _createForOfIteratorHelper(this.store.list),
145
+ _step;
146
+ try {
147
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
148
+ var item = _step.value;
149
+ if ((item === null || item === void 0 ? void 0 : item.id) == null) continue;
150
+ var key = this.idKey(item.id);
151
+ this.store.map.set(key, item);
152
+ if (item.code) {
153
+ this.store.codeMap.set(String(item.code), item);
154
+ }
155
+ }
156
+ } catch (err) {
157
+ _iterator.e(err);
158
+ } finally {
159
+ _iterator.f();
160
+ }
161
+ }
162
+
163
+ /** 与接口约定一致:sort 升序,id 降序 */
164
+ }, {
165
+ key: "getSortedList",
166
+ value: function getSortedList() {
167
+ return _toConsumableArray(this.store.list).sort(function (a, b) {
168
+ var _a$sort, _b$sort;
169
+ var sortDiff = Number((_a$sort = a.sort) !== null && _a$sort !== void 0 ? _a$sort : 0) - Number((_b$sort = b.sort) !== null && _b$sort !== void 0 ? _b$sort : 0);
170
+ if (sortDiff !== 0) return sortDiff;
171
+ return Number(b.id) - Number(a.id);
172
+ });
173
+ }
174
+ }, {
175
+ key: "getById",
176
+ value: function getById(id) {
177
+ return this.store.map.get(this.idKey(id));
178
+ }
179
+ }, {
180
+ key: "getByCode",
181
+ value: function getByCode(code) {
182
+ return this.store.codeMap.get(String(code));
183
+ }
184
+ }, {
185
+ key: "replaceStore",
186
+ value: function replaceStore(list) {
187
+ this.store.list = list.map(function (i) {
188
+ return _objectSpread({}, i);
189
+ });
190
+ this.syncMaps();
191
+ }
192
+ }, {
193
+ key: "mergeItems",
194
+ value: function mergeItems(items) {
195
+ if (items.length === 0) return;
196
+ var byId = new Map(this.store.map);
197
+ var _iterator2 = _createForOfIteratorHelper(items),
198
+ _step2;
199
+ try {
200
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
201
+ var item = _step2.value;
202
+ if ((item === null || item === void 0 ? void 0 : item.id) == null) continue;
203
+ byId.set(this.idKey(item.id), _objectSpread({}, item));
204
+ }
205
+ } catch (err) {
206
+ _iterator2.e(err);
207
+ } finally {
208
+ _iterator2.f();
209
+ }
210
+ this.store.list = Array.from(byId.values());
211
+ this.syncMaps();
212
+ }
213
+ }, {
214
+ key: "removeByIds",
215
+ value: function removeByIds(ids) {
216
+ var _this2 = this;
217
+ if (ids.length === 0) return;
218
+ var set = new Set(ids.map(function (id) {
219
+ return _this2.idKey(id);
220
+ }));
221
+ this.store.list = this.store.list.filter(function (p) {
222
+ return !set.has(_this2.idKey(p.id));
223
+ });
224
+ this.syncMaps();
225
+ }
226
+ }, {
227
+ key: "loadListFromServer",
228
+ value: function () {
229
+ var _loadListFromServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
230
+ var res, body, raw, list;
231
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
232
+ while (1) switch (_context2.prev = _context2.next) {
233
+ case 0:
234
+ _context2.prev = 0;
235
+ _context2.next = 3;
236
+ return this.request.get("/schedule/floor-plan", {}, {
237
+ isShopApi: true
238
+ });
239
+ case 3:
240
+ res = _context2.sent;
241
+ body = res;
242
+ raw = (body === null || body === void 0 ? void 0 : body.data) !== undefined ? body.data : body;
243
+ list = Array.isArray(raw) ? raw : [];
244
+ return _context2.abrupt("return", list);
245
+ case 10:
246
+ _context2.prev = 10;
247
+ _context2.t0 = _context2["catch"](0);
248
+ this.logWarning('loadListFromServer 失败', {
249
+ error: _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0)
250
+ });
251
+ return _context2.abrupt("return", []);
252
+ case 14:
253
+ case "end":
254
+ return _context2.stop();
255
+ }
256
+ }, _callee2, this, [[0, 10]]);
257
+ }));
258
+ function loadListFromServer() {
259
+ return _loadListFromServer.apply(this, arguments);
260
+ }
261
+ return loadListFromServer;
262
+ }()
263
+ }, {
264
+ key: "fetchByIdFromServer",
265
+ value: function () {
266
+ var _fetchByIdFromServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(id) {
267
+ var res, body, data;
268
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
269
+ while (1) switch (_context3.prev = _context3.next) {
270
+ case 0:
271
+ _context3.prev = 0;
272
+ _context3.next = 3;
273
+ return this.request.get("/schedule/floor-plan/".concat(id), {}, {
274
+ isShopApi: true
275
+ });
276
+ case 3:
277
+ res = _context3.sent;
278
+ body = res;
279
+ data = (body === null || body === void 0 ? void 0 : body.data) !== undefined ? body.data : body;
280
+ return _context3.abrupt("return", data && _typeof(data) === 'object' ? data : null);
281
+ case 9:
282
+ _context3.prev = 9;
283
+ _context3.t0 = _context3["catch"](0);
284
+ return _context3.abrupt("return", null);
285
+ case 12:
286
+ case "end":
287
+ return _context3.stop();
288
+ }
289
+ }, _callee3, this, [[0, 9]]);
290
+ }));
291
+ function fetchByIdFromServer(_x3) {
292
+ return _fetchByIdFromServer.apply(this, arguments);
293
+ }
294
+ return fetchByIdFromServer;
295
+ }()
296
+ }, {
297
+ key: "fetchByCodeFromServer",
298
+ value: function () {
299
+ var _fetchByCodeFromServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(code) {
300
+ var enc, res, body, data;
301
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
302
+ while (1) switch (_context4.prev = _context4.next) {
303
+ case 0:
304
+ _context4.prev = 0;
305
+ enc = encodeURIComponent(code);
306
+ _context4.next = 4;
307
+ return this.request.get("/schedule/floor-plan/code/".concat(enc), {}, {
308
+ isShopApi: true
309
+ });
310
+ case 4:
311
+ res = _context4.sent;
312
+ body = res;
313
+ data = (body === null || body === void 0 ? void 0 : body.data) !== undefined ? body.data : body;
314
+ return _context4.abrupt("return", data && _typeof(data) === 'object' ? data : null);
315
+ case 10:
316
+ _context4.prev = 10;
317
+ _context4.t0 = _context4["catch"](0);
318
+ return _context4.abrupt("return", null);
319
+ case 13:
320
+ case "end":
321
+ return _context4.stop();
322
+ }
323
+ }, _callee4, this, [[0, 10]]);
324
+ }));
325
+ function fetchByCodeFromServer(_x4) {
326
+ return _fetchByCodeFromServer.apply(this, arguments);
327
+ }
328
+ return fetchByCodeFromServer;
329
+ }()
330
+ }, {
331
+ key: "preload",
332
+ value: function () {
333
+ var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
334
+ var list;
335
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
336
+ while (1) switch (_context5.prev = _context5.next) {
337
+ case 0:
338
+ this.logInfo('开始预加载平面图列表');
339
+ _context5.next = 3;
340
+ return this.loadListFromServer();
341
+ case 3:
342
+ list = _context5.sent;
343
+ if (list.length > 0) {
344
+ this.replaceStore(list);
345
+ this.core.effects.emit(FloorPlanHooks.onFloorPlansChanged, this.getSortedList());
346
+ this.logInfo('预加载完成', {
347
+ count: list.length
348
+ });
349
+ } else {
350
+ this.logWarning('预加载完成但列表为空');
351
+ }
352
+ case 5:
353
+ case "end":
354
+ return _context5.stop();
355
+ }
356
+ }, _callee5, this);
357
+ }));
358
+ function preload() {
359
+ return _preload.apply(this, arguments);
360
+ }
361
+ return preload;
362
+ }()
363
+ }, {
364
+ key: "initFloorPlanDataSource",
365
+ value: function initFloorPlanDataSource() {
366
+ var _serverOptions;
367
+ var Ctor = (_serverOptions = this.core.serverOptions) === null || _serverOptions === void 0 || (_serverOptions = _serverOptions.All_DATA_SOURCES) === null || _serverOptions === void 0 ? void 0 : _serverOptions.FloorPlanDataSource;
368
+ if (!Ctor) {
369
+ this.logWarning('FloorPlanDataSource 不可用,跳过 pubsub 同步');
370
+ return;
371
+ }
372
+ this.floorPlanDataSource = new Ctor();
373
+ this.logInfo('FloorPlanDataSource 实例已创建');
374
+ }
375
+ }, {
376
+ key: "setupFloorPlanSync",
377
+ value: function setupFloorPlanSync() {
378
+ var _this3 = this;
379
+ if (!this.floorPlanDataSource) return;
380
+ var flush = function flush() {
381
+ if (_this3.syncTimer) clearTimeout(_this3.syncTimer);
382
+ _this3.syncTimer = setTimeout(function () {
383
+ _this3.processFloorPlanSyncMessages();
384
+ }, FLOOR_PLAN_SYNC_DEBOUNCE_MS);
385
+ };
386
+ this.floorPlanDataSource.run({
387
+ pubsub: {
388
+ callback: function callback(res) {
389
+ var data = (res === null || res === void 0 ? void 0 : res.data) || res;
390
+ if (!data || data.module !== 'floor_plan') return;
391
+ _this3.pendingSyncMessages.push(_objectSpread({}, data));
392
+ flush();
393
+ }
394
+ }
395
+ }).catch(function (err) {
396
+ _this3.logError('setupFloorPlanSync: DataSource run 出错', {
397
+ error: err instanceof Error ? err.message : String(err)
398
+ });
399
+ });
400
+ this.logInfo('floor_plan pubsub 订阅已建立');
401
+ }
402
+ }, {
403
+ key: "processFloorPlanSyncMessages",
404
+ value: function () {
405
+ var _processFloorPlanSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
406
+ var messages, changed, deleteIds, bodyItems, needFullList, partialIds, _iterator3, _step3, _msg$ids2, msg, _msg$ids, body, hasBody, uniqueDeletes, list, fetched, _iterator4, _step4, id, one;
407
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
408
+ while (1) switch (_context6.prev = _context6.next) {
409
+ case 0:
410
+ messages = _toConsumableArray(this.pendingSyncMessages);
411
+ this.pendingSyncMessages = [];
412
+ if (!(messages.length === 0)) {
413
+ _context6.next = 4;
414
+ break;
415
+ }
416
+ return _context6.abrupt("return");
417
+ case 4:
418
+ this.logInfo('processFloorPlanSyncMessages 开始', {
419
+ count: messages.length
420
+ });
421
+ changed = false;
422
+ deleteIds = [];
423
+ bodyItems = [];
424
+ needFullList = false;
425
+ partialIds = new Set();
426
+ _iterator3 = _createForOfIteratorHelper(messages);
427
+ _context6.prev = 11;
428
+ _iterator3.s();
429
+ case 13:
430
+ if ((_step3 = _iterator3.n()).done) {
431
+ _context6.next = 29;
432
+ break;
433
+ }
434
+ msg = _step3.value;
435
+ if (!(msg.operation === 'delete' || msg.action === 'delete')) {
436
+ _context6.next = 18;
437
+ break;
438
+ }
439
+ if ((_msg$ids = msg.ids) !== null && _msg$ids !== void 0 && _msg$ids.length) {
440
+ deleteIds.push.apply(deleteIds, _toConsumableArray(msg.ids));
441
+ } else if (msg.id != null) {
442
+ deleteIds.push(msg.id);
443
+ }
444
+ return _context6.abrupt("continue", 27);
445
+ case 18:
446
+ body = msg.body;
447
+ hasBody = body && _typeof(body) === 'object' && Object.keys(body).length > 0 && body.id != null;
448
+ if (!hasBody) {
449
+ _context6.next = 23;
450
+ break;
451
+ }
452
+ bodyItems.push(body);
453
+ return _context6.abrupt("continue", 27);
454
+ case 23:
455
+ if (!(msg.ids && msg.ids.length > 1)) {
456
+ _context6.next = 26;
457
+ break;
458
+ }
459
+ needFullList = true;
460
+ return _context6.abrupt("continue", 27);
461
+ case 26:
462
+ if (((_msg$ids2 = msg.ids) === null || _msg$ids2 === void 0 ? void 0 : _msg$ids2.length) === 1) {
463
+ partialIds.add(msg.ids[0]);
464
+ } else if (msg.id != null) {
465
+ partialIds.add(msg.id);
466
+ }
467
+ case 27:
468
+ _context6.next = 13;
469
+ break;
470
+ case 29:
471
+ _context6.next = 34;
472
+ break;
473
+ case 31:
474
+ _context6.prev = 31;
475
+ _context6.t0 = _context6["catch"](11);
476
+ _iterator3.e(_context6.t0);
477
+ case 34:
478
+ _context6.prev = 34;
479
+ _iterator3.f();
480
+ return _context6.finish(34);
481
+ case 37:
482
+ uniqueDeletes = _toConsumableArray(new Set(deleteIds));
483
+ if (uniqueDeletes.length > 0) {
484
+ this.removeByIds(uniqueDeletes);
485
+ changed = true;
486
+ }
487
+ if (bodyItems.length > 0) {
488
+ this.mergeItems(bodyItems);
489
+ changed = true;
490
+ }
491
+ if (!needFullList) {
492
+ _context6.next = 48;
493
+ break;
494
+ }
495
+ _context6.next = 43;
496
+ return this.loadListFromServer();
497
+ case 43:
498
+ list = _context6.sent;
499
+ this.replaceStore(list);
500
+ changed = true;
501
+ _context6.next = 70;
502
+ break;
503
+ case 48:
504
+ if (!(partialIds.size > 0)) {
505
+ _context6.next = 70;
506
+ break;
507
+ }
508
+ fetched = [];
509
+ _iterator4 = _createForOfIteratorHelper(partialIds);
510
+ _context6.prev = 51;
511
+ _iterator4.s();
512
+ case 53:
513
+ if ((_step4 = _iterator4.n()).done) {
514
+ _context6.next = 61;
515
+ break;
516
+ }
517
+ id = _step4.value;
518
+ _context6.next = 57;
519
+ return this.fetchByIdFromServer(id);
520
+ case 57:
521
+ one = _context6.sent;
522
+ if (one) fetched.push(one);
523
+ case 59:
524
+ _context6.next = 53;
525
+ break;
526
+ case 61:
527
+ _context6.next = 66;
528
+ break;
529
+ case 63:
530
+ _context6.prev = 63;
531
+ _context6.t1 = _context6["catch"](51);
532
+ _iterator4.e(_context6.t1);
533
+ case 66:
534
+ _context6.prev = 66;
535
+ _iterator4.f();
536
+ return _context6.finish(66);
537
+ case 69:
538
+ if (fetched.length > 0) {
539
+ this.mergeItems(fetched);
540
+ changed = true;
541
+ }
542
+ case 70:
543
+ if (changed) {
544
+ this.core.effects.emit(FloorPlanHooks.onFloorPlansChanged, this.getSortedList());
545
+ this.core.effects.emit(FloorPlanHooks.onFloorPlanSyncCompleted, null);
546
+ }
547
+ case 71:
548
+ case "end":
549
+ return _context6.stop();
550
+ }
551
+ }, _callee6, this, [[11, 31, 34, 37], [51, 63, 66, 69]]);
552
+ }));
553
+ function processFloorPlanSyncMessages() {
554
+ return _processFloorPlanSyncMessages.apply(this, arguments);
555
+ }
556
+ return processFloorPlanSyncMessages;
557
+ }()
558
+ }, {
559
+ key: "clear",
560
+ value: function () {
561
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
562
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
563
+ while (1) switch (_context7.prev = _context7.next) {
564
+ case 0:
565
+ this.store.list = [];
566
+ this.store.map.clear();
567
+ this.store.codeMap.clear();
568
+ case 3:
569
+ case "end":
570
+ return _context7.stop();
571
+ }
572
+ }, _callee7, this);
573
+ }));
574
+ function clear() {
575
+ return _clear.apply(this, arguments);
576
+ }
577
+ return clear;
578
+ }()
579
+ }, {
580
+ key: "destroy",
581
+ value: function destroy() {
582
+ var _this$floorPlanDataSo;
583
+ if (this.syncTimer) {
584
+ clearTimeout(this.syncTimer);
585
+ this.syncTimer = undefined;
586
+ }
587
+ this.pendingSyncMessages = [];
588
+ if ((_this$floorPlanDataSo = this.floorPlanDataSource) !== null && _this$floorPlanDataSo !== void 0 && _this$floorPlanDataSo.destroy) {
589
+ this.floorPlanDataSource.destroy();
590
+ }
591
+ _get(_getPrototypeOf(FloorPlanModule.prototype), "destroy", this).call(this);
592
+ }
593
+ }]);
594
+ return FloorPlanModule;
595
+ }(BaseModule);