@pisell/pisellos 0.10.16 → 0.10.18

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 (63) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/OpenData/index.d.ts +5 -2
  3. package/dist/modules/OpenData/index.js +27 -12
  4. package/dist/modules/OpenData/types.d.ts +42 -0
  5. package/dist/modules/OpenData/types.js +7 -1
  6. package/dist/modules/OpenData/utils.d.ts +15 -1
  7. package/dist/modules/OpenData/utils.js +85 -0
  8. package/dist/modules/Order/index.d.ts +3 -1
  9. package/dist/modules/Order/index.js +68 -44
  10. package/dist/modules/Order/types.d.ts +3 -0
  11. package/dist/modules/Order/types.js +1 -0
  12. package/dist/modules/ProductList/index.js +96 -74
  13. package/dist/modules/Rules/index.js +11 -8
  14. package/dist/modules/SalesSummary/index.js +6 -4
  15. package/dist/server/index.d.ts +11 -0
  16. package/dist/server/index.js +845 -481
  17. package/dist/server/modules/order/index.d.ts +8 -0
  18. package/dist/server/modules/order/index.js +251 -215
  19. package/dist/server/utils/small-ticket.d.ts +9 -1
  20. package/dist/server/utils/small-ticket.js +117 -43
  21. package/dist/solution/BaseSales/index.d.ts +7 -0
  22. package/dist/solution/BaseSales/index.js +251 -144
  23. package/dist/solution/BookingByStep/index.d.ts +2 -2
  24. package/dist/solution/BookingTicket/index.d.ts +14 -19
  25. package/dist/solution/BookingTicket/index.js +545 -429
  26. package/dist/solution/Sales/index.d.ts +20 -4
  27. package/dist/solution/Sales/index.js +348 -75
  28. package/dist/solution/Sales/types.d.ts +10 -0
  29. package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
  30. package/dist/solution/UnifiedBookingSales/index.js +495 -422
  31. package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
  32. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  33. package/lib/modules/OpenData/index.d.ts +5 -2
  34. package/lib/modules/OpenData/index.js +50 -3
  35. package/lib/modules/OpenData/types.d.ts +42 -0
  36. package/lib/modules/OpenData/types.js +9 -1
  37. package/lib/modules/OpenData/utils.d.ts +15 -1
  38. package/lib/modules/OpenData/utils.js +85 -0
  39. package/lib/modules/Order/index.d.ts +3 -1
  40. package/lib/modules/Order/index.js +41 -21
  41. package/lib/modules/Order/types.d.ts +3 -0
  42. package/lib/modules/Order/types.js +1 -0
  43. package/lib/modules/ProductList/index.js +9 -6
  44. package/lib/modules/Rules/index.js +8 -6
  45. package/lib/modules/SalesSummary/index.js +3 -1
  46. package/lib/server/index.d.ts +11 -0
  47. package/lib/server/index.js +395 -96
  48. package/lib/server/modules/order/index.d.ts +8 -0
  49. package/lib/server/modules/order/index.js +23 -0
  50. package/lib/server/utils/small-ticket.d.ts +9 -1
  51. package/lib/server/utils/small-ticket.js +107 -35
  52. package/lib/solution/BaseSales/index.d.ts +7 -0
  53. package/lib/solution/BaseSales/index.js +125 -28
  54. package/lib/solution/BookingByStep/index.d.ts +2 -2
  55. package/lib/solution/BookingTicket/index.d.ts +14 -19
  56. package/lib/solution/BookingTicket/index.js +70 -17
  57. package/lib/solution/Sales/index.d.ts +20 -4
  58. package/lib/solution/Sales/index.js +183 -15
  59. package/lib/solution/Sales/types.d.ts +10 -0
  60. package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
  61. package/lib/solution/UnifiedBookingSales/index.js +41 -15
  62. package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
  63. package/package.json +1 -1
@@ -32,6 +32,7 @@ exports.normalizeProductForAvailability = normalizeProductForAvailability;
32
32
  var _dayjs = _interopRequireDefault(require("dayjs"));
33
33
  var _lodashEs = require("lodash-es");
34
34
  var _modules = require("../../modules");
35
+ var _OpenData = require("../../modules/OpenData");
35
36
  var _getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
36
37
  var _ResourcePlanner = require("../../modules/ResourcePlanner");
37
38
  var _types = require("./types");
@@ -50,7 +51,7 @@ var _remoteOccupancyCache = require("./remoteOccupancyCache");
50
51
  var _BookingTicket = require("../BookingTicket");
51
52
  var _localClock = require("../../modules/ResourcePlanner/localClock");
52
53
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
53
- const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'basic', 'checkout', 'availability'];
54
+ const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'basic', 'checkout', 'availability', 'documents'];
54
55
  const OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
55
56
  function normalizePositiveInteger(value) {
56
57
  const normalized = Number(value);
@@ -985,9 +986,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
985
986
  defaultVersion = '1.0.0';
986
987
  store = {};
987
988
  unifiedProductCatalog = [];
988
- openDataTarget = null;
989
- loadOpenDataInFlight = null;
990
- loadOpenDataInFlightTarget = null;
991
989
  availabilityRuntimeOffsetMinutes = null;
992
990
  availabilityScheduleCatalog = null;
993
991
  availabilityProjectionSequence = 0;
@@ -1491,35 +1489,63 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1491
1489
  return this.loadOpenData(params);
1492
1490
  }
1493
1491
  this.loadOpenDataInFlightTarget = target;
1494
- this.loadOpenDataInFlight = this.store.openData.fetchOpenData({
1492
+ const request = this.store.openData.fetchOpenData({
1495
1493
  scope: 'board',
1496
1494
  target,
1497
1495
  section_code: [...OPEN_DATA_SECTION_CODES]
1498
1496
  });
1497
+ this.loadOpenDataInFlight = request;
1499
1498
  try {
1500
- const openData = await this.loadOpenDataInFlight;
1501
- this.openDataTarget = target;
1502
- this.otherParams.openData = openData;
1503
- this.otherParams.businessCode = businessCode;
1504
- this.otherParams.channel = channel;
1499
+ const openData = await request;
1500
+ if (this.loadOpenDataInFlight === request) {
1501
+ this.openDataTarget = target;
1502
+ this.otherParams.openData = openData;
1503
+ this.otherParams.businessCode = businessCode;
1504
+ this.otherParams.channel = channel;
1505
+ }
1505
1506
  return openData;
1506
1507
  } finally {
1507
- this.loadOpenDataInFlight = null;
1508
- this.loadOpenDataInFlightTarget = null;
1508
+ if (this.loadOpenDataInFlight === request) {
1509
+ this.loadOpenDataInFlight = null;
1510
+ this.loadOpenDataInFlightTarget = null;
1511
+ }
1509
1512
  }
1510
1513
  }
1511
1514
  async getOpenData() {
1512
1515
  const businessCode = String(this.otherParams?.businessCode || '').trim();
1513
1516
  const channel = String(this.otherParams?.channel || '').trim();
1514
1517
  if (!businessCode || !channel) return null;
1515
- const target = `${businessCode}+${channel}`;
1516
- const cachedData = this.store.openData?.getOpenData() || null;
1517
- if (cachedData && this.openDataTarget === target) return cachedData;
1518
1518
  return this.loadOpenData({
1519
1519
  businessCode,
1520
1520
  channel
1521
1521
  });
1522
1522
  }
1523
+ clearOpenDataCache() {
1524
+ this.openDataTarget = null;
1525
+ this.loadOpenDataInFlight = null;
1526
+ this.loadOpenDataInFlightTarget = null;
1527
+ super.clearOpenDataCache();
1528
+ }
1529
+ async getInvoiceLayoutConfig() {
1530
+ const openData = await this.getOpenData();
1531
+ if (!openData || !this.store.openData) {
1532
+ return (0, _OpenData.getDefaultInvoiceLayoutConfig)();
1533
+ }
1534
+ return this.store.openData.getInvoiceLayoutConfig();
1535
+ }
1536
+ async getInvoiceTemplateSettings() {
1537
+ const openData = await this.getOpenData();
1538
+ if (!openData || !this.store.openData) {
1539
+ return (0, _OpenData.getDefaultInvoiceTemplateSettings)();
1540
+ }
1541
+ return this.store.openData.getInvoiceTemplateSettings();
1542
+ }
1543
+ isInvoiceOpenDataCacheCurrent() {
1544
+ const businessCode = String(this.otherParams?.businessCode || '').trim();
1545
+ const channel = String(this.otherParams?.channel || '').trim();
1546
+ if (!businessCode || !channel) return false;
1547
+ return this.openDataTarget === `${businessCode}+${channel}`;
1548
+ }
1523
1549
 
1524
1550
  /**
1525
1551
  * Load a resource policy without depending on the legacy appointmentBooking solution.
@@ -1,4 +1,4 @@
1
- import type { OpenDataConfig } from '../../modules/OpenData';
1
+ import type { InvoiceLayoutConfig, InvoiceTemplateSettings, OpenDataConfig } from '../../modules/OpenData';
2
2
  import type { ProductListLoadProductsParams } from '../../modules/ProductList';
3
3
  import type { LoadScheduleAvailableDateParams } from '../../modules/Schedule/types';
4
4
  import type { AvailabilityDateRange, AvailabilityErrorCode, AvailabilityId, AvailabilityOccupancy, AvailabilityProduct, AvailabilityProjection, AvailabilityQuery, AvailabilityRequirementSelection, AvailabilityResource, AvailabilitySelectionValidationResult, DateAvailabilityQueryResult, GetProductTimeRangesRequest, ProductAvailabilityQueryResult, ProductTimeRange, ProductTimeRangeGroup, ResourceAvailabilityGroup, ResourceAvailabilityRangeGroup, TimeAvailabilityGroup, TimeAvailabilityItem } from '../../modules/ResourcePlanner';
@@ -201,7 +201,13 @@ export interface UnifiedBookingSalesDiscountResult {
201
201
  }
202
202
  export interface UnifiedBookingSalesApi {
203
203
  loadOpenData: (params: UnifiedBookingSalesLoadOpenDataParams) => Promise<OpenDataConfig>;
204
+ /** Returns the latest OpenData payload cached by this solution instance. */
204
205
  getOpenData: () => Promise<OpenDataConfig | null>;
206
+ /** Returns the normalized Documents Invoice layout for the active target. */
207
+ getInvoiceLayoutConfig: () => Promise<InvoiceLayoutConfig>;
208
+ /** Returns the Native Invoice template settings for the active target. */
209
+ getInvoiceTemplateSettings: () => Promise<InvoiceTemplateSettings>;
210
+ /** Date-first calendar availability backed by ScheduleModule. */
205
211
  loadScheduleAvailableDate: (params: LoadScheduleAvailableDateParams) => Promise<unknown>;
206
212
  loadProductsByScheduleDate: (params: UnifiedBookingSalesLoadProductsByScheduleDateParams) => Promise<unknown[]>;
207
213
  stageRetailProducts: (params: UnifiedBookingSalesStageRetailProductsParams) => Promise<Record<string, any> | null>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.10.16",
4
+ "version": "0.10.18",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",