arky-sdk 0.7.57 → 0.7.61
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 +775 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +382 -182
- package/dist/index.d.ts +382 -182
- package/dist/index.js +774 -148
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -9
- package/dist/types.d.ts +1 -9
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -46,7 +46,7 @@ function buildQueryString(params) {
|
|
|
46
46
|
|
|
47
47
|
// src/services/createHttpClient.ts
|
|
48
48
|
function createHttpClient(cfg) {
|
|
49
|
-
const refreshEndpoint = `${cfg.baseUrl}/v1/auth/refresh`;
|
|
49
|
+
const refreshEndpoint = `${cfg.baseUrl}${cfg.refreshPath || "/v1/auth/refresh"}`;
|
|
50
50
|
let refreshPromise = null;
|
|
51
51
|
async function ensureFreshToken() {
|
|
52
52
|
if (refreshPromise) {
|
|
@@ -867,13 +867,6 @@ var createEshopApi = (apiConfig) => {
|
|
|
867
867
|
options
|
|
868
868
|
);
|
|
869
869
|
},
|
|
870
|
-
async checkout(params, options) {
|
|
871
|
-
return apiConfig.httpClient.post(
|
|
872
|
-
`/v1/businesses/${apiConfig.businessId}/orders/checkout`,
|
|
873
|
-
{ ...params, businessId: apiConfig.businessId, market: apiConfig.market },
|
|
874
|
-
options
|
|
875
|
-
);
|
|
876
|
-
},
|
|
877
870
|
async processRefund(params, options) {
|
|
878
871
|
return apiConfig.httpClient.post(
|
|
879
872
|
`/v1/businesses/${apiConfig.businessId}/orders/${params.id}/refund`,
|
|
@@ -885,17 +878,6 @@ var createEshopApi = (apiConfig) => {
|
|
|
885
878
|
};
|
|
886
879
|
|
|
887
880
|
// src/api/booking.ts
|
|
888
|
-
function groupCartToItems(cart) {
|
|
889
|
-
const groups = /* @__PURE__ */ new Map();
|
|
890
|
-
for (const s of cart) {
|
|
891
|
-
const key = `${s.serviceId}:${s.providerId}`;
|
|
892
|
-
if (!groups.has(key)) {
|
|
893
|
-
groups.set(key, { serviceId: s.serviceId, providerId: s.providerId, slots: [] });
|
|
894
|
-
}
|
|
895
|
-
groups.get(key).slots.push({ from: s.from, to: s.to });
|
|
896
|
-
}
|
|
897
|
-
return [...groups.values()];
|
|
898
|
-
}
|
|
899
881
|
var createBookingApi = (apiConfig) => {
|
|
900
882
|
let cart = [];
|
|
901
883
|
return {
|
|
@@ -928,16 +910,6 @@ var createBookingApi = (apiConfig) => {
|
|
|
928
910
|
options
|
|
929
911
|
);
|
|
930
912
|
},
|
|
931
|
-
async checkout(params, options) {
|
|
932
|
-
const { businessId, items: paramItems, ...payload } = params || {};
|
|
933
|
-
const targetBusinessId = businessId || apiConfig.businessId;
|
|
934
|
-
const items = paramItems || groupCartToItems(cart);
|
|
935
|
-
return apiConfig.httpClient.post(
|
|
936
|
-
`/v1/businesses/${targetBusinessId}/bookings/checkout`,
|
|
937
|
-
{ market: "booking", ...payload, items },
|
|
938
|
-
options
|
|
939
|
-
);
|
|
940
|
-
},
|
|
941
913
|
async getBooking(params, options) {
|
|
942
914
|
const targetBusinessId = params.businessId || apiConfig.businessId;
|
|
943
915
|
return apiConfig.httpClient.get(
|
|
@@ -1215,36 +1187,6 @@ var createMarketApi = (apiConfig) => {
|
|
|
1215
1187
|
// src/api/crm.ts
|
|
1216
1188
|
var createCustomerApi = (apiConfig) => {
|
|
1217
1189
|
return {
|
|
1218
|
-
async requestCode(params, options) {
|
|
1219
|
-
const businessId = params.businessId || apiConfig.businessId;
|
|
1220
|
-
return apiConfig.httpClient.post(
|
|
1221
|
-
`/v1/businesses/${businessId}/customers/auth/code`,
|
|
1222
|
-
{ email: params.email },
|
|
1223
|
-
options
|
|
1224
|
-
);
|
|
1225
|
-
},
|
|
1226
|
-
async verify(params, options) {
|
|
1227
|
-
const businessId = params.businessId || apiConfig.businessId;
|
|
1228
|
-
return apiConfig.httpClient.post(
|
|
1229
|
-
`/v1/businesses/${businessId}/customers/auth/verify`,
|
|
1230
|
-
{ email: params.email, code: params.code },
|
|
1231
|
-
options
|
|
1232
|
-
);
|
|
1233
|
-
},
|
|
1234
|
-
async refreshToken(params, options) {
|
|
1235
|
-
const businessId = params.businessId || apiConfig.businessId;
|
|
1236
|
-
return apiConfig.httpClient.post(
|
|
1237
|
-
`/v1/businesses/${businessId}/customers/auth/refresh`,
|
|
1238
|
-
{ refreshToken: params.refreshToken },
|
|
1239
|
-
options
|
|
1240
|
-
);
|
|
1241
|
-
},
|
|
1242
|
-
async getMe(options) {
|
|
1243
|
-
return apiConfig.httpClient.get(
|
|
1244
|
-
`/v1/businesses/${apiConfig.businessId}/customers/me`,
|
|
1245
|
-
options
|
|
1246
|
-
);
|
|
1247
|
-
},
|
|
1248
1190
|
async create(params, options) {
|
|
1249
1191
|
return apiConfig.httpClient.post(
|
|
1250
1192
|
`/v1/businesses/${params.businessId || apiConfig.businessId}/customers`,
|
|
@@ -1258,22 +1200,6 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1258
1200
|
options
|
|
1259
1201
|
);
|
|
1260
1202
|
},
|
|
1261
|
-
async initialize(params, options) {
|
|
1262
|
-
const businessId = params?.businessId || apiConfig.businessId;
|
|
1263
|
-
return apiConfig.httpClient.post(
|
|
1264
|
-
`/v1/businesses/${businessId}/customers/initialize`,
|
|
1265
|
-
{ businessId },
|
|
1266
|
-
options
|
|
1267
|
-
);
|
|
1268
|
-
},
|
|
1269
|
-
async connect(params, options) {
|
|
1270
|
-
const businessId = params.businessId || apiConfig.businessId;
|
|
1271
|
-
return apiConfig.httpClient.post(
|
|
1272
|
-
`/v1/businesses/${businessId}/customers/connect`,
|
|
1273
|
-
{ email: params.email },
|
|
1274
|
-
options
|
|
1275
|
-
);
|
|
1276
|
-
},
|
|
1277
1203
|
async find(params, options) {
|
|
1278
1204
|
const businessId = params?.businessId || apiConfig.businessId;
|
|
1279
1205
|
const queryParams = {};
|
|
@@ -1355,25 +1281,6 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1355
1281
|
{ ...options, params }
|
|
1356
1282
|
);
|
|
1357
1283
|
},
|
|
1358
|
-
async subscribe(params, options) {
|
|
1359
|
-
return apiConfig.httpClient.post(
|
|
1360
|
-
`/v1/businesses/${apiConfig.businessId}/audiences/${params.id}/subscribe`,
|
|
1361
|
-
{
|
|
1362
|
-
customerId: params.customerId,
|
|
1363
|
-
...params.priceId && { priceId: params.priceId },
|
|
1364
|
-
...params.successUrl && { successUrl: params.successUrl },
|
|
1365
|
-
...params.cancelUrl && { cancelUrl: params.cancelUrl },
|
|
1366
|
-
...params.confirmUrl && { confirmUrl: params.confirmUrl }
|
|
1367
|
-
},
|
|
1368
|
-
options
|
|
1369
|
-
);
|
|
1370
|
-
},
|
|
1371
|
-
async checkAccess(params, options) {
|
|
1372
|
-
return apiConfig.httpClient.get(
|
|
1373
|
-
`/v1/businesses/${apiConfig.businessId}/audiences/${params.id}/access`,
|
|
1374
|
-
options
|
|
1375
|
-
);
|
|
1376
|
-
},
|
|
1377
1284
|
async getSubscribers(params, options) {
|
|
1378
1285
|
return apiConfig.httpClient.get(
|
|
1379
1286
|
`/v1/businesses/${apiConfig.businessId}/audiences/${params.id}/subscribers`,
|
|
@@ -1961,6 +1868,582 @@ var createTaxonomyApi = (apiConfig) => {
|
|
|
1961
1868
|
};
|
|
1962
1869
|
};
|
|
1963
1870
|
|
|
1871
|
+
// src/api/storefront.ts
|
|
1872
|
+
function groupCartToItems(cart) {
|
|
1873
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1874
|
+
for (const slot of cart) {
|
|
1875
|
+
const key = `${slot.serviceId}:${slot.providerId}`;
|
|
1876
|
+
if (!groups.has(key)) {
|
|
1877
|
+
groups.set(key, {
|
|
1878
|
+
serviceId: slot.serviceId,
|
|
1879
|
+
providerId: slot.providerId,
|
|
1880
|
+
slots: []
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
groups.get(key).slots.push({ from: slot.from, to: slot.to });
|
|
1884
|
+
}
|
|
1885
|
+
return [...groups.values()];
|
|
1886
|
+
}
|
|
1887
|
+
var createStorefrontApi = (apiConfig) => {
|
|
1888
|
+
const base = (businessId = apiConfig.businessId) => `/v1/storefront/${businessId}`;
|
|
1889
|
+
let cart = [];
|
|
1890
|
+
return {
|
|
1891
|
+
business: {
|
|
1892
|
+
getBusiness(options) {
|
|
1893
|
+
return apiConfig.httpClient.get(base(), options);
|
|
1894
|
+
},
|
|
1895
|
+
getIntegrationConfig(params, options) {
|
|
1896
|
+
return apiConfig.httpClient.get(
|
|
1897
|
+
`${base(params.businessId)}/integrations/config/${params.type}`,
|
|
1898
|
+
options
|
|
1899
|
+
);
|
|
1900
|
+
},
|
|
1901
|
+
location: {
|
|
1902
|
+
getCountries(options) {
|
|
1903
|
+
return apiConfig.httpClient.get(`/v1/platform/countries`, options);
|
|
1904
|
+
},
|
|
1905
|
+
getCountry(countryCode, options) {
|
|
1906
|
+
return apiConfig.httpClient.get(
|
|
1907
|
+
`/v1/platform/countries/${countryCode}`,
|
|
1908
|
+
options
|
|
1909
|
+
);
|
|
1910
|
+
},
|
|
1911
|
+
list(options) {
|
|
1912
|
+
return apiConfig.httpClient.get(`${base()}/locations`, options);
|
|
1913
|
+
},
|
|
1914
|
+
get(id, options) {
|
|
1915
|
+
return apiConfig.httpClient.get(`${base()}/locations/${id}`, options);
|
|
1916
|
+
}
|
|
1917
|
+
},
|
|
1918
|
+
market: {
|
|
1919
|
+
list(options) {
|
|
1920
|
+
return apiConfig.httpClient.get(`${base()}/markets`, options);
|
|
1921
|
+
},
|
|
1922
|
+
get(id, options) {
|
|
1923
|
+
return apiConfig.httpClient.get(`${base()}/markets/${id}`, options);
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
},
|
|
1927
|
+
cms: {
|
|
1928
|
+
node: {
|
|
1929
|
+
async get(params, options) {
|
|
1930
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
1931
|
+
let identifier;
|
|
1932
|
+
if (params.id) {
|
|
1933
|
+
identifier = params.id;
|
|
1934
|
+
} else if (params.slug) {
|
|
1935
|
+
identifier = `${businessId}:${apiConfig.locale}:${params.slug}`;
|
|
1936
|
+
} else if (params.key) {
|
|
1937
|
+
identifier = `${businessId}:${params.key}`;
|
|
1938
|
+
} else {
|
|
1939
|
+
throw new Error("GetNodeParams requires id, slug, or key");
|
|
1940
|
+
}
|
|
1941
|
+
const response = await apiConfig.httpClient.get(
|
|
1942
|
+
`${base(businessId)}/nodes/${identifier}`,
|
|
1943
|
+
options
|
|
1944
|
+
);
|
|
1945
|
+
return {
|
|
1946
|
+
...response,
|
|
1947
|
+
getBlock(key) {
|
|
1948
|
+
return getBlockFromArray(response, key, apiConfig.locale);
|
|
1949
|
+
},
|
|
1950
|
+
getBlockValues(key) {
|
|
1951
|
+
return getBlockObjectValues(response, key, apiConfig.locale);
|
|
1952
|
+
},
|
|
1953
|
+
getImage(key) {
|
|
1954
|
+
const block = getBlockFromArray(response, key, apiConfig.locale);
|
|
1955
|
+
return getImageUrl(block, true);
|
|
1956
|
+
}
|
|
1957
|
+
};
|
|
1958
|
+
},
|
|
1959
|
+
find(params, options) {
|
|
1960
|
+
const { businessId, ...queryParams } = params;
|
|
1961
|
+
return apiConfig.httpClient.get(`${base(businessId)}/nodes`, {
|
|
1962
|
+
...options,
|
|
1963
|
+
params: queryParams
|
|
1964
|
+
});
|
|
1965
|
+
},
|
|
1966
|
+
getChildren(params, options) {
|
|
1967
|
+
const { id, businessId, ...queryParams } = params;
|
|
1968
|
+
return apiConfig.httpClient.get(`${base(businessId)}/nodes/${id}/children`, {
|
|
1969
|
+
...options,
|
|
1970
|
+
params: queryParams
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
},
|
|
1974
|
+
form: {
|
|
1975
|
+
get(params, options) {
|
|
1976
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
1977
|
+
let identifier;
|
|
1978
|
+
if (params.id) {
|
|
1979
|
+
identifier = params.id;
|
|
1980
|
+
} else if (params.key) {
|
|
1981
|
+
identifier = `${businessId}:${params.key}`;
|
|
1982
|
+
} else {
|
|
1983
|
+
throw new Error("GetFormParams requires id or key");
|
|
1984
|
+
}
|
|
1985
|
+
return apiConfig.httpClient.get(
|
|
1986
|
+
`${base(businessId)}/forms/${identifier}`,
|
|
1987
|
+
options
|
|
1988
|
+
);
|
|
1989
|
+
},
|
|
1990
|
+
submit(params, options) {
|
|
1991
|
+
const { businessId, formId, ...payload } = params;
|
|
1992
|
+
const targetBusinessId = businessId || apiConfig.businessId;
|
|
1993
|
+
return apiConfig.httpClient.post(
|
|
1994
|
+
`${base(targetBusinessId)}/forms/${formId}/submissions`,
|
|
1995
|
+
{ ...payload, formId, businessId: targetBusinessId },
|
|
1996
|
+
options
|
|
1997
|
+
);
|
|
1998
|
+
}
|
|
1999
|
+
},
|
|
2000
|
+
taxonomy: {
|
|
2001
|
+
get(params, options) {
|
|
2002
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2003
|
+
let identifier;
|
|
2004
|
+
if (params.id) {
|
|
2005
|
+
identifier = params.id;
|
|
2006
|
+
} else if (params.key) {
|
|
2007
|
+
identifier = `${businessId}:${params.key}`;
|
|
2008
|
+
} else {
|
|
2009
|
+
throw new Error("GetTaxonomyParams requires id or key");
|
|
2010
|
+
}
|
|
2011
|
+
return apiConfig.httpClient.get(
|
|
2012
|
+
`${base(businessId)}/taxonomies/${identifier}`,
|
|
2013
|
+
options
|
|
2014
|
+
);
|
|
2015
|
+
},
|
|
2016
|
+
getChildren(params, options) {
|
|
2017
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2018
|
+
return apiConfig.httpClient.get(
|
|
2019
|
+
`${base(businessId)}/taxonomies/${params.id}/children`,
|
|
2020
|
+
options
|
|
2021
|
+
);
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
},
|
|
2025
|
+
eshop: {
|
|
2026
|
+
product: {
|
|
2027
|
+
get(params, options) {
|
|
2028
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2029
|
+
let identifier;
|
|
2030
|
+
if (params.id) {
|
|
2031
|
+
identifier = params.id;
|
|
2032
|
+
} else if (params.slug) {
|
|
2033
|
+
identifier = `${businessId}:${apiConfig.locale}:${params.slug}`;
|
|
2034
|
+
} else {
|
|
2035
|
+
throw new Error("GetProductParams requires id or slug");
|
|
2036
|
+
}
|
|
2037
|
+
return apiConfig.httpClient.get(
|
|
2038
|
+
`${base(businessId)}/products/${identifier}`,
|
|
2039
|
+
options
|
|
2040
|
+
);
|
|
2041
|
+
},
|
|
2042
|
+
find(params, options) {
|
|
2043
|
+
const { businessId, ...queryParams } = params;
|
|
2044
|
+
return apiConfig.httpClient.get(`${base(businessId)}/products`, {
|
|
2045
|
+
...options,
|
|
2046
|
+
params: queryParams
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
},
|
|
2050
|
+
order: {
|
|
2051
|
+
getQuote(params, options) {
|
|
2052
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2053
|
+
const { location, businessId: _businessId, ...rest } = params;
|
|
2054
|
+
const shippingAddress = location ? {
|
|
2055
|
+
country: location.country || "",
|
|
2056
|
+
state: location.state || "",
|
|
2057
|
+
city: location.city || "",
|
|
2058
|
+
postalCode: location.postalCode || "",
|
|
2059
|
+
name: "",
|
|
2060
|
+
street1: "",
|
|
2061
|
+
street2: null
|
|
2062
|
+
} : void 0;
|
|
2063
|
+
return apiConfig.httpClient.post(
|
|
2064
|
+
`${base(businessId)}/orders/quote`,
|
|
2065
|
+
{ ...rest, shippingAddress, market: apiConfig.market },
|
|
2066
|
+
options
|
|
2067
|
+
);
|
|
2068
|
+
},
|
|
2069
|
+
checkout(params, options) {
|
|
2070
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2071
|
+
return apiConfig.httpClient.post(
|
|
2072
|
+
`${base(businessId)}/orders/checkout`,
|
|
2073
|
+
{ ...params, businessId, market: apiConfig.market },
|
|
2074
|
+
options
|
|
2075
|
+
);
|
|
2076
|
+
},
|
|
2077
|
+
get(params, options) {
|
|
2078
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2079
|
+
return apiConfig.httpClient.get(
|
|
2080
|
+
`${base(businessId)}/orders/${params.id}`,
|
|
2081
|
+
options
|
|
2082
|
+
);
|
|
2083
|
+
},
|
|
2084
|
+
find(params, options) {
|
|
2085
|
+
const { businessId, ...queryParams } = params;
|
|
2086
|
+
return apiConfig.httpClient.get(`${base(businessId)}/orders`, {
|
|
2087
|
+
...options,
|
|
2088
|
+
params: queryParams
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
},
|
|
2093
|
+
booking: {
|
|
2094
|
+
addToCart(slot) {
|
|
2095
|
+
cart.push(slot);
|
|
2096
|
+
},
|
|
2097
|
+
removeFromCart(slotId) {
|
|
2098
|
+
cart = cart.filter((slot) => slot.id !== slotId);
|
|
2099
|
+
},
|
|
2100
|
+
getCart() {
|
|
2101
|
+
return [...cart];
|
|
2102
|
+
},
|
|
2103
|
+
clearCart() {
|
|
2104
|
+
cart = [];
|
|
2105
|
+
},
|
|
2106
|
+
checkout(params, options) {
|
|
2107
|
+
const { businessId, items: paramItems, ...payload } = params || {};
|
|
2108
|
+
const targetBusinessId = businessId || apiConfig.businessId;
|
|
2109
|
+
const items = paramItems || groupCartToItems(cart);
|
|
2110
|
+
return apiConfig.httpClient.post(
|
|
2111
|
+
`${base(targetBusinessId)}/bookings/checkout`,
|
|
2112
|
+
{ market: "booking", ...payload, items },
|
|
2113
|
+
options
|
|
2114
|
+
);
|
|
2115
|
+
},
|
|
2116
|
+
get(params, options) {
|
|
2117
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2118
|
+
return apiConfig.httpClient.get(
|
|
2119
|
+
`${base(businessId)}/bookings/${params.id}`,
|
|
2120
|
+
options
|
|
2121
|
+
);
|
|
2122
|
+
},
|
|
2123
|
+
find(params, options) {
|
|
2124
|
+
const { businessId, ...queryParams } = params;
|
|
2125
|
+
return apiConfig.httpClient.get(`${base(businessId)}/bookings`, {
|
|
2126
|
+
...options,
|
|
2127
|
+
params: queryParams
|
|
2128
|
+
});
|
|
2129
|
+
},
|
|
2130
|
+
getQuote(params, options) {
|
|
2131
|
+
const { businessId, ...payload } = params;
|
|
2132
|
+
return apiConfig.httpClient.post(
|
|
2133
|
+
`${base(businessId)}/bookings/quote`,
|
|
2134
|
+
{ market: "booking", ...payload },
|
|
2135
|
+
options
|
|
2136
|
+
);
|
|
2137
|
+
},
|
|
2138
|
+
getAvailability(params, options) {
|
|
2139
|
+
const { businessId, ...queryParams } = params;
|
|
2140
|
+
return apiConfig.httpClient.get(
|
|
2141
|
+
`${base(businessId)}/bookings/availability`,
|
|
2142
|
+
{ ...options, params: queryParams }
|
|
2143
|
+
);
|
|
2144
|
+
},
|
|
2145
|
+
cancelItem(params, options) {
|
|
2146
|
+
const { businessId, bookingId, itemId, ...payload } = params;
|
|
2147
|
+
return apiConfig.httpClient.post(
|
|
2148
|
+
`${base(businessId)}/bookings/${bookingId}/items/${itemId}/cancel`,
|
|
2149
|
+
payload,
|
|
2150
|
+
options
|
|
2151
|
+
);
|
|
2152
|
+
},
|
|
2153
|
+
service: {
|
|
2154
|
+
get(params, options) {
|
|
2155
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2156
|
+
let identifier;
|
|
2157
|
+
if (params.id) {
|
|
2158
|
+
identifier = params.id;
|
|
2159
|
+
} else if (params.slug) {
|
|
2160
|
+
identifier = `${businessId}:${apiConfig.locale}:${params.slug}`;
|
|
2161
|
+
} else {
|
|
2162
|
+
throw new Error("GetServiceParams requires id or slug");
|
|
2163
|
+
}
|
|
2164
|
+
return apiConfig.httpClient.get(
|
|
2165
|
+
`${base(businessId)}/services/${identifier}`,
|
|
2166
|
+
options
|
|
2167
|
+
);
|
|
2168
|
+
},
|
|
2169
|
+
find(params, options) {
|
|
2170
|
+
const { businessId, ...queryParams } = params;
|
|
2171
|
+
return apiConfig.httpClient.get(`${base(businessId)}/services`, {
|
|
2172
|
+
...options,
|
|
2173
|
+
params: queryParams
|
|
2174
|
+
});
|
|
2175
|
+
},
|
|
2176
|
+
findProviders(params, options) {
|
|
2177
|
+
const { businessId, ...queryParams } = params;
|
|
2178
|
+
return apiConfig.httpClient.get(`${base(businessId)}/service-providers`, {
|
|
2179
|
+
...options,
|
|
2180
|
+
params: queryParams
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
},
|
|
2184
|
+
provider: {
|
|
2185
|
+
get(params, options) {
|
|
2186
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2187
|
+
let identifier;
|
|
2188
|
+
if (params.id) {
|
|
2189
|
+
identifier = params.id;
|
|
2190
|
+
} else if (params.slug) {
|
|
2191
|
+
identifier = `${businessId}:${apiConfig.locale}:${params.slug}`;
|
|
2192
|
+
} else {
|
|
2193
|
+
throw new Error("GetProviderParams requires id or slug");
|
|
2194
|
+
}
|
|
2195
|
+
return apiConfig.httpClient.get(
|
|
2196
|
+
`${base(businessId)}/providers/${identifier}`,
|
|
2197
|
+
options
|
|
2198
|
+
);
|
|
2199
|
+
},
|
|
2200
|
+
find(params, options) {
|
|
2201
|
+
const { businessId, ...queryParams } = params;
|
|
2202
|
+
return apiConfig.httpClient.get(`${base(businessId)}/providers`, {
|
|
2203
|
+
...options,
|
|
2204
|
+
params: queryParams
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
},
|
|
2209
|
+
crm: {
|
|
2210
|
+
customer: {
|
|
2211
|
+
initialize(params, options) {
|
|
2212
|
+
const businessId = params?.businessId || apiConfig.businessId;
|
|
2213
|
+
return apiConfig.httpClient.post(
|
|
2214
|
+
`${base(businessId)}/customers/initialize`,
|
|
2215
|
+
{ businessId },
|
|
2216
|
+
options
|
|
2217
|
+
);
|
|
2218
|
+
},
|
|
2219
|
+
signInAnonymously(params, options) {
|
|
2220
|
+
const businessId = params?.businessId || apiConfig.businessId;
|
|
2221
|
+
return apiConfig.httpClient.post(
|
|
2222
|
+
`${base(businessId)}/customers/initialize`,
|
|
2223
|
+
{ businessId },
|
|
2224
|
+
options
|
|
2225
|
+
);
|
|
2226
|
+
},
|
|
2227
|
+
connect(params, options) {
|
|
2228
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2229
|
+
return apiConfig.httpClient.post(
|
|
2230
|
+
`${base(businessId)}/customers/connect`,
|
|
2231
|
+
{ email: params.email, businessId },
|
|
2232
|
+
options
|
|
2233
|
+
);
|
|
2234
|
+
},
|
|
2235
|
+
requestCode(params, options) {
|
|
2236
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2237
|
+
return apiConfig.httpClient.post(
|
|
2238
|
+
`${base(businessId)}/customers/auth/code`,
|
|
2239
|
+
{ email: params.email, businessId },
|
|
2240
|
+
options
|
|
2241
|
+
);
|
|
2242
|
+
},
|
|
2243
|
+
verify(params, options) {
|
|
2244
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2245
|
+
return apiConfig.httpClient.post(
|
|
2246
|
+
`${base(businessId)}/customers/auth/verify`,
|
|
2247
|
+
{ email: params.email, code: params.code, businessId },
|
|
2248
|
+
options
|
|
2249
|
+
);
|
|
2250
|
+
},
|
|
2251
|
+
refreshToken(params, options) {
|
|
2252
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2253
|
+
return apiConfig.httpClient.post(
|
|
2254
|
+
`${base(businessId)}/customers/auth/refresh`,
|
|
2255
|
+
{ refreshToken: params.refreshToken },
|
|
2256
|
+
options
|
|
2257
|
+
);
|
|
2258
|
+
},
|
|
2259
|
+
getMe(options) {
|
|
2260
|
+
return apiConfig.httpClient.get(`${base()}/customers/me`, options);
|
|
2261
|
+
}
|
|
2262
|
+
},
|
|
2263
|
+
audience: {
|
|
2264
|
+
get(params, options) {
|
|
2265
|
+
let identifier;
|
|
2266
|
+
if (params.id) {
|
|
2267
|
+
identifier = params.id;
|
|
2268
|
+
} else if (params.key) {
|
|
2269
|
+
identifier = `${apiConfig.businessId}:${params.key}`;
|
|
2270
|
+
} else {
|
|
2271
|
+
throw new Error("GetAudienceParams requires id or key");
|
|
2272
|
+
}
|
|
2273
|
+
return apiConfig.httpClient.get(
|
|
2274
|
+
`${base(apiConfig.businessId)}/audiences/${identifier}`,
|
|
2275
|
+
options
|
|
2276
|
+
);
|
|
2277
|
+
},
|
|
2278
|
+
find(params, options) {
|
|
2279
|
+
return apiConfig.httpClient.get(`${base()}/audiences`, {
|
|
2280
|
+
...options,
|
|
2281
|
+
params
|
|
2282
|
+
});
|
|
2283
|
+
},
|
|
2284
|
+
subscribe(params, options) {
|
|
2285
|
+
return apiConfig.httpClient.post(
|
|
2286
|
+
`${base()}/audiences/${params.id}/subscribe`,
|
|
2287
|
+
{
|
|
2288
|
+
customerId: params.customerId,
|
|
2289
|
+
priceId: params.priceId,
|
|
2290
|
+
successUrl: params.successUrl,
|
|
2291
|
+
cancelUrl: params.cancelUrl,
|
|
2292
|
+
confirmUrl: params.confirmUrl
|
|
2293
|
+
},
|
|
2294
|
+
options
|
|
2295
|
+
);
|
|
2296
|
+
},
|
|
2297
|
+
checkAccess(params, options) {
|
|
2298
|
+
return apiConfig.httpClient.get(
|
|
2299
|
+
`${base()}/audiences/${params.id}/access`,
|
|
2300
|
+
options
|
|
2301
|
+
);
|
|
2302
|
+
},
|
|
2303
|
+
unsubscribe(token, options) {
|
|
2304
|
+
return apiConfig.httpClient.get(`${base()}/audiences/unsubscribe`, {
|
|
2305
|
+
...options,
|
|
2306
|
+
params: { token }
|
|
2307
|
+
});
|
|
2308
|
+
},
|
|
2309
|
+
confirm(token, options) {
|
|
2310
|
+
return apiConfig.httpClient.get(`${base()}/audiences/confirm`, {
|
|
2311
|
+
...options,
|
|
2312
|
+
params: { token }
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
},
|
|
2316
|
+
reaction: {
|
|
2317
|
+
DEFAULT_REACTION_KINDS,
|
|
2318
|
+
isValidReactionKind,
|
|
2319
|
+
computeAverageStars,
|
|
2320
|
+
create(params, options) {
|
|
2321
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2322
|
+
return apiConfig.httpClient.post(
|
|
2323
|
+
`${base(businessId)}/reactions`,
|
|
2324
|
+
{
|
|
2325
|
+
businessId,
|
|
2326
|
+
target: params.target,
|
|
2327
|
+
kind: params.kind,
|
|
2328
|
+
blocks: params.blocks || [],
|
|
2329
|
+
parentId: params.parentId,
|
|
2330
|
+
taxonomies: params.taxonomies || []
|
|
2331
|
+
},
|
|
2332
|
+
options
|
|
2333
|
+
);
|
|
2334
|
+
},
|
|
2335
|
+
get(params, options) {
|
|
2336
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2337
|
+
return apiConfig.httpClient.get(
|
|
2338
|
+
`${base(businessId)}/reactions/${params.id}`,
|
|
2339
|
+
options
|
|
2340
|
+
);
|
|
2341
|
+
},
|
|
2342
|
+
find(params, options) {
|
|
2343
|
+
const businessId = params?.businessId || apiConfig.businessId;
|
|
2344
|
+
const queryParams = { ...params || {} };
|
|
2345
|
+
delete queryParams.businessId;
|
|
2346
|
+
return apiConfig.httpClient.get(`${base(businessId)}/reactions`, {
|
|
2347
|
+
...options,
|
|
2348
|
+
params: queryParams
|
|
2349
|
+
});
|
|
2350
|
+
},
|
|
2351
|
+
update(params, options) {
|
|
2352
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2353
|
+
return apiConfig.httpClient.put(
|
|
2354
|
+
`${base(businessId)}/reactions/${params.id}`,
|
|
2355
|
+
{
|
|
2356
|
+
id: params.id,
|
|
2357
|
+
businessId,
|
|
2358
|
+
blocks: params.blocks,
|
|
2359
|
+
taxonomies: params.taxonomies
|
|
2360
|
+
},
|
|
2361
|
+
options
|
|
2362
|
+
);
|
|
2363
|
+
},
|
|
2364
|
+
remove(params, options) {
|
|
2365
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2366
|
+
return apiConfig.httpClient.delete(
|
|
2367
|
+
`${base(businessId)}/reactions/${params.id}`,
|
|
2368
|
+
options
|
|
2369
|
+
);
|
|
2370
|
+
},
|
|
2371
|
+
summary(params, options) {
|
|
2372
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2373
|
+
return apiConfig.httpClient.get(`${base(businessId)}/reactions/summary`, {
|
|
2374
|
+
...options,
|
|
2375
|
+
params: {
|
|
2376
|
+
businessId,
|
|
2377
|
+
targetType: params.targetType,
|
|
2378
|
+
targetId: params.targetId,
|
|
2379
|
+
parentId: params.parentId
|
|
2380
|
+
}
|
|
2381
|
+
});
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
},
|
|
2385
|
+
automation: {
|
|
2386
|
+
agent: {
|
|
2387
|
+
getAgents(params, options) {
|
|
2388
|
+
const businessId = params?.businessId || apiConfig.businessId;
|
|
2389
|
+
const queryParams = { ...params || {} };
|
|
2390
|
+
delete queryParams.businessId;
|
|
2391
|
+
return apiConfig.httpClient.get(`${base(businessId)}/agents`, {
|
|
2392
|
+
...options,
|
|
2393
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
2394
|
+
});
|
|
2395
|
+
},
|
|
2396
|
+
getAgent(params, options) {
|
|
2397
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2398
|
+
return apiConfig.httpClient.get(
|
|
2399
|
+
`${base(businessId)}/agents/${params.id}`,
|
|
2400
|
+
options
|
|
2401
|
+
);
|
|
2402
|
+
},
|
|
2403
|
+
sendMessage(params, options) {
|
|
2404
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2405
|
+
const body = { message: params.message };
|
|
2406
|
+
if (params.chatId) body.chatId = params.chatId;
|
|
2407
|
+
return apiConfig.httpClient.post(
|
|
2408
|
+
`${base(businessId)}/agents/${params.id}/chats/messages`,
|
|
2409
|
+
body,
|
|
2410
|
+
options
|
|
2411
|
+
);
|
|
2412
|
+
},
|
|
2413
|
+
getChat(params, options) {
|
|
2414
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2415
|
+
return apiConfig.httpClient.get(
|
|
2416
|
+
`${base(businessId)}/agents/${params.id}/chats/${params.chatId}`,
|
|
2417
|
+
options
|
|
2418
|
+
);
|
|
2419
|
+
},
|
|
2420
|
+
getChatMessages(params, options) {
|
|
2421
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2422
|
+
const queryParams = {};
|
|
2423
|
+
if (params.limit) queryParams.limit = String(params.limit);
|
|
2424
|
+
return apiConfig.httpClient.get(
|
|
2425
|
+
`${base(businessId)}/agents/${params.id}/chats/${params.chatId}/messages`,
|
|
2426
|
+
{
|
|
2427
|
+
...options,
|
|
2428
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
2429
|
+
}
|
|
2430
|
+
);
|
|
2431
|
+
},
|
|
2432
|
+
rateChat(params, options) {
|
|
2433
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
2434
|
+
const body = { rating: params.rating };
|
|
2435
|
+
if (params.comment) body.comment = params.comment;
|
|
2436
|
+
return apiConfig.httpClient.post(
|
|
2437
|
+
`${base(businessId)}/agents/${params.id}/chats/${params.chatId}/rate`,
|
|
2438
|
+
body,
|
|
2439
|
+
options
|
|
2440
|
+
);
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
};
|
|
2445
|
+
};
|
|
2446
|
+
|
|
1964
2447
|
// src/utils/price.ts
|
|
1965
2448
|
function formatCurrency(amount, currencyCode, locale = "en") {
|
|
1966
2449
|
return new Intl.NumberFormat(locale, {
|
|
@@ -2231,7 +2714,7 @@ function getFirstAvailableFCId(variant, quantity = 1) {
|
|
|
2231
2714
|
}
|
|
2232
2715
|
|
|
2233
2716
|
// src/index.ts
|
|
2234
|
-
var SDK_VERSION = "0.7.
|
|
2717
|
+
var SDK_VERSION = "0.7.61";
|
|
2235
2718
|
var SUPPORTED_FRAMEWORKS = [
|
|
2236
2719
|
"astro",
|
|
2237
2720
|
"react",
|
|
@@ -2239,7 +2722,47 @@ var SUPPORTED_FRAMEWORKS = [
|
|
|
2239
2722
|
"svelte",
|
|
2240
2723
|
"vanilla"
|
|
2241
2724
|
];
|
|
2242
|
-
|
|
2725
|
+
function createUtilitySurface(apiConfig) {
|
|
2726
|
+
return {
|
|
2727
|
+
getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock),
|
|
2728
|
+
getBlockValue,
|
|
2729
|
+
getBlockTextValue,
|
|
2730
|
+
getBlockValues,
|
|
2731
|
+
getBlockLabel,
|
|
2732
|
+
getBlockObjectValues,
|
|
2733
|
+
getBlockFromArray,
|
|
2734
|
+
formatBlockValue,
|
|
2735
|
+
prepareBlocksForSubmission,
|
|
2736
|
+
extractBlockValues,
|
|
2737
|
+
formatPrice: (prices) => formatPrice(prices, apiConfig.market),
|
|
2738
|
+
getPriceAmount: (prices) => getPriceAmount(prices, apiConfig.market),
|
|
2739
|
+
formatPayment,
|
|
2740
|
+
formatMinor,
|
|
2741
|
+
getCurrencySymbol,
|
|
2742
|
+
getCurrencyName,
|
|
2743
|
+
validatePhoneNumber,
|
|
2744
|
+
tzGroups,
|
|
2745
|
+
findTimeZone,
|
|
2746
|
+
slugify,
|
|
2747
|
+
humanize,
|
|
2748
|
+
categorify,
|
|
2749
|
+
formatDate,
|
|
2750
|
+
getSvgContentForAstro,
|
|
2751
|
+
fetchSvgContent,
|
|
2752
|
+
injectSvgIntoElement,
|
|
2753
|
+
isValidKey,
|
|
2754
|
+
validateKey,
|
|
2755
|
+
toKey,
|
|
2756
|
+
nameToKey,
|
|
2757
|
+
track,
|
|
2758
|
+
getAvailableStock,
|
|
2759
|
+
getReservedStock,
|
|
2760
|
+
hasStock,
|
|
2761
|
+
getInventoryAt,
|
|
2762
|
+
getFirstAvailableFCId
|
|
2763
|
+
};
|
|
2764
|
+
}
|
|
2765
|
+
async function createAdmin(config) {
|
|
2243
2766
|
const locale = config.locale || "en";
|
|
2244
2767
|
const httpClient = createHttpClient(config);
|
|
2245
2768
|
const apiConfig = {
|
|
@@ -2266,27 +2789,111 @@ async function createArkySDK(config) {
|
|
|
2266
2789
|
}).catch(() => {
|
|
2267
2790
|
});
|
|
2268
2791
|
}
|
|
2792
|
+
const cmsApi = createCmsApi(apiConfig);
|
|
2793
|
+
const eshopApi = createEshopApi(apiConfig);
|
|
2794
|
+
const bookingApi = createBookingApi(apiConfig);
|
|
2795
|
+
const crmApi = createCustomerApi(apiConfig);
|
|
2796
|
+
const reactionApi = createReactionApi(apiConfig);
|
|
2797
|
+
const locationApi = createLocationApi(apiConfig);
|
|
2798
|
+
const marketApi = createMarketApi(apiConfig);
|
|
2799
|
+
const agentApi = createAgentApi(apiConfig);
|
|
2800
|
+
const workflowApi = createWorkflowApi(apiConfig);
|
|
2801
|
+
const formApi = createFormApi(apiConfig);
|
|
2802
|
+
const taxonomyApi = createTaxonomyApi(apiConfig);
|
|
2803
|
+
const emailTemplateApi = createEmailTemplateApi(apiConfig);
|
|
2269
2804
|
const sdk = {
|
|
2270
2805
|
auth: authApi,
|
|
2271
2806
|
account: accountApi,
|
|
2272
|
-
business:
|
|
2807
|
+
business: {
|
|
2808
|
+
...businessApi,
|
|
2809
|
+
location: locationApi,
|
|
2810
|
+
market: marketApi
|
|
2811
|
+
},
|
|
2273
2812
|
media: createMediaApi(apiConfig),
|
|
2274
2813
|
notification: createNotificationApi(apiConfig),
|
|
2275
2814
|
promoCode: createPromoCodeApi(apiConfig),
|
|
2276
2815
|
platform: platformApi,
|
|
2277
|
-
cms: createCmsApi(apiConfig),
|
|
2278
|
-
eshop: createEshopApi(apiConfig),
|
|
2279
|
-
booking: createBookingApi(apiConfig),
|
|
2280
|
-
location: createLocationApi(apiConfig),
|
|
2281
|
-
market: createMarketApi(apiConfig),
|
|
2282
|
-
crm: createCustomerApi(apiConfig),
|
|
2283
|
-
reaction: createReactionApi(apiConfig),
|
|
2284
|
-
workflow: createWorkflowApi(apiConfig),
|
|
2285
2816
|
shipping: createShippingApi(apiConfig),
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2817
|
+
cms: {
|
|
2818
|
+
node: cmsApi,
|
|
2819
|
+
form: formApi,
|
|
2820
|
+
taxonomy: taxonomyApi,
|
|
2821
|
+
emailTemplate: emailTemplateApi
|
|
2822
|
+
},
|
|
2823
|
+
eshop: {
|
|
2824
|
+
product: {
|
|
2825
|
+
create: eshopApi.createProduct,
|
|
2826
|
+
update: eshopApi.updateProduct,
|
|
2827
|
+
delete: eshopApi.deleteProduct,
|
|
2828
|
+
get: eshopApi.getProduct,
|
|
2829
|
+
find: eshopApi.getProducts
|
|
2830
|
+
},
|
|
2831
|
+
order: {
|
|
2832
|
+
create: eshopApi.createOrder,
|
|
2833
|
+
update: eshopApi.updateOrder,
|
|
2834
|
+
get: eshopApi.getOrder,
|
|
2835
|
+
find: eshopApi.getOrders,
|
|
2836
|
+
getQuote: eshopApi.getQuote,
|
|
2837
|
+
processRefund: eshopApi.processRefund
|
|
2838
|
+
}
|
|
2839
|
+
},
|
|
2840
|
+
booking: {
|
|
2841
|
+
addToCart: bookingApi.addToCart,
|
|
2842
|
+
removeFromCart: bookingApi.removeFromCart,
|
|
2843
|
+
getCart: bookingApi.getCart,
|
|
2844
|
+
clearCart: bookingApi.clearCart,
|
|
2845
|
+
create: bookingApi.createBooking,
|
|
2846
|
+
update: bookingApi.updateBooking,
|
|
2847
|
+
get: bookingApi.getBooking,
|
|
2848
|
+
find: bookingApi.searchBookings,
|
|
2849
|
+
getQuote: bookingApi.getQuote,
|
|
2850
|
+
processRefund: bookingApi.processRefund,
|
|
2851
|
+
getAvailability: bookingApi.getAvailability,
|
|
2852
|
+
cancelItem: bookingApi.cancelBookingItem,
|
|
2853
|
+
service: {
|
|
2854
|
+
create: bookingApi.createService,
|
|
2855
|
+
update: bookingApi.updateService,
|
|
2856
|
+
delete: bookingApi.deleteService,
|
|
2857
|
+
get: bookingApi.getService,
|
|
2858
|
+
find: bookingApi.getServices,
|
|
2859
|
+
findProviders: bookingApi.findServiceProviders,
|
|
2860
|
+
createProvider: bookingApi.createServiceProvider,
|
|
2861
|
+
updateProvider: bookingApi.updateServiceProvider,
|
|
2862
|
+
deleteProvider: bookingApi.deleteServiceProvider
|
|
2863
|
+
},
|
|
2864
|
+
provider: {
|
|
2865
|
+
create: bookingApi.createProvider,
|
|
2866
|
+
update: bookingApi.updateProvider,
|
|
2867
|
+
delete: bookingApi.deleteProvider,
|
|
2868
|
+
get: bookingApi.getProvider,
|
|
2869
|
+
find: bookingApi.getProviders
|
|
2870
|
+
}
|
|
2871
|
+
},
|
|
2872
|
+
crm: {
|
|
2873
|
+
customer: {
|
|
2874
|
+
create: crmApi.create,
|
|
2875
|
+
get: crmApi.get,
|
|
2876
|
+
find: crmApi.find,
|
|
2877
|
+
update: crmApi.update,
|
|
2878
|
+
merge: crmApi.merge,
|
|
2879
|
+
revokeToken: crmApi.revokeToken,
|
|
2880
|
+
revokeAllTokens: crmApi.revokeAllTokens
|
|
2881
|
+
},
|
|
2882
|
+
audience: {
|
|
2883
|
+
create: crmApi.audiences.create,
|
|
2884
|
+
update: crmApi.audiences.update,
|
|
2885
|
+
get: crmApi.audiences.get,
|
|
2886
|
+
find: crmApi.audiences.find,
|
|
2887
|
+
getSubscribers: crmApi.audiences.getSubscribers,
|
|
2888
|
+
addSubscriber: crmApi.audiences.addSubscriber,
|
|
2889
|
+
removeSubscriber: crmApi.audiences.removeSubscriber
|
|
2890
|
+
},
|
|
2891
|
+
reaction: reactionApi
|
|
2892
|
+
},
|
|
2893
|
+
automation: {
|
|
2894
|
+
agent: agentApi,
|
|
2895
|
+
workflow: workflowApi
|
|
2896
|
+
},
|
|
2290
2897
|
analytics: {
|
|
2291
2898
|
track
|
|
2292
2899
|
},
|
|
@@ -2306,47 +2913,66 @@ async function createArkySDK(config) {
|
|
|
2306
2913
|
logout: config.logout,
|
|
2307
2914
|
setToken: config.setToken,
|
|
2308
2915
|
extractBlockValues,
|
|
2309
|
-
utils:
|
|
2310
|
-
getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock),
|
|
2311
|
-
getBlockValue,
|
|
2312
|
-
getBlockTextValue,
|
|
2313
|
-
getBlockValues,
|
|
2314
|
-
getBlockLabel,
|
|
2315
|
-
getBlockObjectValues,
|
|
2316
|
-
getBlockFromArray,
|
|
2317
|
-
formatBlockValue,
|
|
2318
|
-
prepareBlocksForSubmission,
|
|
2319
|
-
extractBlockValues,
|
|
2320
|
-
formatPrice: (prices) => formatPrice(prices, apiConfig.market),
|
|
2321
|
-
getPriceAmount: (prices) => getPriceAmount(prices, apiConfig.market),
|
|
2322
|
-
formatPayment,
|
|
2323
|
-
formatMinor,
|
|
2324
|
-
getCurrencySymbol,
|
|
2325
|
-
getCurrencyName,
|
|
2326
|
-
validatePhoneNumber,
|
|
2327
|
-
tzGroups,
|
|
2328
|
-
findTimeZone,
|
|
2329
|
-
slugify,
|
|
2330
|
-
humanize,
|
|
2331
|
-
categorify,
|
|
2332
|
-
formatDate,
|
|
2333
|
-
getSvgContentForAstro,
|
|
2334
|
-
fetchSvgContent,
|
|
2335
|
-
injectSvgIntoElement,
|
|
2336
|
-
isValidKey,
|
|
2337
|
-
validateKey,
|
|
2338
|
-
toKey,
|
|
2339
|
-
nameToKey,
|
|
2340
|
-
track,
|
|
2341
|
-
getAvailableStock,
|
|
2342
|
-
getReservedStock,
|
|
2343
|
-
hasStock,
|
|
2344
|
-
getInventoryAt,
|
|
2345
|
-
getFirstAvailableFCId
|
|
2346
|
-
}
|
|
2916
|
+
utils: createUtilitySurface(apiConfig)
|
|
2347
2917
|
};
|
|
2348
2918
|
return sdk;
|
|
2349
2919
|
}
|
|
2920
|
+
async function createStorefront(config) {
|
|
2921
|
+
const locale = config.locale || "en";
|
|
2922
|
+
const httpClient = createHttpClient({
|
|
2923
|
+
...config,
|
|
2924
|
+
refreshPath: `/v1/storefront/${config.businessId}/customers/auth/refresh`
|
|
2925
|
+
});
|
|
2926
|
+
const apiConfig = {
|
|
2927
|
+
httpClient,
|
|
2928
|
+
businessId: config.businessId,
|
|
2929
|
+
baseUrl: config.baseUrl,
|
|
2930
|
+
market: config.market,
|
|
2931
|
+
locale,
|
|
2932
|
+
setToken: config.setToken,
|
|
2933
|
+
getToken: config.getToken
|
|
2934
|
+
};
|
|
2935
|
+
const storefrontApi = createStorefrontApi(apiConfig);
|
|
2936
|
+
if (typeof window !== "undefined" && apiConfig.businessId) {
|
|
2937
|
+
storefrontApi.business.getIntegrationConfig({ businessId: apiConfig.businessId, type: "analytics" }).then((configs) => {
|
|
2938
|
+
if (!configs) return;
|
|
2939
|
+
for (const c of Array.isArray(configs) ? configs : [configs]) {
|
|
2940
|
+
if (c.measurementId) {
|
|
2941
|
+
injectGA4Script(c.measurementId);
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
}).catch(() => {
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
return {
|
|
2948
|
+
business: storefrontApi.business,
|
|
2949
|
+
cms: storefrontApi.cms,
|
|
2950
|
+
eshop: storefrontApi.eshop,
|
|
2951
|
+
booking: storefrontApi.booking,
|
|
2952
|
+
crm: storefrontApi.crm,
|
|
2953
|
+
automation: storefrontApi.automation,
|
|
2954
|
+
analytics: {
|
|
2955
|
+
track
|
|
2956
|
+
},
|
|
2957
|
+
setBusinessId: (businessId) => {
|
|
2958
|
+
apiConfig.businessId = businessId;
|
|
2959
|
+
},
|
|
2960
|
+
getBusinessId: () => apiConfig.businessId,
|
|
2961
|
+
setMarket: (market) => {
|
|
2962
|
+
apiConfig.market = market;
|
|
2963
|
+
},
|
|
2964
|
+
getMarket: () => apiConfig.market,
|
|
2965
|
+
setLocale: (locale2) => {
|
|
2966
|
+
apiConfig.locale = locale2;
|
|
2967
|
+
},
|
|
2968
|
+
getLocale: () => apiConfig.locale,
|
|
2969
|
+
isAuthenticated: config.isAuthenticated || (() => false),
|
|
2970
|
+
logout: config.logout,
|
|
2971
|
+
setToken: config.setToken,
|
|
2972
|
+
extractBlockValues,
|
|
2973
|
+
utils: createUtilitySurface(apiConfig)
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2350
2976
|
|
|
2351
2977
|
exports.DEFAULT_REACTION_KINDS = DEFAULT_REACTION_KINDS;
|
|
2352
2978
|
exports.PaymentMethodType = PaymentMethodType;
|
|
@@ -2354,7 +2980,8 @@ exports.REACTION_KIND_REGEX = REACTION_KIND_REGEX;
|
|
|
2354
2980
|
exports.SDK_VERSION = SDK_VERSION;
|
|
2355
2981
|
exports.SUPPORTED_FRAMEWORKS = SUPPORTED_FRAMEWORKS;
|
|
2356
2982
|
exports.computeAverageStars = computeAverageStars;
|
|
2357
|
-
exports.
|
|
2983
|
+
exports.createAdmin = createAdmin;
|
|
2984
|
+
exports.createStorefront = createStorefront;
|
|
2358
2985
|
exports.isValidReactionKind = isValidReactionKind;
|
|
2359
2986
|
//# sourceMappingURL=index.cjs.map
|
|
2360
2987
|
//# sourceMappingURL=index.cjs.map
|