@final-commerce/common 2.4.1-staging2.1 → 2.5.0-preprod.1
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/index.d.mts +203 -20
- package/dist/index.d.ts +203 -20
- package/dist/index.js +481 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +461 -41
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +164 -21
- package/dist/pos-types/index.d.ts +164 -21
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -224,7 +224,8 @@ declare enum InventorySpecificActionType {
|
|
|
224
224
|
APPLIED_FROM_WOO = "APPLIED_FROM_WOO",
|
|
225
225
|
PO_RECEIVED = "PO_RECEIVED",
|
|
226
226
|
EXTERNAL_SALE = "EXTERNAL_SALE",
|
|
227
|
-
EXTERNAL_RESTOCK = "EXTERNAL_RESTOCK"
|
|
227
|
+
EXTERNAL_RESTOCK = "EXTERNAL_RESTOCK",
|
|
228
|
+
CUSTOM = "CUSTOM"
|
|
228
229
|
}
|
|
229
230
|
declare enum ExtensionCategory {
|
|
230
231
|
SYNC = "sync",
|
|
@@ -389,7 +390,8 @@ declare enum StripeCurrencyCode {
|
|
|
389
390
|
|
|
390
391
|
declare enum ProductType {
|
|
391
392
|
SIMPLE = "simple",
|
|
392
|
-
VARIABLE = "variable"
|
|
393
|
+
VARIABLE = "variable",
|
|
394
|
+
BOOKING = "booking"
|
|
393
395
|
}
|
|
394
396
|
declare enum ProductStatus {
|
|
395
397
|
ACTIVE = "active",
|
|
@@ -403,6 +405,43 @@ declare enum PaymentProcessor {
|
|
|
403
405
|
EXTERNAL = "external"
|
|
404
406
|
}
|
|
405
407
|
|
|
408
|
+
declare enum BookingType {
|
|
409
|
+
RENTAL = "rental",
|
|
410
|
+
APPOINTMENT = "appointment",
|
|
411
|
+
OVERNIGHT = "overnight",
|
|
412
|
+
GROUP = "group"
|
|
413
|
+
}
|
|
414
|
+
declare enum BookingRatePeriod {
|
|
415
|
+
SLOT = "slot",
|
|
416
|
+
DAY = "day",
|
|
417
|
+
NIGHT = "night",
|
|
418
|
+
WEEK = "week",
|
|
419
|
+
MONTH = "month"
|
|
420
|
+
}
|
|
421
|
+
declare enum BookingResourceKind {
|
|
422
|
+
ASSET = "asset",
|
|
423
|
+
ROOM = "room",
|
|
424
|
+
PROPERTY = "property",
|
|
425
|
+
SPACE = "space",
|
|
426
|
+
STAFF = "staff",
|
|
427
|
+
TABLE = "table"
|
|
428
|
+
}
|
|
429
|
+
declare enum ReservationStatus {
|
|
430
|
+
HELD = "held",
|
|
431
|
+
CONFIRMED = "confirmed",
|
|
432
|
+
CANCELLED = "cancelled",
|
|
433
|
+
EXPIRED = "expired"
|
|
434
|
+
}
|
|
435
|
+
declare enum BookingResourceStatus {
|
|
436
|
+
ACTIVE = "active",
|
|
437
|
+
INACTIVE = "inactive"
|
|
438
|
+
}
|
|
439
|
+
declare enum ResourceAvailabilityState {
|
|
440
|
+
AVAILABLE = "available",
|
|
441
|
+
FULLY_BOOKED = "fullyBooked",
|
|
442
|
+
NO_HOURS_IN_RANGE = "noHoursInRange"
|
|
443
|
+
}
|
|
444
|
+
|
|
406
445
|
interface CurrencyConfig {
|
|
407
446
|
minorUnits: number;
|
|
408
447
|
symbol: string;
|
|
@@ -783,6 +822,13 @@ interface OrderLineItem {
|
|
|
783
822
|
returnedQuantity?: number;
|
|
784
823
|
[key: string]: unknown;
|
|
785
824
|
}
|
|
825
|
+
interface OrderReservationForContext {
|
|
826
|
+
internalId?: string;
|
|
827
|
+
quantity?: number;
|
|
828
|
+
fulfilledQuantity?: number;
|
|
829
|
+
returnedQuantity?: number;
|
|
830
|
+
[key: string]: unknown;
|
|
831
|
+
}
|
|
786
832
|
interface SplitPaymentPayment {
|
|
787
833
|
amount?: number;
|
|
788
834
|
[key: string]: unknown;
|
|
@@ -798,6 +844,7 @@ interface OrderContext {
|
|
|
798
844
|
paymentMethods: OrderPaymentMethod[];
|
|
799
845
|
refunds: OrderRefund[];
|
|
800
846
|
lineItems: OrderLineItem[];
|
|
847
|
+
reservations: OrderReservationForContext[];
|
|
801
848
|
};
|
|
802
849
|
computed: {
|
|
803
850
|
balance: number;
|
|
@@ -911,6 +958,7 @@ interface OrderLikeForContext {
|
|
|
911
958
|
refunds?: OrderRefund[];
|
|
912
959
|
refund?: OrderRefund[];
|
|
913
960
|
lineItems?: OrderLineItem[];
|
|
961
|
+
reservations?: OrderReservationForContext[];
|
|
914
962
|
}
|
|
915
963
|
interface OrderLikeForLegacyInference extends OrderLikeForContext {
|
|
916
964
|
status?: string;
|
|
@@ -1200,25 +1248,160 @@ interface ConfigUpdatedPayload {
|
|
|
1200
1248
|
}
|
|
1201
1249
|
type OrderStateEventPayload = StateTransitionCompletedPayload | StateTransitionBlockedPayload | ConfigUpdatedPayload;
|
|
1202
1250
|
|
|
1251
|
+
interface WeeklyHours {
|
|
1252
|
+
weekday: number;
|
|
1253
|
+
openMinute: number;
|
|
1254
|
+
closeMinute: number;
|
|
1255
|
+
}
|
|
1256
|
+
interface BookingRulesInput {
|
|
1257
|
+
ratePeriod: BookingRatePeriod | `${BookingRatePeriod}`;
|
|
1258
|
+
slot: {
|
|
1259
|
+
lengthMinutes: number;
|
|
1260
|
+
bufferMinutes?: number;
|
|
1261
|
+
minimumToRun?: number;
|
|
1262
|
+
minStay?: number;
|
|
1263
|
+
maxStay?: number;
|
|
1264
|
+
sharedAcrossProducts?: boolean;
|
|
1265
|
+
};
|
|
1266
|
+
window: {
|
|
1267
|
+
maxAdvanceDays?: number;
|
|
1268
|
+
minNoticeMinutes?: number;
|
|
1269
|
+
holdMinutes?: number;
|
|
1270
|
+
bookableFrom?: Date | string | null;
|
|
1271
|
+
bookableTo?: Date | string | null;
|
|
1272
|
+
};
|
|
1273
|
+
availability: {
|
|
1274
|
+
weeklyHours?: WeeklyHours[];
|
|
1275
|
+
offMarket?: {
|
|
1276
|
+
from: Date | string;
|
|
1277
|
+
to: Date | string;
|
|
1278
|
+
}[];
|
|
1279
|
+
arrivalDays?: number[];
|
|
1280
|
+
availableFrom?: Date | string | null;
|
|
1281
|
+
};
|
|
1282
|
+
checkInTime?: string | null;
|
|
1283
|
+
checkOutTime?: string | null;
|
|
1284
|
+
}
|
|
1285
|
+
interface BusyWindow {
|
|
1286
|
+
startAt: Date;
|
|
1287
|
+
bufferEndAt: Date;
|
|
1288
|
+
}
|
|
1289
|
+
interface GridSlot {
|
|
1290
|
+
startAt: Date;
|
|
1291
|
+
endAt: Date;
|
|
1292
|
+
bufferEndAt: Date;
|
|
1293
|
+
canStart: boolean;
|
|
1294
|
+
}
|
|
1295
|
+
declare class BookingRulesError extends Error {
|
|
1296
|
+
constructor(message: string);
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
declare function windowEndsAt(rule: BookingRulesInput, now: Date): Date | null;
|
|
1300
|
+
declare function buildGrid(rule: BookingRulesInput, timeZone: string, from: Date, to: Date, now: Date, busy?: BusyWindow[]): GridSlot[];
|
|
1301
|
+
declare function slotsForWindow(grid: GridSlot[], startAt: Date, endAt: Date): GridSlot[];
|
|
1302
|
+
|
|
1303
|
+
interface BookingOccupancy {
|
|
1304
|
+
resourceId: string;
|
|
1305
|
+
productId: string;
|
|
1306
|
+
qty: number;
|
|
1307
|
+
startAt: Date;
|
|
1308
|
+
bufferEndAt: Date;
|
|
1309
|
+
}
|
|
1310
|
+
interface BookingResourceInput {
|
|
1311
|
+
id: string;
|
|
1312
|
+
name: string;
|
|
1313
|
+
seats?: number | null;
|
|
1314
|
+
timeZone: string;
|
|
1315
|
+
presence?: WeeklyHours[] | null;
|
|
1316
|
+
}
|
|
1317
|
+
interface ResourceAvailability {
|
|
1318
|
+
resourceId: string;
|
|
1319
|
+
name: string;
|
|
1320
|
+
capacity: number;
|
|
1321
|
+
booked: number;
|
|
1322
|
+
free: number;
|
|
1323
|
+
}
|
|
1324
|
+
interface AvailabilitySlot extends GridSlot {
|
|
1325
|
+
capacity: number;
|
|
1326
|
+
booked: number;
|
|
1327
|
+
free: number;
|
|
1328
|
+
resources: ResourceAvailability[];
|
|
1329
|
+
dayKey: string;
|
|
1330
|
+
}
|
|
1331
|
+
interface ResourceInWindow {
|
|
1332
|
+
resourceId: string;
|
|
1333
|
+
name: string;
|
|
1334
|
+
slots: number;
|
|
1335
|
+
free: number;
|
|
1336
|
+
state: ResourceAvailabilityState;
|
|
1337
|
+
}
|
|
1338
|
+
interface AvailabilityInput {
|
|
1339
|
+
productId: string;
|
|
1340
|
+
bookingRulesId?: string;
|
|
1341
|
+
bookingType?: BookingType;
|
|
1342
|
+
rule: BookingRulesInput;
|
|
1343
|
+
resources: BookingResourceInput[];
|
|
1344
|
+
occupied: BookingOccupancy[];
|
|
1345
|
+
from: Date;
|
|
1346
|
+
to: Date;
|
|
1347
|
+
now: Date;
|
|
1348
|
+
}
|
|
1349
|
+
declare const withinPresence: (slot: GridSlot, timeZone: string, presence?: WeeklyHours[] | null) => boolean;
|
|
1350
|
+
declare function occupancyIn(occupied: BookingOccupancy[], productId: string, startAt: Date, bufferEndAt: Date, shared: boolean): {
|
|
1351
|
+
taken: number;
|
|
1352
|
+
foreignProductId?: string;
|
|
1353
|
+
};
|
|
1354
|
+
declare function shopDayKey(instant: Date, timeZone: string): string;
|
|
1355
|
+
declare function shopDayRange(fromDayKey: string, count: number, timeZone: string): {
|
|
1356
|
+
from: Date;
|
|
1357
|
+
to: Date;
|
|
1358
|
+
};
|
|
1359
|
+
declare function buildAvailability({ productId, bookingRulesId, bookingType, rule, resources, occupied, from, to, now, }: AvailabilityInput): {
|
|
1360
|
+
resources: ResourceInWindow[];
|
|
1361
|
+
slots: AvailabilitySlot[];
|
|
1362
|
+
timeZone: string;
|
|
1363
|
+
days: string[];
|
|
1364
|
+
productId: string;
|
|
1365
|
+
bookingRulesId: string | undefined;
|
|
1366
|
+
bookingType: BookingType | undefined;
|
|
1367
|
+
ratePeriod: "slot" | "day" | "night" | "week" | "month" | BookingRatePeriod;
|
|
1368
|
+
minimumToRun: number | undefined;
|
|
1369
|
+
minStay: number | undefined;
|
|
1370
|
+
maxStay: number | undefined;
|
|
1371
|
+
bookableUntil: Date | null;
|
|
1372
|
+
beyondWindow: boolean;
|
|
1373
|
+
};
|
|
1374
|
+
interface ResourcePresenceRow {
|
|
1375
|
+
resourceId: string;
|
|
1376
|
+
outletId: string;
|
|
1377
|
+
weeklyHours?: WeeklyHours[] | null;
|
|
1378
|
+
}
|
|
1379
|
+
declare function presentAt<T extends {
|
|
1380
|
+
id: string;
|
|
1381
|
+
}>(resources: T[], rows: ResourcePresenceRow[], outletId?: string): {
|
|
1382
|
+
resource: T;
|
|
1383
|
+
presence?: WeeklyHours[] | null;
|
|
1384
|
+
}[];
|
|
1385
|
+
|
|
1386
|
+
declare const DEFAULT_HOLD_MINUTES = 10;
|
|
1387
|
+
interface PlanWindowInput {
|
|
1388
|
+
rule: BookingRulesInput;
|
|
1389
|
+
timeZone: string;
|
|
1390
|
+
presence?: WeeklyHours[] | null;
|
|
1391
|
+
startAt: Date;
|
|
1392
|
+
endAt: Date;
|
|
1393
|
+
now: Date;
|
|
1394
|
+
busy?: BusyWindow[];
|
|
1395
|
+
}
|
|
1396
|
+
declare function planWindow({ rule, timeZone, presence, startAt, endAt, now, busy }: PlanWindowInput): {
|
|
1397
|
+
slots: GridSlot[];
|
|
1398
|
+
endAt: Date;
|
|
1399
|
+
bufferEndAt: Date;
|
|
1400
|
+
};
|
|
1401
|
+
declare const holdExpiresAt: (rule: BookingRulesInput, now: Date) => Date;
|
|
1402
|
+
|
|
1203
1403
|
declare const ADYEN_ROLLOUT_COUNTRY_CODES: Set<string>;
|
|
1204
1404
|
declare function isAdyenRolloutCountry(alpha2: string): boolean;
|
|
1205
|
-
declare const ADYEN_STORE_STATE_PROVINCE_COUNTRIES: Set<string>;
|
|
1206
|
-
declare function adyenStoreRequiresStateOrProvince(alpha2: string | undefined): boolean;
|
|
1207
|
-
declare const ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES: Set<string>;
|
|
1208
|
-
declare function adyenLegalEntityRequiresStateOrProvince(alpha2: string | undefined): boolean;
|
|
1209
|
-
declare const ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES: Set<string>;
|
|
1210
|
-
declare function adyenSupportsTaxNumberAbsent(alpha2: string | undefined): boolean;
|
|
1211
|
-
declare const ADYEN_TAX_NUMBER_FORMATS: Record<string, {
|
|
1212
|
-
pattern: RegExp;
|
|
1213
|
-
length: number;
|
|
1214
|
-
}>;
|
|
1215
|
-
declare function adyenTaxNumberFormat(alpha2: string | undefined): {
|
|
1216
|
-
pattern: RegExp;
|
|
1217
|
-
length: number;
|
|
1218
|
-
} | undefined;
|
|
1219
|
-
declare const ADYEN_TAX_NUMBER_MIN_LENGTH = 5;
|
|
1220
|
-
declare const ADYEN_JOB_TITLE_ASSOCIATION_TYPES: readonly string[];
|
|
1221
|
-
declare function adyenRequiresJobTitle(associationType: string): boolean;
|
|
1222
1405
|
|
|
1223
1406
|
interface CurrencyRate {
|
|
1224
1407
|
rate: number;
|
|
@@ -1231,4 +1414,4 @@ declare const EUFixedRates: Record<string, CurrencyRate>;
|
|
|
1231
1414
|
declare const OtherFixedRates: Record<string, CurrencyRate>;
|
|
1232
1415
|
declare const COUNTRY_CURRENCIES: Record<string, string>;
|
|
1233
1416
|
|
|
1234
|
-
export {
|
|
1417
|
+
export { ADYEN_ROLLOUT_COUNTRY_CODES, type Amount, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, type EndOfSessionReport, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, amountToString, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, mapToLegacyStatus, maxPrecisionFor, mergeFragment, multiplyAmount, normalizeMongoIdString, occupancyIn, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, planWindow, presentAt, removeFragment, resolveFamily, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant, windowEndsAt, withinPresence };
|
package/dist/index.d.ts
CHANGED
|
@@ -224,7 +224,8 @@ declare enum InventorySpecificActionType {
|
|
|
224
224
|
APPLIED_FROM_WOO = "APPLIED_FROM_WOO",
|
|
225
225
|
PO_RECEIVED = "PO_RECEIVED",
|
|
226
226
|
EXTERNAL_SALE = "EXTERNAL_SALE",
|
|
227
|
-
EXTERNAL_RESTOCK = "EXTERNAL_RESTOCK"
|
|
227
|
+
EXTERNAL_RESTOCK = "EXTERNAL_RESTOCK",
|
|
228
|
+
CUSTOM = "CUSTOM"
|
|
228
229
|
}
|
|
229
230
|
declare enum ExtensionCategory {
|
|
230
231
|
SYNC = "sync",
|
|
@@ -389,7 +390,8 @@ declare enum StripeCurrencyCode {
|
|
|
389
390
|
|
|
390
391
|
declare enum ProductType {
|
|
391
392
|
SIMPLE = "simple",
|
|
392
|
-
VARIABLE = "variable"
|
|
393
|
+
VARIABLE = "variable",
|
|
394
|
+
BOOKING = "booking"
|
|
393
395
|
}
|
|
394
396
|
declare enum ProductStatus {
|
|
395
397
|
ACTIVE = "active",
|
|
@@ -403,6 +405,43 @@ declare enum PaymentProcessor {
|
|
|
403
405
|
EXTERNAL = "external"
|
|
404
406
|
}
|
|
405
407
|
|
|
408
|
+
declare enum BookingType {
|
|
409
|
+
RENTAL = "rental",
|
|
410
|
+
APPOINTMENT = "appointment",
|
|
411
|
+
OVERNIGHT = "overnight",
|
|
412
|
+
GROUP = "group"
|
|
413
|
+
}
|
|
414
|
+
declare enum BookingRatePeriod {
|
|
415
|
+
SLOT = "slot",
|
|
416
|
+
DAY = "day",
|
|
417
|
+
NIGHT = "night",
|
|
418
|
+
WEEK = "week",
|
|
419
|
+
MONTH = "month"
|
|
420
|
+
}
|
|
421
|
+
declare enum BookingResourceKind {
|
|
422
|
+
ASSET = "asset",
|
|
423
|
+
ROOM = "room",
|
|
424
|
+
PROPERTY = "property",
|
|
425
|
+
SPACE = "space",
|
|
426
|
+
STAFF = "staff",
|
|
427
|
+
TABLE = "table"
|
|
428
|
+
}
|
|
429
|
+
declare enum ReservationStatus {
|
|
430
|
+
HELD = "held",
|
|
431
|
+
CONFIRMED = "confirmed",
|
|
432
|
+
CANCELLED = "cancelled",
|
|
433
|
+
EXPIRED = "expired"
|
|
434
|
+
}
|
|
435
|
+
declare enum BookingResourceStatus {
|
|
436
|
+
ACTIVE = "active",
|
|
437
|
+
INACTIVE = "inactive"
|
|
438
|
+
}
|
|
439
|
+
declare enum ResourceAvailabilityState {
|
|
440
|
+
AVAILABLE = "available",
|
|
441
|
+
FULLY_BOOKED = "fullyBooked",
|
|
442
|
+
NO_HOURS_IN_RANGE = "noHoursInRange"
|
|
443
|
+
}
|
|
444
|
+
|
|
406
445
|
interface CurrencyConfig {
|
|
407
446
|
minorUnits: number;
|
|
408
447
|
symbol: string;
|
|
@@ -783,6 +822,13 @@ interface OrderLineItem {
|
|
|
783
822
|
returnedQuantity?: number;
|
|
784
823
|
[key: string]: unknown;
|
|
785
824
|
}
|
|
825
|
+
interface OrderReservationForContext {
|
|
826
|
+
internalId?: string;
|
|
827
|
+
quantity?: number;
|
|
828
|
+
fulfilledQuantity?: number;
|
|
829
|
+
returnedQuantity?: number;
|
|
830
|
+
[key: string]: unknown;
|
|
831
|
+
}
|
|
786
832
|
interface SplitPaymentPayment {
|
|
787
833
|
amount?: number;
|
|
788
834
|
[key: string]: unknown;
|
|
@@ -798,6 +844,7 @@ interface OrderContext {
|
|
|
798
844
|
paymentMethods: OrderPaymentMethod[];
|
|
799
845
|
refunds: OrderRefund[];
|
|
800
846
|
lineItems: OrderLineItem[];
|
|
847
|
+
reservations: OrderReservationForContext[];
|
|
801
848
|
};
|
|
802
849
|
computed: {
|
|
803
850
|
balance: number;
|
|
@@ -911,6 +958,7 @@ interface OrderLikeForContext {
|
|
|
911
958
|
refunds?: OrderRefund[];
|
|
912
959
|
refund?: OrderRefund[];
|
|
913
960
|
lineItems?: OrderLineItem[];
|
|
961
|
+
reservations?: OrderReservationForContext[];
|
|
914
962
|
}
|
|
915
963
|
interface OrderLikeForLegacyInference extends OrderLikeForContext {
|
|
916
964
|
status?: string;
|
|
@@ -1200,25 +1248,160 @@ interface ConfigUpdatedPayload {
|
|
|
1200
1248
|
}
|
|
1201
1249
|
type OrderStateEventPayload = StateTransitionCompletedPayload | StateTransitionBlockedPayload | ConfigUpdatedPayload;
|
|
1202
1250
|
|
|
1251
|
+
interface WeeklyHours {
|
|
1252
|
+
weekday: number;
|
|
1253
|
+
openMinute: number;
|
|
1254
|
+
closeMinute: number;
|
|
1255
|
+
}
|
|
1256
|
+
interface BookingRulesInput {
|
|
1257
|
+
ratePeriod: BookingRatePeriod | `${BookingRatePeriod}`;
|
|
1258
|
+
slot: {
|
|
1259
|
+
lengthMinutes: number;
|
|
1260
|
+
bufferMinutes?: number;
|
|
1261
|
+
minimumToRun?: number;
|
|
1262
|
+
minStay?: number;
|
|
1263
|
+
maxStay?: number;
|
|
1264
|
+
sharedAcrossProducts?: boolean;
|
|
1265
|
+
};
|
|
1266
|
+
window: {
|
|
1267
|
+
maxAdvanceDays?: number;
|
|
1268
|
+
minNoticeMinutes?: number;
|
|
1269
|
+
holdMinutes?: number;
|
|
1270
|
+
bookableFrom?: Date | string | null;
|
|
1271
|
+
bookableTo?: Date | string | null;
|
|
1272
|
+
};
|
|
1273
|
+
availability: {
|
|
1274
|
+
weeklyHours?: WeeklyHours[];
|
|
1275
|
+
offMarket?: {
|
|
1276
|
+
from: Date | string;
|
|
1277
|
+
to: Date | string;
|
|
1278
|
+
}[];
|
|
1279
|
+
arrivalDays?: number[];
|
|
1280
|
+
availableFrom?: Date | string | null;
|
|
1281
|
+
};
|
|
1282
|
+
checkInTime?: string | null;
|
|
1283
|
+
checkOutTime?: string | null;
|
|
1284
|
+
}
|
|
1285
|
+
interface BusyWindow {
|
|
1286
|
+
startAt: Date;
|
|
1287
|
+
bufferEndAt: Date;
|
|
1288
|
+
}
|
|
1289
|
+
interface GridSlot {
|
|
1290
|
+
startAt: Date;
|
|
1291
|
+
endAt: Date;
|
|
1292
|
+
bufferEndAt: Date;
|
|
1293
|
+
canStart: boolean;
|
|
1294
|
+
}
|
|
1295
|
+
declare class BookingRulesError extends Error {
|
|
1296
|
+
constructor(message: string);
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
declare function windowEndsAt(rule: BookingRulesInput, now: Date): Date | null;
|
|
1300
|
+
declare function buildGrid(rule: BookingRulesInput, timeZone: string, from: Date, to: Date, now: Date, busy?: BusyWindow[]): GridSlot[];
|
|
1301
|
+
declare function slotsForWindow(grid: GridSlot[], startAt: Date, endAt: Date): GridSlot[];
|
|
1302
|
+
|
|
1303
|
+
interface BookingOccupancy {
|
|
1304
|
+
resourceId: string;
|
|
1305
|
+
productId: string;
|
|
1306
|
+
qty: number;
|
|
1307
|
+
startAt: Date;
|
|
1308
|
+
bufferEndAt: Date;
|
|
1309
|
+
}
|
|
1310
|
+
interface BookingResourceInput {
|
|
1311
|
+
id: string;
|
|
1312
|
+
name: string;
|
|
1313
|
+
seats?: number | null;
|
|
1314
|
+
timeZone: string;
|
|
1315
|
+
presence?: WeeklyHours[] | null;
|
|
1316
|
+
}
|
|
1317
|
+
interface ResourceAvailability {
|
|
1318
|
+
resourceId: string;
|
|
1319
|
+
name: string;
|
|
1320
|
+
capacity: number;
|
|
1321
|
+
booked: number;
|
|
1322
|
+
free: number;
|
|
1323
|
+
}
|
|
1324
|
+
interface AvailabilitySlot extends GridSlot {
|
|
1325
|
+
capacity: number;
|
|
1326
|
+
booked: number;
|
|
1327
|
+
free: number;
|
|
1328
|
+
resources: ResourceAvailability[];
|
|
1329
|
+
dayKey: string;
|
|
1330
|
+
}
|
|
1331
|
+
interface ResourceInWindow {
|
|
1332
|
+
resourceId: string;
|
|
1333
|
+
name: string;
|
|
1334
|
+
slots: number;
|
|
1335
|
+
free: number;
|
|
1336
|
+
state: ResourceAvailabilityState;
|
|
1337
|
+
}
|
|
1338
|
+
interface AvailabilityInput {
|
|
1339
|
+
productId: string;
|
|
1340
|
+
bookingRulesId?: string;
|
|
1341
|
+
bookingType?: BookingType;
|
|
1342
|
+
rule: BookingRulesInput;
|
|
1343
|
+
resources: BookingResourceInput[];
|
|
1344
|
+
occupied: BookingOccupancy[];
|
|
1345
|
+
from: Date;
|
|
1346
|
+
to: Date;
|
|
1347
|
+
now: Date;
|
|
1348
|
+
}
|
|
1349
|
+
declare const withinPresence: (slot: GridSlot, timeZone: string, presence?: WeeklyHours[] | null) => boolean;
|
|
1350
|
+
declare function occupancyIn(occupied: BookingOccupancy[], productId: string, startAt: Date, bufferEndAt: Date, shared: boolean): {
|
|
1351
|
+
taken: number;
|
|
1352
|
+
foreignProductId?: string;
|
|
1353
|
+
};
|
|
1354
|
+
declare function shopDayKey(instant: Date, timeZone: string): string;
|
|
1355
|
+
declare function shopDayRange(fromDayKey: string, count: number, timeZone: string): {
|
|
1356
|
+
from: Date;
|
|
1357
|
+
to: Date;
|
|
1358
|
+
};
|
|
1359
|
+
declare function buildAvailability({ productId, bookingRulesId, bookingType, rule, resources, occupied, from, to, now, }: AvailabilityInput): {
|
|
1360
|
+
resources: ResourceInWindow[];
|
|
1361
|
+
slots: AvailabilitySlot[];
|
|
1362
|
+
timeZone: string;
|
|
1363
|
+
days: string[];
|
|
1364
|
+
productId: string;
|
|
1365
|
+
bookingRulesId: string | undefined;
|
|
1366
|
+
bookingType: BookingType | undefined;
|
|
1367
|
+
ratePeriod: "slot" | "day" | "night" | "week" | "month" | BookingRatePeriod;
|
|
1368
|
+
minimumToRun: number | undefined;
|
|
1369
|
+
minStay: number | undefined;
|
|
1370
|
+
maxStay: number | undefined;
|
|
1371
|
+
bookableUntil: Date | null;
|
|
1372
|
+
beyondWindow: boolean;
|
|
1373
|
+
};
|
|
1374
|
+
interface ResourcePresenceRow {
|
|
1375
|
+
resourceId: string;
|
|
1376
|
+
outletId: string;
|
|
1377
|
+
weeklyHours?: WeeklyHours[] | null;
|
|
1378
|
+
}
|
|
1379
|
+
declare function presentAt<T extends {
|
|
1380
|
+
id: string;
|
|
1381
|
+
}>(resources: T[], rows: ResourcePresenceRow[], outletId?: string): {
|
|
1382
|
+
resource: T;
|
|
1383
|
+
presence?: WeeklyHours[] | null;
|
|
1384
|
+
}[];
|
|
1385
|
+
|
|
1386
|
+
declare const DEFAULT_HOLD_MINUTES = 10;
|
|
1387
|
+
interface PlanWindowInput {
|
|
1388
|
+
rule: BookingRulesInput;
|
|
1389
|
+
timeZone: string;
|
|
1390
|
+
presence?: WeeklyHours[] | null;
|
|
1391
|
+
startAt: Date;
|
|
1392
|
+
endAt: Date;
|
|
1393
|
+
now: Date;
|
|
1394
|
+
busy?: BusyWindow[];
|
|
1395
|
+
}
|
|
1396
|
+
declare function planWindow({ rule, timeZone, presence, startAt, endAt, now, busy }: PlanWindowInput): {
|
|
1397
|
+
slots: GridSlot[];
|
|
1398
|
+
endAt: Date;
|
|
1399
|
+
bufferEndAt: Date;
|
|
1400
|
+
};
|
|
1401
|
+
declare const holdExpiresAt: (rule: BookingRulesInput, now: Date) => Date;
|
|
1402
|
+
|
|
1203
1403
|
declare const ADYEN_ROLLOUT_COUNTRY_CODES: Set<string>;
|
|
1204
1404
|
declare function isAdyenRolloutCountry(alpha2: string): boolean;
|
|
1205
|
-
declare const ADYEN_STORE_STATE_PROVINCE_COUNTRIES: Set<string>;
|
|
1206
|
-
declare function adyenStoreRequiresStateOrProvince(alpha2: string | undefined): boolean;
|
|
1207
|
-
declare const ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES: Set<string>;
|
|
1208
|
-
declare function adyenLegalEntityRequiresStateOrProvince(alpha2: string | undefined): boolean;
|
|
1209
|
-
declare const ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES: Set<string>;
|
|
1210
|
-
declare function adyenSupportsTaxNumberAbsent(alpha2: string | undefined): boolean;
|
|
1211
|
-
declare const ADYEN_TAX_NUMBER_FORMATS: Record<string, {
|
|
1212
|
-
pattern: RegExp;
|
|
1213
|
-
length: number;
|
|
1214
|
-
}>;
|
|
1215
|
-
declare function adyenTaxNumberFormat(alpha2: string | undefined): {
|
|
1216
|
-
pattern: RegExp;
|
|
1217
|
-
length: number;
|
|
1218
|
-
} | undefined;
|
|
1219
|
-
declare const ADYEN_TAX_NUMBER_MIN_LENGTH = 5;
|
|
1220
|
-
declare const ADYEN_JOB_TITLE_ASSOCIATION_TYPES: readonly string[];
|
|
1221
|
-
declare function adyenRequiresJobTitle(associationType: string): boolean;
|
|
1222
1405
|
|
|
1223
1406
|
interface CurrencyRate {
|
|
1224
1407
|
rate: number;
|
|
@@ -1231,4 +1414,4 @@ declare const EUFixedRates: Record<string, CurrencyRate>;
|
|
|
1231
1414
|
declare const OtherFixedRates: Record<string, CurrencyRate>;
|
|
1232
1415
|
declare const COUNTRY_CURRENCIES: Record<string, string>;
|
|
1233
1416
|
|
|
1234
|
-
export {
|
|
1417
|
+
export { ADYEN_ROLLOUT_COUNTRY_CODES, type Amount, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, type EndOfSessionReport, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderWriteStrategy, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, amountToString, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, mapToLegacyStatus, maxPrecisionFor, mergeFragment, multiplyAmount, normalizeMongoIdString, occupancyIn, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, planWindow, presentAt, removeFragment, resolveFamily, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant, windowEndsAt, withinPresence };
|