@pisell/pisellos 0.10.65 → 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.
- package/dist/modules/OpenData/contactInfo.d.ts +20 -0
- package/dist/modules/OpenData/contactInfo.js +70 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +1 -0
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/solution/BaseSales/index.d.ts +7 -0
- package/dist/solution/BaseSales/index.js +966 -844
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +5 -14
- package/dist/solution/BookingTicket/index.js +460 -433
- package/lib/modules/OpenData/contactInfo.d.ts +20 -0
- package/lib/modules/OpenData/contactInfo.js +56 -0
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +12 -0
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/solution/BaseSales/index.d.ts +7 -0
- package/lib/solution/BaseSales/index.js +31 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +5 -14
- package/lib/solution/BookingTicket/index.js +13 -2
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -5,6 +5,7 @@ import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentS
|
|
|
5
5
|
import { OrderModule } from '../../modules/Order';
|
|
6
6
|
import { type PickupTimingBookingInput } from '../../modules/Order/pickupTiming';
|
|
7
7
|
import type { PickupTimingAvailability, PickupTimingSelection, PickupTimingValidationResult } from '../../modules/FulfillmentTiming';
|
|
8
|
+
import { type ContactInfoConfig } from '../../modules/OpenData/contactInfo';
|
|
8
9
|
import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from '../../modules/Order/types';
|
|
9
10
|
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
10
11
|
import type { Discount, VirtualCurrencyAsset } from '../../modules/Discount/types';
|
|
@@ -19,6 +20,7 @@ import { QuotationModule } from '../../modules/Quotation';
|
|
|
19
20
|
import type { ISalesDetail, ISalesDetailHeader, ISalesBooking, ISalesPayment, ISalesSurcharge } from './utils/parseSalesResponse';
|
|
20
21
|
import { AppPlugin } from '../../plugins/app';
|
|
21
22
|
import { type TransformBaseProductToOrderProductParams } from './utils/transformBaseProductToOrderProduct';
|
|
23
|
+
import type { OpenDataConfig } from '../../modules/OpenData/types';
|
|
22
24
|
export interface BaseSalesState {
|
|
23
25
|
order?: OrderModule;
|
|
24
26
|
products?: ProductList;
|
|
@@ -283,6 +285,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
283
285
|
setPickupTimingBooking(input: PickupTimingBookingInput): import("../../modules/Order").PickupTimingBooking;
|
|
284
286
|
clearPickupTimingBooking(): void;
|
|
285
287
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
288
|
+
protected loadContactInfoOpenData(): Promise<OpenDataConfig | null>;
|
|
289
|
+
getContactInfoConfig(): Promise<ContactInfoConfig>;
|
|
290
|
+
validateContactInfo(): Promise<void>;
|
|
286
291
|
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
287
292
|
setEnableTempOrderPersist(enabled: boolean): void;
|
|
288
293
|
/** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
|
|
@@ -359,6 +364,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
359
364
|
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
360
365
|
*/
|
|
361
366
|
submitSalesOrder<T = any>(params?: BaseSalesSubmitSalesOrderParams): Promise<T>;
|
|
367
|
+
/** Validate required contact fields before a new payment is initiated. */
|
|
368
|
+
ensureSalesOrderReadyForPayment(): Promise<void>;
|
|
362
369
|
saveSalesOrderDraft<T = any>(params?: {
|
|
363
370
|
platform?: string;
|
|
364
371
|
businessCode?: string;
|