@pisell/pisellos 0.10.76 → 0.10.77
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/apis/picoding.d.ts +0 -0
- package/dist/effects/index.d.ts +19 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +105 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +173 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +70 -0
- package/dist/model/strategy/adapter/promotion/examples.d.ts +224 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +535 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +192 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/engine.d.ts +119 -0
- package/dist/model/strategy/type.d.ts +245 -0
- package/dist/modules/Account/types.d.ts +56 -0
- package/dist/modules/BookingContext/types.d.ts +104 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Date/types.d.ts +84 -0
- package/dist/modules/Date/utils.d.ts +36 -0
- package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
- package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +68 -0
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +21 -0
- package/dist/modules/Payment/mx51.d.ts +0 -0
- package/dist/modules/Payment/types.d.ts +943 -0
- package/dist/modules/Payment/utils.d.ts +19 -0
- package/dist/modules/Quotation/types.d.ts +61 -0
- package/dist/modules/Resource/types.d.ts +50 -0
- package/dist/modules/Resource/utils.d.ts +23 -0
- package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/dist/modules/SalesSummary/types.d.ts +69 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
- package/dist/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
- package/dist/modules/Schedule/type.d.ts +157 -0
- package/dist/modules/Schedule/types.d.ts +201 -0
- package/dist/modules/Schedule/utils.d.ts +67 -0
- package/dist/modules/Step/tyeps.d.ts +20 -0
- package/dist/modules/SurchargeList/types.d.ts +15 -0
- package/dist/plugins/app.d.ts +10 -0
- package/dist/plugins/shopStore.d.ts +4 -0
- package/dist/plugins/user.d.ts +7 -0
- package/dist/server/modules/floor-plan/types.d.ts +43 -0
- package/dist/server/modules/menu/types.d.ts +68 -0
- package/dist/server/modules/payment/types.d.ts +9 -0
- package/dist/server/modules/quotation/types.d.ts +50 -0
- package/dist/server/modules/resource/types.d.ts +121 -0
- package/dist/server/modules/schedule/types.d.ts +1 -0
- package/dist/server/modules/schedule/utils.d.ts +32 -0
- package/dist/server/types.d.ts +66 -0
- package/dist/server/utils/index.d.ts +5 -0
- package/dist/server/utils/schedule.d.ts +14 -0
- package/dist/server/utils/time.d.ts +18 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +38 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/PlaceOrder/index.d.ts +0 -0
- package/dist/solution/RegisterAndLogin/config.d.ts +93 -0
- package/dist/solution/RegisterAndLogin/types.d.ts +445 -0
- package/dist/solution/RegisterAndLogin/utils.d.ts +103 -0
- package/dist/solution/UnifiedBookingSales/index.js +107 -58
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/dist/store/createStore.d.ts +3 -0
- package/dist/types/index.d.ts +132 -0
- package/dist/utils/os-private-payload.d.ts +5 -0
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/task.d.ts +40 -0
- package/dist/utils/watch.d.ts +102 -0
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/effects/index.d.ts +19 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +105 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +173 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +70 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +224 -0
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/model/strategy/adapter/promotion/type.d.ts +535 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +192 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/engine.d.ts +119 -0
- package/lib/model/strategy/type.d.ts +245 -0
- package/lib/modules/Account/types.d.ts +56 -0
- package/lib/modules/BookingContext/types.d.ts +104 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Date/types.d.ts +84 -0
- package/lib/modules/Date/utils.d.ts +36 -0
- package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
- package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +68 -0
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +21 -0
- package/lib/modules/Payment/mx51.d.ts +0 -0
- package/lib/modules/Payment/types.d.ts +943 -0
- package/lib/modules/Payment/utils.d.ts +19 -0
- package/lib/modules/Quotation/types.d.ts +61 -0
- package/lib/modules/Resource/types.d.ts +50 -0
- package/lib/modules/Resource/utils.d.ts +23 -0
- package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/lib/modules/SalesSummary/types.d.ts +69 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
- package/lib/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
- package/lib/modules/Schedule/type.d.ts +157 -0
- package/lib/modules/Schedule/types.d.ts +201 -0
- package/lib/modules/Schedule/utils.d.ts +67 -0
- package/lib/modules/Step/tyeps.d.ts +20 -0
- package/lib/modules/SurchargeList/types.d.ts +15 -0
- package/lib/plugins/app.d.ts +10 -0
- package/lib/plugins/shopStore.d.ts +4 -0
- package/lib/plugins/user.d.ts +7 -0
- package/lib/server/modules/floor-plan/types.d.ts +43 -0
- package/lib/server/modules/menu/types.d.ts +68 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/quotation/types.d.ts +50 -0
- package/lib/server/modules/resource/types.d.ts +121 -0
- package/lib/server/modules/schedule/types.d.ts +1 -0
- package/lib/server/modules/schedule/utils.d.ts +32 -0
- package/lib/server/types.d.ts +66 -0
- package/lib/server/utils/index.d.ts +5 -0
- package/lib/server/utils/schedule.d.ts +14 -0
- package/lib/server/utils/time.d.ts +18 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +38 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/PlaceOrder/index.d.ts +0 -0
- package/lib/solution/RegisterAndLogin/config.d.ts +93 -0
- package/lib/solution/RegisterAndLogin/types.d.ts +445 -0
- package/lib/solution/RegisterAndLogin/utils.d.ts +103 -0
- package/lib/solution/UnifiedBookingSales/index.js +42 -11
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/lib/store/createStore.d.ts +3 -0
- package/lib/types/index.d.ts +132 -0
- package/lib/utils/os-private-payload.d.ts +5 -0
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/task.d.ts +40 -0
- package/lib/utils/watch.d.ts +102 -0
- package/package.json +1 -1
|
@@ -232,6 +232,7 @@ const MAX_AVAILABILITY_RANGE_DAYS = 90;
|
|
|
232
232
|
const MAX_AVAILABILITY_CONTEXT_REGISTRY = 128;
|
|
233
233
|
const MAX_AVAILABILITY_PROJECTION_POOL = 16;
|
|
234
234
|
const MAX_REMOTE_OCCUPANCY_RESOURCE_DATE_CELLS = 4096;
|
|
235
|
+
const PREVIEW_OCCUPANCY_CACHE_MAX_AGE_MS = 30 * 1000;
|
|
235
236
|
function isValidClockTime(value) {
|
|
236
237
|
const match = /^(\d{2}):(\d{2})$/.exec(value);
|
|
237
238
|
if (!match) return false;
|
|
@@ -2811,6 +2812,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2811
2812
|
};
|
|
2812
2813
|
}
|
|
2813
2814
|
assertAvailabilityPrepareParams(params) {
|
|
2815
|
+
if (params.occupancyCachePolicy !== undefined && params.occupancyCachePolicy !== 'cache_first') {
|
|
2816
|
+
throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', 'Unknown occupancyCachePolicy');
|
|
2817
|
+
}
|
|
2814
2818
|
assertAvailabilityCatalogProductIds(params.productIds, 'prepare.productIds');
|
|
2815
2819
|
const hasProductAnchor = Array.isArray(params.productIds) && params.productIds.length > 0;
|
|
2816
2820
|
const hasResourceAnchor = Array.isArray(params.resourceIds) && params.resourceIds.length > 0;
|
|
@@ -3043,7 +3047,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3043
3047
|
const cacheParams = {
|
|
3044
3048
|
scopeKey,
|
|
3045
3049
|
resourceIds: normalizedResourceIds,
|
|
3046
|
-
dateRange: params.dateRange
|
|
3050
|
+
dateRange: params.dateRange,
|
|
3051
|
+
maxAgeMs: params.maxAgeMs
|
|
3047
3052
|
};
|
|
3048
3053
|
const cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
3049
3054
|
if (cachedRawResources) {
|
|
@@ -3058,6 +3063,22 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3058
3063
|
}
|
|
3059
3064
|
return cachedRawResources;
|
|
3060
3065
|
}
|
|
3066
|
+
if (params.maxAgeMs !== undefined) {
|
|
3067
|
+
// A visible-month request can cover a concurrent day/resource-subset preview.
|
|
3068
|
+
// Only share fully covering requests; partial overlaps keep the normal fetch path.
|
|
3069
|
+
const epoch = this.availabilityRemoteResourceEpoch;
|
|
3070
|
+
const covering = Array.from(this.availabilityRemoteResourceQueryInFlight.values()).find(entry => entry.epoch === epoch && entry.scopeKey === scopeKey && entry.dateRange.startDate <= params.dateRange.startDate && entry.dateRange.endDate >= params.dateRange.endDate && normalizedResourceIds.every(id => entry.resourceIds.some(other => String(other) === String(id))));
|
|
3071
|
+
if (covering) {
|
|
3072
|
+
await covering.promise;
|
|
3073
|
+
if (epoch !== this.availabilityRemoteResourceEpoch) {
|
|
3074
|
+
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'Resource settings changed while loading. Please prepare again.');
|
|
3075
|
+
}
|
|
3076
|
+
// Read a detached, correctly sliced graph after publication. A newer overlapping
|
|
3077
|
+
// response may have invalidated cells, in which case fetch this exact range below.
|
|
3078
|
+
const coveredResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
3079
|
+
if (coveredResources) return coveredResources;
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3061
3082
|
return await this.refreshAvailabilityRemoteResourceQuery({
|
|
3062
3083
|
timezone: params.timezone,
|
|
3063
3084
|
dateRange: params.dateRange,
|
|
@@ -3079,19 +3100,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3079
3100
|
}
|
|
3080
3101
|
this.availabilityRemoteResourceQuerySequence += 1;
|
|
3081
3102
|
const writeVersion = this.availabilityRemoteResourceQuerySequence;
|
|
3103
|
+
const scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
|
|
3082
3104
|
const promise = this.fetchAvailabilityResourcesV2({
|
|
3083
3105
|
dateRange: params.dateRange,
|
|
3084
3106
|
resourceIds: normalizedResourceIds
|
|
3085
|
-
})
|
|
3086
|
-
this.availabilityRemoteResourceQueryInFlight.set(queryKey, {
|
|
3087
|
-
epoch,
|
|
3088
|
-
promise
|
|
3089
|
-
});
|
|
3090
|
-
try {
|
|
3091
|
-
const rawResources = await promise;
|
|
3107
|
+
}).then(rawResources => {
|
|
3092
3108
|
if (epoch === this.availabilityRemoteResourceEpoch) {
|
|
3093
3109
|
this.availabilityRemoteOccupancyCache.publish({
|
|
3094
|
-
scopeKey
|
|
3110
|
+
scopeKey,
|
|
3095
3111
|
timezoneName: params.timezone,
|
|
3096
3112
|
resourceIds: normalizedResourceIds,
|
|
3097
3113
|
dateRange: params.dateRange,
|
|
@@ -3100,6 +3116,18 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3100
3116
|
});
|
|
3101
3117
|
}
|
|
3102
3118
|
return rawResources;
|
|
3119
|
+
});
|
|
3120
|
+
this.availabilityRemoteResourceQueryInFlight.set(queryKey, {
|
|
3121
|
+
epoch,
|
|
3122
|
+
scopeKey,
|
|
3123
|
+
dateRange: {
|
|
3124
|
+
...params.dateRange
|
|
3125
|
+
},
|
|
3126
|
+
resourceIds: [...normalizedResourceIds],
|
|
3127
|
+
promise
|
|
3128
|
+
});
|
|
3129
|
+
try {
|
|
3130
|
+
return await promise;
|
|
3103
3131
|
} finally {
|
|
3104
3132
|
const current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
3105
3133
|
if (current?.promise === promise) {
|
|
@@ -3149,7 +3177,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3149
3177
|
};
|
|
3150
3178
|
const rawResources = params.fetchPolicy === 'refresh' ? await this.refreshAvailabilityRemoteResourceQuery(remoteQuery) : await this.fetchAndPublishAvailabilityResourcesV2({
|
|
3151
3179
|
...remoteQuery,
|
|
3152
|
-
useCacheOnHit:
|
|
3180
|
+
useCacheOnHit: params.fetchPolicy !== 'cache_first',
|
|
3181
|
+
...(params.fetchPolicy === 'cache_first' ? {
|
|
3182
|
+
maxAgeMs: PREVIEW_OCCUPANCY_CACHE_MAX_AGE_MS
|
|
3183
|
+
} : {})
|
|
3153
3184
|
});
|
|
3154
3185
|
return buildAvailabilityResourcesFromV2({
|
|
3155
3186
|
rawResources,
|
|
@@ -3374,7 +3405,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3374
3405
|
rawResources: normalizedPrepareParams.rawResources,
|
|
3375
3406
|
scheduleList,
|
|
3376
3407
|
// An explicit internal policy (notably commit's cache_only) remains authoritative.
|
|
3377
|
-
fetchPolicy: options.resourceFetchPolicy || (normalizedPrepareParams.refreshOccupancies ? 'refresh' : 'default'),
|
|
3408
|
+
fetchPolicy: options.resourceFetchPolicy || (normalizedPrepareParams.refreshOccupancies ? 'refresh' : normalizedPrepareParams.occupancyCachePolicy === 'cache_first' ? 'cache_first' : 'default'),
|
|
3378
3409
|
fallbackResources: options.fallbackResources
|
|
3379
3410
|
});
|
|
3380
3411
|
const tempOrder = this.getTempOrder();
|
|
@@ -11,6 +11,8 @@ export declare class AvailabilityRemoteOccupancyCache {
|
|
|
11
11
|
scopeKey: string;
|
|
12
12
|
resourceIds: AvailabilityId[];
|
|
13
13
|
dateRange: AvailabilityDateRange;
|
|
14
|
+
/** Only opt-in preview reads expire cells; legacy reads retain their SWR semantics. */
|
|
15
|
+
maxAgeMs?: number;
|
|
14
16
|
}): Record<string, any>[] | null;
|
|
15
17
|
hasCompleteCoverage(params: {
|
|
16
18
|
scopeKey: string;
|
|
@@ -117,6 +117,7 @@ class AvailabilityRemoteOccupancyCache {
|
|
|
117
117
|
const requestedResourceIds = uniqueIds(params.resourceIds);
|
|
118
118
|
const requestedDates = buildDateList(params.dateRange);
|
|
119
119
|
if (requestedResourceIds.length === 0 || requestedDates.length === 0) return [];
|
|
120
|
+
const now = Date.now();
|
|
120
121
|
const resources = [];
|
|
121
122
|
for (const resourceId of requestedResourceIds) {
|
|
122
123
|
const resourceKey = this.buildResourceKey(params.scopeKey, resourceId);
|
|
@@ -125,6 +126,7 @@ class AvailabilityRemoteOccupancyCache {
|
|
|
125
126
|
const cellKey = this.buildCellKey(resourceKey, date);
|
|
126
127
|
const cell = this.touchCell(cellKey);
|
|
127
128
|
if (!cell) return null;
|
|
129
|
+
if (params.maxAgeMs !== undefined && (now < cell.fetchedAt || now - cell.fetchedAt >= params.maxAgeMs)) return null;
|
|
128
130
|
cell.eventList.forEach(rawEvent => {
|
|
129
131
|
eventList.set(buildEventIdentity(resourceId, rawEvent), (0, _lodashEs.cloneDeep)(rawEvent));
|
|
130
132
|
});
|
|
@@ -85,6 +85,8 @@ export interface UnifiedBookingSalesPrepareAvailabilityProjectionParams {
|
|
|
85
85
|
publishCatalog?: boolean;
|
|
86
86
|
/** Await remote occupancy refresh instead of stale-while-revalidate. Ignores rawResources; does not lock resources. */
|
|
87
87
|
refreshOccupancies?: boolean;
|
|
88
|
+
/** Preview only: reuse complete resource/date coverage for 30 seconds without a background request. refreshOccupancies takes precedence. Omit to retain stale-while-revalidate. */
|
|
89
|
+
occupancyCachePolicy?: 'cache_first';
|
|
88
90
|
/** Enforce configured sale cutoffs and disable manual POS availability overrides for this context. Defaults to false. */
|
|
89
91
|
strictAvailability?: boolean;
|
|
90
92
|
rawResources?: Record<string, any>[];
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pisell OS 核心类型定义
|
|
3
|
+
*/
|
|
4
|
+
export interface Plugin {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
initialize: () => Promise<void> | void;
|
|
8
|
+
destroy?: () => Promise<void> | void;
|
|
9
|
+
getLocalStorage?: (key: string) => string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface PluginOptions {
|
|
12
|
+
dependencies?: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface Module {
|
|
15
|
+
name: string;
|
|
16
|
+
version: string;
|
|
17
|
+
initialize: (core: PisellCore, options: ModuleOptions) => Promise<void> | void;
|
|
18
|
+
/**
|
|
19
|
+
* 父级解决方案运行时更新 otherParams 后,显式通知子模块刷新自己的运行态参数。
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* await module.updateOtherParams?.({ channel: 'pos' }, { changedParams: { channel: 'pos' } });
|
|
23
|
+
*/
|
|
24
|
+
updateOtherParams?: (params: Record<string, any>, meta?: {
|
|
25
|
+
changedParams?: Record<string, any>;
|
|
26
|
+
cover?: boolean;
|
|
27
|
+
}) => Promise<void> | void;
|
|
28
|
+
destroy?: () => Promise<void> | void;
|
|
29
|
+
exports?: Record<string, any>;
|
|
30
|
+
isSolution?: boolean;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}
|
|
33
|
+
export interface ModuleOptions {
|
|
34
|
+
dependencies?: string[];
|
|
35
|
+
plugins?: string[];
|
|
36
|
+
hooks?: any;
|
|
37
|
+
store?: Record<string, any>;
|
|
38
|
+
initialState?: Record<string, any>;
|
|
39
|
+
otherParams?: Record<string, any>;
|
|
40
|
+
}
|
|
41
|
+
export type EventHandler = (data?: any) => void;
|
|
42
|
+
export interface PisellCore {
|
|
43
|
+
registerPlugin: (plugin: Plugin, options?: PluginOptions) => void;
|
|
44
|
+
getPlugin: <T extends Plugin>(name: string) => T | null;
|
|
45
|
+
hasPlugin: (name: string) => boolean;
|
|
46
|
+
registerModule: (module: Module, options?: ModuleOptions) => void;
|
|
47
|
+
unregisterModule: (module: Module, options?: ModuleOptions) => void;
|
|
48
|
+
getModule: <T extends Module>(name: string) => T | null;
|
|
49
|
+
getModuleExports: <T = any>(name: string) => T | null;
|
|
50
|
+
hasModule: (name: string) => boolean;
|
|
51
|
+
getModuleNames: () => string[];
|
|
52
|
+
effects: {
|
|
53
|
+
on: (event: string, callback: (payload: any) => void) => () => void;
|
|
54
|
+
once: (event: string, callback: (payload: any) => void) => () => void;
|
|
55
|
+
only: (event: string, callback: (payload: any) => void) => () => void;
|
|
56
|
+
off: (event: string, callback: (payload: any) => void) => void;
|
|
57
|
+
emit: (event: string, payload: any, value?: any) => Promise<{
|
|
58
|
+
status: boolean;
|
|
59
|
+
data: any;
|
|
60
|
+
}>;
|
|
61
|
+
offByModuleDestroy: (module: string) => void;
|
|
62
|
+
};
|
|
63
|
+
context: BusinessContext;
|
|
64
|
+
validateContext: (config: ModuleContextConfig) => boolean;
|
|
65
|
+
serverOptions?: ServerOptions;
|
|
66
|
+
server?: any;
|
|
67
|
+
setContext: (ctx: Partial<BusinessContext>) => void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 业务上下文接口
|
|
71
|
+
*/
|
|
72
|
+
export interface BusinessContext {
|
|
73
|
+
userId?: string;
|
|
74
|
+
companyId?: string;
|
|
75
|
+
locale?: string;
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 上下文验证规则
|
|
80
|
+
*/
|
|
81
|
+
export interface ContextValidationRule {
|
|
82
|
+
name: string;
|
|
83
|
+
required: boolean;
|
|
84
|
+
validate?: (value: any) => boolean;
|
|
85
|
+
message?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 模块上下文配置
|
|
89
|
+
*/
|
|
90
|
+
export interface ModuleContextConfig {
|
|
91
|
+
name: string;
|
|
92
|
+
validations: ContextValidationRule[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Server 模块配置
|
|
96
|
+
*/
|
|
97
|
+
export interface ServerModuleConfig {
|
|
98
|
+
/** 模块名称 */
|
|
99
|
+
name: string;
|
|
100
|
+
/** 是否自动预加载数据 */
|
|
101
|
+
preload?: boolean;
|
|
102
|
+
/** 模块配置参数 */
|
|
103
|
+
config?: Record<string, any>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Server 配置选项
|
|
107
|
+
*/
|
|
108
|
+
export interface ServerOptions {
|
|
109
|
+
All_DATA_SOURCES: Record<string, any>;
|
|
110
|
+
/** 要启用的模块列表 */
|
|
111
|
+
modules?: string[] | ServerModuleConfig[];
|
|
112
|
+
/** 是否自动初始化数据 */
|
|
113
|
+
autoInitData?: boolean;
|
|
114
|
+
}
|
|
115
|
+
export interface PisellOSOptions {
|
|
116
|
+
debug?: boolean;
|
|
117
|
+
plugins?: Array<{
|
|
118
|
+
plugin: Plugin;
|
|
119
|
+
options?: PluginOptions;
|
|
120
|
+
}>;
|
|
121
|
+
modules?: Array<{
|
|
122
|
+
module: Module;
|
|
123
|
+
options?: ModuleOptions;
|
|
124
|
+
}>;
|
|
125
|
+
context?: BusinessContext;
|
|
126
|
+
/** Server 配置 */
|
|
127
|
+
server?: ServerOptions;
|
|
128
|
+
}
|
|
129
|
+
export interface InitializeServerOptions {
|
|
130
|
+
onModuleLoad?: (module: string) => void;
|
|
131
|
+
onModuleLoadComplete?: (module: string) => void;
|
|
132
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PaymentNumberAppDataGetter = (key: string) => unknown;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the synchronous fallback without caching runtime device data.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData: PaymentNumberAppDataGetter): string;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the latest device segment when a new payment number is generated.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolvePaymentNumberDevicePrefix(getAppData: PaymentNumberAppDataGetter): Promise<string>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type Action = (...args: any[]) => Promise<any>;
|
|
2
|
+
type Task = {
|
|
3
|
+
uuid: string;
|
|
4
|
+
type: string;
|
|
5
|
+
actionParams?: Record<string, any>;
|
|
6
|
+
};
|
|
7
|
+
declare class Tasks {
|
|
8
|
+
private actions;
|
|
9
|
+
private taskQueue;
|
|
10
|
+
isRunning: boolean;
|
|
11
|
+
constructor(actions?: Map<string, Action>);
|
|
12
|
+
/**
|
|
13
|
+
* 清空所有任务
|
|
14
|
+
*/
|
|
15
|
+
clear(): void;
|
|
16
|
+
/**
|
|
17
|
+
* 清空任务执行队列
|
|
18
|
+
*/
|
|
19
|
+
clearTaskQueue(): void;
|
|
20
|
+
/**
|
|
21
|
+
* 添加action
|
|
22
|
+
* @param name action名称
|
|
23
|
+
* @param action action函数
|
|
24
|
+
*/
|
|
25
|
+
addAction(name: string, action: Action): void;
|
|
26
|
+
/**
|
|
27
|
+
* 添加任务
|
|
28
|
+
* @param task 任务
|
|
29
|
+
*/
|
|
30
|
+
addTask(task: Task): void;
|
|
31
|
+
/**
|
|
32
|
+
* 执行任务
|
|
33
|
+
*/
|
|
34
|
+
run(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* 判定当前的任务是否依然存在
|
|
37
|
+
*/
|
|
38
|
+
isTaskExist(uuid: string): boolean;
|
|
39
|
+
}
|
|
40
|
+
export default Tasks;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 监听模块
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
export type WatchEventCallback = (...args: any[]) => void;
|
|
6
|
+
export type WatchEventItem = {
|
|
7
|
+
key: string;
|
|
8
|
+
callback: WatchEventCallback;
|
|
9
|
+
};
|
|
10
|
+
export interface WatchEventSubscription {
|
|
11
|
+
unsubscribe: () => void;
|
|
12
|
+
}
|
|
13
|
+
declare class Watch {
|
|
14
|
+
private events;
|
|
15
|
+
private enableListMap;
|
|
16
|
+
/**
|
|
17
|
+
* 订阅事件
|
|
18
|
+
* @param event 事件名称
|
|
19
|
+
* @param callback 回调函数
|
|
20
|
+
* @returns 订阅对象,可用于取消订阅
|
|
21
|
+
*/
|
|
22
|
+
subscribe(watchKey: string, event: WatchEventItem): WatchEventSubscription;
|
|
23
|
+
/**
|
|
24
|
+
* 启用事件
|
|
25
|
+
* @param watchKey 监听的key
|
|
26
|
+
* @param event 事件名称
|
|
27
|
+
*/
|
|
28
|
+
enableEvent(watchKey: string, eventKey: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* 禁用某个事件
|
|
31
|
+
* @param watchKey 监听的key
|
|
32
|
+
* @param eventKey 事件名称
|
|
33
|
+
*/
|
|
34
|
+
disableEvent(watchKey: string, eventKey: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* 冻结某个监听下的所有事件
|
|
37
|
+
* @param watchKey 监听的key
|
|
38
|
+
*/
|
|
39
|
+
disabledAllEventByWatchKey(watchKey: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* 启用某个监听下的所有事件
|
|
42
|
+
* @param watchKey 监听的key
|
|
43
|
+
*/
|
|
44
|
+
enableAllEventByWatchKey(watchKey: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* 取消订阅事件
|
|
47
|
+
* @param event 事件名称
|
|
48
|
+
* @param callback 回调函数
|
|
49
|
+
* @returns 是否成功取消订阅
|
|
50
|
+
*/
|
|
51
|
+
unsubscribe(watchKey: string, event: WatchEventItem): void;
|
|
52
|
+
/**
|
|
53
|
+
* 发布事件
|
|
54
|
+
* @param event 事件名称
|
|
55
|
+
* @param args 事件参数
|
|
56
|
+
*/
|
|
57
|
+
publish(watchKey: string, ...args: any[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* 根据事件名称发布事件
|
|
60
|
+
* @param watchKey 监听的key
|
|
61
|
+
* @param eventKey 事件名称
|
|
62
|
+
* @param args 事件参数
|
|
63
|
+
*/
|
|
64
|
+
publishByEventKey(watchKey: string, eventKey: string, ...args: any[]): void;
|
|
65
|
+
/**
|
|
66
|
+
* 获取最后一个启用的事件
|
|
67
|
+
* @param watchKey 监听的key
|
|
68
|
+
* @returns 最后一个启用的事件
|
|
69
|
+
*/
|
|
70
|
+
getLastEnableEventKey(watchKey: string): WatchEventItem['key'] | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* 移除某个事件的所有订阅
|
|
73
|
+
* @param event 事件名称
|
|
74
|
+
* @returns 是否成功移除
|
|
75
|
+
*/
|
|
76
|
+
clearEvent(watchKey: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* 移除所有事件订阅
|
|
79
|
+
*/
|
|
80
|
+
clearAllEvents(): void;
|
|
81
|
+
/**
|
|
82
|
+
* 获取事件的订阅数量
|
|
83
|
+
* @param event 事件名称
|
|
84
|
+
* @returns 订阅数量
|
|
85
|
+
*/
|
|
86
|
+
getSubscriberCount(event: string): number;
|
|
87
|
+
/**
|
|
88
|
+
* 检查事件是否有订阅者
|
|
89
|
+
* @param event 事件名称
|
|
90
|
+
* @returns 是否有订阅者
|
|
91
|
+
*/
|
|
92
|
+
hasSubscribers(event: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* 一次性订阅事件,事件触发后自动取消订阅
|
|
95
|
+
* @param event 事件名称
|
|
96
|
+
* @param callback 回调函数
|
|
97
|
+
* @returns 订阅对象,可用于取消订阅
|
|
98
|
+
*/
|
|
99
|
+
once(watchKey: string, event: WatchEventItem): WatchEventSubscription;
|
|
100
|
+
}
|
|
101
|
+
declare const watch: Watch;
|
|
102
|
+
export default watch;
|