@pisell/pisellos 0.0.510 → 0.0.511

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.
@@ -35,7 +35,6 @@ __export(utils_exports, {
35
35
  buildProductKey: () => buildProductKey,
36
36
  buildProductLineFingerprint: () => buildProductLineFingerprint,
37
37
  buildQuantityLimitIndex: () => buildQuantityLimitIndex,
38
- buildSyntheticSingleOptionIdentityKey: () => buildSyntheticSingleOptionIdentityKey,
39
38
  collectLinkProductIdsFromReservationRules: () => collectLinkProductIdsFromReservationRules,
40
39
  computeResourceIsFull: () => computeResourceIsFull,
41
40
  createEmptySummary: () => createEmptySummary,
@@ -62,6 +61,7 @@ __export(utils_exports, {
62
61
  });
63
62
  module.exports = __toCommonJS(utils_exports);
64
63
  var import_dayjs = __toESM(require("dayjs"));
64
+ var import_utils = require("../../modules/Order/utils");
65
65
  function createEmptySummary() {
66
66
  return {
67
67
  product_quantity: 0,
@@ -378,43 +378,6 @@ function isSkuOnlyDeleteIdentity(x) {
378
378
  return false;
379
379
  return !("product_option_item" in x) && !("product_bundle" in x);
380
380
  }
381
- function buildSyntheticSingleOptionIdentityKey(productId, productOptionItem) {
382
- if (productId == null || !Number.isFinite(Number(productId)))
383
- return void 0;
384
- const opts = Array.isArray(productOptionItem) ? productOptionItem : [];
385
- if (opts.length !== 1)
386
- return void 0;
387
- const o = opts[0];
388
- const gid = Number(o == null ? void 0 : o.option_group_id) || 0;
389
- const oid = Number(o == null ? void 0 : o.product_option_item_id) || 0;
390
- const rawNum = o == null ? void 0 : o.num;
391
- const n = typeof rawNum === "number" && !Number.isNaN(rawNum) ? Math.max(1, Math.floor(rawNum)) : 1;
392
- return `${productId}_${gid}_${oid}_${n}`;
393
- }
394
- function collectLineIdentityKeyCandidates(x) {
395
- var _a;
396
- const out = /* @__PURE__ */ new Set();
397
- const row = x;
398
- if (typeof row.identity_key === "string" && row.identity_key.length > 0) {
399
- out.add(row.identity_key);
400
- }
401
- const uid = (_a = row.metadata) == null ? void 0 : _a.unique_identification_number;
402
- if (typeof uid === "string" && uid.length > 0)
403
- out.add(uid);
404
- const synthetic = buildSyntheticSingleOptionIdentityKey(
405
- row.product_id,
406
- row.product_option_item
407
- );
408
- if (synthetic)
409
- out.add(synthetic);
410
- const opts = "product_option_item" in row && Array.isArray(row.product_option_item) ? row.product_option_item : [];
411
- const bundles = "product_bundle" in row && Array.isArray(row.product_bundle) ? row.product_bundle : [];
412
- if (opts.length === 0 && bundles.length === 0 && row.product_id != null && Number.isFinite(Number(row.product_id))) {
413
- const vid = Number(row.product_variant_id) || 0;
414
- out.add(`${row.product_id}_${vid}_0`);
415
- }
416
- return out;
417
- }
418
381
  function fingerprintForIdentityWithOptionKeys(x) {
419
382
  const row = x;
420
383
  const opts = "product_option_item" in row ? Array.isArray(row.product_option_item) ? row.product_option_item : [] : [];
@@ -424,17 +387,10 @@ function fingerprintForIdentityWithOptionKeys(x) {
424
387
  function isIdentityMatch(a, b) {
425
388
  if (a.product_id !== b.product_id || a.product_variant_id !== b.product_variant_id)
426
389
  return false;
427
- if (a.identity_key || b.identity_key) {
428
- if (a.identity_key && b.identity_key)
429
- return a.identity_key === b.identity_key;
430
- if (a.identity_key && !b.identity_key) {
431
- return collectLineIdentityKeyCandidates(b).has(a.identity_key);
432
- }
433
- if (!a.identity_key && b.identity_key) {
434
- return collectLineIdentityKeyCandidates(a).has(b.identity_key);
435
- }
436
- return false;
437
- }
390
+ const aHasKey = typeof a.identity_key === "string" && a.identity_key.length > 0;
391
+ const bHasKey = typeof b.identity_key === "string" && b.identity_key.length > 0;
392
+ if (aHasKey && bHasKey)
393
+ return a.identity_key === b.identity_key;
438
394
  if (isSkuOnlyDeleteIdentity(a) || isSkuOnlyDeleteIdentity(b))
439
395
  return true;
440
396
  return fingerprintForIdentityWithOptionKeys(a) === fingerprintForIdentityWithOptionKeys(b);
@@ -445,8 +401,9 @@ function getProductIdentityIndex(products, identity) {
445
401
  function normalizeOrderProduct(product) {
446
402
  var _a, _b;
447
403
  const metadata = { ...product.metadata || {} };
448
- if (product.identity_key && !metadata.unique_identification_number) {
449
- metadata.unique_identification_number = product.identity_key;
404
+ const resolvedIdentityKey = product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : (0, import_utils.createUuidV4)();
405
+ if (!metadata.unique_identification_number) {
406
+ metadata.unique_identification_number = resolvedIdentityKey;
450
407
  }
451
408
  const resolvedSellingPrice = product.selling_price || "0.00";
452
409
  const resolvedOriginalPrice = product.original_price || resolvedSellingPrice;
@@ -469,7 +426,7 @@ function normalizeOrderProduct(product) {
469
426
  product_id: product.product_id,
470
427
  num: getSafeProductNum(product.num),
471
428
  product_variant_id: product.product_variant_id,
472
- identity_key: product.identity_key,
429
+ identity_key: resolvedIdentityKey,
473
430
  product_option_item: product.product_option_item || [],
474
431
  selling_price: resolvedSellingPrice,
475
432
  original_price: resolvedOriginalPrice,
@@ -478,6 +435,7 @@ function normalizeOrderProduct(product) {
478
435
  discount_list: product.discount_list || [],
479
436
  product_bundle: normalizedBundle,
480
437
  metadata,
438
+ note: product.note != null ? String(product.note) : "",
481
439
  _origin: product._origin
482
440
  };
483
441
  }
@@ -600,7 +558,6 @@ function pickFirstCustomCapacityDimensionId(products) {
600
558
  buildProductKey,
601
559
  buildProductLineFingerprint,
602
560
  buildQuantityLimitIndex,
603
- buildSyntheticSingleOptionIdentityKey,
604
561
  collectLinkProductIdsFromReservationRules,
605
562
  computeResourceIsFull,
606
563
  createEmptySummary,
@@ -2,6 +2,7 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { VenueBookingAddLogParams, VenueBookingSlotConfig, VenueDateSummaryItem, VenueSlotSelection, VenueTimeSlotGrid } from './types';
4
4
  import type { ScanOrderOrderProduct, ScanOrderOrderProductIdentity } from '../ScanOrder/types';
5
+ import type { UpdateProductInOrderParams } from '../../modules/Order/types';
5
6
  import type { OpenDataAvailabilityResult } from '../../modules/OpenData';
6
7
  import type { ProductData } from '../../modules/Product/types';
7
8
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
@@ -165,11 +166,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
165
166
  getSummary(): Promise<import("./types").ScanOrderSummary>;
166
167
  submitOrder<T = any>(): Promise<T>;
167
168
  addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
168
- updateProductInOrder(params: {
169
- product_id: number | null;
170
- product_variant_id: number;
171
- updates: Partial<ScanOrderOrderProduct>;
172
- }): Promise<ScanOrderOrderProduct[]>;
169
+ updateProductInOrder(params: UpdateProductInOrderParams): Promise<ScanOrderOrderProduct[]>;
173
170
  removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
174
171
  getProductList(): Promise<ProductData[]>;
175
172
  private loadOpenDataConfig;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.510",
4
+ "version": "0.0.511",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",