arky-sdk 0.3.8 → 0.3.9
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.cjs +232 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +232 -2
- package/dist/index.js.map +1 -1
- package/dist/{timezone-Cnh6zsAn.d.ts → svg-BhIM4HZW.d.ts} +43 -1
- package/dist/{timezone-Ctc3v4hK.d.cts → svg-CFjyTGXu.d.cts} +43 -1
- package/dist/utils.d.cts +2 -44
- package/dist/utils.d.ts +2 -44
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UpdateUserProfileParams, RequestOptions, UpdateProfilePhoneParams, VerifyPhoneCodeParams, GetUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionParams, CreateSubscriptionParams, UpdateSubscriptionParams, CancelSubscriptionParams, ReactivateSubscriptionParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, GetNotificationsParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, GetAnalyticsHealthParams, SetupAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, CreateProductParams, UpdateProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, GetReservationPartsParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetAvailableSlotsParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, NewsletterFindParams, NewsletterGetParams, CreateNewsletterParams, UpdateNewsletterParams, DeleteNewsletterParams, GetSubscribersParams, NewsletterSubscribeParams, UnsubscribeParams, HandleStripeWebhookParams, GetBusinessMarketsParams, GetBusinessMarketParams } from './types.cjs';
|
|
2
2
|
export { ApiResponse, Block, Business, EshopCartItem, EshopStoreState, Price, ReservationCartPart, ReservationStoreState } from './types.cjs';
|
|
3
|
-
import { g as getGalleryThumbnail, a as
|
|
3
|
+
import { g as getGalleryThumbnail, a as getBlockLabel, b as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, e as extractBlockValues, c as getMarketPrice, d as getPriceAmount, h as formatPayment, i as formatMinor, j as createPaymentForCheckout, k as getCurrencySymbol, v as validatePhoneNumber, l as findTimeZone, s as slugify, m as humanize, n as categorify, o as formatDate, q as getSvgContentForAstro, r as fetchSvgContent, t as injectSvgIntoElement } from './svg-CFjyTGXu.cjs';
|
|
4
4
|
|
|
5
5
|
interface AuthTokens {
|
|
6
6
|
accessToken: string;
|
|
@@ -26,7 +26,7 @@ interface HttpClientConfig {
|
|
|
26
26
|
isAuthenticated?: () => boolean;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
declare const SDK_VERSION = "0.3.
|
|
29
|
+
declare const SDK_VERSION = "0.3.9";
|
|
30
30
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
31
31
|
interface ApiConfig {
|
|
32
32
|
httpClient: any;
|
|
@@ -200,6 +200,15 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
200
200
|
getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
|
|
201
201
|
thumbnailUrl: (service: any) => string;
|
|
202
202
|
getGalleryThumbnail: typeof getGalleryThumbnail;
|
|
203
|
+
getBlockValue: (entry: any, blockKey: string) => any;
|
|
204
|
+
getBlockValues: (entry: any, blockKey: string) => any;
|
|
205
|
+
getBlockLabel: typeof getBlockLabel;
|
|
206
|
+
getBlockTextValue: typeof getBlockTextValue;
|
|
207
|
+
getBlockObjectValues: (entry: any, blockKey: string, locale?: string) => any;
|
|
208
|
+
getBlockFromArray: (entry: any, blockKey: string, locale?: string) => any;
|
|
209
|
+
formatBlockValue: typeof formatBlockValue;
|
|
210
|
+
prepareBlocksForSubmission: typeof prepareBlocksForSubmission;
|
|
211
|
+
extractBlockValues: typeof extractBlockValues;
|
|
203
212
|
getMarketPrice: typeof getMarketPrice;
|
|
204
213
|
getPriceAmount: typeof getPriceAmount;
|
|
205
214
|
formatPayment: typeof formatPayment;
|
|
@@ -215,6 +224,13 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
215
224
|
}[];
|
|
216
225
|
}[];
|
|
217
226
|
findTimeZone: typeof findTimeZone;
|
|
227
|
+
slugify: typeof slugify;
|
|
228
|
+
humanize: typeof humanize;
|
|
229
|
+
categorify: typeof categorify;
|
|
230
|
+
formatDate: typeof formatDate;
|
|
231
|
+
getSvgContentForAstro: typeof getSvgContentForAstro;
|
|
232
|
+
fetchSvgContent: typeof fetchSvgContent;
|
|
233
|
+
injectSvgIntoElement: typeof injectSvgIntoElement;
|
|
218
234
|
};
|
|
219
235
|
};
|
|
220
236
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UpdateUserProfileParams, RequestOptions, UpdateProfilePhoneParams, VerifyPhoneCodeParams, GetUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionParams, CreateSubscriptionParams, UpdateSubscriptionParams, CancelSubscriptionParams, ReactivateSubscriptionParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, GetNotificationsParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, GetAnalyticsHealthParams, SetupAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, CreateProductParams, UpdateProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, GetReservationPartsParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetAvailableSlotsParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, NewsletterFindParams, NewsletterGetParams, CreateNewsletterParams, UpdateNewsletterParams, DeleteNewsletterParams, GetSubscribersParams, NewsletterSubscribeParams, UnsubscribeParams, HandleStripeWebhookParams, GetBusinessMarketsParams, GetBusinessMarketParams } from './types.js';
|
|
2
2
|
export { ApiResponse, Block, Business, EshopCartItem, EshopStoreState, Price, ReservationCartPart, ReservationStoreState } from './types.js';
|
|
3
|
-
import { g as getGalleryThumbnail, a as
|
|
3
|
+
import { g as getGalleryThumbnail, a as getBlockLabel, b as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, e as extractBlockValues, c as getMarketPrice, d as getPriceAmount, h as formatPayment, i as formatMinor, j as createPaymentForCheckout, k as getCurrencySymbol, v as validatePhoneNumber, l as findTimeZone, s as slugify, m as humanize, n as categorify, o as formatDate, q as getSvgContentForAstro, r as fetchSvgContent, t as injectSvgIntoElement } from './svg-BhIM4HZW.js';
|
|
4
4
|
|
|
5
5
|
interface AuthTokens {
|
|
6
6
|
accessToken: string;
|
|
@@ -26,7 +26,7 @@ interface HttpClientConfig {
|
|
|
26
26
|
isAuthenticated?: () => boolean;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
declare const SDK_VERSION = "0.3.
|
|
29
|
+
declare const SDK_VERSION = "0.3.9";
|
|
30
30
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
31
31
|
interface ApiConfig {
|
|
32
32
|
httpClient: any;
|
|
@@ -200,6 +200,15 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
200
200
|
getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
|
|
201
201
|
thumbnailUrl: (service: any) => string;
|
|
202
202
|
getGalleryThumbnail: typeof getGalleryThumbnail;
|
|
203
|
+
getBlockValue: (entry: any, blockKey: string) => any;
|
|
204
|
+
getBlockValues: (entry: any, blockKey: string) => any;
|
|
205
|
+
getBlockLabel: typeof getBlockLabel;
|
|
206
|
+
getBlockTextValue: typeof getBlockTextValue;
|
|
207
|
+
getBlockObjectValues: (entry: any, blockKey: string, locale?: string) => any;
|
|
208
|
+
getBlockFromArray: (entry: any, blockKey: string, locale?: string) => any;
|
|
209
|
+
formatBlockValue: typeof formatBlockValue;
|
|
210
|
+
prepareBlocksForSubmission: typeof prepareBlocksForSubmission;
|
|
211
|
+
extractBlockValues: typeof extractBlockValues;
|
|
203
212
|
getMarketPrice: typeof getMarketPrice;
|
|
204
213
|
getPriceAmount: typeof getPriceAmount;
|
|
205
214
|
formatPayment: typeof formatPayment;
|
|
@@ -215,6 +224,13 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
215
224
|
}[];
|
|
216
225
|
}[];
|
|
217
226
|
findTimeZone: typeof findTimeZone;
|
|
227
|
+
slugify: typeof slugify;
|
|
228
|
+
humanize: typeof humanize;
|
|
229
|
+
categorify: typeof categorify;
|
|
230
|
+
formatDate: typeof formatDate;
|
|
231
|
+
getSvgContentForAstro: typeof getSvgContentForAstro;
|
|
232
|
+
fetchSvgContent: typeof fetchSvgContent;
|
|
233
|
+
injectSvgIntoElement: typeof injectSvgIntoElement;
|
|
218
234
|
};
|
|
219
235
|
};
|
|
220
236
|
|
package/dist/index.js
CHANGED
|
@@ -1039,6 +1039,135 @@ var createPaymentApi = (apiConfig) => {
|
|
|
1039
1039
|
};
|
|
1040
1040
|
|
|
1041
1041
|
// src/utils/blocks.ts
|
|
1042
|
+
function getBlockLabel(block, locale = "en") {
|
|
1043
|
+
if (!block) return "";
|
|
1044
|
+
if (block.properties?.label) {
|
|
1045
|
+
if (typeof block.properties.label === "object") {
|
|
1046
|
+
return block.properties.label[locale] || block.properties.label.en || Object.values(block.properties.label)[0] || "";
|
|
1047
|
+
}
|
|
1048
|
+
if (typeof block.properties.label === "string") {
|
|
1049
|
+
return block.properties.label;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) || "";
|
|
1053
|
+
}
|
|
1054
|
+
function formatBlockValue(block) {
|
|
1055
|
+
if (!block || block.value === null || block.value === void 0) {
|
|
1056
|
+
return "";
|
|
1057
|
+
}
|
|
1058
|
+
switch (block.type) {
|
|
1059
|
+
case "BOOLEAN":
|
|
1060
|
+
return block.value ? "Yes" : "No";
|
|
1061
|
+
case "NUMBER":
|
|
1062
|
+
if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
|
|
1063
|
+
try {
|
|
1064
|
+
return new Date(block.value).toLocaleDateString();
|
|
1065
|
+
} catch (e) {
|
|
1066
|
+
return String(block.value);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
return String(block.value);
|
|
1070
|
+
case "RELATIONSHIP":
|
|
1071
|
+
if (Array.isArray(block.value) && block.value.length > 0) {
|
|
1072
|
+
const firstValue = block.value[0];
|
|
1073
|
+
if (firstValue && firstValue.mimeType) {
|
|
1074
|
+
return firstValue.name || firstValue.id || "Media";
|
|
1075
|
+
}
|
|
1076
|
+
return firstValue.title || firstValue.name || firstValue.id || "Entry";
|
|
1077
|
+
}
|
|
1078
|
+
return String(block.value);
|
|
1079
|
+
default:
|
|
1080
|
+
return String(block.value);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
function prepareBlocksForSubmission(formData) {
|
|
1084
|
+
const preparedBlocks = [];
|
|
1085
|
+
Object.keys(formData).forEach((key) => {
|
|
1086
|
+
if (formData[key] !== null && formData[key] !== void 0) {
|
|
1087
|
+
preparedBlocks.push({
|
|
1088
|
+
key,
|
|
1089
|
+
value: [formData[key]]
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
return preparedBlocks;
|
|
1094
|
+
}
|
|
1095
|
+
function extractBlockValues(blocks) {
|
|
1096
|
+
const values = {};
|
|
1097
|
+
blocks.forEach((block) => {
|
|
1098
|
+
if (block.value && block.value.length > 0) {
|
|
1099
|
+
values[block.key] = block.value[0];
|
|
1100
|
+
} else {
|
|
1101
|
+
values[block.key] = null;
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
return values;
|
|
1105
|
+
}
|
|
1106
|
+
function getBlockTextValue(block, locale = "en") {
|
|
1107
|
+
if (!block || !block.value || block.value.length === 0) return "";
|
|
1108
|
+
const firstValue = block.value[0];
|
|
1109
|
+
if (typeof firstValue === "object" && firstValue !== null) {
|
|
1110
|
+
if (firstValue[locale]) return firstValue[locale];
|
|
1111
|
+
if (firstValue.en) return firstValue.en;
|
|
1112
|
+
const values = Object.values(firstValue);
|
|
1113
|
+
return String(values[0] || "");
|
|
1114
|
+
}
|
|
1115
|
+
return String(firstValue);
|
|
1116
|
+
}
|
|
1117
|
+
var getBlockValue = (entry, blockKey) => {
|
|
1118
|
+
if (!entry || !entry.blocks) return null;
|
|
1119
|
+
const block = entry.blocks.find((f) => f.key === blockKey);
|
|
1120
|
+
if (!block || !block.value || block.value.length === 0) return null;
|
|
1121
|
+
return block.value[0];
|
|
1122
|
+
};
|
|
1123
|
+
var getBlockValues = (entry, blockKey) => {
|
|
1124
|
+
if (!entry || !entry.blocks) return null;
|
|
1125
|
+
const block = entry.blocks.find((f) => f.key === blockKey);
|
|
1126
|
+
if (!block || !block.value || block.value.length === 0) return null;
|
|
1127
|
+
return block.value;
|
|
1128
|
+
};
|
|
1129
|
+
function unwrapBlock(block, locale) {
|
|
1130
|
+
if (!block?.type || block.value === void 0) return block;
|
|
1131
|
+
if (block.type === "BLOCK") {
|
|
1132
|
+
return block.value.map((obj) => {
|
|
1133
|
+
const parsed = {};
|
|
1134
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
1135
|
+
parsed[k] = unwrapBlock(v, locale);
|
|
1136
|
+
}
|
|
1137
|
+
return parsed;
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
const isLocalized = block.type === "TEXT";
|
|
1141
|
+
const isList = block.properties?.ui === "list" || (block.properties?.maxValues ?? 1) > 1 || block.value.length > 1;
|
|
1142
|
+
if (isList) {
|
|
1143
|
+
return isLocalized ? block.value.map((v) => v[locale] || v["en"]) : [...block.value];
|
|
1144
|
+
}
|
|
1145
|
+
return isLocalized ? block.value[0][locale] || block.value[0]["en"] : block.value[0];
|
|
1146
|
+
}
|
|
1147
|
+
var getBlockObjectValues = (entry, blockKey, locale = "en") => {
|
|
1148
|
+
if (!entry) {
|
|
1149
|
+
return [];
|
|
1150
|
+
}
|
|
1151
|
+
const values = getBlockValues(entry, blockKey);
|
|
1152
|
+
const parsed = values.map((obj) => {
|
|
1153
|
+
const res = obj.value.reduce((acc, current) => {
|
|
1154
|
+
acc[current.key] = unwrapBlock(current, locale);
|
|
1155
|
+
return acc;
|
|
1156
|
+
}, {});
|
|
1157
|
+
return res;
|
|
1158
|
+
});
|
|
1159
|
+
return parsed;
|
|
1160
|
+
};
|
|
1161
|
+
var getBlockFromArray = (entry, blockKey, locale = "en") => {
|
|
1162
|
+
if (!entry) {
|
|
1163
|
+
return [];
|
|
1164
|
+
}
|
|
1165
|
+
const values = getBlockValues(entry, blockKey);
|
|
1166
|
+
return values.reduce((acc, current) => {
|
|
1167
|
+
acc[current.key] = unwrapBlock(current, locale);
|
|
1168
|
+
return acc;
|
|
1169
|
+
});
|
|
1170
|
+
};
|
|
1042
1171
|
var getImageUrl = (imageBlock, isBlock = true, storageUrl = "https://storage.arky.io/dev") => {
|
|
1043
1172
|
if (!imageBlock) return null;
|
|
1044
1173
|
const isExternalUrl = (url) => {
|
|
@@ -1360,8 +1489,86 @@ function findTimeZone(groups) {
|
|
|
1360
1489
|
}
|
|
1361
1490
|
}
|
|
1362
1491
|
|
|
1492
|
+
// src/utils/text.ts
|
|
1493
|
+
var locales = ["en", "sr-latn"];
|
|
1494
|
+
var localeMap = {
|
|
1495
|
+
"en": "en-US",
|
|
1496
|
+
"sr-latn": "sr-RS"
|
|
1497
|
+
};
|
|
1498
|
+
function slugify(text) {
|
|
1499
|
+
return text.toString().toLowerCase().replace(/\s+/g, "-").replace(/[^\w-]+/g, "").replace(/--+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
1500
|
+
}
|
|
1501
|
+
function humanize(text) {
|
|
1502
|
+
const slugifiedText = slugify(text);
|
|
1503
|
+
return slugifiedText.replace(/-/g, " ").replace(
|
|
1504
|
+
// upper case first letter of every word, and lower case the rest
|
|
1505
|
+
/\w\S*/g,
|
|
1506
|
+
(w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
function categorify(text) {
|
|
1510
|
+
const slugifiedText = slugify(text);
|
|
1511
|
+
return slugifiedText.replace(/-/g, " ").toUpperCase();
|
|
1512
|
+
}
|
|
1513
|
+
function formatDate(date, locale) {
|
|
1514
|
+
let localeString = "en-US";
|
|
1515
|
+
if (locales.includes(locale)) {
|
|
1516
|
+
localeString = localeMap[locale];
|
|
1517
|
+
}
|
|
1518
|
+
return new Date(date).toLocaleDateString(localeString, {
|
|
1519
|
+
timeZone: "UTC",
|
|
1520
|
+
year: "numeric",
|
|
1521
|
+
month: "short",
|
|
1522
|
+
day: "numeric"
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
// src/utils/svg.ts
|
|
1527
|
+
async function fetchSvgContent(mediaObject) {
|
|
1528
|
+
if (!mediaObject) return null;
|
|
1529
|
+
const svgUrl = getImageUrl(mediaObject, false);
|
|
1530
|
+
try {
|
|
1531
|
+
const response = await fetch(svgUrl);
|
|
1532
|
+
if (!response.ok) {
|
|
1533
|
+
console.error(`Failed to fetch SVG: ${response.status} ${response.statusText}`);
|
|
1534
|
+
return null;
|
|
1535
|
+
}
|
|
1536
|
+
const svgContent = await response.text();
|
|
1537
|
+
return svgContent;
|
|
1538
|
+
} catch (error) {
|
|
1539
|
+
console.error("Error fetching SVG:", error);
|
|
1540
|
+
return null;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
async function getSvgContentForAstro(mediaObject) {
|
|
1544
|
+
try {
|
|
1545
|
+
const svgContent = await fetchSvgContent(mediaObject);
|
|
1546
|
+
return svgContent || "";
|
|
1547
|
+
} catch (error) {
|
|
1548
|
+
console.error("Error getting SVG content for Astro:", error);
|
|
1549
|
+
return "";
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
async function injectSvgIntoElement(mediaObject, targetElement, className) {
|
|
1553
|
+
if (!targetElement) return;
|
|
1554
|
+
try {
|
|
1555
|
+
const svgContent = await fetchSvgContent(mediaObject);
|
|
1556
|
+
if (svgContent) {
|
|
1557
|
+
targetElement.innerHTML = svgContent;
|
|
1558
|
+
if (className) {
|
|
1559
|
+
const svgElement = targetElement.querySelector("svg");
|
|
1560
|
+
if (svgElement) {
|
|
1561
|
+
svgElement.classList.add(...className.split(" "));
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
} catch (error) {
|
|
1566
|
+
console.error("Error injecting SVG:", error);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1363
1570
|
// src/index.ts
|
|
1364
|
-
var SDK_VERSION = "0.3.
|
|
1571
|
+
var SDK_VERSION = "0.3.9";
|
|
1365
1572
|
var SUPPORTED_FRAMEWORKS = [
|
|
1366
1573
|
"astro",
|
|
1367
1574
|
"react",
|
|
@@ -1411,18 +1618,41 @@ function createArkySDK(config) {
|
|
|
1411
1618
|
logout: config.logout,
|
|
1412
1619
|
setToken: config.setToken,
|
|
1413
1620
|
utils: {
|
|
1621
|
+
// Block utilities
|
|
1414
1622
|
getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock, storageUrl),
|
|
1415
1623
|
thumbnailUrl: (service) => thumbnailUrl(service, storageUrl),
|
|
1416
1624
|
getGalleryThumbnail,
|
|
1625
|
+
getBlockValue,
|
|
1626
|
+
getBlockValues,
|
|
1627
|
+
getBlockLabel,
|
|
1628
|
+
getBlockTextValue,
|
|
1629
|
+
getBlockObjectValues,
|
|
1630
|
+
getBlockFromArray,
|
|
1631
|
+
formatBlockValue,
|
|
1632
|
+
prepareBlocksForSubmission,
|
|
1633
|
+
extractBlockValues,
|
|
1634
|
+
// Price utilities
|
|
1417
1635
|
getMarketPrice,
|
|
1418
1636
|
getPriceAmount,
|
|
1419
1637
|
formatPayment,
|
|
1420
1638
|
formatMinor,
|
|
1421
1639
|
createPaymentForCheckout,
|
|
1640
|
+
// Currency utilities
|
|
1422
1641
|
getCurrencySymbol,
|
|
1642
|
+
// Validation utilities
|
|
1423
1643
|
validatePhoneNumber,
|
|
1644
|
+
// Timezone utilities
|
|
1424
1645
|
tzGroups,
|
|
1425
|
-
findTimeZone
|
|
1646
|
+
findTimeZone,
|
|
1647
|
+
// Text utilities
|
|
1648
|
+
slugify,
|
|
1649
|
+
humanize,
|
|
1650
|
+
categorify,
|
|
1651
|
+
formatDate,
|
|
1652
|
+
// SVG utilities
|
|
1653
|
+
getSvgContentForAstro,
|
|
1654
|
+
fetchSvgContent,
|
|
1655
|
+
injectSvgIntoElement
|
|
1426
1656
|
}
|
|
1427
1657
|
};
|
|
1428
1658
|
if (autoGuest) {
|