arky-sdk 0.3.86 → 0.3.88

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,6 @@
1
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
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, I as mapQuoteError } from './promo-CZi1KfyM.cjs';
4
- export { M as AvailableSlot, R as BuildCalendarOptions, Q as CalendarDay, N as ComputeSlotsOptions, O as OutcastDate, S as ServiceDuration, P as SlotProviderWithTimeline, K as SpecificDate, T as TimelinePoint, J as WorkingDay, W as WorkingHours, L as WorkingTime } from './promo-CZi1KfyM.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 } from './svg-3F_m7296.cjs';
5
4
 
6
5
  interface AuthTokens {
7
6
  accessToken: string;
@@ -59,7 +58,7 @@ interface RunScriptResponse {
59
58
  message: string;
60
59
  }
61
60
 
62
- declare const SDK_VERSION = "0.3.86";
61
+ declare const SDK_VERSION = "0.3.88";
63
62
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
64
63
  interface ApiConfig {
65
64
  httpClient: any;
@@ -269,21 +268,6 @@ declare function createArkySDK(config: HttpClientConfig & {
269
268
  getSvgContentForAstro: typeof getSvgContentForAstro;
270
269
  fetchSvgContent: typeof fetchSvgContent;
271
270
  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;
286
- mapQuoteError: typeof mapQuoteError;
287
271
  };
288
272
  }>;
289
273
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
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
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, I as mapQuoteError } from './promo-gWLL0twu.js';
4
- export { M as AvailableSlot, R as BuildCalendarOptions, Q as CalendarDay, N as ComputeSlotsOptions, O as OutcastDate, S as ServiceDuration, P as SlotProviderWithTimeline, K as SpecificDate, T as TimelinePoint, J as WorkingDay, W as WorkingHours, L as WorkingTime } from './promo-gWLL0twu.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 } from './svg-4hIdMU6f.js';
5
4
 
6
5
  interface AuthTokens {
7
6
  accessToken: string;
@@ -59,7 +58,7 @@ interface RunScriptResponse {
59
58
  message: string;
60
59
  }
61
60
 
62
- declare const SDK_VERSION = "0.3.86";
61
+ declare const SDK_VERSION = "0.3.88";
63
62
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
64
63
  interface ApiConfig {
65
64
  httpClient: any;
@@ -269,21 +268,6 @@ declare function createArkySDK(config: HttpClientConfig & {
269
268
  getSvgContentForAstro: typeof getSvgContentForAstro;
270
269
  fetchSvgContent: typeof fetchSvgContent;
271
270
  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;
286
- mapQuoteError: typeof mapQuoteError;
287
271
  };
288
272
  }>;
289
273
 
package/dist/index.js CHANGED
@@ -1710,186 +1710,8 @@ async function injectSvgIntoElement(mediaObject, targetElement, className) {
1710
1710
  }
1711
1711
  }
1712
1712
 
1713
- // src/utils/time.ts
1714
- function formatTime(ts, tz) {
1715
- return new Date(ts * 1e3).toLocaleTimeString([], {
1716
- hour: "2-digit",
1717
- minute: "2-digit",
1718
- timeZone: tz
1719
- });
1720
- }
1721
- function formatSlotTime(from, to, tz) {
1722
- return `${formatTime(from, tz)} \u2013 ${formatTime(to, tz)}`;
1723
- }
1724
- function getTzOffset(date, tz) {
1725
- const utc = new Date(date.toLocaleString("en-US", { timeZone: "UTC" }));
1726
- const local = new Date(date.toLocaleString("en-US", { timeZone: tz }));
1727
- return (utc.getTime() - local.getTime()) / 6e4;
1728
- }
1729
- function toUtcTimestamp(year, month, day, mins, tz) {
1730
- const midnight = new Date(Date.UTC(year, month - 1, day));
1731
- const offset = getTzOffset(midnight, tz);
1732
- return Math.floor(midnight.getTime() / 1e3) + (mins + offset) * 60;
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
- }
1756
- function isBlocked(from, to, timeline, limit) {
1757
- const before = timeline.filter((p) => p.timestamp <= from).sort((a, b) => b.timestamp - a.timestamp);
1758
- if (before.length > 0 && before[0].concurrent >= limit) return true;
1759
- for (const p of timeline) {
1760
- if (p.timestamp >= from && p.timestamp < to && p.concurrent >= limit) {
1761
- return true;
1762
- }
1763
- }
1764
- return false;
1765
- }
1766
- function getWorkingHoursForDate(wt, date, tz) {
1767
- if (!wt) return [];
1768
- const dayName = date.toLocaleDateString("en-US", { weekday: "long", timeZone: tz }).toLowerCase();
1769
- const m = date.getMonth() + 1;
1770
- const d = date.getDate();
1771
- const ts = Math.floor(date.getTime() / 1e3);
1772
- const specific = wt.specificDates?.find((s) => s.date === ts);
1773
- if (specific) return specific.workingHours || [];
1774
- const outcast = wt.outcastDates?.find((o) => o.month === m && o.day === d);
1775
- if (outcast) return outcast.workingHours || [];
1776
- return wt.workingDays?.find((w) => w.day === dayName)?.workingHours || [];
1777
- }
1778
- function computeSlotsForDate(opts) {
1779
- const { providers, date, durations, timezone, slotInterval } = opts;
1780
- const total = getTotalDuration(durations);
1781
- const interval = slotInterval || total;
1782
- const slots = [];
1783
- const nowTs = Math.floor(Date.now() / 1e3);
1784
- const today = /* @__PURE__ */ new Date();
1785
- today.setHours(0, 0, 0, 0);
1786
- if (date < today) return [];
1787
- const [year, month, day] = date.toLocaleDateString("en-CA", { timeZone: timezone }).split("-").map(Number);
1788
- for (const provider of providers) {
1789
- const workingHours = getWorkingHoursForDate(provider.workingTime, date, timezone);
1790
- for (const wh of workingHours) {
1791
- for (let m = wh.from; m + total <= wh.to; m += interval) {
1792
- const from = toUtcTimestamp(year, month, day, m, timezone);
1793
- const to = from + total * 60;
1794
- if (from < nowTs) continue;
1795
- if (!isBlocked(from, to, provider.timeline, provider.concurrentLimit)) {
1796
- slots.push({ from, to, providerId: provider.id });
1797
- }
1798
- }
1799
- }
1800
- }
1801
- return slots.sort((a, b) => a.from - b.from);
1802
- }
1803
- function hasAvailableSlots(opts) {
1804
- return computeSlotsForDate(opts).length > 0;
1805
- }
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;
1847
- if (startDate && endDate) {
1848
- isInRange = iso > startDate && iso < endDate;
1849
- }
1850
- } else {
1851
- isSelected = iso === selectedDate;
1852
- }
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
- }
1868
-
1869
- // src/utils/promo.ts
1870
- function mapQuoteError(code, fallback) {
1871
- switch (code) {
1872
- case "PROMO.MIN_ORDER":
1873
- return fallback || "Promo requires a higher minimum order.";
1874
- case "PROMO.NOT_ACTIVE":
1875
- return "Promo code is not active.";
1876
- case "PROMO.NOT_YET_VALID":
1877
- return "Promo code is not yet valid.";
1878
- case "PROMO.EXPIRED":
1879
- return "Promo code has expired.";
1880
- case "PROMO.MAX_USES":
1881
- return "Promo code usage limit exceeded.";
1882
- case "PROMO.MAX_USES_PER_USER":
1883
- return "You have already used this promo code.";
1884
- case "PROMO.NOT_FOUND":
1885
- return "Promo code not found.";
1886
- default:
1887
- return fallback || "Failed to fetch quote.";
1888
- }
1889
- }
1890
-
1891
1713
  // src/index.ts
1892
- var SDK_VERSION = "0.3.86";
1714
+ var SDK_VERSION = "0.3.88";
1893
1715
  var SUPPORTED_FRAMEWORKS = [
1894
1716
  "astro",
1895
1717
  "react",
@@ -1990,25 +1812,7 @@ async function createArkySDK(config) {
1990
1812
  // SVG utilities
1991
1813
  getSvgContentForAstro,
1992
1814
  fetchSvgContent,
1993
- injectSvgIntoElement,
1994
- // Time utilities
1995
- formatTime,
1996
- formatSlotTime,
1997
- getTzOffset,
1998
- toUtcTimestamp,
1999
- formatDateDisplay,
2000
- getIsoDate,
2001
- parseIsoDate,
2002
- // Slot computation utilities
2003
- computeSlotsForDate,
2004
- hasAvailableSlots,
2005
- buildCalendar,
2006
- getMonthYear,
2007
- getTotalDuration,
2008
- isBlocked,
2009
- getWorkingHoursForDate,
2010
- // Promo utilities
2011
- mapQuoteError
1815
+ injectSvgIntoElement
2012
1816
  }
2013
1817
  };
2014
1818
  return sdk;