@hintergrund/worker 0.3.17 → 0.3.19
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/api/appointments/admin.d.ts +171 -0
- package/dist/api/appointments/admin.d.ts.map +1 -0
- package/dist/api/appointments/admin.js +275 -0
- package/dist/api/appointments/core.d.ts +114 -0
- package/dist/api/appointments/core.d.ts.map +1 -0
- package/dist/api/appointments/core.js +208 -0
- package/dist/api/appointments/cron.d.ts +9 -0
- package/dist/api/appointments/cron.d.ts.map +1 -0
- package/dist/api/appointments/cron.js +71 -0
- package/dist/api/appointments/emails.d.ts +5 -0
- package/dist/api/appointments/emails.d.ts.map +1 -0
- package/dist/api/appointments/emails.js +53 -0
- package/dist/api/appointments/public.d.ts +104 -0
- package/dist/api/appointments/public.d.ts.map +1 -0
- package/dist/api/appointments/public.js +129 -0
- package/dist/api/appointments/routes.d.ts +7 -0
- package/dist/api/appointments/routes.d.ts.map +1 -0
- package/dist/api/appointments/routes.js +28 -0
- package/dist/api/cms/handlers/agent-provider.handler.d.ts +1 -0
- package/dist/api/cms/handlers/agent-provider.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/agent-provider.handler.js +13 -23
- package/dist/api/cms/handlers/github-secrets.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/github-secrets.handler.js +3 -18
- package/dist/api/cms/handlers/integrations.handler.d.ts +2 -2
- package/dist/api/cms/handlers/integrations.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/integrations.handler.js +5 -11
- package/dist/api/cms/handlers/runtime.handler.d.ts +6 -0
- package/dist/api/cms/handlers/runtime.handler.d.ts.map +1 -0
- package/dist/api/cms/handlers/runtime.handler.js +42 -0
- package/dist/api/cms/handlers/website-repo.handler.d.ts +2 -0
- package/dist/api/cms/handlers/website-repo.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/website-repo.handler.js +31 -14
- package/dist/api/cms/routes/index.d.ts.map +1 -1
- package/dist/api/cms/routes/index.js +6 -6
- package/dist/api/emails/handlers/campaigns.handler.d.ts +10 -6
- package/dist/api/emails/handlers/campaigns.handler.d.ts.map +1 -1
- package/dist/api/emails/handlers/campaigns.handler.js +127 -30
- package/dist/api/emails/handlers/public.handler.d.ts +0 -2
- package/dist/api/emails/handlers/public.handler.d.ts.map +1 -1
- package/dist/api/emails/handlers/public.handler.js +32 -77
- package/dist/api/emails/handlers/send.handler.js +2 -2
- package/dist/api/emails/handlers/settings.handler.d.ts +1 -3
- package/dist/api/emails/handlers/settings.handler.d.ts.map +1 -1
- package/dist/api/emails/handlers/settings.handler.js +1 -6
- package/dist/api/emails/handlers/subscribers.handler.d.ts.map +1 -1
- package/dist/api/emails/handlers/subscribers.handler.js +9 -0
- package/dist/api/emails/routes/admin.routes.d.ts.map +1 -1
- package/dist/api/emails/routes/admin.routes.js +3 -1
- package/dist/api/emails/routes/mail.routes.d.ts.map +1 -1
- package/dist/api/emails/routes/mail.routes.js +19 -17
- package/dist/api/emails/routes/public.routes.d.ts.map +1 -1
- package/dist/api/emails/routes/public.routes.js +1 -2
- package/dist/api/enquiries/routes.d.ts +7 -0
- package/dist/api/enquiries/routes.d.ts.map +1 -0
- package/dist/api/enquiries/routes.js +73 -0
- package/dist/api/members/handlers.d.ts +36 -0
- package/dist/api/members/handlers.d.ts.map +1 -0
- package/dist/api/members/handlers.js +322 -0
- package/dist/api/members/routes.d.ts +5 -0
- package/dist/api/members/routes.d.ts.map +1 -0
- package/dist/api/members/routes.js +20 -0
- package/dist/api/reservations/core.d.ts +25 -0
- package/dist/api/reservations/core.d.ts.map +1 -0
- package/dist/api/reservations/core.js +59 -0
- package/dist/api/reservations/mail.d.ts +7 -0
- package/dist/api/reservations/mail.d.ts.map +1 -0
- package/dist/api/reservations/mail.js +63 -0
- package/dist/api/reservations/routes.d.ts +7 -0
- package/dist/api/reservations/routes.d.ts.map +1 -0
- package/dist/api/reservations/routes.js +186 -0
- package/dist/api/shop/handlers/products.handler.d.ts +1 -1
- package/dist/api/shop/handlers/products.handler.d.ts.map +1 -1
- package/dist/api/shop/handlers/products.handler.js +3 -3
- package/dist/api/shop/handlers/public.handler.d.ts +3 -3
- package/dist/api/shop/handlers/public.handler.d.ts.map +1 -1
- package/dist/api/shop/handlers/public.handler.js +25 -28
- package/dist/api/shop/routes.d.ts +2 -4
- package/dist/api/shop/routes.d.ts.map +1 -1
- package/dist/api/shop/routes.js +8 -11
- package/dist/api/stays/actions.d.ts +13 -0
- package/dist/api/stays/actions.d.ts.map +1 -0
- package/dist/api/stays/actions.js +28 -0
- package/dist/api/stays/admin.d.ts +209 -0
- package/dist/api/stays/admin.d.ts.map +1 -0
- package/dist/api/stays/admin.js +228 -0
- package/dist/api/stays/bookings.d.ts +113 -0
- package/dist/api/stays/bookings.d.ts.map +1 -0
- package/dist/api/stays/bookings.js +254 -0
- package/dist/api/stays/core.d.ts +214 -0
- package/dist/api/stays/core.d.ts.map +1 -0
- package/dist/api/stays/core.js +361 -0
- package/dist/api/stays/cron.d.ts +7 -0
- package/dist/api/stays/cron.d.ts.map +1 -0
- package/dist/api/stays/cron.js +56 -0
- package/dist/api/stays/mail.d.ts +8 -0
- package/dist/api/stays/mail.d.ts.map +1 -0
- package/dist/api/stays/mail.js +50 -0
- package/dist/api/stays/offers.d.ts +27 -0
- package/dist/api/stays/offers.d.ts.map +1 -0
- package/dist/api/stays/offers.js +56 -0
- package/dist/api/stays/payments.d.ts +47 -0
- package/dist/api/stays/payments.d.ts.map +1 -0
- package/dist/api/stays/payments.js +148 -0
- package/dist/api/stays/public.d.ts +207 -0
- package/dist/api/stays/public.d.ts.map +1 -0
- package/dist/api/stays/public.js +137 -0
- package/dist/api/stays/routes.d.ts +7 -0
- package/dist/api/stays/routes.d.ts.map +1 -0
- package/dist/api/stays/routes.js +39 -0
- package/dist/api/stripe/webhook.d.ts +5 -0
- package/dist/api/stripe/webhook.d.ts.map +1 -0
- package/dist/api/stripe/webhook.js +45 -0
- package/dist/api/tickets/core.d.ts +40 -0
- package/dist/api/tickets/core.d.ts.map +1 -0
- package/dist/api/tickets/core.js +115 -0
- package/dist/api/tickets/routes.d.ts +5 -0
- package/dist/api/tickets/routes.d.ts.map +1 -0
- package/dist/api/tickets/routes.js +70 -0
- package/dist/index.d.ts +16 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -27
- package/dist/lib/appointments-schema.d.ts +6 -0
- package/dist/lib/appointments-schema.d.ts.map +1 -0
- package/dist/lib/appointments-schema.js +96 -0
- package/dist/lib/config.js +4 -4
- package/dist/lib/email-template.d.ts +2 -2
- package/dist/lib/email-template.d.ts.map +1 -1
- package/dist/lib/email-template.js +3 -3
- package/dist/lib/email.d.ts.map +1 -1
- package/dist/lib/email.js +12 -3
- package/dist/lib/features.d.ts +13 -0
- package/dist/lib/features.d.ts.map +1 -0
- package/dist/lib/features.js +19 -0
- package/dist/lib/invoice.js +3 -3
- package/dist/lib/mail-schema.d.ts +1 -1
- package/dist/lib/mail-schema.d.ts.map +1 -1
- package/dist/lib/mail-schema.js +0 -1
- package/dist/lib/mail.d.ts +23 -3
- package/dist/lib/mail.d.ts.map +1 -1
- package/dist/lib/mail.js +69 -23
- package/dist/lib/members.d.ts +41 -0
- package/dist/lib/members.d.ts.map +1 -0
- package/dist/lib/members.js +92 -0
- package/dist/lib/project-db.d.ts +1 -1
- package/dist/lib/project-db.d.ts.map +1 -1
- package/dist/lib/project-db.js +67 -8
- package/dist/lib/reservations-schema.d.ts +3 -0
- package/dist/lib/reservations-schema.d.ts.map +1 -0
- package/dist/lib/reservations-schema.js +35 -0
- package/dist/lib/stays-schema.d.ts +3 -0
- package/dist/lib/stays-schema.d.ts.map +1 -0
- package/dist/lib/stays-schema.js +247 -0
- package/dist/lib/stripe.d.ts +6 -0
- package/dist/lib/stripe.d.ts.map +1 -0
- package/dist/lib/stripe.js +9 -0
- package/dist/lib/template.d.ts +2 -1
- package/dist/lib/template.d.ts.map +1 -1
- package/dist/lib/template.js +4 -82
- package/dist/lib/user-recovery.d.ts.map +1 -1
- package/dist/lib/user-recovery.js +4 -2
- package/dist/lib/website-i18n.d.ts +17 -0
- package/dist/lib/website-i18n.d.ts.map +1 -1
- package/dist/lib/website-i18n.js +90 -19
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +8 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +1 -0
- package/package.json +2 -2
- package/dist/api/cms/handlers/setup.handler.d.ts +0 -8
- package/dist/api/cms/handlers/setup.handler.d.ts.map +0 -1
- package/dist/api/cms/handlers/setup.handler.js +0 -291
- package/dist/api/emails/handlers/invoice.handler.d.ts +0 -9
- package/dist/api/emails/handlers/invoice.handler.d.ts.map +0 -1
- package/dist/api/emails/handlers/invoice.handler.js +0 -154
- package/dist/lib/brand.d.ts +0 -6
- package/dist/lib/brand.d.ts.map +0 -1
- package/dist/lib/brand.js +0 -31
- package/dist/lib/integration-health.d.ts +0 -18
- package/dist/lib/integration-health.d.ts.map +0 -1
- package/dist/lib/integration-health.js +0 -51
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { Bindings } from '../../index';
|
|
3
|
+
type C = Context<{
|
|
4
|
+
Bindings: Bindings;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const getConfig: (c: C) => Promise<Response & import("hono").TypedResponse<{
|
|
7
|
+
settings: {
|
|
8
|
+
name: string;
|
|
9
|
+
timezone: string;
|
|
10
|
+
currency: string;
|
|
11
|
+
country: string;
|
|
12
|
+
checkInTime: string;
|
|
13
|
+
checkOutTime: string;
|
|
14
|
+
childMaxAge: number;
|
|
15
|
+
maxRooms: number;
|
|
16
|
+
maxNights: number;
|
|
17
|
+
holdMinutes: number;
|
|
18
|
+
vat: {
|
|
19
|
+
accommodation: number;
|
|
20
|
+
board: number;
|
|
21
|
+
other: number;
|
|
22
|
+
};
|
|
23
|
+
idRetentionDays: number;
|
|
24
|
+
invoicePrefix: string;
|
|
25
|
+
policyText: string;
|
|
26
|
+
};
|
|
27
|
+
roomTypes: {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
baseOccupancy: number;
|
|
31
|
+
maxAdults: number;
|
|
32
|
+
maxChildren: number;
|
|
33
|
+
maxOccupancy: number;
|
|
34
|
+
extraBed: boolean;
|
|
35
|
+
sort: number;
|
|
36
|
+
}[];
|
|
37
|
+
units: {
|
|
38
|
+
id: string;
|
|
39
|
+
roomTypeId: string;
|
|
40
|
+
name: string;
|
|
41
|
+
active: boolean;
|
|
42
|
+
sort: number;
|
|
43
|
+
}[];
|
|
44
|
+
ratePlans: {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
parentId: string | null;
|
|
48
|
+
adjType: "pct" | "fixed";
|
|
49
|
+
adjValue: number;
|
|
50
|
+
isPublic: boolean;
|
|
51
|
+
promoCode: string | null;
|
|
52
|
+
board: import("@hintergrund/runtime-contracts").StayBoard;
|
|
53
|
+
cancellationPolicyId: string | null;
|
|
54
|
+
boardSharePct: number;
|
|
55
|
+
active: boolean;
|
|
56
|
+
sort: number;
|
|
57
|
+
rooms: {
|
|
58
|
+
roomTypeId: string;
|
|
59
|
+
extraAdult: number;
|
|
60
|
+
childBands: {
|
|
61
|
+
minAge: number;
|
|
62
|
+
maxAge: number;
|
|
63
|
+
price: number;
|
|
64
|
+
}[];
|
|
65
|
+
}[];
|
|
66
|
+
}[];
|
|
67
|
+
policies: {
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
tiers: {
|
|
71
|
+
hoursBeforeArrival: number;
|
|
72
|
+
feeType: import("@hintergrund/runtime-contracts").StayFeeType;
|
|
73
|
+
value: number;
|
|
74
|
+
}[];
|
|
75
|
+
noShow: {
|
|
76
|
+
feeType: import("@hintergrund/runtime-contracts").StayFeeType;
|
|
77
|
+
value: number;
|
|
78
|
+
};
|
|
79
|
+
guarantee: import("@hintergrund/runtime-contracts").StayGuarantee;
|
|
80
|
+
depositPct: number;
|
|
81
|
+
}[];
|
|
82
|
+
extras: {
|
|
83
|
+
id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
price: number;
|
|
86
|
+
per: import("@hintergrund/runtime-contracts").StayExtraPer;
|
|
87
|
+
vatRate: number;
|
|
88
|
+
active: boolean;
|
|
89
|
+
sort: number;
|
|
90
|
+
}[];
|
|
91
|
+
cityTax: {
|
|
92
|
+
id: string;
|
|
93
|
+
label: string;
|
|
94
|
+
dateFrom: string;
|
|
95
|
+
dateTo: string;
|
|
96
|
+
amount: number;
|
|
97
|
+
ageMin: number;
|
|
98
|
+
ageMax: number;
|
|
99
|
+
maxNights: number;
|
|
100
|
+
}[];
|
|
101
|
+
yieldRules: {
|
|
102
|
+
id: string;
|
|
103
|
+
roomTypeId: string | null;
|
|
104
|
+
thresholdPct: number;
|
|
105
|
+
upliftPct: number;
|
|
106
|
+
active: boolean;
|
|
107
|
+
}[];
|
|
108
|
+
seasons: {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
roomTypeId: string;
|
|
112
|
+
ratePlanId: string;
|
|
113
|
+
dateFrom: string;
|
|
114
|
+
dateTo: string;
|
|
115
|
+
price: number;
|
|
116
|
+
weekdayDeltas: {
|
|
117
|
+
[x: string]: number;
|
|
118
|
+
};
|
|
119
|
+
}[];
|
|
120
|
+
feeds: {
|
|
121
|
+
id: string;
|
|
122
|
+
unitId: string;
|
|
123
|
+
direction: "in" | "out";
|
|
124
|
+
url: string;
|
|
125
|
+
token: string;
|
|
126
|
+
lastSyncedAt: number | null;
|
|
127
|
+
lastError: string;
|
|
128
|
+
}[];
|
|
129
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
|
|
130
|
+
export declare function putSettings(c: C): Promise<(Response & import("hono").TypedResponse<{
|
|
131
|
+
error: string;
|
|
132
|
+
code?: typeof import("@hintergrund/runtime-contracts").STAY_ERRORS[number] | undefined;
|
|
133
|
+
warnings?: string[] | undefined;
|
|
134
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
135
|
+
name: string;
|
|
136
|
+
timezone: string;
|
|
137
|
+
currency: string;
|
|
138
|
+
country: string;
|
|
139
|
+
checkInTime: string;
|
|
140
|
+
checkOutTime: string;
|
|
141
|
+
childMaxAge: number;
|
|
142
|
+
maxRooms: number;
|
|
143
|
+
maxNights: number;
|
|
144
|
+
holdMinutes: number;
|
|
145
|
+
vat: {
|
|
146
|
+
accommodation: number;
|
|
147
|
+
board: number;
|
|
148
|
+
other: number;
|
|
149
|
+
};
|
|
150
|
+
idRetentionDays: number;
|
|
151
|
+
invoicePrefix: string;
|
|
152
|
+
policyText: string;
|
|
153
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
|
|
154
|
+
export declare function createEntity(c: C): Promise<Response>;
|
|
155
|
+
export declare function updateEntity(c: C): Promise<Response>;
|
|
156
|
+
export declare function deleteEntity(c: C): Promise<Response>;
|
|
157
|
+
export declare function getRates(c: C): Promise<(Response & import("hono").TypedResponse<{
|
|
158
|
+
error: string;
|
|
159
|
+
code?: typeof import("@hintergrund/runtime-contracts").STAY_ERRORS[number] | undefined;
|
|
160
|
+
warnings?: string[] | undefined;
|
|
161
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
162
|
+
roomTypeId: string;
|
|
163
|
+
days: {
|
|
164
|
+
roomTypeId: string;
|
|
165
|
+
ratePlanId: string;
|
|
166
|
+
date: string;
|
|
167
|
+
price: number | null;
|
|
168
|
+
minLosArrival: number | null;
|
|
169
|
+
minLosThrough: number | null;
|
|
170
|
+
maxLos: number | null;
|
|
171
|
+
cta: boolean;
|
|
172
|
+
ctd: boolean;
|
|
173
|
+
closed: boolean;
|
|
174
|
+
minAdvance: number | null;
|
|
175
|
+
maxAdvance: number | null;
|
|
176
|
+
effectivePrice?: number | null | undefined;
|
|
177
|
+
}[];
|
|
178
|
+
inventory: {
|
|
179
|
+
date: string;
|
|
180
|
+
capacity: number;
|
|
181
|
+
sold: number;
|
|
182
|
+
}[];
|
|
183
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
|
|
184
|
+
export declare function putRates(c: C): Promise<(Response & import("hono").TypedResponse<{
|
|
185
|
+
error: string;
|
|
186
|
+
code?: typeof import("@hintergrund/runtime-contracts").STAY_ERRORS[number] | undefined;
|
|
187
|
+
warnings?: string[] | undefined;
|
|
188
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
189
|
+
ok: true;
|
|
190
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
|
|
191
|
+
/** Fills base prices from a season template: one price plus a delta per weekday. */
|
|
192
|
+
export declare function applySeason(c: C): Promise<(Response & import("hono").TypedResponse<{
|
|
193
|
+
error: string;
|
|
194
|
+
code?: typeof import("@hintergrund/runtime-contracts").STAY_ERRORS[number] | undefined;
|
|
195
|
+
warnings?: string[] | undefined;
|
|
196
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
197
|
+
ok: true;
|
|
198
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
|
|
199
|
+
export declare function createBlock(c: C): Promise<(Response & import("hono").TypedResponse<{
|
|
200
|
+
error: string;
|
|
201
|
+
code?: typeof import("@hintergrund/runtime-contracts").STAY_ERRORS[number] | undefined;
|
|
202
|
+
warnings?: string[] | undefined;
|
|
203
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
204
|
+
id: string;
|
|
205
|
+
}, 201, "json">)>;
|
|
206
|
+
export declare function deleteBlock(c: C): Promise<Response>;
|
|
207
|
+
export declare function syncFeed(c: C): Promise<Response>;
|
|
208
|
+
export {};
|
|
209
|
+
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../src/api/stays/admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAM5C,KAAK,CAAC,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAIzC,eAAO,MAAM,SAAS,GAAU,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEAAoE,CAAC;AAEzG,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;oEAerC;AAaD,wBAAsB,YAAY,CAAC,CAAC,EAAE,CAAC,qBAiBtC;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,CAAC,qBAsBtC;AAUD,wBAAsB,YAAY,CAAC,CAAC,EAAE,CAAC,qBAmBtC;AAsBD,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;oEAiBlC;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC;;;;;;oEAKlC;AAED,oFAAoF;AACpF,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC;;;;;;oEAgBrC;AAID,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC;;;;;;kBAarC;AAED,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC,qBAKrC;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC,qBAMlC"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { DEFAULT_STAY_SETTINGS, STAY_ENTITIES, addDays, dayDiff, localParts, } from '@hintergrund/runtime-contracts';
|
|
2
|
+
import { createId, ensureSchema } from '../../lib/project-db';
|
|
3
|
+
import { ENTITY_DEFS, MAX_HORIZON_DAYS, entityFields, int, isOverbooked, loadConfig, loadCtx, loadSettings, nightPrice, nightsInsert, seedInventory, syncCapacity, text, validDate } from './core';
|
|
4
|
+
import { randomToken } from '../../lib/features';
|
|
5
|
+
import { importFeed } from './cron';
|
|
6
|
+
const err = (c, status, error, code = 'invalid') => c.json({ error, code }, status);
|
|
7
|
+
const today = (s) => localParts(Date.now(), s.timezone).date;
|
|
8
|
+
export const getConfig = async (c) => c.json(await loadConfig(await ensureSchema(c.env)));
|
|
9
|
+
export async function putSettings(c) {
|
|
10
|
+
const body = await c.req.json().catch(() => null);
|
|
11
|
+
if (!body || typeof body !== 'object')
|
|
12
|
+
return err(c, 400, 'Invalid request.');
|
|
13
|
+
const db = await ensureSchema(c.env), old = await loadSettings(db);
|
|
14
|
+
const s = {
|
|
15
|
+
name: text(body.name ?? old.name, 120), timezone: text(body.timezone ?? old.timezone, 64), currency: text(body.currency ?? old.currency, 3).toLowerCase() || 'eur', country: text(body.country ?? old.country, 2).toUpperCase(),
|
|
16
|
+
checkInTime: /^\d{2}:\d{2}$/.test(String(body.checkInTime)) ? body.checkInTime : old.checkInTime, checkOutTime: /^\d{2}:\d{2}$/.test(String(body.checkOutTime)) ? body.checkOutTime : old.checkOutTime,
|
|
17
|
+
childMaxAge: Math.min(25, Math.max(1, int(body.childMaxAge, old.childMaxAge))), maxRooms: Math.min(10, Math.max(1, int(body.maxRooms, old.maxRooms))), maxNights: Math.min(90, Math.max(1, int(body.maxNights, old.maxNights))),
|
|
18
|
+
holdMinutes: Math.min(30, Math.max(5, int(body.holdMinutes, old.holdMinutes))),
|
|
19
|
+
vat: { accommodation: int(body.vat?.accommodation, old.vat.accommodation), board: int(body.vat?.board, old.vat.board), other: int(body.vat?.other, old.vat.other) },
|
|
20
|
+
idRetentionDays: Math.max(0, int(body.idRetentionDays, old.idRetentionDays)), invoicePrefix: text(body.invoicePrefix ?? old.invoicePrefix, 12), policyText: String(body.policyText ?? old.policyText).slice(0, 5000),
|
|
21
|
+
};
|
|
22
|
+
try {
|
|
23
|
+
new Intl.DateTimeFormat('en', { timeZone: s.timezone });
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return err(c, 400, 'Unknown time zone.');
|
|
27
|
+
}
|
|
28
|
+
await db.prepare('INSERT INTO stay_settings (id, data_json) VALUES (1, ?) ON CONFLICT(id) DO UPDATE SET data_json = excluded.data_json').bind(JSON.stringify({ ...DEFAULT_STAY_SETTINGS, ...s })).run();
|
|
29
|
+
return c.json(s);
|
|
30
|
+
}
|
|
31
|
+
// --- Entities ---
|
|
32
|
+
const entityOf = (c) => STAY_ENTITIES.includes(c.req.param('entity') ?? '') ? c.req.param('entity') : null;
|
|
33
|
+
function roomWrites(db, planId, rooms) {
|
|
34
|
+
if (!Array.isArray(rooms))
|
|
35
|
+
return [];
|
|
36
|
+
return [db.prepare('DELETE FROM stay_rate_plan_rooms WHERE rate_plan_id = ?').bind(planId),
|
|
37
|
+
...rooms.map((r) => db.prepare('INSERT OR REPLACE INTO stay_rate_plan_rooms (rate_plan_id, room_type_id, extra_adult, child_bands_json) VALUES (?, ?, ?, ?)')
|
|
38
|
+
.bind(planId, text(r.roomTypeId, 64), int(r.extraAdult), JSON.stringify((Array.isArray(r.childBands) ? r.childBands : []).map((b) => ({ minAge: int(b.minAge), maxAge: int(b.maxAge), price: int(b.price) })))))];
|
|
39
|
+
}
|
|
40
|
+
export async function createEntity(c) {
|
|
41
|
+
const entity = entityOf(c);
|
|
42
|
+
if (!entity)
|
|
43
|
+
return c.notFound();
|
|
44
|
+
const body = await c.req.json().catch(() => ({}));
|
|
45
|
+
const db = await ensureSchema(c.env), s = await loadSettings(db), id = createId(entity.slice(0, 3));
|
|
46
|
+
try {
|
|
47
|
+
const fields = entityFields(entity, body);
|
|
48
|
+
if (entity === 'feeds') {
|
|
49
|
+
fields.push(['token', randomToken()]);
|
|
50
|
+
if (body.direction === 'in' && !/^https?:\/\//.test(String(body.url)))
|
|
51
|
+
return err(c, 400, 'An import feed needs an http(s) URL.');
|
|
52
|
+
}
|
|
53
|
+
const sync = entity === 'units' ? [syncCapacity(db, text(body.roomTypeId, 64), today(s))] : [];
|
|
54
|
+
await db.batch([db.prepare(`INSERT INTO ${ENTITY_DEFS[entity].table} (id${fields.map(([col]) => `, ${col}`).join('')}) VALUES (?${fields.map(() => ', ?').join('')})`).bind(id, ...fields.map(([, v]) => v)),
|
|
55
|
+
...(entity === 'ratePlans' ? roomWrites(db, id, body.rooms) : []), ...sync]);
|
|
56
|
+
if (entity === 'roomTypes')
|
|
57
|
+
await seedInventory(db, today(s));
|
|
58
|
+
return c.json({ id }, 201);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return isOverbooked(error) ? err(c, 409, 'More rooms are sold than this leaves.', 'conflict') : err(c, 400, error.message);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export async function updateEntity(c) {
|
|
65
|
+
const entity = entityOf(c), id = c.req.param('id') ?? '';
|
|
66
|
+
if (!entity)
|
|
67
|
+
return c.notFound();
|
|
68
|
+
const body = await c.req.json().catch(() => ({}));
|
|
69
|
+
const db = await ensureSchema(c.env), s = await loadSettings(db), def = ENTITY_DEFS[entity];
|
|
70
|
+
const old = await db.prepare(`SELECT * FROM ${def.table} WHERE id = ?`).bind(id).first();
|
|
71
|
+
if (!old)
|
|
72
|
+
return c.notFound();
|
|
73
|
+
try {
|
|
74
|
+
const fields = entityFields(entity, body);
|
|
75
|
+
const sync = [];
|
|
76
|
+
if (entity === 'units') {
|
|
77
|
+
const type = text(body.roomTypeId ?? old.room_type_id, 64);
|
|
78
|
+
if ((body.active === false || type !== old.room_type_id) && await db.prepare('SELECT 1 FROM stay_unit_nights WHERE unit_id = ? AND date >= ? LIMIT 1').bind(id, today(s)).first())
|
|
79
|
+
return err(c, 409, 'Move its bookings and blocks first.', 'conflict');
|
|
80
|
+
sync.push(syncCapacity(db, old.room_type_id, today(s)));
|
|
81
|
+
if (type !== old.room_type_id)
|
|
82
|
+
sync.push(syncCapacity(db, type, today(s)));
|
|
83
|
+
}
|
|
84
|
+
await db.batch([
|
|
85
|
+
...(fields.length ? [db.prepare(`UPDATE ${def.table} SET ${fields.map(([col]) => `${col} = ?`).join(', ')} WHERE id = ?`).bind(...fields.map(([, v]) => v), id)] : []),
|
|
86
|
+
...(entity === 'ratePlans' && 'rooms' in body ? roomWrites(db, id, body.rooms) : []), ...sync,
|
|
87
|
+
]);
|
|
88
|
+
return c.json({ ok: true });
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
return isOverbooked(error) ? err(c, 409, 'More rooms are sold than this leaves.', 'conflict') : err(c, 400, error.message);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** What still refers to an entity, so deleting it would orphan data. */
|
|
95
|
+
const USES = {
|
|
96
|
+
roomTypes: 'SELECT 1 FROM stay_units WHERE room_type_id = ?1 UNION ALL SELECT 1 FROM stay_reservations WHERE room_type_id = ?1 AND status IN (\'booked\', \'checked_in\')',
|
|
97
|
+
units: 'SELECT 1 FROM stay_unit_nights WHERE unit_id = ?1',
|
|
98
|
+
ratePlans: 'SELECT 1 FROM stay_rate_plans WHERE parent_id = ?1 UNION ALL SELECT 1 FROM stay_reservations WHERE rate_plan_id = ?1 AND status IN (\'booked\', \'checked_in\')',
|
|
99
|
+
policies: 'SELECT 1 FROM stay_rate_plans WHERE cancellation_policy_id = ?1',
|
|
100
|
+
};
|
|
101
|
+
export async function deleteEntity(c) {
|
|
102
|
+
const entity = entityOf(c), id = c.req.param('id') ?? '';
|
|
103
|
+
if (!entity)
|
|
104
|
+
return c.notFound();
|
|
105
|
+
const db = await ensureSchema(c.env), from = today(await loadSettings(db));
|
|
106
|
+
if (USES[entity] && await db.prepare(`${USES[entity]} LIMIT 1`).bind(id).first())
|
|
107
|
+
return err(c, 409, 'Still in use.', 'conflict');
|
|
108
|
+
// A unit or an import feed takes its blocks along, which gives capacity back or takes it away: all in one batch.
|
|
109
|
+
const unit = entity === 'units' ? await db.prepare('SELECT room_type_id FROM stay_units WHERE id = ?').bind(id).first()
|
|
110
|
+
: entity === 'feeds' ? await db.prepare('SELECT u.room_type_id FROM stay_ical_feeds f JOIN stay_units u ON u.id = f.unit_id WHERE f.id = ?').bind(id).first() : null;
|
|
111
|
+
try {
|
|
112
|
+
await db.batch([
|
|
113
|
+
db.prepare(`DELETE FROM ${ENTITY_DEFS[entity].table} WHERE id = ?`).bind(id),
|
|
114
|
+
...(entity === 'roomTypes' ? [db.prepare('DELETE FROM stay_inventory WHERE room_type_id = ?').bind(id), db.prepare('DELETE FROM stay_rate_days WHERE room_type_id = ?').bind(id), db.prepare('DELETE FROM stay_rate_plan_rooms WHERE room_type_id = ?').bind(id)] : []),
|
|
115
|
+
...(entity === 'ratePlans' ? [db.prepare('DELETE FROM stay_rate_days WHERE rate_plan_id = ?').bind(id), db.prepare('DELETE FROM stay_rate_plan_rooms WHERE rate_plan_id = ?').bind(id)] : []),
|
|
116
|
+
...(entity === 'units' ? [db.prepare('DELETE FROM stay_ical_feeds WHERE unit_id = ?').bind(id), db.prepare('DELETE FROM stay_blocks WHERE unit_id = ?').bind(id)] : []),
|
|
117
|
+
...(entity === 'feeds' ? [db.prepare('DELETE FROM stay_unit_nights WHERE block_id IN (SELECT id FROM stay_blocks WHERE feed_id = ?)').bind(id), db.prepare('DELETE FROM stay_blocks WHERE feed_id = ?').bind(id)] : []),
|
|
118
|
+
...(unit ? [syncCapacity(db, unit.room_type_id, from)] : []),
|
|
119
|
+
]);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
return isOverbooked(error) ? err(c, 409, 'More rooms are sold than this leaves.', 'conflict') : err(c, 400, error.message);
|
|
123
|
+
}
|
|
124
|
+
return c.json({ ok: true });
|
|
125
|
+
}
|
|
126
|
+
// --- Rates ---
|
|
127
|
+
const RATE_COLS = {
|
|
128
|
+
price: ['price', 'n'], minLosArrival: ['min_los_arrival', 'n'], minLosThrough: ['min_los_through', 'n'], maxLos: ['max_los', 'n'], cta: ['cta', 'b'], ctd: ['ctd', 'b'], closed: ['closed', 'b'], minAdvance: ['min_advance', 'n'], maxAdvance: ['max_advance', 'n'],
|
|
129
|
+
};
|
|
130
|
+
/** Upserts the given fields over a date range (optionally only some weekdays); fields not given stay as they are. */
|
|
131
|
+
function cellStmt(db, cell) {
|
|
132
|
+
const given = Object.keys(RATE_COLS).filter(k => k in (cell.fields ?? {}));
|
|
133
|
+
if (!given.length)
|
|
134
|
+
return null;
|
|
135
|
+
const cols = given.map(k => RATE_COLS[k][0]), values = given.map(k => { const v = cell.fields[k]; return RATE_COLS[k][1] === 'b' ? (v ? 1 : 0) : v == null ? null : int(v); });
|
|
136
|
+
const mask = `,${(cell.weekdays?.length ? cell.weekdays : [1, 2, 3, 4, 5, 6, 7]).map(int).join(',')},`;
|
|
137
|
+
return db.prepare(`WITH RECURSIVE d(date) AS (SELECT ?1 UNION ALL SELECT date(date, '+1 day') FROM d WHERE date < ?2)
|
|
138
|
+
INSERT INTO stay_rate_days (room_type_id, rate_plan_id, date, ${cols.join(', ')}) SELECT ?3, ?4, date, ${cols.map((_, i) => `?${i + 6}`).join(', ')} FROM d
|
|
139
|
+
WHERE instr(?5, ',' || ((CAST(strftime('%w', date) AS INTEGER) + 6) % 7 + 1) || ',') > 0
|
|
140
|
+
ON CONFLICT(room_type_id, rate_plan_id, date) DO UPDATE SET ${cols.map(col => `${col} = excluded.${col}`).join(', ')}`).bind(cell.from, cell.to, cell.roomTypeId, cell.ratePlanId, mask, ...values);
|
|
141
|
+
}
|
|
142
|
+
const validCell = (cell) => cell && typeof cell.roomTypeId === 'string' && typeof cell.ratePlanId === 'string' && validDate(cell.from) && validDate(cell.to) && cell.from <= cell.to && dayDiff(cell.from, cell.to) <= MAX_HORIZON_DAYS && !!cell.fields;
|
|
143
|
+
async function writeCells(db, cells) { await db.batch(cells.flatMap(cell => cellStmt(db, cell) ?? [])); }
|
|
144
|
+
export async function getRates(c) {
|
|
145
|
+
const roomTypeId = c.req.query('roomTypeId') ?? '', from = c.req.query('from'), to = c.req.query('to');
|
|
146
|
+
if (!roomTypeId || !validDate(from) || !validDate(to) || from > to || dayDiff(from, to) > 400)
|
|
147
|
+
return err(c, 400, 'Invalid request.');
|
|
148
|
+
const db = await ensureSchema(c.env), ctx = await loadCtx(db, from, to);
|
|
149
|
+
const plans = [...ctx.plans.values()].filter(p => ctx.planRooms.has(`${p.id}|${roomTypeId}`));
|
|
150
|
+
const dates = Array.from({ length: dayDiff(from, to) + 1 }, (_, i) => addDays(from, i));
|
|
151
|
+
return c.json({
|
|
152
|
+
roomTypeId,
|
|
153
|
+
days: plans.flatMap(plan => dates.map(date => {
|
|
154
|
+
const r = ctx.days.get(`${roomTypeId}|${plan.id}|${date}`);
|
|
155
|
+
return {
|
|
156
|
+
roomTypeId, ratePlanId: plan.id, date, price: r?.price ?? null, minLosArrival: r?.min_los_arrival ?? null, minLosThrough: r?.min_los_through ?? null, maxLos: r?.max_los ?? null,
|
|
157
|
+
cta: !!r?.cta, ctd: !!r?.ctd, closed: !!r?.closed, minAdvance: r?.min_advance ?? null, maxAdvance: r?.max_advance ?? null, effectivePrice: nightPrice(ctx, roomTypeId, plan, date),
|
|
158
|
+
};
|
|
159
|
+
})),
|
|
160
|
+
inventory: dates.flatMap(date => { const i = ctx.inv.get(`${roomTypeId}|${date}`); return i ? [{ date, capacity: i.capacity, sold: i.sold }] : []; }),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
export async function putRates(c) {
|
|
164
|
+
const body = await c.req.json().catch(() => null);
|
|
165
|
+
if (!body?.cells?.length || body.cells.length > 200 || !body.cells.every(validCell))
|
|
166
|
+
return err(c, 400, 'Invalid request.');
|
|
167
|
+
await writeCells(await ensureSchema(c.env), body.cells);
|
|
168
|
+
return c.json({ ok: true });
|
|
169
|
+
}
|
|
170
|
+
/** Fills base prices from a season template: one price plus a delta per weekday. */
|
|
171
|
+
export async function applySeason(c) {
|
|
172
|
+
const body = await c.req.json().catch(() => null);
|
|
173
|
+
if (!body)
|
|
174
|
+
return err(c, 400, 'Invalid request.');
|
|
175
|
+
const db = await ensureSchema(c.env);
|
|
176
|
+
let t = body;
|
|
177
|
+
if (body.templateId) {
|
|
178
|
+
const row = await db.prepare('SELECT * FROM stay_seasons WHERE id = ?').bind(body.templateId).first();
|
|
179
|
+
t = row ? { roomTypeId: row.room_type_id, ratePlanId: row.rate_plan_id, dateFrom: row.date_from, dateTo: row.date_to, price: row.price, weekdayDeltas: JSON.parse(row.weekday_deltas_json) } : undefined;
|
|
180
|
+
}
|
|
181
|
+
if (!t?.roomTypeId || !t.ratePlanId || !validDate(t.dateFrom) || !validDate(t.dateTo) || typeof t.price !== 'number')
|
|
182
|
+
return err(c, 400, 'Invalid request.');
|
|
183
|
+
const groups = new Map();
|
|
184
|
+
for (let day = 1; day <= 7; day++) {
|
|
185
|
+
const delta = int(t.weekdayDeltas?.[day]);
|
|
186
|
+
groups.set(delta, [...(groups.get(delta) ?? []), day]);
|
|
187
|
+
}
|
|
188
|
+
const cells = [...groups].map(([delta, weekdays]) => ({ roomTypeId: t.roomTypeId, ratePlanId: t.ratePlanId, from: t.dateFrom, to: t.dateTo, weekdays, fields: { price: Math.max(0, int(t.price) + delta) } }));
|
|
189
|
+
if (!cells.every(validCell))
|
|
190
|
+
return err(c, 400, 'Invalid request.');
|
|
191
|
+
await writeCells(db, cells);
|
|
192
|
+
return c.json({ ok: true });
|
|
193
|
+
}
|
|
194
|
+
// --- Out-of-order blocks, iCal ---
|
|
195
|
+
export async function createBlock(c) {
|
|
196
|
+
const body = await c.req.json().catch(() => null);
|
|
197
|
+
if (!body?.unitId || !validDate(body.dateFrom) || !validDate(body.dateTo) || body.dateFrom >= body.dateTo)
|
|
198
|
+
return err(c, 400, 'Invalid request.');
|
|
199
|
+
const db = await ensureSchema(c.env), unit = await db.prepare('SELECT * FROM stay_units WHERE id = ?').bind(body.unitId).first();
|
|
200
|
+
if (!unit)
|
|
201
|
+
return err(c, 404, 'Unit not found.', 'not_found');
|
|
202
|
+
const id = createId('blk');
|
|
203
|
+
try {
|
|
204
|
+
await db.batch([
|
|
205
|
+
db.prepare("INSERT INTO stay_blocks (id, unit_id, date_from, date_to, reason, source) VALUES (?, ?, ?, ?, ?, 'manual')").bind(id, unit.id, body.dateFrom, body.dateTo, text(body.reason, 200)),
|
|
206
|
+
nightsInsert(db, unit.id, body.dateFrom, body.dateTo, { blockId: id }), syncCapacity(db, unit.room_type_id, body.dateFrom),
|
|
207
|
+
]);
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
return err(c, 409, isOverbooked(error) ? 'Those nights are already sold; move the bookings first.' : 'The unit is occupied on those nights.', 'conflict');
|
|
211
|
+
}
|
|
212
|
+
return c.json({ id }, 201);
|
|
213
|
+
}
|
|
214
|
+
export async function deleteBlock(c) {
|
|
215
|
+
const db = await ensureSchema(c.env), block = await db.prepare('SELECT b.*, u.room_type_id FROM stay_blocks b JOIN stay_units u ON u.id = b.unit_id WHERE b.id = ?').bind(c.req.param('id') ?? '').first();
|
|
216
|
+
if (!block)
|
|
217
|
+
return c.notFound();
|
|
218
|
+
await db.batch([db.prepare('DELETE FROM stay_unit_nights WHERE block_id = ?').bind(block.id), db.prepare('DELETE FROM stay_blocks WHERE id = ?').bind(block.id), syncCapacity(db, block.room_type_id, block.date_from)]);
|
|
219
|
+
return c.json({ ok: true });
|
|
220
|
+
}
|
|
221
|
+
export async function syncFeed(c) {
|
|
222
|
+
const db = await ensureSchema(c.env), feed = await db.prepare("SELECT * FROM stay_ical_feeds WHERE id = ? AND direction = 'in'").bind(c.req.param('id') ?? '').first();
|
|
223
|
+
if (!feed)
|
|
224
|
+
return c.notFound();
|
|
225
|
+
await importFeed(db, feed);
|
|
226
|
+
const after = await db.prepare('SELECT last_synced_at, last_error FROM stay_ical_feeds WHERE id = ?').bind(feed.id).first();
|
|
227
|
+
return c.json({ lastSyncedAt: after?.last_synced_at ?? null, lastError: after?.last_error ?? '' });
|
|
228
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { Bindings } from '../../index';
|
|
3
|
+
type C = Context<{
|
|
4
|
+
Bindings: Bindings;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function tape(c: C): Promise<(Response & import("hono").TypedResponse<{
|
|
7
|
+
error: string;
|
|
8
|
+
code?: typeof import("@hintergrund/runtime-contracts").STAY_ERRORS[number] | undefined;
|
|
9
|
+
warnings?: string[] | undefined;
|
|
10
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
11
|
+
from: string;
|
|
12
|
+
to: string;
|
|
13
|
+
units: {
|
|
14
|
+
id: string;
|
|
15
|
+
roomTypeId: string;
|
|
16
|
+
name: string;
|
|
17
|
+
active: boolean;
|
|
18
|
+
sort: number;
|
|
19
|
+
}[];
|
|
20
|
+
roomTypes: {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
baseOccupancy: number;
|
|
24
|
+
maxAdults: number;
|
|
25
|
+
maxChildren: number;
|
|
26
|
+
maxOccupancy: number;
|
|
27
|
+
extraBed: boolean;
|
|
28
|
+
sort: number;
|
|
29
|
+
}[];
|
|
30
|
+
reservations: {
|
|
31
|
+
id: string;
|
|
32
|
+
bookingId: string;
|
|
33
|
+
reference: string;
|
|
34
|
+
unitId: string | null;
|
|
35
|
+
roomTypeId: string;
|
|
36
|
+
arrival: string;
|
|
37
|
+
departure: string;
|
|
38
|
+
status: import("@hintergrund/runtime-contracts").StayReservationStatus;
|
|
39
|
+
guestName: string;
|
|
40
|
+
adults: number;
|
|
41
|
+
children: number;
|
|
42
|
+
}[];
|
|
43
|
+
blocks: {
|
|
44
|
+
id: string;
|
|
45
|
+
unitId: string;
|
|
46
|
+
dateFrom: string;
|
|
47
|
+
dateTo: string;
|
|
48
|
+
reason: string;
|
|
49
|
+
source: "manual" | "ical";
|
|
50
|
+
}[];
|
|
51
|
+
inventory: {
|
|
52
|
+
roomTypeId: string;
|
|
53
|
+
date: string;
|
|
54
|
+
capacity: number;
|
|
55
|
+
sold: number;
|
|
56
|
+
}[];
|
|
57
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
|
|
58
|
+
/** Filters: q (reference, name, email), status, arrival / departure / inhouse (a date), limit, offset. */
|
|
59
|
+
export declare function listBookings(c: C): Promise<Response & import("hono").TypedResponse<{
|
|
60
|
+
bookings: {
|
|
61
|
+
id: string;
|
|
62
|
+
reference: string;
|
|
63
|
+
status: import("@hintergrund/runtime-contracts").StayBookingStatus;
|
|
64
|
+
guestName: string;
|
|
65
|
+
guestEmail: string;
|
|
66
|
+
arrival: string;
|
|
67
|
+
departure: string;
|
|
68
|
+
rooms: number;
|
|
69
|
+
total: number;
|
|
70
|
+
paid: number;
|
|
71
|
+
createdAt: number;
|
|
72
|
+
source: "online" | "staff";
|
|
73
|
+
}[];
|
|
74
|
+
total: number;
|
|
75
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
|
|
76
|
+
export declare function getBooking(c: C): Promise<Response>;
|
|
77
|
+
/** Staff booking: restrictions can be overridden with `force` (they come back as warnings first); a full night never can. Nothing is charged online. */
|
|
78
|
+
export declare function manualBooking(c: C): Promise<(Response & import("hono").TypedResponse<{
|
|
79
|
+
error: string;
|
|
80
|
+
code?: typeof import("@hintergrund/runtime-contracts").STAY_ERRORS[number] | undefined;
|
|
81
|
+
warnings?: string[] | undefined;
|
|
82
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
83
|
+
id: string;
|
|
84
|
+
reference: string;
|
|
85
|
+
warnings: string[];
|
|
86
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
|
|
87
|
+
export declare function moveUnit(c: C): Promise<(Response & import("hono").TypedResponse<{
|
|
88
|
+
error: string;
|
|
89
|
+
code?: typeof import("@hintergrund/runtime-contracts").STAY_ERRORS[number] | undefined;
|
|
90
|
+
warnings?: string[] | undefined;
|
|
91
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
92
|
+
ok: true;
|
|
93
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
|
|
94
|
+
export declare function reservationAction(c: C): Promise<(Response & import("hono").TypedResponse<{
|
|
95
|
+
error: string;
|
|
96
|
+
code?: typeof import("@hintergrund/runtime-contracts").STAY_ERRORS[number] | undefined;
|
|
97
|
+
warnings?: string[] | undefined;
|
|
98
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
|
|
99
|
+
status: import("@hintergrund/runtime-contracts").StayReservationStatus;
|
|
100
|
+
fee: number;
|
|
101
|
+
refunded: number;
|
|
102
|
+
charged: number;
|
|
103
|
+
paymentLink?: boolean | undefined;
|
|
104
|
+
}, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
|
|
105
|
+
/** Cancels every still-booked room of a booking. */
|
|
106
|
+
export declare function cancelBooking(c: C): Promise<Response>;
|
|
107
|
+
export declare function chargeFee(c: C): Promise<Response>;
|
|
108
|
+
export declare function updateGuest(c: C): Promise<Response>;
|
|
109
|
+
/** One invoice per booking: re-issuing returns the existing one. Lines are gross; VAT is itemised in the notes. */
|
|
110
|
+
export declare function issueInvoice(c: C): Promise<Response>;
|
|
111
|
+
export declare function invoicePdf(c: C): Promise<Response>;
|
|
112
|
+
export {};
|
|
113
|
+
//# sourceMappingURL=bookings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bookings.d.ts","sourceRoot":"","sources":["../../../src/api/stays/bookings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAW5C,KAAK,CAAC,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAKzC,wBAAsB,IAAI,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oEAgB9B;AAMD,0GAA0G;AAC1G,wBAAsB,YAAY,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;mEAetC;AA6BD,wBAAsB,UAAU,CAAC,CAAC,EAAE,CAAC,qBAGpC;AAED,wJAAwJ;AACxJ,wBAAsB,aAAa,CAAC,CAAC,EAAE,CAAC;;;;;;;;oEAgBvC;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC;;;;;;oEAmBlC;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;oEAa3C;AAED,oDAAoD;AACpD,wBAAsB,aAAa,CAAC,CAAC,EAAE,CAAC,qBAOvC;AAED,wBAAsB,SAAS,CAAC,CAAC,EAAE,CAAC,qBAOnC;AAED,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC,qBAWrC;AAMD,mHAAmH;AACnH,wBAAsB,YAAY,CAAC,CAAC,EAAE,CAAC,qBAiCtC;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,CAAC,qBAIpC"}
|