arky-sdk 0.4.13 → 0.4.15
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 +40 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -61
- package/dist/index.d.ts +17 -61
- package/dist/index.js +40 -88
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +8 -13
- package/dist/types.d.ts +8 -13
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +0 -34
- package/dist/utils.d.ts +0 -34
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -211,7 +211,6 @@ function createHttpClient(cfg) {
|
|
|
211
211
|
// src/api/account.ts
|
|
212
212
|
var createAccountApi = (apiConfig) => {
|
|
213
213
|
return {
|
|
214
|
-
// ===== ACCOUNT PROFILE =====
|
|
215
214
|
async updateAccount(params, options) {
|
|
216
215
|
const payload = {};
|
|
217
216
|
if (params.phoneNumbers !== void 0) payload.phoneNumbers = params.phoneNumbers;
|
|
@@ -240,7 +239,6 @@ var createAccountApi = (apiConfig) => {
|
|
|
240
239
|
}
|
|
241
240
|
});
|
|
242
241
|
},
|
|
243
|
-
// ===== SUBSCRIPTION =====
|
|
244
242
|
async subscribe(params, options) {
|
|
245
243
|
return apiConfig.httpClient.post("/v1/accounts/subscribe", params, options);
|
|
246
244
|
}
|
|
@@ -250,17 +248,9 @@ var createAccountApi = (apiConfig) => {
|
|
|
250
248
|
// src/api/auth.ts
|
|
251
249
|
var createAuthApi = (apiConfig) => {
|
|
252
250
|
return {
|
|
253
|
-
/**
|
|
254
|
-
* Create a guest session (anonymous user)
|
|
255
|
-
* POST /auth/session
|
|
256
|
-
*/
|
|
257
251
|
async session(options) {
|
|
258
252
|
return apiConfig.httpClient.post("/v1/auth/session", {}, options);
|
|
259
253
|
},
|
|
260
|
-
/**
|
|
261
|
-
* Sign in anonymously (creates guest session if not already authenticated)
|
|
262
|
-
* Following Firebase/Supabase pattern - idempotent, safe to call multiple times
|
|
263
|
-
*/
|
|
264
254
|
async signInAnonymously(options) {
|
|
265
255
|
const tokens = await apiConfig.getToken();
|
|
266
256
|
if (tokens?.accessToken) {
|
|
@@ -272,28 +262,15 @@ var createAuthApi = (apiConfig) => {
|
|
|
272
262
|
}
|
|
273
263
|
return result;
|
|
274
264
|
},
|
|
275
|
-
/**
|
|
276
|
-
* Check if current user is a guest (anonymous)
|
|
277
|
-
* Guest emails follow pattern: guest+uuid@arky.io
|
|
278
|
-
*/
|
|
279
265
|
async isGuest() {
|
|
280
266
|
const tokens = await apiConfig.getToken();
|
|
281
267
|
if (!tokens?.accessToken) return true;
|
|
282
268
|
const email = tokens.email || "";
|
|
283
269
|
return !email || email.startsWith("guest+");
|
|
284
270
|
},
|
|
285
|
-
// ==================== PLATFORM AUTH (Admin) ====================
|
|
286
|
-
/**
|
|
287
|
-
* Request platform auth code (Arky admin)
|
|
288
|
-
* POST /auth/code
|
|
289
|
-
*/
|
|
290
271
|
async code(params, options) {
|
|
291
272
|
return apiConfig.httpClient.post("/v1/auth/code", params, options);
|
|
292
273
|
},
|
|
293
|
-
/**
|
|
294
|
-
* Verify platform auth code - automatically sets token on success
|
|
295
|
-
* POST /auth/verify
|
|
296
|
-
*/
|
|
297
274
|
async verify(params, options) {
|
|
298
275
|
const result = await apiConfig.httpClient.post("/v1/auth/verify", params, options);
|
|
299
276
|
if (result?.accessToken) {
|
|
@@ -301,25 +278,12 @@ var createAuthApi = (apiConfig) => {
|
|
|
301
278
|
}
|
|
302
279
|
return result;
|
|
303
280
|
},
|
|
304
|
-
/**
|
|
305
|
-
* Refresh access token
|
|
306
|
-
* POST /auth/refresh
|
|
307
|
-
*/
|
|
308
281
|
async refresh(params, options) {
|
|
309
282
|
return apiConfig.httpClient.post("/v1/auth/refresh", params, options);
|
|
310
283
|
},
|
|
311
|
-
// ==================== BUSINESS AUTH (arky.io, delfin, soulofstrings) ====================
|
|
312
|
-
/**
|
|
313
|
-
* Request business auth code
|
|
314
|
-
* POST /businesses/{businessId}/auth/code
|
|
315
|
-
*/
|
|
316
284
|
async businessCode(businessId, params, options) {
|
|
317
285
|
return apiConfig.httpClient.post(`/v1/businesses/${businessId}/auth/code`, params, options);
|
|
318
286
|
},
|
|
319
|
-
/**
|
|
320
|
-
* Verify business auth code - automatically sets token on success
|
|
321
|
-
* POST /businesses/{businessId}/auth/verify
|
|
322
|
-
*/
|
|
323
287
|
async businessVerify(businessId, params, options) {
|
|
324
288
|
const result = await apiConfig.httpClient.post(`/v1/businesses/${businessId}/auth/verify`, params, options);
|
|
325
289
|
if (result?.accessToken) {
|
|
@@ -327,10 +291,6 @@ var createAuthApi = (apiConfig) => {
|
|
|
327
291
|
}
|
|
328
292
|
return result;
|
|
329
293
|
},
|
|
330
|
-
// ==================== DEPRECATED (for backwards compatibility) ====================
|
|
331
|
-
/**
|
|
332
|
-
* @deprecated Use code() instead
|
|
333
|
-
*/
|
|
334
294
|
async magicLink(params, options) {
|
|
335
295
|
return apiConfig.httpClient.post("/v1/auth/code", params, options);
|
|
336
296
|
}
|
|
@@ -467,6 +427,20 @@ var createBusinessApi = (apiConfig) => {
|
|
|
467
427
|
{ payload: params.payload },
|
|
468
428
|
options
|
|
469
429
|
);
|
|
430
|
+
},
|
|
431
|
+
async connectStripe(params, options) {
|
|
432
|
+
return apiConfig.httpClient.post(
|
|
433
|
+
`/v1/businesses/${params.businessId}/stripe/connect`,
|
|
434
|
+
{ code: params.code },
|
|
435
|
+
options
|
|
436
|
+
);
|
|
437
|
+
},
|
|
438
|
+
async disconnectStripe(params, options) {
|
|
439
|
+
return apiConfig.httpClient.post(
|
|
440
|
+
`/v1/businesses/${params.businessId}/stripe/disconnect`,
|
|
441
|
+
{},
|
|
442
|
+
options
|
|
443
|
+
);
|
|
470
444
|
}
|
|
471
445
|
};
|
|
472
446
|
};
|
|
@@ -859,7 +833,6 @@ var createCmsApi = (apiConfig) => {
|
|
|
859
833
|
// src/api/eshop.ts
|
|
860
834
|
var createEshopApi = (apiConfig) => {
|
|
861
835
|
return {
|
|
862
|
-
// ===== PRODUCTS =====
|
|
863
836
|
async createProduct(params, options) {
|
|
864
837
|
return apiConfig.httpClient.post(
|
|
865
838
|
`/v1/businesses/${apiConfig.businessId}/products`,
|
|
@@ -903,7 +876,6 @@ var createEshopApi = (apiConfig) => {
|
|
|
903
876
|
}
|
|
904
877
|
);
|
|
905
878
|
},
|
|
906
|
-
// ===== ORDERS =====
|
|
907
879
|
async createOrder(params, options) {
|
|
908
880
|
return apiConfig.httpClient.post(
|
|
909
881
|
`/v1/businesses/${apiConfig.businessId}/orders`,
|
|
@@ -933,7 +905,6 @@ var createEshopApi = (apiConfig) => {
|
|
|
933
905
|
}
|
|
934
906
|
);
|
|
935
907
|
},
|
|
936
|
-
// ===== PAYMENTS =====
|
|
937
908
|
async getQuote(params, options) {
|
|
938
909
|
const payload = {
|
|
939
910
|
market: apiConfig.market,
|
|
@@ -972,7 +943,6 @@ var createEshopApi = (apiConfig) => {
|
|
|
972
943
|
var createReservationApi = (apiConfig) => {
|
|
973
944
|
let cart = [];
|
|
974
945
|
return {
|
|
975
|
-
// ===== CART =====
|
|
976
946
|
addToCart(slot) {
|
|
977
947
|
cart.push(slot);
|
|
978
948
|
},
|
|
@@ -985,7 +955,6 @@ var createReservationApi = (apiConfig) => {
|
|
|
985
955
|
clearCart() {
|
|
986
956
|
cart = [];
|
|
987
957
|
},
|
|
988
|
-
// ===== RESERVATIONS =====
|
|
989
958
|
async createReservation(params, options) {
|
|
990
959
|
const { businessId, ...rest } = params;
|
|
991
960
|
const targetBusinessId = businessId || apiConfig.businessId;
|
|
@@ -1045,7 +1014,6 @@ var createReservationApi = (apiConfig) => {
|
|
|
1045
1014
|
}
|
|
1046
1015
|
);
|
|
1047
1016
|
},
|
|
1048
|
-
// ===== QUOTES =====
|
|
1049
1017
|
async getQuote(params, options) {
|
|
1050
1018
|
const { businessId, ...rest } = params;
|
|
1051
1019
|
const targetBusinessId = businessId || apiConfig.businessId;
|
|
@@ -1059,7 +1027,6 @@ var createReservationApi = (apiConfig) => {
|
|
|
1059
1027
|
options
|
|
1060
1028
|
);
|
|
1061
1029
|
},
|
|
1062
|
-
// ===== SERVICES =====
|
|
1063
1030
|
async createService(params, options) {
|
|
1064
1031
|
const { businessId, ...payload } = params;
|
|
1065
1032
|
const targetBusinessId = businessId || apiConfig.businessId;
|
|
@@ -1118,7 +1085,6 @@ var createReservationApi = (apiConfig) => {
|
|
|
1118
1085
|
}
|
|
1119
1086
|
);
|
|
1120
1087
|
},
|
|
1121
|
-
// ===== PROVIDERS =====
|
|
1122
1088
|
async createProvider(params, options) {
|
|
1123
1089
|
const { businessId, ...payload } = params;
|
|
1124
1090
|
const targetBusinessId = businessId || apiConfig.businessId;
|
|
@@ -1241,11 +1207,6 @@ var createLocationApi = (apiConfig) => {
|
|
|
1241
1207
|
// src/api/network.ts
|
|
1242
1208
|
var createNetworkApi = (apiConfig) => {
|
|
1243
1209
|
return {
|
|
1244
|
-
/**
|
|
1245
|
-
* Search services across all businesses that have opted into a network
|
|
1246
|
-
* @param networkKey - The network key (e.g., "delfin")
|
|
1247
|
-
* @param params - Search parameters
|
|
1248
|
-
*/
|
|
1249
1210
|
async searchServices(networkKey, params, options) {
|
|
1250
1211
|
const queryParams = {};
|
|
1251
1212
|
if (params?.limit !== void 0) queryParams.limit = params.limit;
|
|
@@ -1272,11 +1233,6 @@ var createNetworkApi = (apiConfig) => {
|
|
|
1272
1233
|
params: queryParams
|
|
1273
1234
|
});
|
|
1274
1235
|
},
|
|
1275
|
-
/**
|
|
1276
|
-
* Search products across all businesses that have opted into a network
|
|
1277
|
-
* @param networkKey - The network key (e.g., "delfin")
|
|
1278
|
-
* @param params - Search parameters
|
|
1279
|
-
*/
|
|
1280
1236
|
async searchProducts(networkKey, params, options) {
|
|
1281
1237
|
const queryParams = {};
|
|
1282
1238
|
if (params?.limit !== void 0) queryParams.limit = params.limit;
|
|
@@ -1303,11 +1259,6 @@ var createNetworkApi = (apiConfig) => {
|
|
|
1303
1259
|
params: queryParams
|
|
1304
1260
|
});
|
|
1305
1261
|
},
|
|
1306
|
-
/**
|
|
1307
|
-
* Search providers across all businesses that have opted into a network
|
|
1308
|
-
* @param networkKey - The network key (e.g., "delfin")
|
|
1309
|
-
* @param params - Search parameters
|
|
1310
|
-
*/
|
|
1311
1262
|
async searchProviders(networkKey, params, options) {
|
|
1312
1263
|
const queryParams = {};
|
|
1313
1264
|
if (params?.limit !== void 0) queryParams.limit = params.limit;
|
|
@@ -1373,10 +1324,6 @@ var createWorkflowApi = (apiConfig) => {
|
|
|
1373
1324
|
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
1374
1325
|
});
|
|
1375
1326
|
},
|
|
1376
|
-
/**
|
|
1377
|
-
* Trigger a workflow execution via webhook
|
|
1378
|
-
* No authentication required - the secret in the URL validates the request
|
|
1379
|
-
*/
|
|
1380
1327
|
async triggerWorkflow(params, options) {
|
|
1381
1328
|
const { secret, ...input } = params;
|
|
1382
1329
|
return apiConfig.httpClient.post(`/v1/workflows/trigger/${secret}`, input, options);
|
|
@@ -1457,6 +1404,15 @@ var createAudienceApi = (apiConfig) => {
|
|
|
1457
1404
|
};
|
|
1458
1405
|
};
|
|
1459
1406
|
|
|
1407
|
+
// src/api/platform.ts
|
|
1408
|
+
var createPlatformApi = (apiConfig) => {
|
|
1409
|
+
return {
|
|
1410
|
+
async getConfig(options) {
|
|
1411
|
+
return apiConfig.httpClient.get("/v1/platform/config", options);
|
|
1412
|
+
}
|
|
1413
|
+
};
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1460
1416
|
// src/utils/currency.ts
|
|
1461
1417
|
function getCurrencySymbol(currency) {
|
|
1462
1418
|
const currencySymbols = {
|
|
@@ -1747,7 +1703,6 @@ function slugify(text) {
|
|
|
1747
1703
|
function humanize(text) {
|
|
1748
1704
|
const slugifiedText = slugify(text);
|
|
1749
1705
|
return slugifiedText.replace(/-/g, " ").replace(
|
|
1750
|
-
// upper case first letter of every word, and lower case the rest
|
|
1751
1706
|
/\w\S*/g,
|
|
1752
1707
|
(w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()
|
|
1753
1708
|
);
|
|
@@ -1857,19 +1812,15 @@ function injectGA4Script(measurementId) {
|
|
|
1857
1812
|
script.src = `https://www.googletagmanager.com/gtag/js?id=${measurementId}`;
|
|
1858
1813
|
document.head.appendChild(script);
|
|
1859
1814
|
}
|
|
1860
|
-
function
|
|
1815
|
+
function track(eventName, params) {
|
|
1861
1816
|
if (typeof window === "undefined") return;
|
|
1862
1817
|
if (window.gtag) {
|
|
1863
1818
|
window.gtag("event", eventName, params);
|
|
1864
1819
|
}
|
|
1865
1820
|
}
|
|
1866
|
-
function isAnalyticsReady() {
|
|
1867
|
-
if (typeof window === "undefined") return false;
|
|
1868
|
-
return typeof window.gtag === "function";
|
|
1869
|
-
}
|
|
1870
1821
|
|
|
1871
1822
|
// src/index.ts
|
|
1872
|
-
var SDK_VERSION = "0.
|
|
1823
|
+
var SDK_VERSION = "0.4.15";
|
|
1873
1824
|
var SUPPORTED_FRAMEWORKS = [
|
|
1874
1825
|
"astro",
|
|
1875
1826
|
"react",
|
|
@@ -1891,13 +1842,23 @@ async function createArkySDK(config) {
|
|
|
1891
1842
|
};
|
|
1892
1843
|
const accountApi = createAccountApi(apiConfig);
|
|
1893
1844
|
const authApi = createAuthApi(apiConfig);
|
|
1845
|
+
const businessApi = createBusinessApi(apiConfig);
|
|
1846
|
+
if (typeof window !== "undefined") {
|
|
1847
|
+
businessApi.getBusiness({}).then(({ data: business }) => {
|
|
1848
|
+
if (business?.config?.analytics?.measurementId) {
|
|
1849
|
+
injectGA4Script(business.config.analytics.measurementId);
|
|
1850
|
+
}
|
|
1851
|
+
}).catch(() => {
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1894
1854
|
const sdk = {
|
|
1895
1855
|
auth: authApi,
|
|
1896
1856
|
account: accountApi,
|
|
1897
|
-
business:
|
|
1857
|
+
business: businessApi,
|
|
1898
1858
|
media: createMediaApi(apiConfig),
|
|
1899
1859
|
notification: createNotificationApi(apiConfig),
|
|
1900
1860
|
promoCode: createPromoCodeApi(apiConfig),
|
|
1861
|
+
platform: createPlatformApi(apiConfig),
|
|
1901
1862
|
cms: createCmsApi(apiConfig),
|
|
1902
1863
|
eshop: createEshopApi(apiConfig),
|
|
1903
1864
|
reservation: createReservationApi(apiConfig),
|
|
@@ -1906,6 +1867,9 @@ async function createArkySDK(config) {
|
|
|
1906
1867
|
network: createNetworkApi(apiConfig),
|
|
1907
1868
|
workflow: createWorkflowApi(apiConfig),
|
|
1908
1869
|
audience: createAudienceApi(apiConfig),
|
|
1870
|
+
analytics: {
|
|
1871
|
+
track
|
|
1872
|
+
},
|
|
1909
1873
|
setBusinessId: (businessId) => {
|
|
1910
1874
|
apiConfig.businessId = businessId;
|
|
1911
1875
|
},
|
|
@@ -1921,10 +1885,8 @@ async function createArkySDK(config) {
|
|
|
1921
1885
|
isAuthenticated: config.isAuthenticated || (() => false),
|
|
1922
1886
|
logout: config.logout,
|
|
1923
1887
|
setToken: config.setToken,
|
|
1924
|
-
// Top-level block utilities for convenience
|
|
1925
1888
|
extractBlockValues,
|
|
1926
1889
|
utils: {
|
|
1927
|
-
// Block utilities
|
|
1928
1890
|
getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock),
|
|
1929
1891
|
getBlockValue,
|
|
1930
1892
|
getBlockValues,
|
|
@@ -1935,37 +1897,27 @@ async function createArkySDK(config) {
|
|
|
1935
1897
|
formatBlockValue,
|
|
1936
1898
|
prepareBlocksForSubmission,
|
|
1937
1899
|
extractBlockValues,
|
|
1938
|
-
// Price utilities
|
|
1939
1900
|
getMarketPrice,
|
|
1940
1901
|
getPriceAmount,
|
|
1941
1902
|
formatPayment,
|
|
1942
1903
|
formatMinor,
|
|
1943
1904
|
createPaymentForCheckout,
|
|
1944
|
-
// Currency utilities
|
|
1945
1905
|
getCurrencySymbol,
|
|
1946
|
-
// Validation utilities
|
|
1947
1906
|
validatePhoneNumber,
|
|
1948
|
-
// Timezone utilities
|
|
1949
1907
|
tzGroups,
|
|
1950
1908
|
findTimeZone,
|
|
1951
|
-
// Text utilities
|
|
1952
1909
|
slugify,
|
|
1953
1910
|
humanize,
|
|
1954
1911
|
categorify,
|
|
1955
1912
|
formatDate,
|
|
1956
|
-
// SVG utilities
|
|
1957
1913
|
getSvgContentForAstro,
|
|
1958
1914
|
fetchSvgContent,
|
|
1959
1915
|
injectSvgIntoElement,
|
|
1960
|
-
// Key validation utilities
|
|
1961
1916
|
isValidKey,
|
|
1962
1917
|
validateKey,
|
|
1963
1918
|
toKey,
|
|
1964
1919
|
nameToKey,
|
|
1965
|
-
|
|
1966
|
-
injectGA4Script,
|
|
1967
|
-
trackEvent,
|
|
1968
|
-
isAnalyticsReady
|
|
1920
|
+
track
|
|
1969
1921
|
}
|
|
1970
1922
|
};
|
|
1971
1923
|
return sdk;
|