arky-sdk 0.3.1 → 0.3.3

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.d.cts CHANGED
@@ -3,6 +3,30 @@ export { ApiResponse, ApplyPromoCodeParams, Block, Business, BusinessConfig, Bus
3
3
  import { g as getGalleryThumbnail, a as getMarketPrice, b as getPriceAmount, f as formatPayment, c as formatMinor, d as createPaymentForCheckout, e as getCurrencySymbol, v as validatePhoneNumber, h as findTimeZone } from './index-DOEos-hV.cjs';
4
4
  export { C as Collection, i as CollectionEntry, E as ERROR_CODES, x as ERROR_CONSTANTS, R as RequestError, S as SYMBOL_AFTER_CURRENCIES, y as ServerError, V as ValidationError, U as ValidationResult, P as categorify, D as convertServerErrorToRequestError, G as convertToMajor, H as convertToMinor, F as errors, l as extractBlockValues, K as fetchSvgContent, k as formatBlockValue, J as formatCurrencyAmount, Q as formatDate, r as getBlockFromArray, j as getBlockLabel, q as getBlockObjectValues, m as getBlockTextValue, n as getBlockValue, o as getBlockValues, I as getCurrencyFromMarket, z as getErrorMessage, s as getImageUrl, L as getSvgContentForAstro, O as humanize, M as injectSvgIntoElement, A as isErrorCode, w as isSymbolAfterCurrency, p as prepareBlocksForSubmission, N as slugify, t as thumbnailUrl, B as transformErrors, u as translateMap, T as tzGroups, W as validateEmail, Y as validateRequired, X as validateVerificationCode } from './index-DOEos-hV.cjs';
5
5
 
6
+ interface AuthTokens {
7
+ accessToken: string;
8
+ refreshToken?: string;
9
+ provider?: string;
10
+ expiresAt?: number;
11
+ userId?: string;
12
+ }
13
+ interface HttpClientConfig {
14
+ baseUrl: string;
15
+ storageUrl?: string;
16
+ businessId: string;
17
+ getTokens: () => Promise<AuthTokens> | AuthTokens;
18
+ setTokens: (tokens: AuthTokens) => void;
19
+ autoGuest?: boolean;
20
+ logout: () => void;
21
+ navigate?: (path: string) => void;
22
+ loginFallbackPath?: string;
23
+ notify?: (opts: {
24
+ message: string;
25
+ type: 'error' | 'success';
26
+ }) => void;
27
+ isAuthenticated?: () => boolean;
28
+ }
29
+
6
30
  declare const createCmsApi: (apiConfig: ApiConfig) => {
7
31
  createCollection(params: CreateCollectionParams, options?: RequestOptions): Promise<any>;
8
32
  updateCollection(params: UpdateCollectionParams, options?: RequestOptions): Promise<any>;
@@ -190,33 +214,7 @@ declare function buildQueryString(params: QueryParams): string;
190
214
  */
191
215
  declare function appendQueryString(url: string, params: QueryParams): string;
192
216
 
193
- interface AuthTokens {
194
- accessToken: string;
195
- refreshToken?: string;
196
- provider?: string;
197
- expiresAt?: number;
198
- userId?: string;
199
- }
200
- interface HttpClientConfig {
201
- baseUrl: string;
202
- storageUrl?: string;
203
- businessId: string;
204
- getTokens: () => Promise<AuthTokens> | AuthTokens;
205
- setTokens: (tokens: AuthTokens) => void;
206
- autoGuest?: boolean;
207
- onAuthFailure: () => void;
208
- navigate?: (path: string) => void;
209
- loginFallbackPath?: string;
210
- notify?: (opts: {
211
- message: string;
212
- type: 'error' | 'success';
213
- }) => void;
214
- isAuthenticated?: () => boolean;
215
- logout?: () => void;
216
- setUserToken?: (userToken: any) => void;
217
- }
218
-
219
- declare const SDK_VERSION = "0.3.1";
217
+ declare const SDK_VERSION = "0.3.3";
220
218
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
221
219
  interface ApiConfig {
222
220
  httpClient: any;
@@ -382,11 +380,9 @@ declare function createArkySDK(config: HttpClientConfig & {
382
380
  };
383
381
  setBusinessId: (businessId: string) => void;
384
382
  getBusinessId: () => string;
385
- auth: {
386
- isAuthenticated: () => boolean;
387
- logout: () => void;
388
- setUserToken: (userToken: any) => void;
389
- };
383
+ isAuthenticated: () => boolean;
384
+ logout: () => void;
385
+ setTokens: (tokens: AuthTokens) => void;
390
386
  utils: {
391
387
  getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
392
388
  thumbnailUrl: (service: any) => string;
package/dist/index.d.ts CHANGED
@@ -3,6 +3,30 @@ export { ApiResponse, ApplyPromoCodeParams, Block, Business, BusinessConfig, Bus
3
3
  import { g as getGalleryThumbnail, a as getMarketPrice, b as getPriceAmount, f as formatPayment, c as formatMinor, d as createPaymentForCheckout, e as getCurrencySymbol, v as validatePhoneNumber, h as findTimeZone } from './index-DEmVFs0E.js';
4
4
  export { C as Collection, i as CollectionEntry, E as ERROR_CODES, x as ERROR_CONSTANTS, R as RequestError, S as SYMBOL_AFTER_CURRENCIES, y as ServerError, V as ValidationError, U as ValidationResult, P as categorify, D as convertServerErrorToRequestError, G as convertToMajor, H as convertToMinor, F as errors, l as extractBlockValues, K as fetchSvgContent, k as formatBlockValue, J as formatCurrencyAmount, Q as formatDate, r as getBlockFromArray, j as getBlockLabel, q as getBlockObjectValues, m as getBlockTextValue, n as getBlockValue, o as getBlockValues, I as getCurrencyFromMarket, z as getErrorMessage, s as getImageUrl, L as getSvgContentForAstro, O as humanize, M as injectSvgIntoElement, A as isErrorCode, w as isSymbolAfterCurrency, p as prepareBlocksForSubmission, N as slugify, t as thumbnailUrl, B as transformErrors, u as translateMap, T as tzGroups, W as validateEmail, Y as validateRequired, X as validateVerificationCode } from './index-DEmVFs0E.js';
5
5
 
6
+ interface AuthTokens {
7
+ accessToken: string;
8
+ refreshToken?: string;
9
+ provider?: string;
10
+ expiresAt?: number;
11
+ userId?: string;
12
+ }
13
+ interface HttpClientConfig {
14
+ baseUrl: string;
15
+ storageUrl?: string;
16
+ businessId: string;
17
+ getTokens: () => Promise<AuthTokens> | AuthTokens;
18
+ setTokens: (tokens: AuthTokens) => void;
19
+ autoGuest?: boolean;
20
+ logout: () => void;
21
+ navigate?: (path: string) => void;
22
+ loginFallbackPath?: string;
23
+ notify?: (opts: {
24
+ message: string;
25
+ type: 'error' | 'success';
26
+ }) => void;
27
+ isAuthenticated?: () => boolean;
28
+ }
29
+
6
30
  declare const createCmsApi: (apiConfig: ApiConfig) => {
7
31
  createCollection(params: CreateCollectionParams, options?: RequestOptions): Promise<any>;
8
32
  updateCollection(params: UpdateCollectionParams, options?: RequestOptions): Promise<any>;
@@ -190,33 +214,7 @@ declare function buildQueryString(params: QueryParams): string;
190
214
  */
191
215
  declare function appendQueryString(url: string, params: QueryParams): string;
192
216
 
193
- interface AuthTokens {
194
- accessToken: string;
195
- refreshToken?: string;
196
- provider?: string;
197
- expiresAt?: number;
198
- userId?: string;
199
- }
200
- interface HttpClientConfig {
201
- baseUrl: string;
202
- storageUrl?: string;
203
- businessId: string;
204
- getTokens: () => Promise<AuthTokens> | AuthTokens;
205
- setTokens: (tokens: AuthTokens) => void;
206
- autoGuest?: boolean;
207
- onAuthFailure: () => void;
208
- navigate?: (path: string) => void;
209
- loginFallbackPath?: string;
210
- notify?: (opts: {
211
- message: string;
212
- type: 'error' | 'success';
213
- }) => void;
214
- isAuthenticated?: () => boolean;
215
- logout?: () => void;
216
- setUserToken?: (userToken: any) => void;
217
- }
218
-
219
- declare const SDK_VERSION = "0.3.1";
217
+ declare const SDK_VERSION = "0.3.3";
220
218
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
221
219
  interface ApiConfig {
222
220
  httpClient: any;
@@ -382,11 +380,9 @@ declare function createArkySDK(config: HttpClientConfig & {
382
380
  };
383
381
  setBusinessId: (businessId: string) => void;
384
382
  getBusinessId: () => string;
385
- auth: {
386
- isAuthenticated: () => boolean;
387
- logout: () => void;
388
- setUserToken: (userToken: any) => void;
389
- };
383
+ isAuthenticated: () => boolean;
384
+ logout: () => void;
385
+ setTokens: (tokens: AuthTokens) => void;
390
386
  utils: {
391
387
  getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
392
388
  thumbnailUrl: (service: any) => string;
package/dist/index.js CHANGED
@@ -1641,20 +1641,14 @@ function createHttpClient(cfg) {
1641
1641
  cfg.setTokens(data2);
1642
1642
  accessToken = data2.accessToken;
1643
1643
  } else {
1644
- cfg.onAuthFailure();
1645
- if (cfg.loginFallbackPath) {
1646
- cfg.navigate?.(cfg.loginFallbackPath);
1647
- }
1644
+ cfg.logout();
1648
1645
  const err = new Error("Error refreshing token");
1649
1646
  err.name = "ApiError";
1650
1647
  err.statusCode = 401;
1651
1648
  throw err;
1652
1649
  }
1653
1650
  } else {
1654
- cfg.onAuthFailure();
1655
- if (cfg.loginFallbackPath) {
1656
- cfg.navigate?.(cfg.loginFallbackPath);
1657
- }
1651
+ cfg.logout();
1658
1652
  const err = new Error("No refresh token");
1659
1653
  err.name = "ApiError";
1660
1654
  err.statusCode = 401;
@@ -1673,7 +1667,6 @@ function createHttpClient(cfg) {
1673
1667
  let data;
1674
1668
  try {
1675
1669
  const fullUrl = `${cfg.baseUrl}${finalPath}`;
1676
- console.log("[SDK] Fetching:", method, fullUrl, fetchOpts);
1677
1670
  res = await fetch(fullUrl, fetchOpts);
1678
1671
  data = await res.json();
1679
1672
  } catch (error) {
@@ -1708,7 +1701,7 @@ function createHttpClient(cfg) {
1708
1701
  }
1709
1702
 
1710
1703
  // src/index.ts
1711
- var SDK_VERSION = "0.3.1";
1704
+ var SDK_VERSION = "0.3.3";
1712
1705
  var SUPPORTED_FRAMEWORKS = ["astro", "react", "vue", "svelte", "vanilla"];
1713
1706
  function createArkySDK(config) {
1714
1707
  const httpClient = createHttpClient(config);
@@ -1741,12 +1734,9 @@ function createArkySDK(config) {
1741
1734
  apiConfig.businessId = businessId;
1742
1735
  },
1743
1736
  getBusinessId: () => apiConfig.businessId,
1744
- auth: {
1745
- isAuthenticated: config.isAuthenticated || (() => false),
1746
- logout: config.logout || config.onAuthFailure,
1747
- setUserToken: config.setUserToken || (() => {
1748
- })
1749
- },
1737
+ isAuthenticated: config.isAuthenticated || (() => false),
1738
+ logout: config.logout,
1739
+ setTokens: config.setTokens,
1750
1740
  utils: {
1751
1741
  getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock, storageUrl),
1752
1742
  thumbnailUrl: (service) => thumbnailUrl(service, storageUrl),