@pisell/pisellos 0.10.64 → 0.10.66

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 (42) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/OpenData/contactInfo.d.ts +20 -0
  3. package/dist/modules/OpenData/contactInfo.js +70 -0
  4. package/dist/modules/OpenData/index.d.ts +1 -0
  5. package/dist/modules/OpenData/index.js +1 -0
  6. package/dist/modules/OpenData/types.d.ts +9 -0
  7. package/dist/modules/Order/index.d.ts +6 -1
  8. package/dist/modules/Order/index.js +564 -475
  9. package/dist/modules/Order/types.d.ts +2 -0
  10. package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
  11. package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  12. package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
  13. package/dist/modules/Product/index.d.ts +1 -1
  14. package/dist/modules/Rules/index.d.ts +2 -0
  15. package/dist/modules/Rules/index.js +29 -21
  16. package/dist/solution/BaseSales/index.d.ts +15 -1
  17. package/dist/solution/BaseSales/index.js +1018 -884
  18. package/dist/solution/BookingByStep/index.d.ts +2 -2
  19. package/dist/solution/BookingTicket/index.d.ts +4 -1
  20. package/dist/solution/BookingTicket/index.js +485 -433
  21. package/dist/solution/BookingTicket/types.d.ts +2 -0
  22. package/lib/modules/OpenData/contactInfo.d.ts +20 -0
  23. package/lib/modules/OpenData/contactInfo.js +56 -0
  24. package/lib/modules/OpenData/index.d.ts +1 -0
  25. package/lib/modules/OpenData/index.js +12 -0
  26. package/lib/modules/OpenData/types.d.ts +9 -0
  27. package/lib/modules/Order/index.d.ts +6 -1
  28. package/lib/modules/Order/index.js +49 -6
  29. package/lib/modules/Order/types.d.ts +2 -0
  30. package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
  31. package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  32. package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
  33. package/lib/modules/Product/index.d.ts +1 -1
  34. package/lib/modules/Rules/index.d.ts +2 -0
  35. package/lib/modules/Rules/index.js +6 -0
  36. package/lib/solution/BaseSales/index.d.ts +15 -1
  37. package/lib/solution/BaseSales/index.js +40 -2
  38. package/lib/solution/BookingByStep/index.d.ts +2 -2
  39. package/lib/solution/BookingTicket/index.d.ts +4 -1
  40. package/lib/solution/BookingTicket/index.js +27 -2
  41. package/lib/solution/BookingTicket/types.d.ts +2 -0
  42. package/package.json +1 -1
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -0,0 +1,20 @@
1
+ import type { OpenDataConfig } from './types';
2
+ export declare const CONTACT_INFO_FIELDS: readonly ["first_name", "last_name", "phone", "email"];
3
+ export type ContactInfoField = typeof CONTACT_INFO_FIELDS[number];
4
+ export interface ContactInfoConfig {
5
+ enabled: boolean;
6
+ fields: Record<ContactInfoField, {
7
+ visible: boolean;
8
+ required: boolean;
9
+ }>;
10
+ }
11
+ export declare function resolveContactInfoConfig(data?: OpenDataConfig | null): ContactInfoConfig;
12
+ export declare function getMissingContactInfoFields(config: ContactInfoConfig, value: unknown): ContactInfoField[];
13
+ export declare function isContactRecord(value: unknown): value is Record<string, any>;
14
+ /** Customer relations wrap the contact in value; sales orders store the object itself. */
15
+ export declare function extractCustomerContactInfo(customer: unknown): Record<string, any> | null;
16
+ export declare class ContactInfoRequiredError extends Error {
17
+ readonly fields: ContactInfoField[];
18
+ readonly code = "CONTACT_INFO_REQUIRED";
19
+ constructor(fields: ContactInfoField[]);
20
+ }
@@ -0,0 +1,70 @@
1
+ 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); } }
2
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+ 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); }
5
+ 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); }; }
6
+ 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); }
7
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
8
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
9
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
10
+ 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; } }
11
+ function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
12
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
13
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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
+ 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); }
18
+ export var CONTACT_INFO_FIELDS = ['first_name', 'last_name', 'phone', 'email'];
19
+ export function resolveContactInfoConfig(data) {
20
+ var enabled = (data === null || data === void 0 ? void 0 : data['sale.enable_contact_info']) === true;
21
+ var fields = CONTACT_INFO_FIELDS.reduce(function (result, field) {
22
+ var visible = (data === null || data === void 0 ? void 0 : data["sale.".concat(field, ".visible")]) !== false;
23
+ result[field] = {
24
+ visible: visible,
25
+ required: enabled && visible && (data === null || data === void 0 ? void 0 : data["sale.".concat(field, ".required")]) === true
26
+ };
27
+ return result;
28
+ }, {});
29
+ return {
30
+ enabled: enabled && CONTACT_INFO_FIELDS.some(function (field) {
31
+ return fields[field].visible;
32
+ }),
33
+ fields: fields
34
+ };
35
+ }
36
+ export function getMissingContactInfoFields(config, value) {
37
+ if (!config.enabled) return [];
38
+ var contact = isContactRecord(value) ? value : {};
39
+ return CONTACT_INFO_FIELDS.filter(function (field) {
40
+ if (!config.fields[field].visible || !config.fields[field].required) return false;
41
+ var fieldValue = field === 'phone' ? isContactRecord(contact.phone) ? contact.phone.phone : undefined : contact[field];
42
+ return typeof fieldValue !== 'string' || !fieldValue.trim();
43
+ });
44
+ }
45
+ export function isContactRecord(value) {
46
+ return !!value && _typeof(value) === 'object' && !Array.isArray(value);
47
+ }
48
+
49
+ /** Customer relations wrap the contact in value; sales orders store the object itself. */
50
+ export function extractCustomerContactInfo(customer) {
51
+ if (!isContactRecord(customer)) return null;
52
+ var contact = customer.contacts_info;
53
+ if (!isContactRecord(contact)) return null;
54
+ var value = Object.prototype.hasOwnProperty.call(contact, 'value') ? contact.value : contact;
55
+ return isContactRecord(value) ? value : null;
56
+ }
57
+ export var ContactInfoRequiredError = /*#__PURE__*/function (_Error) {
58
+ _inherits(ContactInfoRequiredError, _Error);
59
+ var _super = _createSuper(ContactInfoRequiredError);
60
+ function ContactInfoRequiredError(fields) {
61
+ var _this;
62
+ _classCallCheck(this, ContactInfoRequiredError);
63
+ _this = _super.call(this, "Contact information is required: ".concat(fields.join(', ')));
64
+ _defineProperty(_assertThisInitialized(_this), "code", 'CONTACT_INFO_REQUIRED');
65
+ _this.fields = fields;
66
+ _this.name = 'ContactInfoRequiredError';
67
+ return _this;
68
+ }
69
+ return _createClass(ContactInfoRequiredError);
70
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
@@ -3,6 +3,7 @@ import { BaseModule } from '../BaseModule';
3
3
  import type { ScheduleModule } from '../Schedule';
4
4
  import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
5
5
  export * from './types';
6
+ export * from './contactInfo';
6
7
  export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales, } from './utils';
7
8
  export declare class OpenDataModule extends BaseModule implements Module {
8
9
  protected defaultName: string;
@@ -18,6 +18,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
18
18
  import { BaseModule } from "../BaseModule";
19
19
  import { computeAvailability, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "./utils";
20
20
  export * from "./types";
21
+ export * from "./contactInfo";
21
22
  export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "./utils";
22
23
  function isRecord(value) {
23
24
  return !!value && _typeof(value) === 'object' && !Array.isArray(value);
@@ -69,6 +69,15 @@ export interface OpenDataConfig {
69
69
  'reservation.time_slice'?: number | string;
70
70
  'sale.allow_item_notes'?: boolean;
71
71
  'sale.allow_order_notes'?: boolean;
72
+ 'sale.enable_contact_info'?: boolean;
73
+ 'sale.first_name.visible'?: boolean;
74
+ 'sale.first_name.required'?: boolean;
75
+ 'sale.last_name.visible'?: boolean;
76
+ 'sale.last_name.required'?: boolean;
77
+ 'sale.phone.visible'?: boolean;
78
+ 'sale.phone.required'?: boolean;
79
+ 'sale.email.visible'?: boolean;
80
+ 'sale.email.required'?: boolean;
72
81
  /** False submits an order without starting or confirming payment. */
73
82
  'sale.require_payment_on_submit'?: boolean | null;
74
83
  'sale.enable_item_rules'?: boolean;
@@ -4,6 +4,7 @@ import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrde
4
4
  import { CartItem } from '../Cart/types';
5
5
  import { type SubmitPayloadEnhancer } from './utils';
6
6
  import { type PickupTimingBooking, type PickupTimingBookingInput } from './pickupTiming';
7
+ import { type ProductVoucherGroup } from './utils/productVoucherGroups';
7
8
  import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderHooksConfig, OrderCartIntentCommitContext, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
8
9
  import type { ICustomer } from '../AccountList/types';
9
10
  import type { Discount } from '../Discount/types';
@@ -94,6 +95,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
94
95
  */
95
96
  private logError;
96
97
  private registerDiscountModules;
98
+ setProductVoucherGroups(groups: ProductVoucherGroup[]): void;
99
+ validateProductVoucherSelection(): void;
97
100
  private createDefaultRulesHooks;
98
101
  /**
99
102
  * Stable across notifyTempOrderChanged's immutable copy, but changes when a
@@ -112,7 +115,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
112
115
  getCustomerWalletPrepareConfigEpoch(): number;
113
116
  private syncScannedDiscountsToOriginalDiscountList;
114
117
  private ensureEditDiscountConfigForProductChange;
115
- scanCode(code: string, customerId?: number): Promise<{
118
+ scanCode(code: string, customerId?: number, options?: {
119
+ productVouchersOnly?: boolean;
120
+ }): Promise<{
116
121
  isAvailable: boolean;
117
122
  isAccepted?: boolean;
118
123
  discountList: Discount[];