arky-sdk 0.7.57 → 0.7.60

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 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,503 @@ 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
+ },
1902
+ cms: {
1903
+ async getNode(params, options) {
1904
+ const businessId = params.businessId || apiConfig.businessId;
1905
+ let identifier;
1906
+ if (params.id) {
1907
+ identifier = params.id;
1908
+ } else if (params.slug) {
1909
+ identifier = `${businessId}:${apiConfig.locale}:${params.slug}`;
1910
+ } else if (params.key) {
1911
+ identifier = `${businessId}:${params.key}`;
1912
+ } else {
1913
+ throw new Error("GetNodeParams requires id, slug, or key");
1914
+ }
1915
+ const response = await apiConfig.httpClient.get(
1916
+ `${base(businessId)}/nodes/${identifier}`,
1917
+ options
1918
+ );
1919
+ return {
1920
+ ...response,
1921
+ getBlock(key) {
1922
+ return getBlockFromArray(response, key, apiConfig.locale);
1923
+ },
1924
+ getBlockValues(key) {
1925
+ return getBlockObjectValues(response, key, apiConfig.locale);
1926
+ },
1927
+ getImage(key) {
1928
+ const block = getBlockFromArray(response, key, apiConfig.locale);
1929
+ return getImageUrl(block, true);
1930
+ }
1931
+ };
1932
+ },
1933
+ getNodes(params, options) {
1934
+ const { businessId, ...queryParams } = params;
1935
+ return apiConfig.httpClient.get(`${base(businessId)}/nodes`, {
1936
+ ...options,
1937
+ params: queryParams
1938
+ });
1939
+ },
1940
+ getNodeChildren(params, options) {
1941
+ const { id, businessId, ...queryParams } = params;
1942
+ return apiConfig.httpClient.get(`${base(businessId)}/nodes/${id}/children`, {
1943
+ ...options,
1944
+ params: queryParams
1945
+ });
1946
+ }
1947
+ },
1948
+ form: {
1949
+ getForm(params, options) {
1950
+ const businessId = params.businessId || apiConfig.businessId;
1951
+ let identifier;
1952
+ if (params.id) {
1953
+ identifier = params.id;
1954
+ } else if (params.key) {
1955
+ identifier = `${businessId}:${params.key}`;
1956
+ } else {
1957
+ throw new Error("GetFormParams requires id or key");
1958
+ }
1959
+ return apiConfig.httpClient.get(
1960
+ `${base(businessId)}/forms/${identifier}`,
1961
+ options
1962
+ );
1963
+ },
1964
+ submit(params, options) {
1965
+ const { businessId, formId, ...payload } = params;
1966
+ const targetBusinessId = businessId || apiConfig.businessId;
1967
+ return apiConfig.httpClient.post(
1968
+ `${base(targetBusinessId)}/forms/${formId}/submissions`,
1969
+ { ...payload, formId, businessId: targetBusinessId },
1970
+ options
1971
+ );
1972
+ }
1973
+ },
1974
+ taxonomy: {
1975
+ getTaxonomy(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("GetTaxonomyParams requires id or key");
1984
+ }
1985
+ return apiConfig.httpClient.get(
1986
+ `${base(businessId)}/taxonomies/${identifier}`,
1987
+ options
1988
+ );
1989
+ },
1990
+ getTaxonomyChildren(params, options) {
1991
+ const businessId = params.businessId || apiConfig.businessId;
1992
+ return apiConfig.httpClient.get(
1993
+ `${base(businessId)}/taxonomies/${params.id}/children`,
1994
+ options
1995
+ );
1996
+ }
1997
+ },
1998
+ eshop: {
1999
+ getProduct(params, options) {
2000
+ const businessId = params.businessId || apiConfig.businessId;
2001
+ let identifier;
2002
+ if (params.id) {
2003
+ identifier = params.id;
2004
+ } else if (params.slug) {
2005
+ identifier = `${businessId}:${apiConfig.locale}:${params.slug}`;
2006
+ } else {
2007
+ throw new Error("GetProductParams requires id or slug");
2008
+ }
2009
+ return apiConfig.httpClient.get(
2010
+ `${base(businessId)}/products/${identifier}`,
2011
+ options
2012
+ );
2013
+ },
2014
+ getProducts(params, options) {
2015
+ const { businessId, ...queryParams } = params;
2016
+ return apiConfig.httpClient.get(`${base(businessId)}/products`, {
2017
+ ...options,
2018
+ params: queryParams
2019
+ });
2020
+ },
2021
+ getQuote(params, options) {
2022
+ const businessId = params.businessId || apiConfig.businessId;
2023
+ const { location, businessId: _businessId, ...rest } = params;
2024
+ const shippingAddress = location ? {
2025
+ country: location.country || "",
2026
+ state: location.state || "",
2027
+ city: location.city || "",
2028
+ postalCode: location.postalCode || "",
2029
+ name: "",
2030
+ street1: "",
2031
+ street2: null
2032
+ } : void 0;
2033
+ return apiConfig.httpClient.post(
2034
+ `${base(businessId)}/orders/quote`,
2035
+ { ...rest, shippingAddress, market: apiConfig.market },
2036
+ options
2037
+ );
2038
+ },
2039
+ checkout(params, options) {
2040
+ const businessId = params.businessId || apiConfig.businessId;
2041
+ return apiConfig.httpClient.post(
2042
+ `${base(businessId)}/orders/checkout`,
2043
+ { ...params, businessId, market: apiConfig.market },
2044
+ options
2045
+ );
2046
+ },
2047
+ getOrder(params, options) {
2048
+ const businessId = params.businessId || apiConfig.businessId;
2049
+ return apiConfig.httpClient.get(
2050
+ `${base(businessId)}/orders/${params.id}`,
2051
+ options
2052
+ );
2053
+ },
2054
+ getOrders(params, options) {
2055
+ const { businessId, ...queryParams } = params;
2056
+ return apiConfig.httpClient.get(`${base(businessId)}/orders`, {
2057
+ ...options,
2058
+ params: queryParams
2059
+ });
2060
+ }
2061
+ },
2062
+ booking: {
2063
+ addToCart(slot) {
2064
+ cart.push(slot);
2065
+ },
2066
+ removeFromCart(slotId) {
2067
+ cart = cart.filter((slot) => slot.id !== slotId);
2068
+ },
2069
+ getCart() {
2070
+ return [...cart];
2071
+ },
2072
+ clearCart() {
2073
+ cart = [];
2074
+ },
2075
+ checkout(params, options) {
2076
+ const { businessId, items: paramItems, ...payload } = params || {};
2077
+ const targetBusinessId = businessId || apiConfig.businessId;
2078
+ const items = paramItems || groupCartToItems(cart);
2079
+ return apiConfig.httpClient.post(
2080
+ `${base(targetBusinessId)}/bookings/checkout`,
2081
+ { market: "booking", ...payload, items },
2082
+ options
2083
+ );
2084
+ },
2085
+ getBooking(params, options) {
2086
+ const businessId = params.businessId || apiConfig.businessId;
2087
+ return apiConfig.httpClient.get(
2088
+ `${base(businessId)}/bookings/${params.id}`,
2089
+ options
2090
+ );
2091
+ },
2092
+ searchBookings(params, options) {
2093
+ const { businessId, ...queryParams } = params;
2094
+ return apiConfig.httpClient.get(`${base(businessId)}/bookings`, {
2095
+ ...options,
2096
+ params: queryParams
2097
+ });
2098
+ },
2099
+ getQuote(params, options) {
2100
+ const { businessId, ...payload } = params;
2101
+ return apiConfig.httpClient.post(
2102
+ `${base(businessId)}/bookings/quote`,
2103
+ { market: "booking", ...payload },
2104
+ options
2105
+ );
2106
+ },
2107
+ getAvailability(params, options) {
2108
+ const { businessId, ...queryParams } = params;
2109
+ return apiConfig.httpClient.get(
2110
+ `${base(businessId)}/bookings/availability`,
2111
+ { ...options, params: queryParams }
2112
+ );
2113
+ },
2114
+ getService(params, options) {
2115
+ const businessId = params.businessId || apiConfig.businessId;
2116
+ let identifier;
2117
+ if (params.id) {
2118
+ identifier = params.id;
2119
+ } else if (params.slug) {
2120
+ identifier = `${businessId}:${apiConfig.locale}:${params.slug}`;
2121
+ } else {
2122
+ throw new Error("GetServiceParams requires id or slug");
2123
+ }
2124
+ return apiConfig.httpClient.get(
2125
+ `${base(businessId)}/services/${identifier}`,
2126
+ options
2127
+ );
2128
+ },
2129
+ getServices(params, options) {
2130
+ const { businessId, ...queryParams } = params;
2131
+ return apiConfig.httpClient.get(`${base(businessId)}/services`, {
2132
+ ...options,
2133
+ params: queryParams
2134
+ });
2135
+ },
2136
+ getProvider(params, options) {
2137
+ const businessId = params.businessId || apiConfig.businessId;
2138
+ let identifier;
2139
+ if (params.id) {
2140
+ identifier = params.id;
2141
+ } else if (params.slug) {
2142
+ identifier = `${businessId}:${apiConfig.locale}:${params.slug}`;
2143
+ } else {
2144
+ throw new Error("GetProviderParams requires id or slug");
2145
+ }
2146
+ return apiConfig.httpClient.get(
2147
+ `${base(businessId)}/providers/${identifier}`,
2148
+ options
2149
+ );
2150
+ },
2151
+ getProviders(params, options) {
2152
+ const { businessId, ...queryParams } = params;
2153
+ return apiConfig.httpClient.get(`${base(businessId)}/providers`, {
2154
+ ...options,
2155
+ params: queryParams
2156
+ });
2157
+ },
2158
+ cancelBookingItem(params, options) {
2159
+ const { businessId, bookingId, itemId, ...payload } = params;
2160
+ return apiConfig.httpClient.post(
2161
+ `${base(businessId)}/bookings/${bookingId}/items/${itemId}/cancel`,
2162
+ payload,
2163
+ options
2164
+ );
2165
+ },
2166
+ findServiceProviders(params, options) {
2167
+ const { businessId, ...queryParams } = params;
2168
+ return apiConfig.httpClient.get(`${base(businessId)}/service-providers`, {
2169
+ ...options,
2170
+ params: queryParams
2171
+ });
2172
+ }
2173
+ },
2174
+ location: {
2175
+ getCountries(options) {
2176
+ return apiConfig.httpClient.get(`/v1/platform/countries`, options);
2177
+ },
2178
+ getCountry(countryCode, options) {
2179
+ return apiConfig.httpClient.get(
2180
+ `/v1/platform/countries/${countryCode}`,
2181
+ options
2182
+ );
2183
+ },
2184
+ list(options) {
2185
+ return apiConfig.httpClient.get(`${base()}/locations`, options);
2186
+ },
2187
+ get(id, options) {
2188
+ return apiConfig.httpClient.get(`${base()}/locations/${id}`, options);
2189
+ }
2190
+ },
2191
+ market: {
2192
+ list(options) {
2193
+ return apiConfig.httpClient.get(`${base()}/markets`, options);
2194
+ },
2195
+ get(id, options) {
2196
+ return apiConfig.httpClient.get(`${base()}/markets/${id}`, options);
2197
+ }
2198
+ },
2199
+ crm: {
2200
+ requestCode(params, options) {
2201
+ const businessId = params.businessId || apiConfig.businessId;
2202
+ return apiConfig.httpClient.post(
2203
+ `${base(businessId)}/customers/auth/code`,
2204
+ { email: params.email, businessId },
2205
+ options
2206
+ );
2207
+ },
2208
+ verify(params, options) {
2209
+ const businessId = params.businessId || apiConfig.businessId;
2210
+ return apiConfig.httpClient.post(
2211
+ `${base(businessId)}/customers/auth/verify`,
2212
+ { email: params.email, code: params.code, businessId },
2213
+ options
2214
+ );
2215
+ },
2216
+ refreshToken(params, options) {
2217
+ const businessId = params.businessId || apiConfig.businessId;
2218
+ return apiConfig.httpClient.post(
2219
+ `${base(businessId)}/customers/auth/refresh`,
2220
+ { refreshToken: params.refreshToken },
2221
+ options
2222
+ );
2223
+ },
2224
+ getMe(options) {
2225
+ return apiConfig.httpClient.get(`${base()}/customers/me`, options);
2226
+ },
2227
+ initialize(params, options) {
2228
+ const businessId = params?.businessId || apiConfig.businessId;
2229
+ return apiConfig.httpClient.post(
2230
+ `${base(businessId)}/customers/initialize`,
2231
+ { businessId },
2232
+ options
2233
+ );
2234
+ },
2235
+ connect(params, options) {
2236
+ const businessId = params.businessId || apiConfig.businessId;
2237
+ return apiConfig.httpClient.post(
2238
+ `${base(businessId)}/customers/connect`,
2239
+ { email: params.email, businessId },
2240
+ options
2241
+ );
2242
+ },
2243
+ audiences: {
2244
+ get(params, options) {
2245
+ let identifier;
2246
+ if (params.id) {
2247
+ identifier = params.id;
2248
+ } else if (params.key) {
2249
+ identifier = `${apiConfig.businessId}:${params.key}`;
2250
+ } else {
2251
+ throw new Error("GetAudienceParams requires id or key");
2252
+ }
2253
+ return apiConfig.httpClient.get(
2254
+ `${base(apiConfig.businessId)}/audiences/${identifier}`,
2255
+ options
2256
+ );
2257
+ },
2258
+ find(params, options) {
2259
+ return apiConfig.httpClient.get(`${base()}/audiences`, {
2260
+ ...options,
2261
+ params
2262
+ });
2263
+ },
2264
+ subscribe(params, options) {
2265
+ return apiConfig.httpClient.post(
2266
+ `${base()}/audiences/${params.id}/subscribe`,
2267
+ {
2268
+ customerId: params.customerId,
2269
+ priceId: params.priceId,
2270
+ successUrl: params.successUrl,
2271
+ cancelUrl: params.cancelUrl,
2272
+ confirmUrl: params.confirmUrl
2273
+ },
2274
+ options
2275
+ );
2276
+ },
2277
+ checkAccess(params, options) {
2278
+ return apiConfig.httpClient.get(
2279
+ `${base()}/audiences/${params.id}/access`,
2280
+ options
2281
+ );
2282
+ },
2283
+ unsubscribe(token, options) {
2284
+ return apiConfig.httpClient.get(`${base()}/audiences/unsubscribe`, {
2285
+ ...options,
2286
+ params: { token }
2287
+ });
2288
+ },
2289
+ confirm(token, options) {
2290
+ return apiConfig.httpClient.get(`${base()}/audiences/confirm`, {
2291
+ ...options,
2292
+ params: { token }
2293
+ });
2294
+ }
2295
+ }
2296
+ },
2297
+ reaction: {
2298
+ DEFAULT_REACTION_KINDS,
2299
+ isValidReactionKind,
2300
+ computeAverageStars,
2301
+ create(params, options) {
2302
+ const businessId = params.businessId || apiConfig.businessId;
2303
+ return apiConfig.httpClient.post(
2304
+ `${base(businessId)}/reactions`,
2305
+ {
2306
+ businessId,
2307
+ target: params.target,
2308
+ kind: params.kind,
2309
+ blocks: params.blocks || [],
2310
+ parentId: params.parentId,
2311
+ taxonomies: params.taxonomies || []
2312
+ },
2313
+ options
2314
+ );
2315
+ },
2316
+ get(params, options) {
2317
+ const businessId = params.businessId || apiConfig.businessId;
2318
+ return apiConfig.httpClient.get(
2319
+ `${base(businessId)}/reactions/${params.id}`,
2320
+ options
2321
+ );
2322
+ },
2323
+ find(params, options) {
2324
+ const businessId = params?.businessId || apiConfig.businessId;
2325
+ const queryParams = { ...params || {} };
2326
+ delete queryParams.businessId;
2327
+ return apiConfig.httpClient.get(`${base(businessId)}/reactions`, {
2328
+ ...options,
2329
+ params: queryParams
2330
+ });
2331
+ },
2332
+ update(params, options) {
2333
+ const businessId = params.businessId || apiConfig.businessId;
2334
+ return apiConfig.httpClient.put(
2335
+ `${base(businessId)}/reactions/${params.id}`,
2336
+ {
2337
+ id: params.id,
2338
+ businessId,
2339
+ blocks: params.blocks,
2340
+ taxonomies: params.taxonomies
2341
+ },
2342
+ options
2343
+ );
2344
+ },
2345
+ remove(params, options) {
2346
+ const businessId = params.businessId || apiConfig.businessId;
2347
+ return apiConfig.httpClient.delete(
2348
+ `${base(businessId)}/reactions/${params.id}`,
2349
+ options
2350
+ );
2351
+ },
2352
+ summary(params, options) {
2353
+ const businessId = params.businessId || apiConfig.businessId;
2354
+ return apiConfig.httpClient.get(`${base(businessId)}/reactions/summary`, {
2355
+ ...options,
2356
+ params: {
2357
+ businessId,
2358
+ targetType: params.targetType,
2359
+ targetId: params.targetId,
2360
+ parentId: params.parentId
2361
+ }
2362
+ });
2363
+ }
2364
+ }
2365
+ };
2366
+ };
2367
+
1964
2368
  // src/utils/price.ts
1965
2369
  function formatCurrency(amount, currencyCode, locale = "en") {
1966
2370
  return new Intl.NumberFormat(locale, {
@@ -2231,7 +2635,7 @@ function getFirstAvailableFCId(variant, quantity = 1) {
2231
2635
  }
2232
2636
 
2233
2637
  // src/index.ts
2234
- var SDK_VERSION = "0.7.27";
2638
+ var SDK_VERSION = "0.7.59";
2235
2639
  var SUPPORTED_FRAMEWORKS = [
2236
2640
  "astro",
2237
2641
  "react",
@@ -2239,7 +2643,47 @@ var SUPPORTED_FRAMEWORKS = [
2239
2643
  "svelte",
2240
2644
  "vanilla"
2241
2645
  ];
2242
- async function createArkySDK(config) {
2646
+ function createUtilitySurface(apiConfig) {
2647
+ return {
2648
+ getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock),
2649
+ getBlockValue,
2650
+ getBlockTextValue,
2651
+ getBlockValues,
2652
+ getBlockLabel,
2653
+ getBlockObjectValues,
2654
+ getBlockFromArray,
2655
+ formatBlockValue,
2656
+ prepareBlocksForSubmission,
2657
+ extractBlockValues,
2658
+ formatPrice: (prices) => formatPrice(prices, apiConfig.market),
2659
+ getPriceAmount: (prices) => getPriceAmount(prices, apiConfig.market),
2660
+ formatPayment,
2661
+ formatMinor,
2662
+ getCurrencySymbol,
2663
+ getCurrencyName,
2664
+ validatePhoneNumber,
2665
+ tzGroups,
2666
+ findTimeZone,
2667
+ slugify,
2668
+ humanize,
2669
+ categorify,
2670
+ formatDate,
2671
+ getSvgContentForAstro,
2672
+ fetchSvgContent,
2673
+ injectSvgIntoElement,
2674
+ isValidKey,
2675
+ validateKey,
2676
+ toKey,
2677
+ nameToKey,
2678
+ track,
2679
+ getAvailableStock,
2680
+ getReservedStock,
2681
+ hasStock,
2682
+ getInventoryAt,
2683
+ getFirstAvailableFCId
2684
+ };
2685
+ }
2686
+ async function createAdmin(config) {
2243
2687
  const locale = config.locale || "en";
2244
2688
  const httpClient = createHttpClient(config);
2245
2689
  const apiConfig = {
@@ -2266,6 +2710,11 @@ async function createArkySDK(config) {
2266
2710
  }).catch(() => {
2267
2711
  });
2268
2712
  }
2713
+ const cmsApi = createCmsApi(apiConfig);
2714
+ const eshopApi = createEshopApi(apiConfig);
2715
+ const bookingApi = createBookingApi(apiConfig);
2716
+ const crmApi = createCustomerApi(apiConfig);
2717
+ const reactionApi = createReactionApi(apiConfig);
2269
2718
  const sdk = {
2270
2719
  auth: authApi,
2271
2720
  account: accountApi,
@@ -2274,13 +2723,69 @@ async function createArkySDK(config) {
2274
2723
  notification: createNotificationApi(apiConfig),
2275
2724
  promoCode: createPromoCodeApi(apiConfig),
2276
2725
  platform: platformApi,
2277
- cms: createCmsApi(apiConfig),
2278
- eshop: createEshopApi(apiConfig),
2279
- booking: createBookingApi(apiConfig),
2726
+ cms: cmsApi,
2727
+ eshop: {
2728
+ createProduct: eshopApi.createProduct,
2729
+ updateProduct: eshopApi.updateProduct,
2730
+ deleteProduct: eshopApi.deleteProduct,
2731
+ getProduct: eshopApi.getProduct,
2732
+ getProducts: eshopApi.getProducts,
2733
+ createOrder: eshopApi.createOrder,
2734
+ updateOrder: eshopApi.updateOrder,
2735
+ getOrder: eshopApi.getOrder,
2736
+ getOrders: eshopApi.getOrders,
2737
+ getQuote: eshopApi.getQuote,
2738
+ processRefund: eshopApi.processRefund
2739
+ },
2740
+ booking: {
2741
+ addToCart: bookingApi.addToCart,
2742
+ removeFromCart: bookingApi.removeFromCart,
2743
+ getCart: bookingApi.getCart,
2744
+ clearCart: bookingApi.clearCart,
2745
+ createBooking: bookingApi.createBooking,
2746
+ updateBooking: bookingApi.updateBooking,
2747
+ getBooking: bookingApi.getBooking,
2748
+ searchBookings: bookingApi.searchBookings,
2749
+ getQuote: bookingApi.getQuote,
2750
+ processRefund: bookingApi.processRefund,
2751
+ getAvailability: bookingApi.getAvailability,
2752
+ createService: bookingApi.createService,
2753
+ updateService: bookingApi.updateService,
2754
+ deleteService: bookingApi.deleteService,
2755
+ getService: bookingApi.getService,
2756
+ getServices: bookingApi.getServices,
2757
+ createProvider: bookingApi.createProvider,
2758
+ updateProvider: bookingApi.updateProvider,
2759
+ deleteProvider: bookingApi.deleteProvider,
2760
+ getProvider: bookingApi.getProvider,
2761
+ getProviders: bookingApi.getProviders,
2762
+ cancelBookingItem: bookingApi.cancelBookingItem,
2763
+ findServiceProviders: bookingApi.findServiceProviders,
2764
+ createServiceProvider: bookingApi.createServiceProvider,
2765
+ updateServiceProvider: bookingApi.updateServiceProvider,
2766
+ deleteServiceProvider: bookingApi.deleteServiceProvider
2767
+ },
2280
2768
  location: createLocationApi(apiConfig),
2281
2769
  market: createMarketApi(apiConfig),
2282
- crm: createCustomerApi(apiConfig),
2283
- reaction: createReactionApi(apiConfig),
2770
+ crm: {
2771
+ create: crmApi.create,
2772
+ get: crmApi.get,
2773
+ find: crmApi.find,
2774
+ update: crmApi.update,
2775
+ merge: crmApi.merge,
2776
+ revokeToken: crmApi.revokeToken,
2777
+ revokeAllTokens: crmApi.revokeAllTokens,
2778
+ audiences: {
2779
+ create: crmApi.audiences.create,
2780
+ update: crmApi.audiences.update,
2781
+ get: crmApi.audiences.get,
2782
+ find: crmApi.audiences.find,
2783
+ getSubscribers: crmApi.audiences.getSubscribers,
2784
+ addSubscriber: crmApi.audiences.addSubscriber,
2785
+ removeSubscriber: crmApi.audiences.removeSubscriber
2786
+ }
2787
+ },
2788
+ reaction: reactionApi,
2284
2789
  workflow: createWorkflowApi(apiConfig),
2285
2790
  shipping: createShippingApi(apiConfig),
2286
2791
  agent: createAgentApi(apiConfig),
@@ -2306,47 +2811,70 @@ async function createArkySDK(config) {
2306
2811
  logout: config.logout,
2307
2812
  setToken: config.setToken,
2308
2813
  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
- }
2814
+ utils: createUtilitySurface(apiConfig)
2347
2815
  };
2348
2816
  return sdk;
2349
2817
  }
2818
+ async function createStorefront(config) {
2819
+ const locale = config.locale || "en";
2820
+ const httpClient = createHttpClient({
2821
+ ...config,
2822
+ refreshPath: `/v1/storefront/${config.businessId}/customers/auth/refresh`
2823
+ });
2824
+ const apiConfig = {
2825
+ httpClient,
2826
+ businessId: config.businessId,
2827
+ baseUrl: config.baseUrl,
2828
+ market: config.market,
2829
+ locale,
2830
+ setToken: config.setToken,
2831
+ getToken: config.getToken
2832
+ };
2833
+ const storefrontApi = createStorefrontApi(apiConfig);
2834
+ if (typeof window !== "undefined" && apiConfig.businessId) {
2835
+ storefrontApi.business.getIntegrationConfig({ businessId: apiConfig.businessId, type: "analytics" }).then((configs) => {
2836
+ if (!configs) return;
2837
+ for (const c of Array.isArray(configs) ? configs : [configs]) {
2838
+ if (c.measurementId) {
2839
+ injectGA4Script(c.measurementId);
2840
+ }
2841
+ }
2842
+ }).catch(() => {
2843
+ });
2844
+ }
2845
+ return {
2846
+ business: storefrontApi.business,
2847
+ cms: storefrontApi.cms,
2848
+ form: storefrontApi.form,
2849
+ taxonomy: storefrontApi.taxonomy,
2850
+ eshop: storefrontApi.eshop,
2851
+ booking: storefrontApi.booking,
2852
+ location: storefrontApi.location,
2853
+ market: storefrontApi.market,
2854
+ crm: storefrontApi.crm,
2855
+ reaction: storefrontApi.reaction,
2856
+ analytics: {
2857
+ track
2858
+ },
2859
+ setBusinessId: (businessId) => {
2860
+ apiConfig.businessId = businessId;
2861
+ },
2862
+ getBusinessId: () => apiConfig.businessId,
2863
+ setMarket: (market) => {
2864
+ apiConfig.market = market;
2865
+ },
2866
+ getMarket: () => apiConfig.market,
2867
+ setLocale: (locale2) => {
2868
+ apiConfig.locale = locale2;
2869
+ },
2870
+ getLocale: () => apiConfig.locale,
2871
+ isAuthenticated: config.isAuthenticated || (() => false),
2872
+ logout: config.logout,
2873
+ setToken: config.setToken,
2874
+ extractBlockValues,
2875
+ utils: createUtilitySurface(apiConfig)
2876
+ };
2877
+ }
2350
2878
 
2351
2879
  exports.DEFAULT_REACTION_KINDS = DEFAULT_REACTION_KINDS;
2352
2880
  exports.PaymentMethodType = PaymentMethodType;
@@ -2354,7 +2882,8 @@ exports.REACTION_KIND_REGEX = REACTION_KIND_REGEX;
2354
2882
  exports.SDK_VERSION = SDK_VERSION;
2355
2883
  exports.SUPPORTED_FRAMEWORKS = SUPPORTED_FRAMEWORKS;
2356
2884
  exports.computeAverageStars = computeAverageStars;
2357
- exports.createArkySDK = createArkySDK;
2885
+ exports.createAdmin = createAdmin;
2886
+ exports.createStorefront = createStorefront;
2358
2887
  exports.isValidReactionKind = isValidReactionKind;
2359
2888
  //# sourceMappingURL=index.cjs.map
2360
2889
  //# sourceMappingURL=index.cjs.map