more-apartments-astro-integration 1.4.1 → 1.5.3
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/cli/index.js +234 -81
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.mts +331 -34
- package/dist/index.d.ts +331 -34
- package/dist/index.js +252 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +244 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -96,7 +96,7 @@ var PropertySchema = zod.z.object({
|
|
|
96
96
|
zipcode: zod.z.string().nullable(),
|
|
97
97
|
area: zod.z.string().nullable(),
|
|
98
98
|
city: zod.z.string(),
|
|
99
|
-
country: zod.z.string(),
|
|
99
|
+
country: zod.z.string().nullable(),
|
|
100
100
|
latitude: zod.z.number(),
|
|
101
101
|
longitude: zod.z.number(),
|
|
102
102
|
// Beds
|
|
@@ -399,32 +399,136 @@ var BookingSettingsSchema = zod.z.object({
|
|
|
399
399
|
}).optional()
|
|
400
400
|
}).optional()
|
|
401
401
|
});
|
|
402
|
-
var
|
|
402
|
+
var BookingDraftRequestSchema = zod.z.object({
|
|
403
|
+
property_id: zod.z.number().int().positive(),
|
|
404
|
+
arrival: zod.z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
405
|
+
departure: zod.z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
406
|
+
amount_adults: zod.z.number().int().min(1),
|
|
407
|
+
amount_children: zod.z.number().int().min(0)
|
|
408
|
+
});
|
|
409
|
+
var BookingDraftResponseSchema = zod.z.object({
|
|
410
|
+
uuid: zod.z.string().uuid(),
|
|
411
|
+
status: zod.z.literal("pending_details"),
|
|
412
|
+
property_id: zod.z.number(),
|
|
413
|
+
arrival: zod.z.string(),
|
|
414
|
+
departure: zod.z.string(),
|
|
415
|
+
amount_adults: zod.z.number(),
|
|
416
|
+
amount_children: zod.z.number(),
|
|
417
|
+
total_price: zod.z.number(),
|
|
418
|
+
nights: zod.z.number(),
|
|
419
|
+
expires_at: zod.z.string(),
|
|
420
|
+
created_at: zod.z.string(),
|
|
421
|
+
updated_at: zod.z.string()
|
|
422
|
+
});
|
|
423
|
+
var PersonalInfoRequestSchema = zod.z.object({
|
|
424
|
+
first_name: zod.z.string().min(1).max(255),
|
|
425
|
+
last_name: zod.z.string().min(1).max(255),
|
|
426
|
+
email: zod.z.string().email().max(255),
|
|
427
|
+
phone: zod.z.string().max(50),
|
|
428
|
+
address_1: zod.z.string().min(1).max(255),
|
|
429
|
+
address_2: zod.z.string().max(255).optional(),
|
|
430
|
+
postal_code: zod.z.string().max(20).optional(),
|
|
431
|
+
city: zod.z.string().min(1).max(100),
|
|
432
|
+
country: zod.z.string().min(1).max(100)
|
|
433
|
+
});
|
|
434
|
+
var BookingDetailsRequestSchema = zod.z.object({
|
|
435
|
+
time_arrival: zod.z.string().regex(/^([01]\d|2[0-3]):([0-5]\d)$/),
|
|
436
|
+
flight: zod.z.string().max(50).optional(),
|
|
437
|
+
notes: zod.z.string().max(1e3).optional()
|
|
438
|
+
});
|
|
439
|
+
var ReviewRequestSchema = zod.z.object({
|
|
440
|
+
terms_accepted: zod.z.boolean().refine((val) => val === true, {
|
|
441
|
+
message: "Terms must be accepted"
|
|
442
|
+
}),
|
|
443
|
+
marketing_consent: zod.z.boolean().optional()
|
|
444
|
+
});
|
|
445
|
+
var PropertySummarySchema = zod.z.object({
|
|
446
|
+
id: zod.z.number(),
|
|
447
|
+
name: zod.z.string(),
|
|
448
|
+
slug: zod.z.string(),
|
|
449
|
+
city: zod.z.string(),
|
|
450
|
+
image: zod.z.string(),
|
|
451
|
+
max_guests: zod.z.number()
|
|
452
|
+
});
|
|
453
|
+
var PriceBreakdownSchema = zod.z.object({
|
|
454
|
+
base_price: zod.z.number(),
|
|
455
|
+
cleaning_fee: zod.z.number(),
|
|
456
|
+
tourist_tax: zod.z.number(),
|
|
457
|
+
vat: zod.z.number(),
|
|
458
|
+
total: zod.z.number()
|
|
459
|
+
});
|
|
460
|
+
var BookingPricingResponseSchema = zod.z.object({
|
|
461
|
+
uuid: zod.z.string().uuid(),
|
|
403
462
|
property_id: zod.z.number(),
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
total_amount: zod.z.number(),
|
|
413
|
-
payment_method: zod.z.enum(["stripe", "cash", "bank_transfer"]).optional()
|
|
463
|
+
arrival: zod.z.string(),
|
|
464
|
+
departure: zod.z.string(),
|
|
465
|
+
amount_adults: zod.z.number(),
|
|
466
|
+
amount_children: zod.z.number(),
|
|
467
|
+
nights: zod.z.number(),
|
|
468
|
+
total_price: zod.z.number(),
|
|
469
|
+
price_per_night: zod.z.number(),
|
|
470
|
+
currency: zod.z.string()
|
|
414
471
|
});
|
|
415
472
|
var BookingResponseSchema = zod.z.object({
|
|
416
|
-
|
|
473
|
+
uuid: zod.z.string().uuid(),
|
|
474
|
+
status: zod.z.enum(["pending_details", "waiting_payment", "fresh", "confirmed", "cancelled", "completed"]),
|
|
417
475
|
property_id: zod.z.number(),
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
476
|
+
property: PropertySummarySchema.optional(),
|
|
477
|
+
arrival: zod.z.string(),
|
|
478
|
+
departure: zod.z.string(),
|
|
479
|
+
amount_adults: zod.z.number(),
|
|
480
|
+
amount_children: zod.z.number(),
|
|
481
|
+
first_name: zod.z.string().nullish(),
|
|
482
|
+
last_name: zod.z.string().nullish(),
|
|
483
|
+
email: zod.z.string().nullish(),
|
|
484
|
+
phone: zod.z.string().nullish(),
|
|
485
|
+
address_1: zod.z.string().nullish(),
|
|
486
|
+
address_2: zod.z.string().nullish(),
|
|
487
|
+
postal_code: zod.z.string().nullish(),
|
|
488
|
+
city: zod.z.string().nullish(),
|
|
489
|
+
country: zod.z.string().nullish(),
|
|
490
|
+
time_arrival: zod.z.string().nullish(),
|
|
491
|
+
flight: zod.z.string().nullish(),
|
|
492
|
+
notes: zod.z.string().nullish(),
|
|
493
|
+
terms_accepted: zod.z.boolean().nullish(),
|
|
494
|
+
marketing_consent: zod.z.boolean().nullish(),
|
|
495
|
+
total_price: zod.z.number(),
|
|
496
|
+
price_breakdown: PriceBreakdownSchema.optional(),
|
|
497
|
+
nights: zod.z.number(),
|
|
498
|
+
expires_at: zod.z.string().nullish(),
|
|
425
499
|
created_at: zod.z.string(),
|
|
426
500
|
updated_at: zod.z.string()
|
|
427
501
|
});
|
|
502
|
+
var BookingConfirmResponseSchema = zod.z.object({
|
|
503
|
+
message: zod.z.string(),
|
|
504
|
+
data: zod.z.object({
|
|
505
|
+
uuid: zod.z.string().uuid(),
|
|
506
|
+
status: zod.z.enum(["pending_details", "waiting_payment", "fresh", "confirmed", "cancelled", "completed"]),
|
|
507
|
+
property_id: zod.z.number(),
|
|
508
|
+
arrival: zod.z.string(),
|
|
509
|
+
departure: zod.z.string(),
|
|
510
|
+
first_name: zod.z.string(),
|
|
511
|
+
last_name: zod.z.string(),
|
|
512
|
+
email: zod.z.string(),
|
|
513
|
+
phone: zod.z.string(),
|
|
514
|
+
address_1: zod.z.string(),
|
|
515
|
+
address_2: zod.z.string().optional(),
|
|
516
|
+
postal_code: zod.z.string().optional(),
|
|
517
|
+
city: zod.z.string(),
|
|
518
|
+
country: zod.z.string(),
|
|
519
|
+
amount_adults: zod.z.number(),
|
|
520
|
+
amount_children: zod.z.number(),
|
|
521
|
+
time_arrival: zod.z.string(),
|
|
522
|
+
flight: zod.z.string().optional(),
|
|
523
|
+
notes: zod.z.string().optional(),
|
|
524
|
+
external_id: zod.z.string().optional(),
|
|
525
|
+
identifier: zod.z.string().optional(),
|
|
526
|
+
balance_due: zod.z.number(),
|
|
527
|
+
created_at: zod.z.string(),
|
|
528
|
+
updated_at: zod.z.string()
|
|
529
|
+
}),
|
|
530
|
+
stripe_url: zod.z.string().optional()
|
|
531
|
+
});
|
|
428
532
|
var MoreApartmentsConfigSchema = zod.z.object({
|
|
429
533
|
baseUrl: zod.z.string().optional(),
|
|
430
534
|
apiKey: zod.z.string().optional(),
|
|
@@ -490,7 +594,6 @@ var MoreApartmentsClient = class {
|
|
|
490
594
|
"Content-Type": "application/json",
|
|
491
595
|
"Accept": "application/json",
|
|
492
596
|
...this.config.apiKey && { "Authorization": `Bearer ${this.config.apiKey}` },
|
|
493
|
-
...this.config.instance && { "X-Instance": this.config.instance },
|
|
494
597
|
...options.headers
|
|
495
598
|
};
|
|
496
599
|
let lastError = null;
|
|
@@ -642,23 +745,123 @@ var MoreApartmentsClient = class {
|
|
|
642
745
|
const response = await this.fetchWithRetry(url, {}, zod.z.object({ data: BookingSettingsSchema }));
|
|
643
746
|
return response.data;
|
|
644
747
|
}
|
|
645
|
-
// Booking endpoints
|
|
646
|
-
|
|
647
|
-
|
|
748
|
+
// Booking endpoints - 3-step wizard flow
|
|
749
|
+
/**
|
|
750
|
+
* Create a booking draft with property and dates
|
|
751
|
+
* @param data Draft booking data (property, dates, guests)
|
|
752
|
+
* @returns BookingDraftResponse with UUID and status
|
|
753
|
+
*/
|
|
754
|
+
async createBookingDraft(data) {
|
|
755
|
+
const url = `${this.config.baseUrl}/api/v1/bookings/draft`;
|
|
648
756
|
const response = await this.fetchWithRetry(
|
|
649
757
|
url,
|
|
650
758
|
{
|
|
651
759
|
method: "POST",
|
|
652
|
-
body: JSON.stringify(
|
|
760
|
+
body: JSON.stringify(data)
|
|
653
761
|
},
|
|
654
|
-
|
|
762
|
+
BookingDraftResponseSchema
|
|
655
763
|
);
|
|
656
|
-
return response
|
|
764
|
+
return response;
|
|
657
765
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
766
|
+
/**
|
|
767
|
+
* Update booking with personal information (Step 1)
|
|
768
|
+
* @param uuid Booking UUID
|
|
769
|
+
* @param data Personal info (name, email, phone, address)
|
|
770
|
+
* @returns Updated BookingResponse
|
|
771
|
+
*/
|
|
772
|
+
async updateBookingStep1(uuid, data) {
|
|
773
|
+
const url = `${this.config.baseUrl}/api/v1/bookings/${uuid}/step-1`;
|
|
774
|
+
const response = await this.fetchWithRetry(
|
|
775
|
+
url,
|
|
776
|
+
{
|
|
777
|
+
method: "PATCH",
|
|
778
|
+
body: JSON.stringify(data)
|
|
779
|
+
},
|
|
780
|
+
BookingResponseSchema
|
|
781
|
+
);
|
|
782
|
+
return response;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Update booking with arrival details (Step 2)
|
|
786
|
+
* @param uuid Booking UUID
|
|
787
|
+
* @param data Arrival time, flight, notes
|
|
788
|
+
* @returns Updated BookingResponse
|
|
789
|
+
*/
|
|
790
|
+
async updateBookingStep2(uuid, data) {
|
|
791
|
+
const url = `${this.config.baseUrl}/api/v1/bookings/${uuid}/step-2`;
|
|
792
|
+
const response = await this.fetchWithRetry(
|
|
793
|
+
url,
|
|
794
|
+
{
|
|
795
|
+
method: "PATCH",
|
|
796
|
+
body: JSON.stringify(data)
|
|
797
|
+
},
|
|
798
|
+
BookingResponseSchema
|
|
799
|
+
);
|
|
800
|
+
return response;
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Update booking with review data (Step 3)
|
|
804
|
+
* @param uuid Booking UUID
|
|
805
|
+
* @param data Terms acceptance, marketing consent
|
|
806
|
+
* @returns Updated BookingResponse with price breakdown
|
|
807
|
+
*/
|
|
808
|
+
async updateBookingStep3(uuid, data) {
|
|
809
|
+
const url = `${this.config.baseUrl}/api/v1/bookings/${uuid}/step-3`;
|
|
810
|
+
const response = await this.fetchWithRetry(
|
|
811
|
+
url,
|
|
812
|
+
{
|
|
813
|
+
method: "PATCH",
|
|
814
|
+
body: JSON.stringify(data)
|
|
815
|
+
},
|
|
816
|
+
BookingResponseSchema
|
|
817
|
+
);
|
|
818
|
+
return response;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Confirm booking and get payment URL
|
|
822
|
+
* @param uuid Booking UUID
|
|
823
|
+
* @param paymentMethod Payment method (stripe, bank_transfer, cash)
|
|
824
|
+
* @returns Confirmation response with payment URL
|
|
825
|
+
*/
|
|
826
|
+
async confirmBooking(uuid, paymentMethod = "stripe") {
|
|
827
|
+
const url = `${this.config.baseUrl}/api/v1/bookings/${uuid}/confirm`;
|
|
828
|
+
const response = await this.fetchWithRetry(
|
|
829
|
+
url,
|
|
830
|
+
{
|
|
831
|
+
method: "POST",
|
|
832
|
+
body: JSON.stringify({ payment_method: paymentMethod })
|
|
833
|
+
},
|
|
834
|
+
BookingConfirmResponseSchema
|
|
835
|
+
);
|
|
836
|
+
return response;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Get current booking state
|
|
840
|
+
* @param uuid Booking UUID
|
|
841
|
+
* @returns Full BookingResponse with all data
|
|
842
|
+
*/
|
|
843
|
+
async getBookingState(uuid) {
|
|
844
|
+
const url = `${this.config.baseUrl}/api/v1/bookings/${uuid}`;
|
|
845
|
+
const response = await this.fetchWithRetry(
|
|
846
|
+
url,
|
|
847
|
+
{ method: "GET" },
|
|
848
|
+
BookingResponseSchema
|
|
849
|
+
);
|
|
850
|
+
return response;
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Get pricing details for a booking
|
|
854
|
+
* @param uuid Booking UUID
|
|
855
|
+
* @returns Pricing breakdown with total, per-night rate, and currency
|
|
856
|
+
*/
|
|
857
|
+
async getPricing(uuid) {
|
|
858
|
+
const url = `${this.config.baseUrl}/api/v1/bookings/${uuid}/pricing`;
|
|
859
|
+
const response = await this.fetchWithRetry(
|
|
860
|
+
url,
|
|
861
|
+
{ method: "GET" },
|
|
862
|
+
BookingPricingResponseSchema
|
|
863
|
+
);
|
|
864
|
+
return response;
|
|
662
865
|
}
|
|
663
866
|
/**
|
|
664
867
|
* Search properties with advanced filtering
|
|
@@ -745,26 +948,26 @@ function moreApartmentsIntegration(options) {
|
|
|
745
948
|
}) => {
|
|
746
949
|
let apiKey = options.apiKey;
|
|
747
950
|
let apiKeySource = "environment variable";
|
|
748
|
-
if (options.
|
|
951
|
+
if (options.projectPath && !apiKey) {
|
|
749
952
|
try {
|
|
750
953
|
const fs = await import('fs');
|
|
751
954
|
const path = await import('path');
|
|
752
|
-
const
|
|
753
|
-
const
|
|
754
|
-
if (fs.existsSync(
|
|
755
|
-
apiKey = fs.readFileSync(
|
|
756
|
-
apiKeySource =
|
|
955
|
+
const resolvedProjectPath = path.resolve(process.cwd(), options.projectPath);
|
|
956
|
+
const tokenPath = path.join(resolvedProjectPath, ".headless-token");
|
|
957
|
+
if (fs.existsSync(tokenPath)) {
|
|
958
|
+
apiKey = fs.readFileSync(tokenPath, "utf-8").trim();
|
|
959
|
+
apiKeySource = `.headless-token`;
|
|
757
960
|
logger.info(`\u2713 Using development API key from ${apiKeySource}`);
|
|
758
961
|
} else {
|
|
759
|
-
logger.warn(`
|
|
962
|
+
logger.warn(`Project directory configured but .headless-token not found at ${resolvedProjectPath}`);
|
|
760
963
|
}
|
|
761
964
|
} catch (error) {
|
|
762
|
-
logger.debug(`Could not read .
|
|
965
|
+
logger.debug(`Could not read .headless-token: ${error}`);
|
|
763
966
|
}
|
|
764
967
|
} else if (apiKey) {
|
|
765
968
|
logger.info(`\u2713 Using API key from ${apiKeySource}`);
|
|
766
969
|
} else {
|
|
767
|
-
logger.warn("\u26A0\uFE0F No API key configured. Set MORE_APARTMENTS_API_KEY or configure
|
|
970
|
+
logger.warn("\u26A0\uFE0F No API key configured. Set MORE_APARTMENTS_API_KEY or configure projectPath for auto-discovery");
|
|
768
971
|
}
|
|
769
972
|
const clientOptions = { ...options, apiKey };
|
|
770
973
|
new MoreApartmentsClient(clientOptions);
|
|
@@ -1016,7 +1219,11 @@ async function searchProperties(client, params) {
|
|
|
1016
1219
|
exports.ApiErrorSchema = ApiErrorSchema;
|
|
1017
1220
|
exports.AvailabilitySchema = AvailabilitySchema;
|
|
1018
1221
|
exports.AvailableDay = AvailableDay;
|
|
1019
|
-
exports.
|
|
1222
|
+
exports.BookingConfirmResponseSchema = BookingConfirmResponseSchema;
|
|
1223
|
+
exports.BookingDetailsRequestSchema = BookingDetailsRequestSchema;
|
|
1224
|
+
exports.BookingDraftRequestSchema = BookingDraftRequestSchema;
|
|
1225
|
+
exports.BookingDraftResponseSchema = BookingDraftResponseSchema;
|
|
1226
|
+
exports.BookingPricingResponseSchema = BookingPricingResponseSchema;
|
|
1020
1227
|
exports.BookingResponseSchema = BookingResponseSchema;
|
|
1021
1228
|
exports.BookingSettingsSchema = BookingSettingsSchema;
|
|
1022
1229
|
exports.CategorySchema = CategorySchema;
|
|
@@ -1028,13 +1235,17 @@ exports.PageSchema = PageSchema;
|
|
|
1028
1235
|
exports.PaginatedResponseSchema = PaginatedResponseSchema;
|
|
1029
1236
|
exports.PaginationLinksSchema = PaginationLinksSchema;
|
|
1030
1237
|
exports.PaginationMetaSchema = PaginationMetaSchema;
|
|
1238
|
+
exports.PersonalInfoRequestSchema = PersonalInfoRequestSchema;
|
|
1031
1239
|
exports.PostSchema = PostSchema;
|
|
1240
|
+
exports.PriceBreakdownSchema = PriceBreakdownSchema;
|
|
1032
1241
|
exports.PropertyImageSchema = PropertyImageSchema;
|
|
1033
1242
|
exports.PropertyPageSettingsSchema = PropertyPageSettingsSchema;
|
|
1034
1243
|
exports.PropertySchema = PropertySchema;
|
|
1035
1244
|
exports.PropertySearchParamsSchema = PropertySearchParamsSchema;
|
|
1036
1245
|
exports.PropertySearchResultSchema = PropertySearchResultSchema;
|
|
1037
1246
|
exports.PropertySettingsSchema = PropertySettingsSchema;
|
|
1247
|
+
exports.PropertySummarySchema = PropertySummarySchema;
|
|
1248
|
+
exports.ReviewRequestSchema = ReviewRequestSchema;
|
|
1038
1249
|
exports.ThemeSettingsSchema = ThemeSettingsSchema;
|
|
1039
1250
|
exports.default = moreApartmentsIntegration;
|
|
1040
1251
|
exports.fetchAvailability = fetchAvailability;
|