arky-sdk 0.3.151 → 0.3.153

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,14 +46,14 @@ function buildQueryString(params) {
46
46
 
47
47
  // src/services/createHttpClient.ts
48
48
  function createHttpClient(cfg) {
49
- const refreshEndpoint = `${cfg.baseUrl}/v1/users/refresh-access-token`;
49
+ const refreshEndpoint = `${cfg.baseUrl}/v1/auth/refresh`;
50
50
  let refreshPromise = null;
51
51
  async function ensureFreshToken() {
52
52
  if (refreshPromise) {
53
53
  return refreshPromise;
54
54
  }
55
55
  refreshPromise = (async () => {
56
- const { refreshToken, provider } = await cfg.getToken();
56
+ const { refreshToken } = await cfg.getToken();
57
57
  if (!refreshToken) {
58
58
  cfg.logout();
59
59
  const err = new Error("No refresh token available");
@@ -64,7 +64,7 @@ function createHttpClient(cfg) {
64
64
  const refRes = await fetch(refreshEndpoint, {
65
65
  method: "POST",
66
66
  headers: { Accept: "application/json", "Content-Type": "application/json" },
67
- body: JSON.stringify({ provider, refreshToken })
67
+ body: JSON.stringify({ refreshToken })
68
68
  });
69
69
  if (!refRes.ok) {
70
70
  cfg.logout();
@@ -212,32 +212,31 @@ function createHttpClient(cfg) {
212
212
  };
213
213
  }
214
214
 
215
- // src/api/user.ts
216
- var createUserApi = (apiConfig) => {
215
+ // src/api/account.ts
216
+ var createAccountApi = (apiConfig) => {
217
217
  return {
218
- // ===== USER PROFILE =====
219
- async updateUser(params, options) {
218
+ // ===== ACCOUNT PROFILE =====
219
+ async updateAccount(params, options) {
220
220
  const payload = {};
221
- if (params.name !== void 0) payload.name = params.name;
222
221
  if (params.phoneNumbers !== void 0) payload.phoneNumbers = params.phoneNumbers;
223
222
  if (params.addresses !== void 0) payload.addresses = params.addresses;
224
223
  if (params.apiTokens !== void 0) payload.apiTokens = params.apiTokens;
225
- return apiConfig.httpClient.put("/v1/users", payload, options);
224
+ return apiConfig.httpClient.put("/v1/accounts", payload, options);
226
225
  },
227
- async deleteUser(params, options) {
228
- return apiConfig.httpClient.delete("/v1/users", options);
226
+ async deleteAccount(params, options) {
227
+ return apiConfig.httpClient.delete("/v1/accounts", options);
229
228
  },
230
229
  async addPhoneNumber(params, options) {
231
- return apiConfig.httpClient.post("/v1/users/phone-number", params, options);
230
+ return apiConfig.httpClient.post("/v1/accounts/phone-number", params, options);
232
231
  },
233
232
  async phoneNumberConfirm(params, options) {
234
- return apiConfig.httpClient.post("/v1/users/phone-number/confirm", params, options);
233
+ return apiConfig.httpClient.post("/v1/accounts/phone-number/confirm", params, options);
235
234
  },
236
235
  async getMe(params, options) {
237
- return apiConfig.httpClient.get("/v1/users/me", options);
236
+ return apiConfig.httpClient.get("/v1/accounts/me", options);
238
237
  },
239
- async searchUsers(params, options) {
240
- return apiConfig.httpClient.get("/v1/users/search", {
238
+ async searchAccounts(params, options) {
239
+ return apiConfig.httpClient.get("/v1/accounts/search", {
241
240
  ...options,
242
241
  params: {
243
242
  ...params,
@@ -246,39 +245,45 @@ var createUserApi = (apiConfig) => {
246
245
  });
247
246
  },
248
247
  async setRole(params, options) {
249
- return apiConfig.httpClient.put("/v1/users/set-role", params, options);
248
+ return apiConfig.httpClient.put("/v1/accounts/set-role", params, options);
250
249
  },
251
- // ===== AUTHENTICATION =====
252
- async loginUser(params, options) {
253
- return apiConfig.httpClient.post("/v1/users/login", params, options);
254
- },
255
- async registerUser(params, options) {
256
- return apiConfig.httpClient.post("/v1/users/register", params, options);
257
- },
258
- async logout(params, options) {
259
- return apiConfig.httpClient.post("/v1/users/logout", {}, options);
260
- },
261
- async confirmUser(params, options) {
262
- return apiConfig.httpClient.put("/v1/users/confirm", params, options);
263
- },
264
- async getLoginUrl(params, options) {
265
- return apiConfig.httpClient.get("/v1/users/login/url", {
266
- ...options,
267
- params
268
- });
269
- },
270
- // ===== PASSWORD MANAGEMENT =====
271
- async forgotPassword(params, options) {
272
- return apiConfig.httpClient.post("/v1/users/forgot-password", params, options);
250
+ // ===== SUBSCRIPTION =====
251
+ async subscribe(params, options) {
252
+ return apiConfig.httpClient.post("/v1/accounts/subscribe", params, options);
253
+ }
254
+ };
255
+ };
256
+
257
+ // src/api/auth.ts
258
+ var createAuthApi = (apiConfig) => {
259
+ return {
260
+ /**
261
+ * Create a guest session (anonymous user)
262
+ * POST /auth/session
263
+ */
264
+ async session(options) {
265
+ return apiConfig.httpClient.post("/v1/auth/session", {}, options);
273
266
  },
274
- async resetForgotPassword(params, options) {
275
- return apiConfig.httpClient.post("/v1/users/reset-forgot-password", params, options);
267
+ /**
268
+ * Request a magic link to be sent to email
269
+ * POST /auth/magic-link
270
+ */
271
+ async magicLink(params, options) {
272
+ return apiConfig.httpClient.post("/v1/auth/magic-link", params, options);
276
273
  },
277
- async resetPassword(params, options) {
278
- return apiConfig.httpClient.post("/v1/users/reset-password", params, options);
274
+ /**
275
+ * Verify magic link token and get auth tokens
276
+ * POST /auth/verify
277
+ */
278
+ async verify(params, options) {
279
+ return apiConfig.httpClient.post("/v1/auth/verify", params, options);
279
280
  },
280
- async subscribe(params, options) {
281
- return apiConfig.httpClient.post("/v1/users/subscribe", params, options);
281
+ /**
282
+ * Refresh access token
283
+ * POST /auth/refresh
284
+ */
285
+ async refresh(params, options) {
286
+ return apiConfig.httpClient.post("/v1/auth/refresh", params, options);
282
287
  }
283
288
  };
284
289
  };
@@ -1524,31 +1529,6 @@ var createWorkflowApi = (apiConfig) => {
1524
1529
  async triggerWorkflow(params, options) {
1525
1530
  const { secret, ...input } = params;
1526
1531
  return apiConfig.httpClient.post(`/v1/workflows/trigger/${secret}`, input, options);
1527
- },
1528
- /**
1529
- * Get executions for a workflow
1530
- */
1531
- async getWorkflowExecutions(params, options) {
1532
- const businessId = params.businessId || apiConfig.businessId;
1533
- const { workflowId, limit, cursor } = params;
1534
- return apiConfig.httpClient.get(
1535
- `/v1/businesses/${businessId}/workflows/${workflowId}/executions`,
1536
- {
1537
- ...options,
1538
- params: { limit, cursor }
1539
- }
1540
- );
1541
- },
1542
- /**
1543
- * Get a specific workflow execution
1544
- */
1545
- async getWorkflowExecution(params, options) {
1546
- const businessId = params.businessId || apiConfig.businessId;
1547
- const { workflowId, executionId } = params;
1548
- return apiConfig.httpClient.get(
1549
- `/v1/businesses/${businessId}/workflows/${workflowId}/executions/${executionId}`,
1550
- options
1551
- );
1552
1532
  }
1553
1533
  };
1554
1534
  };
@@ -1939,7 +1919,7 @@ function nameToKey(name) {
1939
1919
  }
1940
1920
 
1941
1921
  // src/index.ts
1942
- var SDK_VERSION = "0.3.145";
1922
+ var SDK_VERSION = "0.3.153";
1943
1923
  var SUPPORTED_FRAMEWORKS = [
1944
1924
  "astro",
1945
1925
  "react",
@@ -1959,15 +1939,14 @@ async function createArkySDK(config) {
1959
1939
  setToken: config.setToken,
1960
1940
  getToken: config.getToken
1961
1941
  };
1962
- const userApi = createUserApi(apiConfig);
1942
+ const accountApi = createAccountApi(apiConfig);
1943
+ const authApi = createAuthApi(apiConfig);
1963
1944
  const autoGuest = config.autoGuest !== void 0 ? config.autoGuest : true;
1964
1945
  if (autoGuest) {
1965
1946
  try {
1966
1947
  const tokens = await config.getToken();
1967
1948
  if (!tokens.accessToken && !tokens.refreshToken) {
1968
- const result = await httpClient.post("/v1/users/login", {
1969
- provider: "GUEST"
1970
- });
1949
+ const result = await httpClient.post("/v1/auth/session", {});
1971
1950
  const token = result.accessToken || result.token || "";
1972
1951
  if (token) {
1973
1952
  config.setToken(result);
@@ -1977,7 +1956,8 @@ async function createArkySDK(config) {
1977
1956
  }
1978
1957
  }
1979
1958
  const sdk = {
1980
- user: userApi,
1959
+ auth: authApi,
1960
+ account: accountApi,
1981
1961
  business: createBusinessApi(apiConfig),
1982
1962
  media: createMediaApi(apiConfig),
1983
1963
  role: createRoleApi(apiConfig),