arky-sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/config-CPkOgumU.d.cts +16 -0
  2. package/dist/config-CPkOgumU.d.ts +16 -0
  3. package/dist/index.cjs +1517 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +268 -0
  6. package/dist/index.d.ts +268 -26
  7. package/dist/index.js +1457 -56
  8. package/dist/index.js.map +1 -0
  9. package/dist/stores.cjs +2148 -0
  10. package/dist/stores.cjs.map +1 -0
  11. package/dist/stores.d.cts +218 -0
  12. package/dist/stores.d.ts +218 -0
  13. package/dist/stores.js +2111 -0
  14. package/dist/stores.js.map +1 -0
  15. package/dist/types.cjs +13 -0
  16. package/dist/types.cjs.map +1 -0
  17. package/dist/{types/index.d.ts → types.d.cts} +25 -24
  18. package/dist/types.d.ts +245 -0
  19. package/dist/types.js +11 -0
  20. package/dist/types.js.map +1 -0
  21. package/dist/utils.cjs +725 -0
  22. package/dist/utils.cjs.map +1 -0
  23. package/dist/utils.d.cts +9 -0
  24. package/dist/utils.d.ts +9 -0
  25. package/dist/utils.js +680 -0
  26. package/dist/utils.js.map +1 -0
  27. package/dist/validation-C9UAYKke.d.cts +245 -0
  28. package/dist/validation-DIvAzYjG.d.ts +245 -0
  29. package/package.json +17 -11
  30. package/dist/api/cms.d.ts +0 -19
  31. package/dist/api/cms.d.ts.map +0 -1
  32. package/dist/api/cms.js +0 -41
  33. package/dist/api/eshop.d.ts +0 -89
  34. package/dist/api/eshop.d.ts.map +0 -1
  35. package/dist/api/eshop.js +0 -183
  36. package/dist/api/index.d.ts +0 -6
  37. package/dist/api/index.d.ts.map +0 -1
  38. package/dist/api/index.js +0 -5
  39. package/dist/api/newsletter.d.ts +0 -32
  40. package/dist/api/newsletter.d.ts.map +0 -1
  41. package/dist/api/newsletter.js +0 -70
  42. package/dist/api/reservation.d.ts +0 -84
  43. package/dist/api/reservation.d.ts.map +0 -1
  44. package/dist/api/reservation.js +0 -239
  45. package/dist/config.d.ts +0 -15
  46. package/dist/config.d.ts.map +0 -1
  47. package/dist/config.js +0 -20
  48. package/dist/index.d.ts.map +0 -1
  49. package/dist/services/auth.d.ts +0 -17
  50. package/dist/services/auth.d.ts.map +0 -1
  51. package/dist/services/auth.js +0 -62
  52. package/dist/services/http.d.ts +0 -20
  53. package/dist/services/http.d.ts.map +0 -1
  54. package/dist/services/http.js +0 -73
  55. package/dist/stores/business.d.ts +0 -28
  56. package/dist/stores/business.d.ts.map +0 -1
  57. package/dist/stores/business.js +0 -122
  58. package/dist/stores/cart.d.ts +0 -8
  59. package/dist/stores/cart.d.ts.map +0 -1
  60. package/dist/stores/cart.js +0 -20
  61. package/dist/stores/eshop.d.ts +0 -121
  62. package/dist/stores/eshop.d.ts.map +0 -1
  63. package/dist/stores/eshop.js +0 -377
  64. package/dist/stores/index.d.ts +0 -7
  65. package/dist/stores/index.d.ts.map +0 -1
  66. package/dist/stores/index.js +0 -19
  67. package/dist/stores/reservation.d.ts +0 -237
  68. package/dist/stores/reservation.d.ts.map +0 -1
  69. package/dist/stores/reservation.js +0 -853
  70. package/dist/types/index.d.ts.map +0 -1
  71. package/dist/types/index.js +0 -8
  72. package/dist/utils/blocks.d.ts +0 -30
  73. package/dist/utils/blocks.d.ts.map +0 -1
  74. package/dist/utils/blocks.js +0 -237
  75. package/dist/utils/currency.d.ts +0 -9
  76. package/dist/utils/currency.d.ts.map +0 -1
  77. package/dist/utils/currency.js +0 -99
  78. package/dist/utils/errors.d.ts +0 -121
  79. package/dist/utils/errors.d.ts.map +0 -1
  80. package/dist/utils/errors.js +0 -114
  81. package/dist/utils/i18n.d.ts +0 -5
  82. package/dist/utils/i18n.d.ts.map +0 -1
  83. package/dist/utils/i18n.js +0 -37
  84. package/dist/utils/index.d.ts +0 -9
  85. package/dist/utils/index.d.ts.map +0 -1
  86. package/dist/utils/index.js +0 -10
  87. package/dist/utils/price.d.ts +0 -33
  88. package/dist/utils/price.d.ts.map +0 -1
  89. package/dist/utils/price.js +0 -141
  90. package/dist/utils/queryParams.d.ts +0 -21
  91. package/dist/utils/queryParams.d.ts.map +0 -1
  92. package/dist/utils/queryParams.js +0 -47
  93. package/dist/utils/svg.d.ts +0 -17
  94. package/dist/utils/svg.d.ts.map +0 -1
  95. package/dist/utils/svg.js +0 -62
  96. package/dist/utils/text.d.ts +0 -26
  97. package/dist/utils/text.d.ts.map +0 -1
  98. package/dist/utils/text.js +0 -64
  99. package/dist/utils/timezone.d.ts +0 -9
  100. package/dist/utils/timezone.d.ts.map +0 -1
  101. package/dist/utils/timezone.js +0 -49
  102. package/dist/utils/validation.d.ts +0 -9
  103. package/dist/utils/validation.d.ts.map +0 -1
  104. package/dist/utils/validation.js +0 -44
@@ -1,37 +0,0 @@
1
- // Simple i18n utilities for SDK
2
- // Can be enhanced or replaced by user's i18n library
3
- let defaultLocale = 'en';
4
- export function setDefaultLocale(locale) {
5
- defaultLocale = locale;
6
- }
7
- export function getLocale() {
8
- // Try to get from browser if available
9
- if (typeof window !== 'undefined' && window.navigator) {
10
- return window.navigator.language.split('-')[0] || defaultLocale;
11
- }
12
- return defaultLocale;
13
- }
14
- export function getLocaleFromUrl(url) {
15
- // Simple implementation - can be enhanced
16
- const pathParts = url.pathname.split('/').filter(Boolean);
17
- const potentialLocale = pathParts[0];
18
- // Common locale codes
19
- const validLocales = ['en', 'fr', 'es', 'de', 'it', 'pt', 'ja', 'zh', 'ko', 'ru'];
20
- if (potentialLocale && validLocales.includes(potentialLocale)) {
21
- return potentialLocale;
22
- }
23
- return getLocale();
24
- }
25
- export function getLocalizedString(value, locale) {
26
- if (!value)
27
- return '';
28
- // If it's already a string, return it
29
- if (typeof value === 'string')
30
- return value;
31
- // If it's an object with locale keys
32
- if (typeof value === 'object') {
33
- const targetLocale = locale || getLocale();
34
- return value[targetLocale] || value['en'] || value[Object.keys(value)[0]] || '';
35
- }
36
- return String(value);
37
- }
@@ -1,9 +0,0 @@
1
- export * from './blocks';
2
- export * from './errors';
3
- export * from './price';
4
- export * from './svg';
5
- export * from './text';
6
- export * from './timezone';
7
- export * from './validation';
8
- export { getCurrencySymbol } from './currency';
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,10 +0,0 @@
1
- // Utilities entry point (@arky/sdk/utils)
2
- export * from './blocks';
3
- export * from './errors';
4
- export * from './price';
5
- export * from './svg';
6
- export * from './text';
7
- export * from './timezone';
8
- export * from './validation';
9
- // Export specific functions from currency to avoid conflicts with price.ts
10
- export { getCurrencySymbol } from './currency';
@@ -1,33 +0,0 @@
1
- import type { Payment, Price } from '../types';
2
- export declare function convertToMajor(minorAmount: number): number;
3
- export declare function convertToMinor(majorAmount: number): number;
4
- export declare function getSymbol(currency: string): string;
5
- export declare function getCurrencyFromMarket(marketId: string): string;
6
- export declare function formatCurrencyAmount(amount: number, currency: string, options?: {
7
- showSymbols?: boolean;
8
- decimalPlaces?: number;
9
- customSymbol?: string;
10
- }): string;
11
- export declare function formatMinor(amountMinor: number, currency: string, options?: {
12
- showSymbols?: boolean;
13
- decimalPlaces?: number;
14
- customSymbol?: string;
15
- }): string;
16
- export declare function formatPayment(payment: Payment, options?: {
17
- showSymbols?: boolean;
18
- decimalPlaces?: number;
19
- showBreakdown?: boolean;
20
- }): string;
21
- export declare function getMarketPrice(prices: Price[], marketId: string, businessMarkets?: any[], options?: {
22
- showSymbols?: boolean;
23
- decimalPlaces?: number;
24
- showCompareAt?: boolean;
25
- fallbackMarket?: string;
26
- }): string;
27
- export declare function getPriceAmount(prices: Price[], marketId: string, fallbackMarket?: string): number;
28
- export declare function createPaymentForCheckout(subtotalMinor: number, marketId: string, currency: string, paymentMethod: any, options?: {
29
- discount?: number;
30
- tax?: number;
31
- promoCodeId?: string;
32
- }): Payment;
33
- //# sourceMappingURL=price.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../src/utils/price.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAqB9D,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE1D;AAGD,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE1D;AAGD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElD;AAGD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9D;AAGD,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IACL,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACpB,GACP,MAAM,CAUR;AAGD,wBAAgB,WAAW,CACvB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IACL,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACpB,GACP,MAAM,CAGR;AAGD,wBAAgB,aAAa,CACzB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE;IACL,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACtB,GACP,MAAM,CAmBR;AAGD,wBAAgB,cAAc,CAC1B,MAAM,EAAE,KAAK,EAAE,EACf,QAAQ,EAAE,MAAM,EAChB,eAAe,CAAC,EAAE,GAAG,EAAE,EACvB,OAAO,GAAE;IACL,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACtB,GACP,MAAM,CAwDR;AAGD,wBAAgB,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,GAAE,MAAa,GAAG,MAAM,CASvG;AAGD,wBAAgB,wBAAwB,CACpC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,GAAG,EAClB,OAAO,GAAE;IACL,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACnB,GACP,OAAO,CAeT"}
@@ -1,141 +0,0 @@
1
- import { getCurrencySymbol } from './currency';
2
- // Market-based currency symbols mapping
3
- const CURRENCY_SYMBOLS = {
4
- 'USD': '$',
5
- 'EUR': '€',
6
- 'GBP': '£',
7
- 'CAD': 'C$',
8
- 'AUD': 'A$'
9
- };
10
- const MARKET_CURRENCIES = {
11
- 'US': 'USD',
12
- 'EU': 'EUR',
13
- 'UK': 'GBP',
14
- 'CA': 'CAD',
15
- 'AU': 'AUD'
16
- };
17
- // Convert minor units (cents) to major units (dollars)
18
- export function convertToMajor(minorAmount) {
19
- return (minorAmount ?? 0) / 100;
20
- }
21
- // Convert major units to minor units
22
- export function convertToMinor(majorAmount) {
23
- return Math.round((majorAmount ?? 0) * 100);
24
- }
25
- // Get currency symbol from currency code
26
- export function getSymbol(currency) {
27
- return CURRENCY_SYMBOLS[currency] || '$';
28
- }
29
- // Get currency from market ID
30
- export function getCurrencyFromMarket(marketId) {
31
- return MARKET_CURRENCIES[marketId] || 'USD';
32
- }
33
- // Format currency amount with symbol
34
- export function formatCurrencyAmount(amount, currency, options = {}) {
35
- const { showSymbols = true, decimalPlaces = 2, customSymbol } = options;
36
- const roundedAmount = amount.toFixed(decimalPlaces);
37
- if (!showSymbols) {
38
- return `${roundedAmount} ${currency}`;
39
- }
40
- const symbol = customSymbol || getSymbol(currency);
41
- return `${symbol}${roundedAmount}`;
42
- }
43
- // Format minor units with currency
44
- export function formatMinor(amountMinor, currency, options = {}) {
45
- const major = convertToMajor(amountMinor);
46
- return formatCurrencyAmount(major, currency, options);
47
- }
48
- // Format Payment structure for display
49
- export function formatPayment(payment, options = {}) {
50
- if (!payment)
51
- return '';
52
- const { showSymbols = true, decimalPlaces = 2, showBreakdown = false } = options;
53
- if (showBreakdown) {
54
- const subtotal = formatMinor(payment.subtotal, payment.currency, { showSymbols, decimalPlaces });
55
- const discount = (payment.discount ?? 0) > 0 ? formatMinor(payment.discount, payment.currency, { showSymbols, decimalPlaces }) : null;
56
- const tax = (payment.tax ?? 0) > 0 ? formatMinor(payment.tax, payment.currency, { showSymbols, decimalPlaces }) : null;
57
- const total = formatMinor(payment.total, payment.currency, { showSymbols, decimalPlaces });
58
- let result = `Subtotal: ${subtotal}`;
59
- if (discount)
60
- result += `, Discount: -${discount}`;
61
- if (tax)
62
- result += `, Tax: ${tax}`;
63
- result += `, Total: ${total}`;
64
- return result;
65
- }
66
- return formatMinor(payment.total, payment.currency, { showSymbols, decimalPlaces });
67
- }
68
- // Format market-based prices (from product variants)
69
- export function getMarketPrice(prices, marketId, businessMarkets, options = {}) {
70
- if (!prices || prices.length === 0)
71
- return '';
72
- const { showSymbols = true, decimalPlaces = 2, showCompareAt = true, fallbackMarket = 'US', } = options;
73
- // Find price for the specific market
74
- let price = prices.find(p => p.market === marketId);
75
- // Fallback to first available or fallback market
76
- if (!price) {
77
- price = prices.find(p => p.market === fallbackMarket) || prices[0];
78
- }
79
- if (!price)
80
- return '';
81
- let currency;
82
- let symbol;
83
- // If we have business markets, use the currency directly from market data
84
- if (businessMarkets) {
85
- const marketData = businessMarkets.find(m => m.id === price.market || m.code === price.market);
86
- if (marketData?.currency) {
87
- currency = marketData.currency;
88
- symbol = getCurrencySymbol(currency);
89
- }
90
- else {
91
- currency = getCurrencyFromMarket(price.market);
92
- symbol = getSymbol(currency);
93
- }
94
- }
95
- else {
96
- currency = getCurrencyFromMarket(price.market);
97
- symbol = getSymbol(currency);
98
- }
99
- // Format price with custom symbol
100
- const formattedPrice = formatMinor(price.amount ?? 0, currency, {
101
- showSymbols,
102
- decimalPlaces,
103
- customSymbol: symbol
104
- });
105
- // Add compare-at price if available
106
- if (showCompareAt && price.compareAt && price.compareAt > (price.amount ?? 0)) {
107
- const formattedCompareAt = formatMinor(price.compareAt, currency, {
108
- showSymbols,
109
- decimalPlaces,
110
- customSymbol: symbol
111
- });
112
- return `${formattedPrice} was ${formattedCompareAt}`;
113
- }
114
- return formattedPrice;
115
- }
116
- // Get price amount from market-based prices (for calculations)
117
- export function getPriceAmount(prices, marketId, fallbackMarket = 'US') {
118
- if (!prices || prices.length === 0)
119
- return 0;
120
- const price = prices.find(p => p.market === marketId) ||
121
- prices.find(p => p.market === fallbackMarket) ||
122
- prices[0];
123
- // Amounts are stored in minor units (e.g., cents)
124
- return price?.amount || 0;
125
- }
126
- // Create Payment structure for checkout (all amounts in minor units)
127
- export function createPaymentForCheckout(subtotalMinor, marketId, currency, paymentMethod, options = {}) {
128
- const { discount = 0, tax = 0, promoCodeId } = options;
129
- const total = subtotalMinor - discount + tax;
130
- return {
131
- currency,
132
- market: marketId,
133
- subtotal: subtotalMinor,
134
- shipping: 0,
135
- discount,
136
- tax,
137
- total,
138
- promoCodeId,
139
- method: paymentMethod,
140
- };
141
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Query parameter builder utility that maintains exact backward compatibility
3
- * with existing API parameter encoding patterns
4
- */
5
- export interface QueryParams {
6
- [key: string]: string | number | boolean | string[] | number[] | null | undefined;
7
- }
8
- /**
9
- * Builds a query string from parameters following the exact encoding patterns
10
- * used by the existing API implementation:
11
- * - Arrays: JSON.stringify then encodeURIComponent
12
- * - Strings: encodeURIComponent
13
- * - Numbers: No encoding
14
- * - Null/undefined: Skip
15
- */
16
- export declare function buildQueryString(params: QueryParams): string;
17
- /**
18
- * Appends query string to a URL
19
- */
20
- export declare function appendQueryString(url: string, params: QueryParams): string;
21
- //# sourceMappingURL=queryParams.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queryParams.d.ts","sourceRoot":"","sources":["../../src/utils/queryParams.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;CACrF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CA8B5D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAG1E"}
@@ -1,47 +0,0 @@
1
- /**
2
- * Query parameter builder utility that maintains exact backward compatibility
3
- * with existing API parameter encoding patterns
4
- */
5
- /**
6
- * Builds a query string from parameters following the exact encoding patterns
7
- * used by the existing API implementation:
8
- * - Arrays: JSON.stringify then encodeURIComponent
9
- * - Strings: encodeURIComponent
10
- * - Numbers: No encoding
11
- * - Null/undefined: Skip
12
- */
13
- export function buildQueryString(params) {
14
- const queryParts = [];
15
- Object.entries(params).forEach(([key, value]) => {
16
- // Skip null and undefined values
17
- if (value === null || value === undefined) {
18
- return;
19
- }
20
- // Handle arrays: JSON.stringify then encode
21
- if (Array.isArray(value)) {
22
- const jsonString = JSON.stringify(value);
23
- queryParts.push(`${key}=${encodeURIComponent(jsonString)}`);
24
- }
25
- // Handle strings: encode
26
- else if (typeof value === 'string') {
27
- queryParts.push(`${key}=${encodeURIComponent(value)}`);
28
- }
29
- // Handle numbers and booleans: no encoding
30
- else if (typeof value === 'number' || typeof value === 'boolean') {
31
- queryParts.push(`${key}=${value}`);
32
- }
33
- // Handle objects (in case needed in future): JSON.stringify then encode
34
- else if (typeof value === 'object') {
35
- const jsonString = JSON.stringify(value);
36
- queryParts.push(`${key}=${encodeURIComponent(jsonString)}`);
37
- }
38
- });
39
- return queryParts.length > 0 ? `?${queryParts.join('&')}` : '';
40
- }
41
- /**
42
- * Appends query string to a URL
43
- */
44
- export function appendQueryString(url, params) {
45
- const queryString = buildQueryString(params);
46
- return queryString ? `${url}${queryString}` : url;
47
- }
@@ -1,17 +0,0 @@
1
- export declare function fetchSvgContent(mediaObject: any): Promise<string | null>;
2
- /**
3
- * Server-side helper for Astro components to fetch SVG content during SSR
4
- *
5
- * @param mediaObject The media object from the CMS
6
- * @returns The SVG content as a string, or empty string on failure
7
- */
8
- export declare function getSvgContentForAstro(mediaObject: any): Promise<string>;
9
- /**
10
- * Client-side helper to fetch and inject SVG content into DOM elements
11
- *
12
- * @param mediaObject The media object from the CMS
13
- * @param targetElement The DOM element to inject the SVG into
14
- * @param className Optional CSS class to add to the SVG
15
- */
16
- export declare function injectSvgIntoElement(mediaObject: any, targetElement: HTMLElement, className?: string): Promise<void>;
17
- //# sourceMappingURL=svg.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../src/utils/svg.ts"],"names":[],"mappings":"AAEA,wBAAsB,eAAe,CAAC,WAAW,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmB9E;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ7E;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACzC,WAAW,EAAE,GAAG,EAChB,aAAa,EAAE,WAAW,EAC1B,SAAS,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAoBf"}
package/dist/utils/svg.js DELETED
@@ -1,62 +0,0 @@
1
- import { getImageUrl } from "./blocks";
2
- export async function fetchSvgContent(mediaObject) {
3
- if (!mediaObject)
4
- return null;
5
- const svgUrl = getImageUrl(mediaObject, false);
6
- try {
7
- const response = await fetch(svgUrl);
8
- if (!response.ok) {
9
- console.error(`Failed to fetch SVG: ${response.status} ${response.statusText}`);
10
- return null;
11
- }
12
- const svgContent = await response.text();
13
- return svgContent;
14
- }
15
- catch (error) {
16
- console.error("Error fetching SVG:", error);
17
- return null;
18
- }
19
- }
20
- /**
21
- * Server-side helper for Astro components to fetch SVG content during SSR
22
- *
23
- * @param mediaObject The media object from the CMS
24
- * @returns The SVG content as a string, or empty string on failure
25
- */
26
- export async function getSvgContentForAstro(mediaObject) {
27
- try {
28
- const svgContent = await fetchSvgContent(mediaObject);
29
- return svgContent || "";
30
- }
31
- catch (error) {
32
- console.error("Error getting SVG content for Astro:", error);
33
- return "";
34
- }
35
- }
36
- /**
37
- * Client-side helper to fetch and inject SVG content into DOM elements
38
- *
39
- * @param mediaObject The media object from the CMS
40
- * @param targetElement The DOM element to inject the SVG into
41
- * @param className Optional CSS class to add to the SVG
42
- */
43
- export async function injectSvgIntoElement(mediaObject, targetElement, className) {
44
- if (!targetElement)
45
- return;
46
- try {
47
- const svgContent = await fetchSvgContent(mediaObject);
48
- if (svgContent) {
49
- targetElement.innerHTML = svgContent;
50
- // Add class if provided
51
- if (className) {
52
- const svgElement = targetElement.querySelector("svg");
53
- if (svgElement) {
54
- svgElement.classList.add(...className.split(" "));
55
- }
56
- }
57
- }
58
- }
59
- catch (error) {
60
- console.error("Error injecting SVG:", error);
61
- }
62
- }
@@ -1,26 +0,0 @@
1
- declare const locales: readonly ["en", "sr-latn"];
2
- /**
3
- * * returns "slugified" text.
4
- * @param text: string - text to slugify
5
- */
6
- export declare function slugify(text: string): string;
7
- /**
8
- * * returns "humanized" text. runs slugify() and then replaces - with space and upper case first letter of every word, and lower case the rest
9
- * @param text: string - text to humanize
10
- */
11
- export declare function humanize(text: string): string;
12
- /**
13
- * * returns "categorified" text. runs slugify() and then replaces - with space and upper cases everything
14
- * @param text: string - text to categorify
15
- * @returns string - categorified text
16
- */
17
- export declare function categorify(text: string): string;
18
- /**
19
- * * returns a nicely formatted string of the date passed
20
- * @param date: string | number | Date - date to format
21
- * @param locale: string - locale to format the date in
22
- * @returns string - formatted date
23
- */
24
- export declare function formatDate(date: string | number | Date, locale: (typeof locales)[number]): string;
25
- export {};
26
- //# sourceMappingURL=text.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,OAAO,4BAA6B,CAAC;AAM3C;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY7C;AAGD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/C;AAGD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAajG"}
@@ -1,64 +0,0 @@
1
- // Define locales inline since we don't have @lib/i18n in SDK
2
- const locales = ['en', 'sr-latn'];
3
- const localeMap = {
4
- 'en': 'en-US',
5
- 'sr-latn': 'sr-RS'
6
- };
7
- /**
8
- * * returns "slugified" text.
9
- * @param text: string - text to slugify
10
- */
11
- export function slugify(text) {
12
- return text
13
- .toString()
14
- .toLowerCase() // convert to lowercase
15
- .replace(/\s+/g, "-") // replace spaces with -
16
- .replace(/[^\w-]+/g, "") // remove all non-word chars
17
- .replace(/--+/g, "-") // replace multiple dashes with single dash
18
- .replace(/^-+/, "") // trim dash from start of text
19
- .replace(/-+$/, ""); // trim dash from end of text
20
- }
21
- /**
22
- * * returns "humanized" text. runs slugify() and then replaces - with space and upper case first letter of every word, and lower case the rest
23
- * @param text: string - text to humanize
24
- */
25
- export function humanize(text) {
26
- const slugifiedText = slugify(text);
27
- return (slugifiedText
28
- .replace(/-/g, " ") // replace "-" with space
29
- // .toLowerCase();
30
- .replace(
31
- // upper case first letter of every word, and lower case the rest
32
- /\w\S*/g, (w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()));
33
- }
34
- // --------------------------------------------------------
35
- /**
36
- * * returns "categorified" text. runs slugify() and then replaces - with space and upper cases everything
37
- * @param text: string - text to categorify
38
- * @returns string - categorified text
39
- */
40
- export function categorify(text) {
41
- const slugifiedText = slugify(text);
42
- return slugifiedText
43
- .replace(/-/g, " ") // replace "-" with space
44
- .toUpperCase();
45
- }
46
- // --------------------------------------------------------
47
- /**
48
- * * returns a nicely formatted string of the date passed
49
- * @param date: string | number | Date - date to format
50
- * @param locale: string - locale to format the date in
51
- * @returns string - formatted date
52
- */
53
- export function formatDate(date, locale) {
54
- let localeString = "en-US";
55
- if (locales.includes(locale)) {
56
- localeString = localeMap[locale];
57
- }
58
- return new Date(date).toLocaleDateString(localeString, {
59
- timeZone: "UTC",
60
- year: "numeric",
61
- month: "short",
62
- day: "numeric",
63
- });
64
- }
@@ -1,9 +0,0 @@
1
- export declare const tzGroups: {
2
- label: string;
3
- zones: {
4
- label: string;
5
- value: string;
6
- }[];
7
- }[];
8
- export declare function findTimeZone(groups: typeof tzGroups): string;
9
- //# sourceMappingURL=timezone.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/utils/timezone.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;;;;;GA4BpB,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,QAAQ,GAAG,MAAM,CAmB5D"}
@@ -1,49 +0,0 @@
1
- // Timezone utilities (moved from Reservation folder)
2
- export const tzGroups = [
3
- {
4
- label: "US",
5
- zones: [
6
- { label: "Eastern Time", value: "America/New_York" },
7
- { label: "Central Time", value: "America/Chicago" },
8
- { label: "Mountain Time", value: "America/Denver" },
9
- { label: "Pacific Time", value: "America/Los_Angeles" },
10
- ],
11
- },
12
- {
13
- label: "Europe",
14
- zones: [
15
- { label: "London", value: "Europe/London" },
16
- { label: "Paris", value: "Europe/Paris" },
17
- { label: "Berlin", value: "Europe/Berlin" },
18
- { label: "Rome", value: "Europe/Rome" },
19
- ],
20
- },
21
- {
22
- label: "Asia",
23
- zones: [
24
- { label: "Tokyo", value: "Asia/Tokyo" },
25
- { label: "Shanghai", value: "Asia/Shanghai" },
26
- { label: "Mumbai", value: "Asia/Kolkata" },
27
- { label: "Dubai", value: "Asia/Dubai" },
28
- ],
29
- },
30
- ];
31
- export function findTimeZone(groups) {
32
- try {
33
- const detected = Intl.DateTimeFormat().resolvedOptions().timeZone;
34
- // Check if detected timezone is in our list
35
- for (const group of groups) {
36
- for (const zone of group.zones) {
37
- if (zone.value === detected) {
38
- return detected;
39
- }
40
- }
41
- }
42
- // Fallback to UTC if not found
43
- return "UTC";
44
- }
45
- catch (e) {
46
- // Fallback to UTC if detection fails
47
- return "UTC";
48
- }
49
- }
@@ -1,9 +0,0 @@
1
- export interface ValidationResult {
2
- isValid: boolean;
3
- error?: string;
4
- }
5
- export declare function validatePhoneNumber(phone: string): ValidationResult;
6
- export declare function validateEmail(email: string): ValidationResult;
7
- export declare function validateVerificationCode(code: string): ValidationResult;
8
- export declare function validateRequired(value: any, fieldName?: string): ValidationResult;
9
- //# sourceMappingURL=validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAgBnE;AAGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAY7D;AAGD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAYvE;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,GAAE,MAAqB,GAAG,gBAAgB,CAM/F"}
@@ -1,44 +0,0 @@
1
- // Validation utilities
2
- // Phone number validation
3
- export function validatePhoneNumber(phone) {
4
- if (!phone) {
5
- return { isValid: false, error: 'Phone number is required' };
6
- }
7
- const cleaned = phone.replace(/\D/g, '');
8
- if (cleaned.length < 8) {
9
- return { isValid: false, error: 'Phone number is too short' };
10
- }
11
- if (cleaned.length > 15) {
12
- return { isValid: false, error: 'Phone number is too long' };
13
- }
14
- return { isValid: true };
15
- }
16
- // Email validation
17
- export function validateEmail(email) {
18
- if (!email) {
19
- return { isValid: false, error: 'Email is required' };
20
- }
21
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
22
- if (!emailRegex.test(email)) {
23
- return { isValid: false, error: 'Please enter a valid email address' };
24
- }
25
- return { isValid: true };
26
- }
27
- // Verification code validation (4-digit codes)
28
- export function validateVerificationCode(code) {
29
- if (!code) {
30
- return { isValid: false, error: 'Verification code is required' };
31
- }
32
- const cleaned = code.replace(/\D/g, '');
33
- if (cleaned.length !== 4) {
34
- return { isValid: false, error: 'Please enter a 4-digit verification code' };
35
- }
36
- return { isValid: true };
37
- }
38
- // Generic required field validation
39
- export function validateRequired(value, fieldName = 'This field') {
40
- if (value === null || value === undefined || value === '') {
41
- return { isValid: false, error: `${fieldName} is required` };
42
- }
43
- return { isValid: true };
44
- }