arky-sdk 0.3.83 → 0.3.85

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.cts CHANGED
@@ -1,7 +1,7 @@
1
- import * as nanostores from 'nanostores';
2
- import { ProviderWithTimeline, Slot, UpdateUserProfileParams, RequestOptions, DeleteUserParams, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, UserSubscribeParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, ProcessRefundParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetServiceProvidersParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, CreateFeatureFlagParams, FeatureFlag, GetFeatureFlagParams, GetFeatureFlagsParams, UpdateFeatureFlagParams, DeleteFeatureFlagParams, GetFeatureFlagResultsParams, FlagResults, GetVariantParams, GetVariantResponse, TrackEventParams, TrackEventResponse } from './types.cjs';
3
- export { ApiResponse, Block, Business, BusinessConfig, DayAvailability, EshopCartItem, EshopStoreState, GetAvailabilityParams, GetSlotsForDateParams, Language, Location, Market, Media, MediaResolution, PaginatedResponse, Payment, PaymentMethod, PaymentMethodType, PaymentProviderConfig, Price, PromoCodeValidation, Quote, QuoteLineItem, ReservationCartItem, ReservationStoreState, Seo, ShippingMethod, ShippingWeightTier, Zone } from './types.cjs';
4
- import { e as extractBlockValues, g as getBlockLabel, a as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, b as getMarketPrice, c as getPriceAmount, d as formatPayment, h as formatMinor, i as createPaymentForCheckout, j as getCurrencySymbol, v as validatePhoneNumber, k as findTimeZone, s as slugify, l as humanize, m as categorify, n as formatDate, o as getSvgContentForAstro, q as fetchSvgContent, r as injectSvgIntoElement } from './svg-3F_m7296.cjs';
1
+ import { UpdateUserProfileParams, RequestOptions, DeleteUserParams, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, UserSubscribeParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, ProcessRefundParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, Slot, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetServiceProvidersParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, CreateFeatureFlagParams, FeatureFlag, GetFeatureFlagParams, GetFeatureFlagsParams, UpdateFeatureFlagParams, DeleteFeatureFlagParams, GetFeatureFlagResultsParams, FlagResults, GetVariantParams, GetVariantResponse, TrackEventParams, TrackEventResponse } from './types.cjs';
2
+ export { ApiResponse, Block, Business, BusinessConfig, DayAvailability, EshopCartItem, EshopStoreState, GetAvailabilityParams, GetSlotsForDateParams, Language, Location, Market, Media, MediaResolution, PaginatedResponse, Payment, PaymentMethod, PaymentMethodType, PaymentProviderConfig, Price, PromoCodeValidation, ProviderWithTimeline, Quote, QuoteLineItem, ReservationCartItem, ReservationStoreState, Seo, ShippingMethod, ShippingWeightTier, Zone } from './types.cjs';
3
+ import { e as extractBlockValues, g as getBlockLabel, a as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, b as getMarketPrice, c as getPriceAmount, d as formatPayment, h as formatMinor, i as createPaymentForCheckout, j as getCurrencySymbol, v as validatePhoneNumber, k as findTimeZone, s as slugify, l as humanize, m as categorify, n as formatDate, o as getSvgContentForAstro, q as fetchSvgContent, r as injectSvgIntoElement, t as formatTime, u as formatSlotTime, w as getTzOffset, x as toUtcTimestamp, y as formatDateDisplay, z as getIsoDate, A as parseIsoDate, B as computeSlotsForDate, C as hasAvailableSlots, D as buildCalendar, E as getMonthYear, F as getTotalDuration, G as isBlocked, H as getWorkingHoursForDate } from './time-DPOc8E1C.cjs';
4
+ export { L as AvailableSlot, Q as BuildCalendarOptions, N as CalendarDay, M as ComputeSlotsOptions, O as OutcastDate, S as ServiceDuration, P as SlotProviderWithTimeline, J as SpecificDate, T as TimelinePoint, I as WorkingDay, W as WorkingHours, K as WorkingTime } from './time-DPOc8E1C.cjs';
5
5
 
6
6
  interface AuthTokens {
7
7
  accessToken: string;
@@ -59,35 +59,7 @@ interface RunScriptResponse {
59
59
  message: string;
60
60
  }
61
61
 
62
- interface CalendarDay {
63
- date: Date;
64
- iso: string;
65
- available: boolean;
66
- isSelected: boolean;
67
- isInRange: boolean;
68
- isToday: boolean;
69
- blank: boolean;
70
- }
71
- interface ReservationEngineState {
72
- service: any | null;
73
- providers: ProviderWithTimeline[];
74
- selectedProvider: ProviderWithTimeline | null;
75
- currentMonth: Date;
76
- calendar: CalendarDay[];
77
- selectedDate: string | null;
78
- startDate: string | null;
79
- endDate: string | null;
80
- slots: Slot[];
81
- selectedSlot: Slot | null;
82
- cart: Slot[];
83
- timezone: string;
84
- loading: boolean;
85
- }
86
- interface ReservationEngineConfig {
87
- timezone?: string;
88
- }
89
-
90
- declare const SDK_VERSION = "0.3.83";
62
+ declare const SDK_VERSION = "0.3.85";
91
63
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
92
64
  interface ApiConfig {
93
65
  httpClient: any;
@@ -254,32 +226,6 @@ declare function createArkySDK(config: HttpClientConfig & {
254
226
  getCountries(options?: RequestOptions): Promise<GetCountriesResponse>;
255
227
  getCountryStates(countryCode: string, options?: RequestOptions): Promise<LocationCountry>;
256
228
  };
257
- reservationEngine: (engineConfig?: ReservationEngineConfig) => {
258
- setTimezone(tz: string): void;
259
- setService(serviceId: string): Promise<void>;
260
- loadMonth(): Promise<void>;
261
- prevMonth(): void;
262
- nextMonth(): void;
263
- selectProvider(provider: ProviderWithTimeline | null): void;
264
- selectDate(day: CalendarDay): void;
265
- selectSlot(slot: Slot): void;
266
- findFirstAvailable(): void;
267
- updateCalendar(): void;
268
- addToCart(): void;
269
- removeFromCart(slotId: string): void;
270
- clearCart(): void;
271
- checkout(options?: {
272
- paymentMethod?: string;
273
- blocks?: any[];
274
- promoCode?: string;
275
- }): Promise<any>;
276
- getQuote(options?: {
277
- paymentMethod?: string;
278
- promoCode?: string;
279
- }): Promise<any>;
280
- getProvidersList(): Promise<any[]>;
281
- store: nanostores.PreinitializedMapStore<ReservationEngineState> & object;
282
- };
283
229
  setBusinessId: (businessId: string) => void;
284
230
  getBusinessId: () => string;
285
231
  setMarket: (market: string) => void;
@@ -323,7 +269,21 @@ declare function createArkySDK(config: HttpClientConfig & {
323
269
  getSvgContentForAstro: typeof getSvgContentForAstro;
324
270
  fetchSvgContent: typeof fetchSvgContent;
325
271
  injectSvgIntoElement: typeof injectSvgIntoElement;
272
+ formatTime: typeof formatTime;
273
+ formatSlotTime: typeof formatSlotTime;
274
+ getTzOffset: typeof getTzOffset;
275
+ toUtcTimestamp: typeof toUtcTimestamp;
276
+ formatDateDisplay: typeof formatDateDisplay;
277
+ getIsoDate: typeof getIsoDate;
278
+ parseIsoDate: typeof parseIsoDate;
279
+ computeSlotsForDate: typeof computeSlotsForDate;
280
+ hasAvailableSlots: typeof hasAvailableSlots;
281
+ buildCalendar: typeof buildCalendar;
282
+ getMonthYear: typeof getMonthYear;
283
+ getTotalDuration: typeof getTotalDuration;
284
+ isBlocked: typeof isBlocked;
285
+ getWorkingHoursForDate: typeof getWorkingHoursForDate;
326
286
  };
327
287
  }>;
328
288
 
329
- export { type ApiConfig, type CalendarDay, type GetCountriesResponse, type HttpClientConfig, type LocationCountry, type LocationState, ProviderWithTimeline, type ReservationEngineConfig, type ReservationEngineState, SDK_VERSION, SUPPORTED_FRAMEWORKS, Slot, createArkySDK };
289
+ export { type ApiConfig, type GetCountriesResponse, type HttpClientConfig, type LocationCountry, type LocationState, SDK_VERSION, SUPPORTED_FRAMEWORKS, Slot, createArkySDK };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import * as nanostores from 'nanostores';
2
- import { ProviderWithTimeline, Slot, UpdateUserProfileParams, RequestOptions, DeleteUserParams, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, UserSubscribeParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, ProcessRefundParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetServiceProvidersParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, CreateFeatureFlagParams, FeatureFlag, GetFeatureFlagParams, GetFeatureFlagsParams, UpdateFeatureFlagParams, DeleteFeatureFlagParams, GetFeatureFlagResultsParams, FlagResults, GetVariantParams, GetVariantResponse, TrackEventParams, TrackEventResponse } from './types.js';
3
- export { ApiResponse, Block, Business, BusinessConfig, DayAvailability, EshopCartItem, EshopStoreState, GetAvailabilityParams, GetSlotsForDateParams, Language, Location, Market, Media, MediaResolution, PaginatedResponse, Payment, PaymentMethod, PaymentMethodType, PaymentProviderConfig, Price, PromoCodeValidation, Quote, QuoteLineItem, ReservationCartItem, ReservationStoreState, Seo, ShippingMethod, ShippingWeightTier, Zone } from './types.js';
4
- import { e as extractBlockValues, g as getBlockLabel, a as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, b as getMarketPrice, c as getPriceAmount, d as formatPayment, h as formatMinor, i as createPaymentForCheckout, j as getCurrencySymbol, v as validatePhoneNumber, k as findTimeZone, s as slugify, l as humanize, m as categorify, n as formatDate, o as getSvgContentForAstro, q as fetchSvgContent, r as injectSvgIntoElement } from './svg-4hIdMU6f.js';
1
+ import { UpdateUserProfileParams, RequestOptions, DeleteUserParams, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, UserSubscribeParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, ProcessRefundParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, Slot, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetServiceProvidersParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, CreateFeatureFlagParams, FeatureFlag, GetFeatureFlagParams, GetFeatureFlagsParams, UpdateFeatureFlagParams, DeleteFeatureFlagParams, GetFeatureFlagResultsParams, FlagResults, GetVariantParams, GetVariantResponse, TrackEventParams, TrackEventResponse } from './types.js';
2
+ export { ApiResponse, Block, Business, BusinessConfig, DayAvailability, EshopCartItem, EshopStoreState, GetAvailabilityParams, GetSlotsForDateParams, Language, Location, Market, Media, MediaResolution, PaginatedResponse, Payment, PaymentMethod, PaymentMethodType, PaymentProviderConfig, Price, PromoCodeValidation, ProviderWithTimeline, Quote, QuoteLineItem, ReservationCartItem, ReservationStoreState, Seo, ShippingMethod, ShippingWeightTier, Zone } from './types.js';
3
+ import { e as extractBlockValues, g as getBlockLabel, a as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, b as getMarketPrice, c as getPriceAmount, d as formatPayment, h as formatMinor, i as createPaymentForCheckout, j as getCurrencySymbol, v as validatePhoneNumber, k as findTimeZone, s as slugify, l as humanize, m as categorify, n as formatDate, o as getSvgContentForAstro, q as fetchSvgContent, r as injectSvgIntoElement, t as formatTime, u as formatSlotTime, w as getTzOffset, x as toUtcTimestamp, y as formatDateDisplay, z as getIsoDate, A as parseIsoDate, B as computeSlotsForDate, C as hasAvailableSlots, D as buildCalendar, E as getMonthYear, F as getTotalDuration, G as isBlocked, H as getWorkingHoursForDate } from './time-DAeZRwPk.js';
4
+ export { L as AvailableSlot, Q as BuildCalendarOptions, N as CalendarDay, M as ComputeSlotsOptions, O as OutcastDate, S as ServiceDuration, P as SlotProviderWithTimeline, J as SpecificDate, T as TimelinePoint, I as WorkingDay, W as WorkingHours, K as WorkingTime } from './time-DAeZRwPk.js';
5
5
 
6
6
  interface AuthTokens {
7
7
  accessToken: string;
@@ -59,35 +59,7 @@ interface RunScriptResponse {
59
59
  message: string;
60
60
  }
61
61
 
62
- interface CalendarDay {
63
- date: Date;
64
- iso: string;
65
- available: boolean;
66
- isSelected: boolean;
67
- isInRange: boolean;
68
- isToday: boolean;
69
- blank: boolean;
70
- }
71
- interface ReservationEngineState {
72
- service: any | null;
73
- providers: ProviderWithTimeline[];
74
- selectedProvider: ProviderWithTimeline | null;
75
- currentMonth: Date;
76
- calendar: CalendarDay[];
77
- selectedDate: string | null;
78
- startDate: string | null;
79
- endDate: string | null;
80
- slots: Slot[];
81
- selectedSlot: Slot | null;
82
- cart: Slot[];
83
- timezone: string;
84
- loading: boolean;
85
- }
86
- interface ReservationEngineConfig {
87
- timezone?: string;
88
- }
89
-
90
- declare const SDK_VERSION = "0.3.83";
62
+ declare const SDK_VERSION = "0.3.85";
91
63
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
92
64
  interface ApiConfig {
93
65
  httpClient: any;
@@ -254,32 +226,6 @@ declare function createArkySDK(config: HttpClientConfig & {
254
226
  getCountries(options?: RequestOptions): Promise<GetCountriesResponse>;
255
227
  getCountryStates(countryCode: string, options?: RequestOptions): Promise<LocationCountry>;
256
228
  };
257
- reservationEngine: (engineConfig?: ReservationEngineConfig) => {
258
- setTimezone(tz: string): void;
259
- setService(serviceId: string): Promise<void>;
260
- loadMonth(): Promise<void>;
261
- prevMonth(): void;
262
- nextMonth(): void;
263
- selectProvider(provider: ProviderWithTimeline | null): void;
264
- selectDate(day: CalendarDay): void;
265
- selectSlot(slot: Slot): void;
266
- findFirstAvailable(): void;
267
- updateCalendar(): void;
268
- addToCart(): void;
269
- removeFromCart(slotId: string): void;
270
- clearCart(): void;
271
- checkout(options?: {
272
- paymentMethod?: string;
273
- blocks?: any[];
274
- promoCode?: string;
275
- }): Promise<any>;
276
- getQuote(options?: {
277
- paymentMethod?: string;
278
- promoCode?: string;
279
- }): Promise<any>;
280
- getProvidersList(): Promise<any[]>;
281
- store: nanostores.PreinitializedMapStore<ReservationEngineState> & object;
282
- };
283
229
  setBusinessId: (businessId: string) => void;
284
230
  getBusinessId: () => string;
285
231
  setMarket: (market: string) => void;
@@ -323,7 +269,21 @@ declare function createArkySDK(config: HttpClientConfig & {
323
269
  getSvgContentForAstro: typeof getSvgContentForAstro;
324
270
  fetchSvgContent: typeof fetchSvgContent;
325
271
  injectSvgIntoElement: typeof injectSvgIntoElement;
272
+ formatTime: typeof formatTime;
273
+ formatSlotTime: typeof formatSlotTime;
274
+ getTzOffset: typeof getTzOffset;
275
+ toUtcTimestamp: typeof toUtcTimestamp;
276
+ formatDateDisplay: typeof formatDateDisplay;
277
+ getIsoDate: typeof getIsoDate;
278
+ parseIsoDate: typeof parseIsoDate;
279
+ computeSlotsForDate: typeof computeSlotsForDate;
280
+ hasAvailableSlots: typeof hasAvailableSlots;
281
+ buildCalendar: typeof buildCalendar;
282
+ getMonthYear: typeof getMonthYear;
283
+ getTotalDuration: typeof getTotalDuration;
284
+ isBlocked: typeof isBlocked;
285
+ getWorkingHoursForDate: typeof getWorkingHoursForDate;
326
286
  };
327
287
  }>;
328
288
 
329
- export { type ApiConfig, type CalendarDay, type GetCountriesResponse, type HttpClientConfig, type LocationCountry, type LocationState, ProviderWithTimeline, type ReservationEngineConfig, type ReservationEngineState, SDK_VERSION, SUPPORTED_FRAMEWORKS, Slot, createArkySDK };
289
+ export { type ApiConfig, type GetCountriesResponse, type HttpClientConfig, type LocationCountry, type LocationState, SDK_VERSION, SUPPORTED_FRAMEWORKS, Slot, createArkySDK };
package/dist/index.js CHANGED
@@ -1,5 +1,3 @@
1
- import { map } from 'nanostores';
2
-
3
1
  // src/types/index.ts
4
2
  var PaymentMethodType = /* @__PURE__ */ ((PaymentMethodType2) => {
5
3
  PaymentMethodType2["Cash"] = "CASH";
@@ -1711,6 +1709,8 @@ async function injectSvgIntoElement(mediaObject, targetElement, className) {
1711
1709
  console.error("Error injecting SVG:", error);
1712
1710
  }
1713
1711
  }
1712
+
1713
+ // src/utils/time.ts
1714
1714
  function formatTime(ts, tz) {
1715
1715
  return new Date(ts * 1e3).toLocaleTimeString([], {
1716
1716
  hour: "2-digit",
@@ -1731,17 +1731,38 @@ function toUtcTimestamp(year, month, day, mins, tz) {
1731
1731
  const offset = getTzOffset(midnight, tz);
1732
1732
  return Math.floor(midnight.getTime() / 1e3) + (mins + offset) * 60;
1733
1733
  }
1734
+ function formatDateDisplay(dateStr, tz) {
1735
+ if (!dateStr) return "";
1736
+ const date = /* @__PURE__ */ new Date(dateStr + "T00:00:00");
1737
+ return date.toLocaleDateString("en-US", {
1738
+ weekday: "short",
1739
+ month: "short",
1740
+ day: "numeric",
1741
+ timeZone: tz
1742
+ });
1743
+ }
1744
+ function getIsoDate(date, tz) {
1745
+ return date.toLocaleDateString("en-CA", { timeZone: tz });
1746
+ }
1747
+ function parseIsoDate(isoDate) {
1748
+ const [year, month, day] = isoDate.split("-").map(Number);
1749
+ return { year, month, day };
1750
+ }
1751
+
1752
+ // src/utils/slots.ts
1753
+ function getTotalDuration(durations) {
1754
+ return durations.reduce((sum, d) => sum + d.duration, 0);
1755
+ }
1734
1756
  function isBlocked(from, to, timeline, limit) {
1735
1757
  const before = timeline.filter((p) => p.timestamp <= from).sort((a, b) => b.timestamp - a.timestamp);
1736
1758
  if (before.length > 0 && before[0].concurrent >= limit) return true;
1737
1759
  for (const p of timeline) {
1738
- if (p.timestamp >= from && p.timestamp < to && p.concurrent >= limit) return true;
1760
+ if (p.timestamp >= from && p.timestamp < to && p.concurrent >= limit) {
1761
+ return true;
1762
+ }
1739
1763
  }
1740
1764
  return false;
1741
1765
  }
1742
- function getTotalDuration(durations) {
1743
- return durations.reduce((sum, d) => sum + d.duration, 0);
1744
- }
1745
1766
  function getWorkingHoursForDate(wt, date, tz) {
1746
1767
  if (!wt) return [];
1747
1768
  const dayName = date.toLocaleDateString("en-US", { weekday: "long", timeZone: tz }).toLowerCase();
@@ -1764,14 +1785,15 @@ function computeSlotsForDate(opts) {
1764
1785
  today.setHours(0, 0, 0, 0);
1765
1786
  if (date < today) return [];
1766
1787
  const [year, month, day] = date.toLocaleDateString("en-CA", { timeZone: timezone }).split("-").map(Number);
1767
- for (const p of providers) {
1768
- for (const wh of getWorkingHoursForDate(p.workingTime, date, timezone)) {
1788
+ for (const provider of providers) {
1789
+ const workingHours = getWorkingHoursForDate(provider.workingTime, date, timezone);
1790
+ for (const wh of workingHours) {
1769
1791
  for (let m = wh.from; m + total <= wh.to; m += interval) {
1770
1792
  const from = toUtcTimestamp(year, month, day, m, timezone);
1771
1793
  const to = from + total * 60;
1772
1794
  if (from < nowTs) continue;
1773
- if (!isBlocked(from, to, p.timeline, p.concurrentLimit)) {
1774
- slots.push({ from, to, providerId: p.id });
1795
+ if (!isBlocked(from, to, provider.timeline, provider.concurrentLimit)) {
1796
+ slots.push({ from, to, providerId: provider.id });
1775
1797
  }
1776
1798
  }
1777
1799
  }
@@ -1781,240 +1803,71 @@ function computeSlotsForDate(opts) {
1781
1803
  function hasAvailableSlots(opts) {
1782
1804
  return computeSlotsForDate(opts).length > 0;
1783
1805
  }
1784
- var createInitialState = (timezone) => ({
1785
- service: null,
1786
- providers: [],
1787
- selectedProvider: null,
1788
- currentMonth: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
1789
- calendar: [],
1790
- selectedDate: null,
1791
- startDate: null,
1792
- endDate: null,
1793
- slots: [],
1794
- selectedSlot: null,
1795
- cart: [],
1796
- timezone,
1797
- loading: false
1798
- });
1799
- var createReservationEngine = (api, config = {}) => {
1800
- const timezone = config.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone;
1801
- const store = map(createInitialState(timezone));
1802
- const getServiceDurations = () => {
1803
- const state = store.get();
1804
- if (!state.service?.durations?.length) return [{ duration: 60, isPause: false }];
1805
- return state.service.durations.map((d) => ({
1806
- duration: d.duration,
1807
- isPause: d.isPause || d.is_pause || false
1808
- }));
1809
- };
1810
- const buildCalendar = () => {
1811
- const state = store.get();
1812
- const { currentMonth, selectedDate, startDate, endDate, providers, selectedProvider, timezone: timezone2 } = state;
1813
- const year = currentMonth.getFullYear();
1814
- const month = currentMonth.getMonth();
1815
- const first = new Date(year, month, 1);
1816
- const last = new Date(year, month + 1, 0);
1817
- const today = /* @__PURE__ */ new Date();
1818
- today.setHours(0, 0, 0, 0);
1819
- const cells = [];
1820
- const pad = (first.getDay() + 6) % 7;
1821
- for (let i = 0; i < pad; i++) {
1822
- cells.push({ date: /* @__PURE__ */ new Date(0), iso: "", available: false, isSelected: false, isInRange: false, isToday: false, blank: true });
1823
- }
1824
- const activeProviders = selectedProvider ? providers.filter((p) => p.id === selectedProvider.id) : providers;
1825
- const durations = getServiceDurations();
1826
- for (let d = 1; d <= last.getDate(); d++) {
1827
- const date = new Date(year, month, d);
1828
- const iso = `${year}-${String(month + 1).padStart(2, "0")}-${String(d).padStart(2, "0")}`;
1829
- const available = activeProviders.length > 0 && hasAvailableSlots({ providers: activeProviders, date, durations, timezone: timezone2 });
1830
- const isToday = date.getTime() === today.getTime();
1831
- const isSelected = iso === selectedDate || iso === startDate || iso === endDate;
1832
- let isInRange = false;
1806
+ function buildCalendar(opts) {
1807
+ const {
1808
+ currentMonth,
1809
+ selectedDate,
1810
+ startDate,
1811
+ endDate,
1812
+ providers,
1813
+ selectedProvider,
1814
+ durations,
1815
+ timezone,
1816
+ isMultiDay
1817
+ } = opts;
1818
+ const year = currentMonth.getFullYear();
1819
+ const month = currentMonth.getMonth();
1820
+ const first = new Date(year, month, 1);
1821
+ const last = new Date(year, month + 1, 0);
1822
+ const today = /* @__PURE__ */ new Date();
1823
+ today.setHours(0, 0, 0, 0);
1824
+ const cells = [];
1825
+ const pad = (first.getDay() + 6) % 7;
1826
+ for (let i = 0; i < pad; i++) {
1827
+ cells.push({
1828
+ date: /* @__PURE__ */ new Date(0),
1829
+ iso: "",
1830
+ available: false,
1831
+ isSelected: false,
1832
+ isInRange: false,
1833
+ isToday: false,
1834
+ blank: true
1835
+ });
1836
+ }
1837
+ const activeProviders = selectedProvider ? providers.filter((p) => p.id === selectedProvider.id) : providers;
1838
+ for (let d = 1; d <= last.getDate(); d++) {
1839
+ const date = new Date(year, month, d);
1840
+ const iso = `${year}-${String(month + 1).padStart(2, "0")}-${String(d).padStart(2, "0")}`;
1841
+ const available = activeProviders.length > 0 && hasAvailableSlots({ providers: activeProviders, date, durations, timezone });
1842
+ const isToday = date.getTime() === today.getTime();
1843
+ let isSelected = false;
1844
+ let isInRange = false;
1845
+ if (isMultiDay) {
1846
+ isSelected = iso === startDate || iso === endDate;
1833
1847
  if (startDate && endDate) {
1834
- const t = date.getTime();
1835
- isInRange = t > new Date(startDate).getTime() && t < new Date(endDate).getTime();
1836
- }
1837
- cells.push({ date, iso, available, isSelected, isInRange, isToday, blank: false });
1838
- }
1839
- const suffix = (7 - cells.length % 7) % 7;
1840
- for (let i = 0; i < suffix; i++) {
1841
- cells.push({ date: /* @__PURE__ */ new Date(0), iso: "", available: false, isSelected: false, isInRange: false, isToday: false, blank: true });
1842
- }
1843
- return cells;
1844
- };
1845
- const computeSlots = (dateStr) => {
1846
- const state = store.get();
1847
- const { providers, selectedProvider, timezone: timezone2, service } = state;
1848
- const date = /* @__PURE__ */ new Date(dateStr + "T00:00:00");
1849
- const activeProviders = selectedProvider ? providers.filter((p) => p.id === selectedProvider.id) : providers;
1850
- const raw = computeSlotsForDate({ providers: activeProviders, date, durations: getServiceDurations(), timezone: timezone2 });
1851
- return raw.map((s, i) => ({
1852
- id: `${service?.id}-${s.from}-${i}`,
1853
- serviceId: service?.id || "",
1854
- providerId: s.providerId,
1855
- from: s.from,
1856
- to: s.to,
1857
- timeText: formatSlotTime(s.from, s.to, timezone2),
1858
- dateText: new Date(s.from * 1e3).toLocaleDateString([], { weekday: "short", month: "short", day: "numeric", timeZone: timezone2 })
1859
- }));
1860
- };
1861
- const actions = {
1862
- setTimezone(tz) {
1863
- store.setKey("timezone", tz);
1864
- store.setKey("calendar", buildCalendar());
1865
- const state = store.get();
1866
- if (state.selectedDate) {
1867
- store.setKey("slots", computeSlots(state.selectedDate));
1868
- store.setKey("selectedSlot", null);
1869
- }
1870
- },
1871
- async setService(serviceId) {
1872
- store.setKey("loading", true);
1873
- try {
1874
- const service = await api.getService({ id: serviceId });
1875
- store.set({
1876
- ...store.get(),
1877
- service,
1878
- selectedProvider: null,
1879
- providers: [],
1880
- selectedDate: null,
1881
- startDate: null,
1882
- endDate: null,
1883
- slots: [],
1884
- selectedSlot: null,
1885
- currentMonth: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
1886
- loading: false
1887
- });
1888
- await actions.loadMonth();
1889
- } catch (e) {
1890
- store.setKey("loading", false);
1891
- throw e;
1892
- }
1893
- },
1894
- async loadMonth() {
1895
- const state = store.get();
1896
- if (!state.service) return;
1897
- store.setKey("loading", true);
1898
- try {
1899
- const { currentMonth, service } = state;
1900
- const year = currentMonth.getFullYear();
1901
- const month = currentMonth.getMonth();
1902
- const from = Math.floor(new Date(year, month, 1).getTime() / 1e3);
1903
- const to = Math.floor(new Date(year, month + 1, 0, 23, 59, 59).getTime() / 1e3);
1904
- const providers = await api.getServiceProviders({ serviceId: service.id, from, to });
1905
- store.setKey("providers", providers || []);
1906
- store.setKey("calendar", buildCalendar());
1907
- } finally {
1908
- store.setKey("loading", false);
1909
- }
1910
- },
1911
- prevMonth() {
1912
- const { currentMonth } = store.get();
1913
- store.setKey("currentMonth", new Date(currentMonth.getFullYear(), currentMonth.getMonth() - 1, 1));
1914
- actions.loadMonth();
1915
- },
1916
- nextMonth() {
1917
- const { currentMonth } = store.get();
1918
- store.setKey("currentMonth", new Date(currentMonth.getFullYear(), currentMonth.getMonth() + 1, 1));
1919
- actions.loadMonth();
1920
- },
1921
- selectProvider(provider) {
1922
- store.set({
1923
- ...store.get(),
1924
- selectedProvider: provider,
1925
- selectedDate: null,
1926
- startDate: null,
1927
- endDate: null,
1928
- slots: [],
1929
- selectedSlot: null
1930
- });
1931
- store.setKey("calendar", buildCalendar());
1932
- },
1933
- selectDate(day) {
1934
- if (day.blank || !day.available) return;
1935
- const state = store.get();
1936
- const slots = computeSlots(day.iso);
1937
- store.set({ ...state, selectedDate: day.iso, slots, selectedSlot: null });
1938
- store.setKey("calendar", buildCalendar());
1939
- },
1940
- selectSlot(slot) {
1941
- store.setKey("selectedSlot", slot);
1942
- },
1943
- findFirstAvailable() {
1944
- const state = store.get();
1945
- for (const day of state.calendar) {
1946
- if (!day.blank && day.available) {
1947
- actions.selectDate(day);
1948
- return;
1949
- }
1950
- }
1951
- },
1952
- updateCalendar() {
1953
- store.setKey("calendar", buildCalendar());
1954
- },
1955
- addToCart() {
1956
- const state = store.get();
1957
- if (!state.selectedSlot) return;
1958
- store.set({
1959
- ...state,
1960
- cart: [...state.cart, state.selectedSlot],
1961
- selectedDate: null,
1962
- startDate: null,
1963
- endDate: null,
1964
- slots: [],
1965
- selectedSlot: null
1966
- });
1967
- store.setKey("calendar", buildCalendar());
1968
- },
1969
- removeFromCart(slotId) {
1970
- const state = store.get();
1971
- store.setKey("cart", state.cart.filter((s) => s.id !== slotId));
1972
- },
1973
- clearCart() {
1974
- store.setKey("cart", []);
1975
- },
1976
- async checkout(options = {}) {
1977
- const state = store.get();
1978
- if (!state.cart.length) throw new Error("Cart is empty");
1979
- store.setKey("loading", true);
1980
- try {
1981
- return api.checkout({
1982
- items: state.cart.map((s) => ({
1983
- serviceId: s.serviceId,
1984
- providerId: s.providerId,
1985
- from: s.from,
1986
- to: s.to,
1987
- blocks: s.serviceBlocks || []
1988
- })),
1989
- paymentMethod: options.paymentMethod,
1990
- promoCode: options.promoCode ?? null,
1991
- blocks: options.blocks || []
1992
- });
1993
- } finally {
1994
- store.setKey("loading", false);
1848
+ isInRange = iso > startDate && iso < endDate;
1995
1849
  }
1996
- },
1997
- async getQuote(options = {}) {
1998
- const state = store.get();
1999
- if (!state.cart.length) return null;
2000
- return api.getQuote({
2001
- items: state.cart.map((s) => ({ serviceId: s.serviceId })),
2002
- paymentMethod: options.paymentMethod || "CASH",
2003
- promoCode: options.promoCode
2004
- });
2005
- },
2006
- async getProvidersList() {
2007
- const state = store.get();
2008
- if (!state.service) return [];
2009
- const response = await api.getProviders({ serviceId: state.service.id, limit: 100 });
2010
- return response?.items || [];
1850
+ } else {
1851
+ isSelected = iso === selectedDate;
2011
1852
  }
2012
- };
2013
- return { store, ...actions };
2014
- };
1853
+ cells.push({
1854
+ date,
1855
+ iso,
1856
+ available,
1857
+ isSelected,
1858
+ isInRange,
1859
+ isToday,
1860
+ blank: false
1861
+ });
1862
+ }
1863
+ return cells;
1864
+ }
1865
+ function getMonthYear(date) {
1866
+ return date.toLocaleDateString("en-US", { month: "long", year: "numeric" });
1867
+ }
2015
1868
 
2016
1869
  // src/index.ts
2017
- var SDK_VERSION = "0.3.83";
1870
+ var SDK_VERSION = "0.3.85";
2018
1871
  var SUPPORTED_FRAMEWORKS = [
2019
1872
  "astro",
2020
1873
  "react",
@@ -2065,11 +1918,6 @@ async function createArkySDK(config) {
2065
1918
  database: createDatabaseApi(apiConfig),
2066
1919
  featureFlags: createFeatureFlagsApi(apiConfig),
2067
1920
  location: createLocationApi(apiConfig),
2068
- // High-level reservation engine
2069
- reservationEngine: (engineConfig) => {
2070
- const reservationApi = createReservationApi(apiConfig);
2071
- return createReservationEngine(reservationApi, engineConfig);
2072
- },
2073
1921
  setBusinessId: (businessId) => {
2074
1922
  apiConfig.businessId = businessId;
2075
1923
  },
@@ -2120,7 +1968,23 @@ async function createArkySDK(config) {
2120
1968
  // SVG utilities
2121
1969
  getSvgContentForAstro,
2122
1970
  fetchSvgContent,
2123
- injectSvgIntoElement
1971
+ injectSvgIntoElement,
1972
+ // Time utilities
1973
+ formatTime,
1974
+ formatSlotTime,
1975
+ getTzOffset,
1976
+ toUtcTimestamp,
1977
+ formatDateDisplay,
1978
+ getIsoDate,
1979
+ parseIsoDate,
1980
+ // Slot computation utilities
1981
+ computeSlotsForDate,
1982
+ hasAvailableSlots,
1983
+ buildCalendar,
1984
+ getMonthYear,
1985
+ getTotalDuration,
1986
+ isBlocked,
1987
+ getWorkingHoursForDate
2124
1988
  }
2125
1989
  };
2126
1990
  return sdk;