arky-sdk 0.7.95 → 0.7.102

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/admin.js CHANGED
@@ -162,36 +162,31 @@ function buildQueryString(params) {
162
162
  }
163
163
 
164
164
  // src/services/createHttpClient.ts
165
- var STORAGE_KEYS = {
166
- access_token: "arky_token",
167
- refresh_token: "arky_refresh",
168
- access_expires_at: "arky_expires_at"
169
- };
165
+ var TOKEN_KEY = "arky_token";
166
+ var LEGACY_KEYS = ["arky_refresh", "arky_expires_at"];
170
167
  function defaultGetToken() {
171
168
  if (typeof window === "undefined") return { access_token: "" };
172
169
  return {
173
- access_token: localStorage.getItem(STORAGE_KEYS.access_token) || "",
174
- refresh_token: localStorage.getItem(STORAGE_KEYS.refresh_token) || "",
175
- access_expires_at: parseInt(localStorage.getItem(STORAGE_KEYS.access_expires_at) || "0", 10)
170
+ access_token: localStorage.getItem(TOKEN_KEY) || ""
176
171
  };
177
172
  }
178
173
  function defaultSetToken(tokens) {
179
174
  if (typeof window === "undefined") return;
180
175
  if (tokens.access_token) {
181
- localStorage.setItem(STORAGE_KEYS.access_token, tokens.access_token);
182
- localStorage.setItem(STORAGE_KEYS.refresh_token, tokens.refresh_token || "");
183
- localStorage.setItem(STORAGE_KEYS.access_expires_at, (tokens.access_expires_at || 0).toString());
176
+ localStorage.setItem(TOKEN_KEY, tokens.access_token);
184
177
  } else {
185
- Object.values(STORAGE_KEYS).forEach((key) => localStorage.removeItem(key));
178
+ localStorage.removeItem(TOKEN_KEY);
186
179
  }
180
+ LEGACY_KEYS.forEach((key) => localStorage.removeItem(key));
187
181
  }
188
182
  function defaultLogout() {
189
183
  if (typeof window === "undefined") return;
190
- Object.values(STORAGE_KEYS).forEach((key) => localStorage.removeItem(key));
184
+ localStorage.removeItem(TOKEN_KEY);
185
+ LEGACY_KEYS.forEach((key) => localStorage.removeItem(key));
191
186
  }
192
187
  function defaultIsAuthenticated() {
193
188
  if (typeof window === "undefined") return false;
194
- const token = localStorage.getItem(STORAGE_KEYS.access_token) || "";
189
+ const token = localStorage.getItem(TOKEN_KEY) || "";
195
190
  return token.startsWith("customer_") || token.startsWith("account_");
196
191
  }
197
192
  function createHttpClient(cfg) {
@@ -373,10 +368,10 @@ var createAccountApi = (apiConfig) => {
373
368
  if (params.api_tokens !== void 0) payload.api_tokens = params.api_tokens;
374
369
  return apiConfig.httpClient.put("/v1/accounts", payload, options);
375
370
  },
376
- async deleteAccount(params, options) {
371
+ async deleteAccount(_params, options) {
377
372
  return apiConfig.httpClient.delete("/v1/accounts", options);
378
373
  },
379
- async getMe(params, options) {
374
+ async getMe(_params, options) {
380
375
  return apiConfig.httpClient.get("/v1/accounts/me", options);
381
376
  },
382
377
  async searchAccounts(params, options) {
@@ -398,9 +393,13 @@ var createAuthApi = (apiConfig) => {
398
393
  return apiConfig.httpClient.post("/v1/auth/code", params, options);
399
394
  },
400
395
  async verify(params, options) {
401
- const result = await apiConfig.httpClient.post("/v1/auth/verify", params, options);
396
+ const result = await apiConfig.httpClient.post(
397
+ "/v1/auth/verify",
398
+ params,
399
+ options
400
+ );
402
401
  if (result?.access_token) {
403
- apiConfig.setToken({ ...result, email: params.email, is_verified: true });
402
+ apiConfig.setToken({ access_token: result.access_token, refresh_token: result.refresh_token });
404
403
  }
405
404
  return result;
406
405
  },
@@ -411,9 +410,13 @@ var createAuthApi = (apiConfig) => {
411
410
  return apiConfig.httpClient.post(`/v1/stores/${storeId}/auth/code`, params, options);
412
411
  },
413
412
  async storeVerify(storeId, params, options) {
414
- const result = await apiConfig.httpClient.post(`/v1/stores/${storeId}/auth/verify`, params, options);
413
+ const result = await apiConfig.httpClient.post(
414
+ `/v1/stores/${storeId}/auth/verify`,
415
+ params,
416
+ options
417
+ );
415
418
  if (result?.access_token) {
416
- apiConfig.setToken({ ...result, email: params.email, is_verified: true });
419
+ apiConfig.setToken({ access_token: result.access_token, refresh_token: result.refresh_token });
417
420
  }
418
421
  return result;
419
422
  },
@@ -442,7 +445,7 @@ var createStoreApi = (apiConfig) => {
442
445
  options
443
446
  );
444
447
  },
445
- async getStore(params, options) {
448
+ async getStore(_params, options) {
446
449
  return apiConfig.httpClient.get(
447
450
  `/v1/stores/${apiConfig.storeId}`,
448
451
  options
@@ -454,7 +457,7 @@ var createStoreApi = (apiConfig) => {
454
457
  params
455
458
  });
456
459
  },
457
- async getSubscriptionPlans(params, options) {
460
+ async getSubscriptionPlans(_params, options) {
458
461
  return apiConfig.httpClient.get("/v1/stores/plans", options);
459
462
  },
460
463
  async subscribe(params, options) {
@@ -606,7 +609,7 @@ var createMediaApi = (apiConfig) => {
606
609
  options
607
610
  );
608
611
  },
609
- async uploadStoreMedia(params, options) {
612
+ async uploadStoreMedia(params, _options) {
610
613
  const { store_id, files = [], urls = [] } = params;
611
614
  const target_store_id = store_id || apiConfig.storeId;
612
615
  const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
@@ -633,7 +636,7 @@ var createMediaApi = (apiConfig) => {
633
636
  options
634
637
  );
635
638
  },
636
- async getStoreMedia(params, options) {
639
+ async getStoreMedia(params, _options) {
637
640
  const { store_id, cursor, limit, ids, query, mime_type, sort_field, sort_direction } = params;
638
641
  const target_store_id = store_id || apiConfig.storeId;
639
642
  const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
@@ -955,7 +958,7 @@ var createBookingApi = (apiConfig) => {
955
958
  const target_store_id = store_id || apiConfig.storeId;
956
959
  return apiConfig.httpClient.post(
957
960
  `/v1/stores/${target_store_id}/bookings`,
958
- { market: "booking", ...payload },
961
+ { market: apiConfig.market, ...payload },
959
962
  options
960
963
  );
961
964
  },
@@ -990,7 +993,7 @@ var createBookingApi = (apiConfig) => {
990
993
  const target_store_id = store_id || apiConfig.storeId;
991
994
  return apiConfig.httpClient.post(
992
995
  `/v1/stores/${target_store_id}/bookings/quote`,
993
- { market: "booking", ...payload },
996
+ { market: apiConfig.market, ...payload },
994
997
  options
995
998
  );
996
999
  },