@roomstay/core 0.1.85-2 → 0.1.85-4

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.
Files changed (40) hide show
  1. package/dist/node.js +1 -1
  2. package/dist/types/Company/IAdminCompany.type.d.ts +2 -1
  3. package/dist/types/DisplayPolicy/ERuleType.d.ts +6 -0
  4. package/dist/types/DisplayPolicy/ERuleType.enum.d.ts +6 -0
  5. package/dist/types/DisplayPolicy/IDisplayPolicy.d.ts +25 -0
  6. package/dist/types/DisplayPolicy/IDisplayPolicy.type.d.ts +5 -34
  7. package/dist/types/Permission/IPermission.type.d.ts +4 -4
  8. package/dist/types/RMS/ERMSSyncStrategy.enum.d.ts +0 -1
  9. package/dist/types/RMS/IRMSDiscount.type.d.ts +34 -0
  10. package/dist/types/RMS/IRMSPropertyDiscount.type.d.ts +2 -0
  11. package/dist/types/Role/IRole.type.d.ts +2 -0
  12. package/dist/types/Rule/EDayOfWeek.enum.d.ts +9 -0
  13. package/dist/types/Rule/EDisplayPolicyEffectType.enum.d.ts +11 -0
  14. package/dist/types/Rule/ERuleType.enum.d.ts +11 -0
  15. package/dist/types/Rule/IRule.type.d.ts +1 -0
  16. package/dist/types/Rule/IRuleConfigurations.type.d.ts +68 -0
  17. package/dist/types/Rule/IRuleContext.type.d.ts +13 -0
  18. package/dist/types/Rule/index.d.ts +4 -0
  19. package/dist/types/Rules/DisplayPolicyEffect.schema.d.ts +22 -0
  20. package/dist/types/Rules/ERuleType.enum.d.ts +19 -0
  21. package/dist/types/Rules/Rule.schema.d.ts +124 -0
  22. package/dist/types/index.d.ts +6 -1
  23. package/dist/web.js +1 -1
  24. package/package.json +1 -1
  25. package/dist/node.js.LICENSE.txt +0 -7
  26. package/dist/types/Analytics/IAnalyticsEvent.type.d.ts +0 -35
  27. package/dist/types/Analytics/IAnalyticsSession.type.d.ts +0 -11
  28. package/dist/types/Analytics/IBigQueryResponse.type.d.ts +0 -24
  29. package/dist/types/Booking/ISplitPayment.type.d.ts +0 -89
  30. package/dist/types/Fees/IFeeOptions.type.d.ts +0 -6
  31. package/dist/types/Member/LoyaltyTiers.d.ts +0 -6
  32. package/dist/types/Newbook/ENewbookSiteSelectionFeeType.enum.d.ts +0 -4
  33. package/dist/types/Newbook/ENewbookSiteSelectionType.enum.d.ts +0 -6
  34. package/dist/types/Newbook/ENewbookSyncType.enum.d.ts +0 -3
  35. package/dist/types/Newbook/INewbookSyncResponse.type.d.ts +0 -9
  36. package/dist/types/PMS/EPMSSyncStatus.enum.d.ts +0 -8
  37. package/dist/types/PMS/IPMSSyncResponse.type.d.ts +0 -10
  38. package/dist/types/PMS/index.d.ts +0 -2
  39. package/dist/utils/feeOptionRules.d.ts +0 -0
  40. package/dist/web.js.LICENSE.txt +0 -7
@@ -0,0 +1,9 @@
1
+ export declare enum EDayOfWeek {
2
+ MON = "MON",
3
+ TUE = "TUE",
4
+ WED = "WED",
5
+ THU = "THU",
6
+ FRI = "FRI",
7
+ SAT = "SAT",
8
+ SUN = "SUN"
9
+ }
@@ -0,0 +1,11 @@
1
+ export declare enum EDisplayPolicyEffectType {
2
+ Visibility = "visibility",
3
+ Exclusivity = "exclusivity"
4
+ }
5
+ export declare enum EDisplayPolicyExclusivityMode {
6
+ Cheapest = "cheapest",
7
+ MostExpensive = "most_expensive"
8
+ }
9
+ export interface IDisplayPolicyExclusivityConfiguration {
10
+ mode: EDisplayPolicyExclusivityMode;
11
+ }
@@ -0,0 +1,11 @@
1
+ export declare enum ERuleType {
2
+ Schedule = "Schedule",
3
+ GeoLock = "GeoLock",
4
+ DeviceTarget = "DeviceTarget",
5
+ DayOfWeek = "DayOfWeek",
6
+ HotelRestriction = "HotelRestriction",
7
+ RoomRestriction = "RoomRestriction",
8
+ RateRestriction = "RateRestriction",
9
+ NightCount = "NightCount",
10
+ AnyOf = "AnyOf"
11
+ }
@@ -0,0 +1 @@
1
+ export type { IRuleSpec } from './IRuleConfigurations.type';
@@ -0,0 +1,68 @@
1
+ import { EDayOfWeek } from './EDayOfWeek.enum';
2
+ import { ERuleType } from './ERuleType.enum';
3
+ export interface IScheduleConfig {
4
+ type: 'clock' | 'stay';
5
+ rules: Array<{
6
+ type: 'include' | 'exclude';
7
+ startDate: string;
8
+ endDate: string;
9
+ rrule?: string;
10
+ }>;
11
+ }
12
+ export interface IGeoLockConfig {
13
+ applicableCountryCodes: string[];
14
+ mode: 'allow' | 'deny';
15
+ }
16
+ export type TDeviceTarget = 'mobile' | 'desktop';
17
+ export interface IDeviceTargetConfig {
18
+ allowedDevices: TDeviceTarget[];
19
+ }
20
+ export type TDayOfWeekSource = 'arrival' | 'night' | 'booking';
21
+ export interface IDayOfWeekConfig {
22
+ source: TDayOfWeekSource;
23
+ allowedDays: EDayOfWeek[];
24
+ }
25
+ export interface IHotelRestrictionConfig {
26
+ hotelIds: string[];
27
+ }
28
+ export interface IRoomRestrictionConfig {
29
+ roomCodes: string[];
30
+ }
31
+ export interface IRateRestrictionConfig {
32
+ rateCodes: string[];
33
+ }
34
+ export interface INightCountConfig {
35
+ min?: number;
36
+ max?: number;
37
+ }
38
+ export interface IAnyOfConfig {
39
+ branches: IRuleSpec[][];
40
+ }
41
+ export type IRuleSpec = {
42
+ ruleType: ERuleType.Schedule;
43
+ configuration: IScheduleConfig;
44
+ } | {
45
+ ruleType: ERuleType.GeoLock;
46
+ configuration: IGeoLockConfig;
47
+ } | {
48
+ ruleType: ERuleType.DeviceTarget;
49
+ configuration: IDeviceTargetConfig;
50
+ } | {
51
+ ruleType: ERuleType.DayOfWeek;
52
+ configuration: IDayOfWeekConfig;
53
+ } | {
54
+ ruleType: ERuleType.HotelRestriction;
55
+ configuration: IHotelRestrictionConfig;
56
+ } | {
57
+ ruleType: ERuleType.RoomRestriction;
58
+ configuration: IRoomRestrictionConfig;
59
+ } | {
60
+ ruleType: ERuleType.RateRestriction;
61
+ configuration: IRateRestrictionConfig;
62
+ } | {
63
+ ruleType: ERuleType.NightCount;
64
+ configuration: INightCountConfig;
65
+ } | {
66
+ ruleType: ERuleType.AnyOf;
67
+ configuration: IAnyOfConfig;
68
+ };
@@ -0,0 +1,13 @@
1
+ export interface IRuleContextDescriptor {
2
+ hasHotel: true;
3
+ hasNow: true;
4
+ optional: {
5
+ checkInDate?: true;
6
+ checkOutDate?: true;
7
+ nightDate?: true;
8
+ event?: true;
9
+ geolocation?: true;
10
+ rateCode?: true;
11
+ roomCode?: true;
12
+ };
13
+ }
@@ -0,0 +1,4 @@
1
+ export * from './EDayOfWeek.enum';
2
+ export * from './EDisplayPolicyEffectType.enum';
3
+ export * from './ERuleType.enum';
4
+ export * from './IRuleConfigurations.type';
@@ -0,0 +1,22 @@
1
+ import * as z from 'zod';
2
+ import { EDisplayPolicyExclusiveMode } from '../DisplayPolicy/IDisplayPolicy.type';
3
+ /**
4
+ * Every DisplayPolicy has *rules* (predicates that gate when it applies) and an *effect*
5
+ * (what it does to its bound rates):
6
+ *
7
+ * - `visibility` — show the bound rates only when the rules pass (no config needed).
8
+ * - `exclusivity` — show only the cheapest / most expensive of the bound rates.
9
+ */
10
+ export type EDisplayPolicyEffectType = 'visibility' | 'exclusivity';
11
+ export declare const DISPLAY_POLICY_EFFECT_TYPES: EDisplayPolicyEffectType[];
12
+ export declare const EDisplayPolicyEffectTypeSchema: z.ZodEnum<{
13
+ visibility: "visibility";
14
+ exclusivity: "exclusivity";
15
+ }>;
16
+ export declare const ExclusivityEffectConfigSchema: z.ZodObject<{
17
+ mode: z.ZodEnum<{
18
+ Cheapest: EDisplayPolicyExclusiveMode.Cheapest;
19
+ MostExpensive: EDisplayPolicyExclusiveMode.MostExpensive;
20
+ }>;
21
+ }, z.core.$strip>;
22
+ export type IExclusivityEffectConfig = z.infer<typeof ExclusivityEffectConfigSchema>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The shared library of reusable Rules — predicates over a context, written once
3
+ * and used by every subject (DisplayPolicy rate visibility, RMS discount applicability,
4
+ * PromoCode eligibility).
5
+ *
6
+ * `AnyOf` = OR (`.some`), `AllOf` = AND (`.every`); both are shaped `{ rules: IRule[] }`.
7
+ * The top-level rule list of any subject is an implicit root AND.
8
+ */
9
+ export declare enum ERuleType {
10
+ Schedule = "Schedule",
11
+ GeoLock = "GeoLock",
12
+ DeviceTarget = "DeviceTarget",
13
+ HotelRestriction = "HotelRestriction",
14
+ RoomRestriction = "RoomRestriction",
15
+ RateRestriction = "RateRestriction",
16
+ StayLength = "StayLength",
17
+ AnyOf = "AnyOf",
18
+ AllOf = "AllOf"
19
+ }
@@ -0,0 +1,124 @@
1
+ import * as z from 'zod';
2
+ import { EDisplayPolicyDeviceTarget } from '../DisplayPolicy/IDisplayPolicy.type';
3
+ import { ERuleType } from './ERuleType.enum';
4
+ /**
5
+ * Which date a Schedule rule's windows test.
6
+ *
7
+ * - `bookingTime` → `hotel.now()` (the moment the booking is being made)
8
+ * - `arrivalDate` → the stay's check-in date
9
+ * - `stayDates` → a single night under test (per-night pass only)
10
+ *
11
+ * `mode` replaces the legacy `type: 'clock' | 'stay'` field, which collided with the
12
+ * per-window `type: 'include' | 'exclude'` and misleadingly called the arrival date "stay".
13
+ */
14
+ export declare enum EScheduleMode {
15
+ BookingTime = "bookingTime",
16
+ ArrivalDate = "arrivalDate",
17
+ StayDates = "stayDates"
18
+ }
19
+ export declare const ScheduleWindowSchema: z.ZodObject<{
20
+ type: z.ZodEnum<{
21
+ include: "include";
22
+ exclude: "exclude";
23
+ }>;
24
+ startDate: z.ZodString;
25
+ endDate: z.ZodString;
26
+ rrule: z.ZodOptional<z.ZodString>;
27
+ }, z.core.$strip>;
28
+ export declare const ScheduleConfigSchema: z.ZodObject<{
29
+ mode: z.ZodEnum<{
30
+ bookingTime: EScheduleMode.BookingTime;
31
+ arrivalDate: EScheduleMode.ArrivalDate;
32
+ stayDates: EScheduleMode.StayDates;
33
+ }>;
34
+ rules: z.ZodArray<z.ZodObject<{
35
+ type: z.ZodEnum<{
36
+ include: "include";
37
+ exclude: "exclude";
38
+ }>;
39
+ startDate: z.ZodString;
40
+ endDate: z.ZodString;
41
+ rrule: z.ZodOptional<z.ZodString>;
42
+ }, z.core.$strip>>;
43
+ }, z.core.$strip>;
44
+ export declare const GeoLockConfigSchema: z.ZodObject<{
45
+ applicableCountryCodes: z.ZodArray<z.ZodString>;
46
+ mode: z.ZodEnum<{
47
+ block: "block";
48
+ allow: "allow";
49
+ }>;
50
+ }, z.core.$strip>;
51
+ export declare const DeviceTargetConfigSchema: z.ZodObject<{
52
+ allowedDevices: z.ZodArray<z.ZodEnum<{
53
+ desktop: EDisplayPolicyDeviceTarget.Desktop;
54
+ mobile: EDisplayPolicyDeviceTarget.Mobile;
55
+ }>>;
56
+ }, z.core.$strip>;
57
+ export declare const HotelRestrictionConfigSchema: z.ZodObject<{
58
+ providerIds: z.ZodArray<z.ZodString>;
59
+ }, z.core.$strip>;
60
+ export declare const RoomRestrictionConfigSchema: z.ZodObject<{
61
+ roomCodes: z.ZodArray<z.ZodString>;
62
+ }, z.core.$strip>;
63
+ export declare const RateRestrictionConfigSchema: z.ZodObject<{
64
+ rateCodes: z.ZodArray<z.ZodString>;
65
+ }, z.core.$strip>;
66
+ export declare const StayLengthConfigSchema: z.ZodObject<{
67
+ minNights: z.ZodOptional<z.ZodNumber>;
68
+ maxNights: z.ZodOptional<z.ZodNumber>;
69
+ }, z.core.$strip>;
70
+ export type IScheduleConfig = z.infer<typeof ScheduleConfigSchema>;
71
+ export type IScheduleWindow = z.infer<typeof ScheduleWindowSchema>;
72
+ export type IGeoLockConfig = z.infer<typeof GeoLockConfigSchema>;
73
+ export type IDeviceTargetConfig = z.infer<typeof DeviceTargetConfigSchema>;
74
+ export type IHotelRestrictionConfig = z.infer<typeof HotelRestrictionConfigSchema>;
75
+ export type IRoomRestrictionConfig = z.infer<typeof RoomRestrictionConfigSchema>;
76
+ export type IRateRestrictionConfig = z.infer<typeof RateRestrictionConfigSchema>;
77
+ export type IStayLengthConfig = z.infer<typeof StayLengthConfigSchema>;
78
+ /** `AnyOf`/`AllOf` config: a nested rule list. `AnyOf` = OR, `AllOf` = AND. */
79
+ export interface ICompositeConfig {
80
+ rules: IRule[];
81
+ }
82
+ /**
83
+ * The canonical rule — a discriminated union that ties each `ruleType` to its config shape,
84
+ * so constructing a rule with the wrong configuration is a compile error. Use this everywhere
85
+ * rules are *built* (the RMS sync mapper, the write path).
86
+ */
87
+ export type IRule = {
88
+ ruleType: ERuleType.Schedule;
89
+ configuration: IScheduleConfig;
90
+ } | {
91
+ ruleType: ERuleType.GeoLock;
92
+ configuration: IGeoLockConfig;
93
+ } | {
94
+ ruleType: ERuleType.DeviceTarget;
95
+ configuration: IDeviceTargetConfig;
96
+ } | {
97
+ ruleType: ERuleType.HotelRestriction;
98
+ configuration: IHotelRestrictionConfig;
99
+ } | {
100
+ ruleType: ERuleType.RoomRestriction;
101
+ configuration: IRoomRestrictionConfig;
102
+ } | {
103
+ ruleType: ERuleType.RateRestriction;
104
+ configuration: IRateRestrictionConfig;
105
+ } | {
106
+ ruleType: ERuleType.StayLength;
107
+ configuration: IStayLengthConfig;
108
+ } | {
109
+ ruleType: ERuleType.AnyOf;
110
+ configuration: ICompositeConfig;
111
+ } | {
112
+ ruleType: ERuleType.AllOf;
113
+ configuration: ICompositeConfig;
114
+ };
115
+ /**
116
+ * A persisted / dynamically-edited rule row whose `configuration` hasn't been validated yet
117
+ * (a JSON DB column, an HTTP body, an admin field-array row). Narrow it to {@link IRule} with
118
+ * {@link RuleSchema}.parse — parse returns the typed value, so narrowing never needs a cast.
119
+ */
120
+ export type IStoredRule = {
121
+ ruleType: ERuleType;
122
+ configuration: unknown;
123
+ };
124
+ export declare const RuleSchema: z.ZodType<IRule>;
@@ -172,7 +172,12 @@ export * from './GiftCards/GiftCardLogs.enum';
172
172
  * Display Policies
173
173
  */
174
174
  export * from './DisplayPolicy/IDisplayPolicy.type';
175
- export * from './DisplayPolicy/EDisplayPolicyRuleType.enum';
175
+ /**
176
+ * Shared Rules library + DisplayPolicy effect model
177
+ */
178
+ export * from './Rules/ERuleType.enum';
179
+ export * from './Rules/Rule.schema';
180
+ export * from './Rules/DisplayPolicyEffect.schema';
176
181
  /**
177
182
  * Metasearch
178
183
  */