@pisell/pisellos 0.10.45 → 0.10.46

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.
@@ -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";
@@ -572,7 +572,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
572
572
  generateIdempotencyToken(): string;
573
573
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
574
574
  createOrder(params: CommitOrderParams['query']): {
575
- type: "virtual" | "appointment_booking";
575
+ type: "appointment_booking" | "virtual";
576
576
  platform: string;
577
577
  sales_channel: string;
578
578
  order_sales_channel: string;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -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 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -572,7 +572,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
572
572
  generateIdempotencyToken(): string;
573
573
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
574
574
  createOrder(params: CommitOrderParams['query']): {
575
- type: "virtual" | "appointment_booking";
575
+ type: "appointment_booking" | "virtual";
576
576
  platform: string;
577
577
  sales_channel: string;
578
578
  order_sales_channel: string;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -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 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
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": "0.10.45",
4
+ "version": "0.10.46",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",