@pisell/pisellos 0.0.6 → 0.0.7

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 (71) hide show
  1. package/dist/core/index.d.ts +1 -0
  2. package/dist/core/index.js +7 -1
  3. package/dist/effects/index.d.ts +1 -1
  4. package/dist/effects/index.js +4 -5
  5. package/dist/modules/Account/index.d.ts +7 -1
  6. package/dist/modules/Account/index.js +67 -17
  7. package/dist/modules/Account/types.d.ts +2 -1
  8. package/dist/modules/AccountList/index.d.ts +18 -0
  9. package/dist/modules/AccountList/index.js +264 -0
  10. package/dist/modules/AccountList/types.d.ts +37 -0
  11. package/dist/modules/AccountList/types.js +17 -0
  12. package/dist/modules/BaseModule.js +1 -0
  13. package/dist/modules/Cart/index.d.ts +3 -1
  14. package/dist/modules/Cart/index.js +53 -12
  15. package/dist/modules/Cart/types.d.ts +3 -3
  16. package/dist/modules/Date/types.d.ts +2 -1
  17. package/dist/modules/Date/types.js +1 -0
  18. package/dist/modules/ProductList/index.d.ts +1 -1
  19. package/dist/modules/ProductList/index.js +20 -12
  20. package/dist/modules/Resource/index.d.ts +7 -5
  21. package/dist/modules/Resource/index.js +17 -20
  22. package/dist/modules/Resource/utils.d.ts +23 -0
  23. package/dist/modules/Resource/utils.js +28 -0
  24. package/dist/modules/Step/index.d.ts +19 -0
  25. package/dist/modules/Step/index.js +107 -0
  26. package/dist/modules/Step/tyeps.d.ts +18 -0
  27. package/dist/modules/Step/tyeps.js +1 -0
  28. package/dist/solution/BookingByStep/index.d.ts +29 -1
  29. package/dist/solution/BookingByStep/index.js +363 -12
  30. package/dist/solution/BookingByStep/types.d.ts +6 -2
  31. package/dist/solution/BookingByStep/types.js +29 -0
  32. package/dist/solution/BookingByStep/utils/resources.d.ts +61 -0
  33. package/dist/solution/BookingByStep/utils/resources.js +380 -0
  34. package/dist/store/createStore.js +1 -1
  35. package/dist/types/index.d.ts +2 -1
  36. package/lib/core/index.d.ts +1 -0
  37. package/lib/core/index.js +5 -1
  38. package/lib/effects/index.d.ts +1 -1
  39. package/lib/effects/index.js +1 -2
  40. package/lib/modules/Account/index.d.ts +7 -1
  41. package/lib/modules/Account/index.js +34 -18
  42. package/lib/modules/Account/types.d.ts +2 -1
  43. package/lib/modules/AccountList/index.d.ts +18 -0
  44. package/lib/modules/AccountList/index.js +126 -0
  45. package/lib/modules/AccountList/types.d.ts +37 -0
  46. package/lib/modules/AccountList/types.js +33 -0
  47. package/lib/modules/BaseModule.js +1 -0
  48. package/lib/modules/Cart/index.d.ts +3 -1
  49. package/lib/modules/Cart/index.js +13 -3
  50. package/lib/modules/Cart/types.d.ts +3 -3
  51. package/lib/modules/Date/types.d.ts +2 -1
  52. package/lib/modules/Date/types.js +1 -0
  53. package/lib/modules/ProductList/index.d.ts +1 -1
  54. package/lib/modules/ProductList/index.js +8 -7
  55. package/lib/modules/Resource/index.d.ts +7 -5
  56. package/lib/modules/Resource/index.js +16 -20
  57. package/lib/modules/Resource/utils.d.ts +23 -0
  58. package/lib/modules/Resource/utils.js +39 -0
  59. package/lib/modules/Step/index.d.ts +19 -0
  60. package/lib/modules/Step/index.js +76 -0
  61. package/lib/modules/Step/tyeps.d.ts +18 -0
  62. package/lib/modules/Step/tyeps.js +17 -0
  63. package/lib/solution/BookingByStep/index.d.ts +29 -1
  64. package/lib/solution/BookingByStep/index.js +99 -5
  65. package/lib/solution/BookingByStep/types.d.ts +6 -2
  66. package/lib/solution/BookingByStep/types.js +33 -2
  67. package/lib/solution/BookingByStep/utils/resources.d.ts +61 -0
  68. package/lib/solution/BookingByStep/utils/resources.js +215 -0
  69. package/lib/store/createStore.js +1 -1
  70. package/lib/types/index.d.ts +2 -1
  71. package/package.json +9 -8
@@ -0,0 +1,107 @@
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 _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; }
3
+ 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); } }
4
+ 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); }); }; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ 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); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ 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); }
9
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10
+ 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); }; }
11
+ 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); }
12
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13
+ 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; } }
14
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15
+ 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; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
+ 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); }
18
+ import { BaseModule } from "../BaseModule";
19
+ export var StepModule = /*#__PURE__*/function (_BaseModule) {
20
+ _inherits(StepModule, _BaseModule);
21
+ var _super = _createSuper(StepModule);
22
+ function StepModule(name, version) {
23
+ var _this;
24
+ _classCallCheck(this, StepModule);
25
+ _this = _super.call(this, name, version);
26
+ _defineProperty(_assertThisInitialized(_this), "defaultName", "step");
27
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
28
+ _defineProperty(_assertThisInitialized(_this), "store", void 0);
29
+ return _this;
30
+ }
31
+ _createClass(StepModule, [{
32
+ key: "initialize",
33
+ value: function () {
34
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
35
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
36
+ while (1) switch (_context.prev = _context.next) {
37
+ case 0:
38
+ this.core = core;
39
+ this.store = options.store;
40
+ case 2:
41
+ case "end":
42
+ return _context.stop();
43
+ }
44
+ }, _callee, this);
45
+ }));
46
+ function initialize(_x, _x2) {
47
+ return _initialize.apply(this, arguments);
48
+ }
49
+ return initialize;
50
+ }()
51
+ }, {
52
+ key: "init",
53
+ value: function init(steps) {
54
+ this.setSteps(steps);
55
+ this.setCurrentStep(0);
56
+ }
57
+ }, {
58
+ key: "setSteps",
59
+ value: function setSteps(stepList) {
60
+ this.store.stepList = stepList;
61
+ }
62
+ }, {
63
+ key: "setCurrentStep",
64
+ value: function setCurrentStep(stepIndex) {
65
+ if (stepIndex < 0 || stepIndex >= this.store.stepList.length) {
66
+ return;
67
+ }
68
+ this.store.currentStepIndex = stepIndex;
69
+ this.store.currentStep = this.store.stepList[stepIndex];
70
+ }
71
+ }, {
72
+ key: "getStepList",
73
+ value: function getStepList() {
74
+ return this.store.stepList;
75
+ }
76
+ }, {
77
+ key: "getCurrentStep",
78
+ value: function getCurrentStep() {
79
+ return this.store.currentStep;
80
+ }
81
+ }, {
82
+ key: "getCurrentStepIndex",
83
+ value: function getCurrentStepIndex() {
84
+ return this.store.currentStepIndex;
85
+ }
86
+ }, {
87
+ key: "prevStep",
88
+ value: function prevStep() {
89
+ if (this.store.currentStepIndex > 0) {
90
+ this.setCurrentStep(this.store.currentStepIndex - 1);
91
+ }
92
+ }
93
+ }, {
94
+ key: "nextStep",
95
+ value: function nextStep() {
96
+ if (this.store.currentStepIndex < this.store.stepList.length - 1) {
97
+ this.setCurrentStep(this.store.currentStepIndex + 1);
98
+ }
99
+ }
100
+ }, {
101
+ key: "gotoStep",
102
+ value: function gotoStep(stepIndex) {
103
+ this.setCurrentStep(stepIndex);
104
+ }
105
+ }]);
106
+ return StepModule;
107
+ }(BaseModule);
@@ -0,0 +1,18 @@
1
+ export interface IStepState {
2
+ stepList: IStep[];
3
+ currentStep: IStep;
4
+ currentStepIndex: number;
5
+ }
6
+ export interface IStep {
7
+ index: number;
8
+ key: string;
9
+ [key: string]: any;
10
+ }
11
+ export interface IStepModuleAPI {
12
+ getStepList: () => IStep[];
13
+ getCurrentStep: () => IStep;
14
+ getCurrentStepIndex: () => number;
15
+ nextStep: () => void;
16
+ prevStep: () => void;
17
+ gotoStep: (stepIndex: number) => void;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,8 @@
1
- import { Module, PisellCore } from '../../types';
1
+ import { Module, PisellCore } from "../../types";
2
2
  import { BaseModule } from "../../modules/BaseModule";
3
+ import { BookingByStepState } from "./types";
4
+ import { Account } from "../../modules/Account/types";
5
+ import { IStep } from "../../modules/Step/tyeps";
3
6
  export declare class BookingByStepImpl extends BaseModule implements Module {
4
7
  protected defaultName: string;
5
8
  protected defaultVersion: string;
@@ -9,4 +12,29 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
9
12
  private store;
10
13
  private otherParams;
11
14
  initialize(core: PisellCore, options: any): Promise<void>;
15
+ initStep(stepList: (keyof BookingByStepState)[]): void;
16
+ getCurrentStep(): {
17
+ index: number;
18
+ step: IStep;
19
+ };
20
+ next(): void;
21
+ getStoreCart(key?: string): Promise<any>;
22
+ loadProducts({ category_ids, product_ids }: {
23
+ category_ids?: number[];
24
+ product_ids?: number[];
25
+ }): Promise<void>;
26
+ storeProducts(productData: any[]): Promise<void>;
27
+ addAccount(accounts: Account[]): Promise<void>;
28
+ getAccounts(): Promise<import("../../modules/Account").AccountModule[]>;
29
+ setDateRange(dateRange: string[]): Promise<void>;
30
+ getRangeDate(): Promise<string>;
31
+ getAvailableDate(): Promise<void>;
32
+ getResourceTimeslot(): Promise<void>;
33
+ getProducts(): Promise<import("../../modules").ProductData[]>;
34
+ storeResources(resources: any[]): Promise<void>;
35
+ setLoginAccount(account: Account): Promise<void>;
36
+ generateCartData(): Promise<void>;
37
+ submitOrder(): Promise<void>;
38
+ pay(): Promise<void>;
39
+ getPayInfo(): Promise<void>;
12
40
  }
@@ -16,7 +16,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
16
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
17
  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); }
18
18
  import { BaseModule } from "../../modules/BaseModule";
19
- import { BookingByStepHooks } from "./types";
19
+ import { BookingByStepHooks, createModule } from "./types";
20
20
  export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
21
21
  _inherits(BookingByStepImpl, _BaseModule);
22
22
  var _super = _createSuper(BookingByStepImpl);
@@ -27,8 +27,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
27
27
  args[_key] = arguments[_key];
28
28
  }
29
29
  _this = _super.call.apply(_super, [this].concat(args));
30
- _defineProperty(_assertThisInitialized(_this), "defaultName", 'bookingByStep');
31
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
30
+ _defineProperty(_assertThisInitialized(_this), "defaultName", "bookingByStep");
31
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
32
32
  _defineProperty(_assertThisInitialized(_this), "isSolution", true);
33
33
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
34
34
  _defineProperty(_assertThisInitialized(_this), "window", void 0);
@@ -40,27 +40,35 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
40
40
  key: "initialize",
41
41
  value: function () {
42
42
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
43
+ var _this2 = this;
44
+ var moduleArr;
43
45
  return _regeneratorRuntime().wrap(function _callee$(_context) {
44
46
  while (1) switch (_context.prev = _context.next) {
45
47
  case 0:
46
48
  this.core = core;
47
49
  this.store = options.store || {};
48
50
  this.otherParams = options.otherParams || {};
49
- console.log('[BuyTickets] 初始化完成');
51
+ console.log("[BookingByStep] 初始化完成");
50
52
  // 获取依赖的插件
51
- this.request = core.getPlugin('request');
52
- this.window = core.getPlugin('window');
53
+ this.request = core.getPlugin("request");
54
+ this.window = core.getPlugin("window");
53
55
  if (this.request) {
54
56
  _context.next = 8;
55
57
  break;
56
58
  }
57
- throw new Error('tickets解决方案需要 request 插件支持');
59
+ throw new Error("bookingByStep解决方案需要 request 插件支持");
58
60
  case 8:
59
- if (this.otherParams.prodctIds) {
60
- // await this.loadProductsByIds(this.otherParams.prodctIds)
61
- }
62
- _context.next = 11;
63
- return this.core.effects.emit(BookingByStepHooks.onInited, {});
61
+ moduleArr = ["cart", "step", "products", "guests", "date", "accountList", "order", "payment"];
62
+ moduleArr.forEach(function (step) {
63
+ var targetModule = createModule(step, _this2.name);
64
+ if (targetModule) {
65
+ _this2.store[step] = targetModule;
66
+ _this2.core.registerModule(targetModule);
67
+ } else {
68
+ throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
69
+ }
70
+ });
71
+ this.core.effects.emit(BookingByStepHooks.onInited, {});
64
72
  case 11:
65
73
  case "end":
66
74
  return _context.stop();
@@ -71,6 +79,349 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
71
79
  return _initialize.apply(this, arguments);
72
80
  }
73
81
  return initialize;
82
+ }() // 初始化step
83
+ }, {
84
+ key: "initStep",
85
+ value: function initStep(stepList) {
86
+ this.store.step.init(stepList);
87
+ }
88
+ }, {
89
+ key: "getCurrentStep",
90
+ value: function getCurrentStep() {
91
+ return {
92
+ index: this.store.step.getCurrentStepIndex(),
93
+ step: this.store.step.getCurrentStep()
94
+ };
95
+ }
96
+ }, {
97
+ key: "next",
98
+ value: function next() {
99
+ this.store.step.nextStep();
100
+ }
101
+
102
+ // 获取购物车里 temp.xxx的方法
103
+ }, {
104
+ key: "getStoreCart",
105
+ value: function () {
106
+ var _getStoreCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key) {
107
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
108
+ while (1) switch (_context2.prev = _context2.next) {
109
+ case 0:
110
+ return _context2.abrupt("return", this.store.cart.getTemp(key));
111
+ case 1:
112
+ case "end":
113
+ return _context2.stop();
114
+ }
115
+ }, _callee2, this);
116
+ }));
117
+ function getStoreCart(_x3) {
118
+ return _getStoreCart.apply(this, arguments);
119
+ }
120
+ return getStoreCart;
121
+ }() // 加载商品,然后导到商品列表里去
122
+ }, {
123
+ key: "loadProducts",
124
+ value: function () {
125
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
126
+ var category_ids, product_ids, productsData;
127
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
128
+ while (1) switch (_context3.prev = _context3.next) {
129
+ case 0:
130
+ category_ids = _ref.category_ids, product_ids = _ref.product_ids;
131
+ _context3.next = 3;
132
+ return this.request.post("".concat(this.core.context.apiBasePath, "/h5/product/query"), {
133
+ open_quotation: 1,
134
+ open_bundle: 1,
135
+ extension_type: ['product_appointment', 'appointment_ticket'],
136
+ status: "published",
137
+ num: 500,
138
+ skip: 1,
139
+ category_ids: category_ids,
140
+ ids: product_ids
141
+ });
142
+ case 3:
143
+ productsData = _context3.sent;
144
+ this.store.products.addProduct(productsData.data.list);
145
+ case 5:
146
+ case "end":
147
+ return _context3.stop();
148
+ }
149
+ }, _callee3, this);
150
+ }));
151
+ function loadProducts(_x4) {
152
+ return _loadProducts.apply(this, arguments);
153
+ }
154
+ return loadProducts;
155
+ }() // 往购物车里加一些商品/服务相关的选中数据
156
+ }, {
157
+ key: "storeProducts",
158
+ value: function () {
159
+ var _storeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(productData) {
160
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
161
+ while (1) switch (_context4.prev = _context4.next) {
162
+ case 0:
163
+ this.store.cart.storeTemp("products", productData);
164
+ case 1:
165
+ case "end":
166
+ return _context4.stop();
167
+ }
168
+ }, _callee4, this);
169
+ }));
170
+ function storeProducts(_x5) {
171
+ return _storeProducts.apply(this, arguments);
172
+ }
173
+ return storeProducts;
174
+ }() // 添加账户或者 guest
175
+ }, {
176
+ key: "addAccount",
177
+ value: function () {
178
+ var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(accounts) {
179
+ var _this3 = this;
180
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
181
+ while (1) switch (_context5.prev = _context5.next) {
182
+ case 0:
183
+ accounts.forEach(function (account) {
184
+ _this3.store.accountList.addAccount(account);
185
+ });
186
+ case 1:
187
+ case "end":
188
+ return _context5.stop();
189
+ }
190
+ }, _callee5);
191
+ }));
192
+ function addAccount(_x6) {
193
+ return _addAccount.apply(this, arguments);
194
+ }
195
+ return addAccount;
196
+ }() // 获取所有账户
197
+ }, {
198
+ key: "getAccounts",
199
+ value: function () {
200
+ var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
201
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
202
+ while (1) switch (_context6.prev = _context6.next) {
203
+ case 0:
204
+ return _context6.abrupt("return", this.store.accountList.getAccounts());
205
+ case 1:
206
+ case "end":
207
+ return _context6.stop();
208
+ }
209
+ }, _callee6, this);
210
+ }));
211
+ function getAccounts() {
212
+ return _getAccounts.apply(this, arguments);
213
+ }
214
+ return getAccounts;
215
+ }() // 设置日期范围,注入到日期模块中
216
+ }, {
217
+ key: "setDateRange",
218
+ value: function () {
219
+ var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(dateRange) {
220
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
221
+ while (1) switch (_context7.prev = _context7.next) {
222
+ case 0:
223
+ case "end":
224
+ return _context7.stop();
225
+ }
226
+ }, _callee7);
227
+ }));
228
+ function setDateRange(_x7) {
229
+ return _setDateRange.apply(this, arguments);
230
+ }
231
+ return setDateRange;
232
+ }() // 获取日期模块里选中的日期
233
+ }, {
234
+ key: "getRangeDate",
235
+ value: function () {
236
+ var _getRangeDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
237
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
238
+ while (1) switch (_context8.prev = _context8.next) {
239
+ case 0:
240
+ return _context8.abrupt("return", '2024-01-01');
241
+ case 1:
242
+ case "end":
243
+ return _context8.stop();
244
+ }
245
+ }, _callee8);
246
+ }));
247
+ function getRangeDate() {
248
+ return _getRangeDate.apply(this, arguments);
249
+ }
250
+ return getRangeDate;
251
+ }() // 获取商品/服务的可用日期
252
+ }, {
253
+ key: "getAvailableDate",
254
+ value: function () {
255
+ var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
256
+ var products;
257
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
258
+ while (1) switch (_context9.prev = _context9.next) {
259
+ case 0:
260
+ _context9.next = 2;
261
+ return this.getStoreCart('products');
262
+ case 2:
263
+ products = _context9.sent;
264
+ console.log(products);
265
+ case 4:
266
+ case "end":
267
+ return _context9.stop();
268
+ }
269
+ }, _callee9, this);
270
+ }));
271
+ function getAvailableDate() {
272
+ return _getAvailableDate.apply(this, arguments);
273
+ }
274
+ return getAvailableDate;
275
+ }() // 获取具体资源的可用时段
276
+ }, {
277
+ key: "getResourceTimeslot",
278
+ value: function () {
279
+ var _getResourceTimeslot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
280
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
281
+ while (1) switch (_context10.prev = _context10.next) {
282
+ case 0:
283
+ case "end":
284
+ return _context10.stop();
285
+ }
286
+ }, _callee10);
287
+ }));
288
+ function getResourceTimeslot() {
289
+ return _getResourceTimeslot.apply(this, arguments);
290
+ }
291
+ return getResourceTimeslot;
292
+ }() // 获取可选择的商品、服务列表
293
+ }, {
294
+ key: "getProducts",
295
+ value: function () {
296
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
297
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
298
+ while (1) switch (_context11.prev = _context11.next) {
299
+ case 0:
300
+ return _context11.abrupt("return", this.store.products.getProducts());
301
+ case 1:
302
+ case "end":
303
+ return _context11.stop();
304
+ }
305
+ }, _callee11, this);
306
+ }));
307
+ function getProducts() {
308
+ return _getProducts.apply(this, arguments);
309
+ }
310
+ return getProducts;
311
+ }() // 往购物车里加一些资源相关的选中数据
312
+ }, {
313
+ key: "storeResources",
314
+ value: function () {
315
+ var _storeResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(resources) {
316
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
317
+ while (1) switch (_context12.prev = _context12.next) {
318
+ case 0:
319
+ this.store.cart.storeTemp("resources", resources);
320
+ case 1:
321
+ case "end":
322
+ return _context12.stop();
323
+ }
324
+ }, _callee12, this);
325
+ }));
326
+ function storeResources(_x8) {
327
+ return _storeResources.apply(this, arguments);
328
+ }
329
+ return storeResources;
330
+ }() // 如果用户登录
331
+ }, {
332
+ key: "setLoginAccount",
333
+ value: function () {
334
+ var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(account) {
335
+ var accounts, mainAccount;
336
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
337
+ while (1) switch (_context13.prev = _context13.next) {
338
+ case 0:
339
+ _context13.next = 2;
340
+ return this.getAccounts();
341
+ case 2:
342
+ accounts = _context13.sent;
343
+ mainAccount = accounts.find(function (n) {
344
+ return n.getLoginStatus();
345
+ });
346
+ mainAccount === null || mainAccount === void 0 || mainAccount.setAccountInfo(account);
347
+ case 5:
348
+ case "end":
349
+ return _context13.stop();
350
+ }
351
+ }, _callee13, this);
352
+ }));
353
+ function setLoginAccount(_x9) {
354
+ return _setLoginAccount.apply(this, arguments);
355
+ }
356
+ return setLoginAccount;
357
+ }() // 生成购物车的正规数据
358
+ }, {
359
+ key: "generateCartData",
360
+ value: function () {
361
+ var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
362
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
363
+ while (1) switch (_context14.prev = _context14.next) {
364
+ case 0:
365
+ case "end":
366
+ return _context14.stop();
367
+ }
368
+ }, _callee14);
369
+ }));
370
+ function generateCartData() {
371
+ return _generateCartData.apply(this, arguments);
372
+ }
373
+ return generateCartData;
374
+ }() // 购物车提交订单
375
+ }, {
376
+ key: "submitOrder",
377
+ value: function () {
378
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
379
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
380
+ while (1) switch (_context15.prev = _context15.next) {
381
+ case 0:
382
+ case "end":
383
+ return _context15.stop();
384
+ }
385
+ }, _callee15);
386
+ }));
387
+ function submitOrder() {
388
+ return _submitOrder.apply(this, arguments);
389
+ }
390
+ return submitOrder;
391
+ }() // 拉起支付模块
392
+ }, {
393
+ key: "pay",
394
+ value: function () {
395
+ var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
396
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
397
+ while (1) switch (_context16.prev = _context16.next) {
398
+ case 0:
399
+ case "end":
400
+ return _context16.stop();
401
+ }
402
+ }, _callee16);
403
+ }));
404
+ function pay() {
405
+ return _pay.apply(this, arguments);
406
+ }
407
+ return pay;
408
+ }() // 获取支付信息
409
+ }, {
410
+ key: "getPayInfo",
411
+ value: function () {
412
+ var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
413
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
414
+ while (1) switch (_context17.prev = _context17.next) {
415
+ case 0:
416
+ case "end":
417
+ return _context17.stop();
418
+ }
419
+ }, _callee17);
420
+ }));
421
+ function getPayInfo() {
422
+ return _getPayInfo.apply(this, arguments);
423
+ }
424
+ return getPayInfo;
74
425
  }()
75
426
  }]);
76
427
  return BookingByStepImpl;
@@ -1,21 +1,25 @@
1
1
  import { ProductList, CartModule } from "../../modules";
2
2
  import { AccountModule } from "../../modules/Account";
3
+ import { AccountListModule } from "../../modules/AccountList";
3
4
  import { DateModule } from "../../modules/Date";
4
5
  import { GuestListModule } from "../../modules/Guests";
5
6
  import { OrderModule } from "../../modules/Order";
6
7
  import { PaymentModule } from "../../modules/Payment";
7
8
  import { ResourceListModule } from "../../modules/Resource";
9
+ import { StepModule } from "../../modules/Step";
8
10
  export interface BookingByStepState {
9
11
  cart: CartModule;
10
- currentStep: number;
12
+ step: StepModule;
11
13
  products: ProductList;
12
14
  guests: GuestListModule;
13
15
  date: DateModule;
14
- resources: ResourceListModule[];
16
+ resources?: ResourceListModule;
15
17
  account: AccountModule;
18
+ accountList: AccountListModule;
16
19
  order: OrderModule;
17
20
  payment: PaymentModule;
18
21
  }
22
+ export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
19
23
  export declare enum BookingByStepHooks {
20
24
  onInited = "bookingByStep:onInited",
21
25
  onDestroy = "bookingByStep:onDestroy",
@@ -1,3 +1,32 @@
1
+ import { ProductList, CartModule } from "../../modules";
2
+ import { AccountListModule } from "../../modules/AccountList";
3
+ import { DateModule } from "../../modules/Date";
4
+ import { GuestListModule } from "../../modules/Guests";
5
+ import { OrderModule } from "../../modules/Order";
6
+ import { PaymentModule } from "../../modules/Payment";
7
+ import { StepModule } from "../../modules/Step";
8
+ export function createModule(moduleName, solutionName, name, version) {
9
+ switch (moduleName) {
10
+ case 'cart':
11
+ return new CartModule("".concat(solutionName, "_").concat(name || moduleName), version);
12
+ case 'step':
13
+ return new StepModule("".concat(solutionName, "_").concat(name || moduleName), version);
14
+ case 'products':
15
+ return new ProductList("".concat(solutionName, "_").concat(name || moduleName), version);
16
+ case 'guests':
17
+ return new GuestListModule("".concat(solutionName, "_").concat(name || moduleName), version);
18
+ case 'date':
19
+ return new DateModule("".concat(solutionName, "_").concat(name || moduleName), version);
20
+ case 'accountList':
21
+ return new AccountListModule("".concat(solutionName, "_").concat(name || moduleName), version);
22
+ case 'order':
23
+ return new OrderModule("".concat(solutionName, "_").concat(name || moduleName), version);
24
+ case 'payment':
25
+ return new PaymentModule("".concat(solutionName, "_").concat(name || moduleName), version);
26
+ default:
27
+ throw new Error("Unknown module type: ".concat(moduleName));
28
+ }
29
+ }
1
30
  export var BookingByStepHooks = /*#__PURE__*/function (BookingByStepHooks) {
2
31
  BookingByStepHooks["onInited"] = "bookingByStep:onInited";
3
32
  BookingByStepHooks["onDestroy"] = "bookingByStep:onDestroy";