@pisell/pisellos 2.2.304 → 2.2.305

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.
@@ -557,7 +557,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
557
557
  generateIdempotencyToken(): string;
558
558
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
559
559
  createOrder(params: CommitOrderParams['query']): {
560
- type: "virtual" | "appointment_booking";
560
+ type: "appointment_booking" | "virtual";
561
561
  platform: string;
562
562
  sales_channel: string;
563
563
  order_sales_channel: string;
@@ -294,12 +294,14 @@ function evaluateCandidateTimeGate(params) {
294
294
  };
295
295
  }
296
296
  if (policy.type === 'before_start') {
297
- // Flexible-duration candidates and POS fixed-duration anchors start at
298
- // minute precision. Keep that current minute selectable instead of treating
299
- // the freshly generated candidate as already started because the query
300
- // clock still contains seconds.
297
+ // POS fixed-duration candidates use the context's stable opening-minute
298
+ // anchor. Keep that anchored range selectable while it is still active;
299
+ // otherwise a minute refresh turns it into 0 capacity and incorrectly
300
+ // advances a create flow to the next slot. The earlier `past` gate still
301
+ // rejects the anchor once its booking range has ended.
302
+ var isActivePosDurationAnchor = evaluationContext.useExactDurationCandidateMinute && product.kind === 'duration' && !product.isFlexibleDuration && evaluationContext.durationCandidateAnchorAtMs === candidateRange.start;
301
303
  var usesMinutePrecision = product.isFlexibleDuration || evaluationContext.useExactDurationCandidateMinute && product.kind === 'duration';
302
- var hasNotReachedStart = usesMinutePrecision ? floorToMinute(now) <= candidateRange.start : now < candidateRange.start;
304
+ var hasNotReachedStart = isActivePosDurationAnchor || (usesMinutePrecision ? floorToMinute(now) <= candidateRange.start : now < candidateRange.start);
303
305
  if (hasNotReachedStart) return null;
304
306
  return {
305
307
  status: 'unavailable',
@@ -1437,6 +1439,7 @@ function buildAvailabilityCellIndex(projection) {
1437
1439
  function buildEvaluationContext(params) {
1438
1440
  var _params$resourceIds2;
1439
1441
  var evaluatedAt = toDateTime(params.evaluatedAt || params.projection.meta.now, params.projection.meta.timezone);
1442
+ var durationCandidateAnchorAt = toDateTime(params.projection.meta.durationCandidateAnchorAt, params.projection.meta.timezone);
1440
1443
  var selectionsByGroupKey = new Map();
1441
1444
  (params.requirementSelections || []).forEach(function (selection) {
1442
1445
  var _selection$formId;
@@ -1449,6 +1452,7 @@ function buildEvaluationContext(params) {
1449
1452
  resourceIdSet: (_params$resourceIds2 = params.resourceIds) !== null && _params$resourceIds2 !== void 0 && _params$resourceIds2.length ? new Set(params.resourceIds.map(String)) : null,
1450
1453
  selectionsByGroupKey: selectionsByGroupKey,
1451
1454
  useExactDurationCandidateMinute: params.useExactDurationCandidateMinute === true,
1455
+ durationCandidateAnchorAtMs: Number.isFinite(durationCandidateAnchorAt) ? floorToMinute(durationCandidateAnchorAt) : null,
1452
1456
  allowExcludedScheduleDateOverride: params.allowExcludedScheduleDateOverride === true
1453
1457
  };
1454
1458
  }
@@ -253,7 +253,8 @@ export interface GetProductTimeRangesRuntimeOptions {
253
253
  /**
254
254
  * Internal POS capability: fixed-duration candidates start from the stable
255
255
  * context anchor's current minute instead of rounding up to ten minutes, and
256
- * that minute remains selectable during before-start cutoff evaluation.
256
+ * that anchored range remains selectable while active during before-start
257
+ * cutoff evaluation.
257
258
  * Other callers keep the legacy alignment and strict second-level cutoff.
258
259
  */
259
260
  useExactDurationCandidateMinute?: boolean;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 5 | 3 | 1 | 2 | 4 | 6;
329
+ weekNum: 0 | 2 | 3 | 1 | 5 | 6 | 4;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -1 +1,46 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _examples.ITEM_REWARD_STRATEGY;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "PromotionAdapter", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _adapter.PromotionAdapter;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PromotionEvaluator", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _evaluator.PromotionEvaluator;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "default", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _adapter.default;
40
+ }
41
+ });
42
+ var _evaluator = require("./evaluator");
43
+ var _adapter = _interopRequireWildcard(require("./adapter"));
44
+ var _examples = require("./examples");
45
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -557,7 +557,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
557
557
  generateIdempotencyToken(): string;
558
558
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
559
559
  createOrder(params: CommitOrderParams['query']): {
560
- type: "virtual" | "appointment_booking";
560
+ type: "appointment_booking" | "virtual";
561
561
  platform: string;
562
562
  sales_channel: string;
563
563
  order_sales_channel: string;
@@ -281,12 +281,14 @@ function evaluateCandidateTimeGate(params) {
281
281
  };
282
282
  }
283
283
  if (policy.type === 'before_start') {
284
- // Flexible-duration candidates and POS fixed-duration anchors start at
285
- // minute precision. Keep that current minute selectable instead of treating
286
- // the freshly generated candidate as already started because the query
287
- // clock still contains seconds.
284
+ // POS fixed-duration candidates use the context's stable opening-minute
285
+ // anchor. Keep that anchored range selectable while it is still active;
286
+ // otherwise a minute refresh turns it into 0 capacity and incorrectly
287
+ // advances a create flow to the next slot. The earlier `past` gate still
288
+ // rejects the anchor once its booking range has ended.
289
+ const isActivePosDurationAnchor = evaluationContext.useExactDurationCandidateMinute && product.kind === 'duration' && !product.isFlexibleDuration && evaluationContext.durationCandidateAnchorAtMs === candidateRange.start;
288
290
  const usesMinutePrecision = product.isFlexibleDuration || evaluationContext.useExactDurationCandidateMinute && product.kind === 'duration';
289
- const hasNotReachedStart = usesMinutePrecision ? floorToMinute(now) <= candidateRange.start : now < candidateRange.start;
291
+ const hasNotReachedStart = isActivePosDurationAnchor || (usesMinutePrecision ? floorToMinute(now) <= candidateRange.start : now < candidateRange.start);
290
292
  if (hasNotReachedStart) return null;
291
293
  return {
292
294
  status: 'unavailable',
@@ -1249,6 +1251,7 @@ function buildAvailabilityCellIndex(projection) {
1249
1251
  }
1250
1252
  function buildEvaluationContext(params) {
1251
1253
  const evaluatedAt = toDateTime(params.evaluatedAt || params.projection.meta.now, params.projection.meta.timezone);
1254
+ const durationCandidateAnchorAt = toDateTime(params.projection.meta.durationCandidateAnchorAt, params.projection.meta.timezone);
1252
1255
  const selectionsByGroupKey = new Map();
1253
1256
  (params.requirementSelections || []).forEach(selection => {
1254
1257
  const key = selection.requirementGroupId || String(selection.formId ?? '');
@@ -1260,6 +1263,7 @@ function buildEvaluationContext(params) {
1260
1263
  resourceIdSet: params.resourceIds?.length ? new Set(params.resourceIds.map(String)) : null,
1261
1264
  selectionsByGroupKey,
1262
1265
  useExactDurationCandidateMinute: params.useExactDurationCandidateMinute === true,
1266
+ durationCandidateAnchorAtMs: Number.isFinite(durationCandidateAnchorAt) ? floorToMinute(durationCandidateAnchorAt) : null,
1263
1267
  allowExcludedScheduleDateOverride: params.allowExcludedScheduleDateOverride === true
1264
1268
  };
1265
1269
  }
@@ -253,7 +253,8 @@ export interface GetProductTimeRangesRuntimeOptions {
253
253
  /**
254
254
  * Internal POS capability: fixed-duration candidates start from the stable
255
255
  * context anchor's current minute instead of rounding up to ten minutes, and
256
- * that minute remains selectable during before-start cutoff evaluation.
256
+ * that anchored range remains selectable while active during before-start
257
+ * cutoff evaluation.
257
258
  * Other callers keep the legacy alignment and strict second-level cutoff.
258
259
  */
259
260
  useExactDurationCandidateMinute?: boolean;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 5 | 3 | 1 | 2 | 4 | 6;
329
+ weekNum: 0 | 2 | 3 | 1 | 5 | 6 | 4;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.304",
4
+ "version": "2.2.305",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",