arky-sdk 0.9.13 → 0.9.16

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.
Files changed (40) hide show
  1. package/README.md +16 -12
  2. package/dist/admin-C-ZTxvz3.d.ts +1544 -0
  3. package/dist/admin-Dm2WRN6q.d.cts +1544 -0
  4. package/dist/admin.cjs +982 -425
  5. package/dist/admin.cjs.map +1 -1
  6. package/dist/admin.d.cts +3 -3
  7. package/dist/admin.d.ts +3 -3
  8. package/dist/admin.js +982 -425
  9. package/dist/admin.js.map +1 -1
  10. package/dist/{api-DvsFdOaF.d.cts → api-D37IpMSq.d.cts} +1417 -665
  11. package/dist/{api-DvsFdOaF.d.ts → api-D37IpMSq.d.ts} +1417 -665
  12. package/dist/index.cjs +1317 -539
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +3 -3
  15. package/dist/index.d.ts +3 -3
  16. package/dist/index.js +1317 -539
  17. package/dist/index.js.map +1 -1
  18. package/dist/{index-CQd9b_7n.d.ts → inventory-DdN96PX3.d.cts} +6 -4
  19. package/dist/{index-BC06yiuv.d.cts → inventory-Dh1RevEb.d.ts} +6 -4
  20. package/dist/storefront.cjs +1210 -658
  21. package/dist/storefront.cjs.map +1 -1
  22. package/dist/storefront.d.cts +88 -285
  23. package/dist/storefront.d.ts +88 -285
  24. package/dist/storefront.js +1207 -659
  25. package/dist/storefront.js.map +1 -1
  26. package/dist/types.cjs.map +1 -1
  27. package/dist/types.d.cts +1 -1
  28. package/dist/types.d.ts +1 -1
  29. package/dist/types.js.map +1 -1
  30. package/dist/utils.cjs +198 -16
  31. package/dist/utils.cjs.map +1 -1
  32. package/dist/utils.d.cts +18 -2
  33. package/dist/utils.d.ts +18 -2
  34. package/dist/utils.js +191 -17
  35. package/dist/utils.js.map +1 -1
  36. package/package.json +4 -5
  37. package/dist/admin-Q9MBFwCb.d.cts +0 -1496
  38. package/dist/admin-ZLXD4_en.d.ts +0 -1496
  39. package/scripts/contract-admin.mjs +0 -120
  40. package/scripts/contract-storefront.mjs +0 -296
package/dist/admin.cjs CHANGED
@@ -1,29 +1,5 @@
1
1
  'use strict';
2
2
 
3
- // src/utils/orderItems.ts
4
- function normalizeOrderQuoteItems(items) {
5
- return items.map((item) => {
6
- if ("type" in item) {
7
- return item;
8
- }
9
- if ("product_id" in item) {
10
- return { type: "product", ...item };
11
- }
12
- return { type: "service", ...item };
13
- });
14
- }
15
- function normalizeOrderCheckoutItems(items) {
16
- return items.map((item) => {
17
- if ("type" in item) {
18
- return item;
19
- }
20
- if ("product_id" in item) {
21
- return { type: "product", ...item };
22
- }
23
- return { type: "service", ...item };
24
- });
25
- }
26
-
27
3
  // src/utils/errors.ts
28
4
  var convertServerErrorToRequestError = (serverError, renameRules) => {
29
5
  const validationErrors = serverError?.validationErrors ?? [];
@@ -41,27 +17,47 @@ var convertServerErrorToRequestError = (serverError, renameRules) => {
41
17
 
42
18
  // src/utils/queryParams.ts
43
19
  function buildQueryString(params) {
44
- const queryParts = [];
45
- Object.entries(params).forEach(([key, value]) => {
46
- if (value === null || value === void 0) {
47
- return;
48
- }
49
- if (Array.isArray(value)) {
50
- const jsonString = JSON.stringify(value);
51
- queryParts.push(`${key}=${encodeURIComponent(jsonString)}`);
52
- } else if (typeof value === "string") {
53
- queryParts.push(`${key}=${encodeURIComponent(value)}`);
54
- } else if (typeof value === "number" || typeof value === "boolean") {
55
- queryParts.push(`${key}=${value}`);
56
- } else if (typeof value === "object") {
57
- const jsonString = JSON.stringify(value);
58
- queryParts.push(`${key}=${encodeURIComponent(jsonString)}`);
20
+ const queryParts = Object.entries(params).flatMap(
21
+ ([key, value]) => {
22
+ if (value === null || value === void 0) return [];
23
+ if (typeof value === "string") {
24
+ return [`${key}=${encodeURIComponent(value)}`];
25
+ }
26
+ if (typeof value === "number" || typeof value === "boolean") {
27
+ return [`${key}=${value}`];
28
+ }
29
+ if (Array.isArray(value) || typeof value === "object") {
30
+ return [`${key}=${encodeURIComponent(JSON.stringify(value))}`];
31
+ }
32
+ return [];
59
33
  }
60
- });
34
+ );
61
35
  return queryParts.length > 0 ? `?${queryParts.join("&")}` : "";
62
36
  }
63
37
 
64
38
  // src/services/createHttpClient.ts
39
+ function requestError(name, message, details = {}) {
40
+ return Object.assign(new Error(message), { name }, details);
41
+ }
42
+ function isRecord(value) {
43
+ return typeof value === "object" && value !== null;
44
+ }
45
+ function isTokenSet(value) {
46
+ return isRecord(value) && typeof value.access_token === "string" && (value.refresh_token === void 0 || typeof value.refresh_token === "string") && (value.access_expires_at === void 0 || typeof value.access_expires_at === "number");
47
+ }
48
+ function isValidationError(value) {
49
+ return isRecord(value) && typeof value.field === "string" && typeof value.error === "string";
50
+ }
51
+ function toServerError(value, statusCode) {
52
+ const payload = isRecord(value) ? value : {};
53
+ const validationErrors = Array.isArray(payload.validationErrors) ? payload.validationErrors.filter(isValidationError) : [];
54
+ return {
55
+ message: typeof payload.message === "string" ? payload.message : "Request failed",
56
+ error: typeof payload.error === "string" ? payload.error : "REQUEST_FAILED",
57
+ statusCode: typeof payload.statusCode === "number" ? payload.statusCode : statusCode,
58
+ validationErrors
59
+ };
60
+ }
65
61
  function createHttpClient(cfg) {
66
62
  const { authStorage } = cfg;
67
63
  let refreshPromise = null;
@@ -78,32 +74,41 @@ function createHttpClient(cfg) {
78
74
  const refresh_token = tokens?.refresh_token;
79
75
  if (!refresh_token) {
80
76
  authStorage.onForcedLogout();
81
- const err = new Error("No refresh token available");
82
- err.name = "ApiError";
83
- err.statusCode = 401;
84
- throw err;
77
+ throw requestError("ApiError", "No refresh token available", {
78
+ statusCode: 401
79
+ });
85
80
  }
86
81
  const refRes = await fetch(getRefreshEndpoint(), {
87
82
  method: "POST",
88
- headers: { Accept: "application/json", "Content-Type": "application/json" },
83
+ headers: {
84
+ Accept: "application/json",
85
+ "Content-Type": "application/json"
86
+ },
89
87
  body: JSON.stringify({ refresh_token })
90
88
  });
91
89
  if (!refRes.ok) {
92
90
  authStorage.onForcedLogout();
93
- const err = new Error("Token refresh failed");
94
- err.name = "ApiError";
95
- err.statusCode = 401;
96
- throw err;
91
+ throw requestError("ApiError", "Token refresh failed", {
92
+ statusCode: 401
93
+ });
97
94
  }
98
95
  const data = await refRes.json();
96
+ if (!isTokenSet(data)) {
97
+ authStorage.onForcedLogout();
98
+ throw requestError(
99
+ "ParseError",
100
+ "Token refresh returned an invalid response",
101
+ { statusCode: refRes.status }
102
+ );
103
+ }
99
104
  authStorage.onTokensRefreshed(data);
100
105
  })().finally(() => {
101
106
  refreshPromise = null;
102
107
  });
103
108
  return refreshPromise;
104
109
  }
105
- async function request(method, path, body, options) {
106
- if (options?.transformRequest) {
110
+ async function request(method, path, body, options, retried = false) {
111
+ if (!retried && options?.transformRequest) {
107
112
  body = options.transformRequest(body);
108
113
  }
109
114
  const headers = {
@@ -121,23 +126,27 @@ function createHttpClient(cfg) {
121
126
  headers["Authorization"] = `Bearer ${tokens.access_token}`;
122
127
  }
123
128
  const finalPath = options?.params ? path + buildQueryString(options.params) : path;
124
- const fetchOpts = { method, headers, signal: options?.signal };
129
+ const fetchOptions = {
130
+ method,
131
+ headers,
132
+ signal: options?.signal
133
+ };
125
134
  if (!["GET", "DELETE"].includes(method) && body !== void 0) {
126
- fetchOpts.body = JSON.stringify(body);
135
+ fetchOptions.body = body instanceof URLSearchParams ? body.toString() : JSON.stringify(body);
127
136
  }
128
137
  const fullUrl = `${cfg.baseUrl}${finalPath}`;
129
138
  let res;
130
139
  let data;
131
140
  const startedAt = Date.now();
132
141
  try {
133
- res = await fetch(fullUrl, fetchOpts);
142
+ res = await fetch(fullUrl, fetchOptions);
134
143
  } catch (error) {
135
144
  const aborted = options?.signal?.aborted || error instanceof Error && error.name === "AbortError";
136
- const err = new Error(error instanceof Error ? error.message : "Network request failed");
137
- err.name = aborted ? "AbortError" : "NetworkError";
138
- err.method = method;
139
- err.url = fullUrl;
140
- err.aborted = aborted;
145
+ const err = requestError(
146
+ aborted ? "AbortError" : "NetworkError",
147
+ error instanceof Error ? error.message : "Network request failed",
148
+ { method, url: fullUrl, aborted }
149
+ );
141
150
  if (options?.onError && method !== "GET") {
142
151
  Promise.resolve(
143
152
  options.onError({ error: err, method, url: fullUrl, aborted })
@@ -146,18 +155,9 @@ function createHttpClient(cfg) {
146
155
  }
147
156
  throw err;
148
157
  }
149
- if (res.status === 401 && !options?.["_retried"]) {
150
- try {
151
- await ensureFreshToken();
152
- const refreshed = authStorage.getTokens();
153
- if (refreshed?.access_token) {
154
- headers["Authorization"] = `Bearer ${refreshed.access_token}`;
155
- fetchOpts.headers = headers;
156
- }
157
- return request(method, path, body, { ...options, _retried: true });
158
- } catch (refreshError) {
159
- throw refreshError;
160
- }
158
+ if (res.status === 401 && !retried) {
159
+ await ensureFreshToken();
160
+ return request(method, path, body, options, true);
161
161
  }
162
162
  try {
163
163
  const contentLength = res.headers.get("content-length");
@@ -168,30 +168,35 @@ function createHttpClient(cfg) {
168
168
  data = await res.json();
169
169
  }
170
170
  } catch (error) {
171
- const err = new Error("Failed to parse response");
172
- err.name = "ParseError";
173
- err.method = method;
174
- err.url = fullUrl;
175
- err.status = res.status;
171
+ const err = requestError("ParseError", "Failed to parse response", {
172
+ method,
173
+ url: fullUrl,
174
+ statusCode: res.status
175
+ });
176
176
  if (options?.onError && method !== "GET") {
177
177
  Promise.resolve(
178
- options.onError({ error: err, method, url: fullUrl, status: res.status })
178
+ options.onError({
179
+ error: err,
180
+ method,
181
+ url: fullUrl,
182
+ status: res.status
183
+ })
179
184
  ).catch(() => {
180
185
  });
181
186
  }
182
187
  throw err;
183
188
  }
184
189
  if (!res.ok) {
185
- const serverErr = data;
190
+ const serverErr = toServerError(data, res.status);
186
191
  const reqErr = convertServerErrorToRequestError(serverErr);
187
- const err = new Error(serverErr.message || "Request failed");
188
- err.name = "ApiError";
189
- err.statusCode = serverErr.statusCode || res.status;
190
- err.validationErrors = reqErr.validationErrors;
191
- err.method = method;
192
- err.url = fullUrl;
193
192
  const requestId = res.headers.get("x-request-id") || res.headers.get("request-id");
194
- if (requestId) err.requestId = requestId;
193
+ const err = requestError("ApiError", serverErr.message, {
194
+ statusCode: serverErr.statusCode,
195
+ validationErrors: reqErr.validationErrors,
196
+ method,
197
+ url: fullUrl,
198
+ requestId: requestId || void 0
199
+ });
195
200
  if (options?.onError && method !== "GET") {
196
201
  Promise.resolve(
197
202
  options.onError({
@@ -234,35 +239,73 @@ function createHttpClient(cfg) {
234
239
  }
235
240
 
236
241
  // src/api/account.ts
237
- var createAccountApi = (apiConfig) => {
238
- return {
239
- async updateAccount(params, options) {
240
- const payload = {};
241
- if (params.phone_numbers !== void 0) payload.phone_numbers = params.phone_numbers;
242
- if (params.addresses !== void 0) payload.addresses = params.addresses;
243
- if (params.api_tokens !== void 0) payload.api_tokens = params.api_tokens;
244
- return apiConfig.httpClient.put("/v1/accounts", payload, options);
245
- },
246
- async deleteAccount(_params, options) {
247
- return apiConfig.httpClient.delete("/v1/accounts", options);
248
- },
249
- async getMe(_params, options) {
250
- return apiConfig.httpClient.get("/v1/accounts/me", options);
251
- },
252
- async searchAccounts(params, options) {
253
- return apiConfig.httpClient.get("/v1/accounts/search", {
254
- ...options,
255
- params: {
256
- ...params,
257
- store_id: apiConfig.storeId
258
- }
259
- });
260
- }
261
- };
262
- };
242
+ var createAccountApi = (apiConfig) => ({
243
+ async updateAccount(_params, options) {
244
+ return apiConfig.httpClient.put(
245
+ "/v1/accounts",
246
+ {},
247
+ options
248
+ );
249
+ },
250
+ async deleteAccount(_params, options) {
251
+ return apiConfig.httpClient.delete(
252
+ "/v1/accounts",
253
+ options
254
+ );
255
+ },
256
+ async getMe(_params, options) {
257
+ return apiConfig.httpClient.get("/v1/accounts/me", options);
258
+ },
259
+ async searchAccounts(params, options) {
260
+ return apiConfig.httpClient.get(
261
+ "/v1/accounts/search",
262
+ { ...options, params }
263
+ );
264
+ },
265
+ async listApiTokens(options) {
266
+ return apiConfig.httpClient.get(
267
+ "/v1/accounts/me/api-tokens",
268
+ options
269
+ );
270
+ },
271
+ async createApiToken(params, options) {
272
+ return apiConfig.httpClient.post(
273
+ "/v1/accounts/me/api-tokens",
274
+ params,
275
+ options
276
+ );
277
+ },
278
+ async updateApiToken(params, options) {
279
+ const { id, ...payload } = params;
280
+ return apiConfig.httpClient.put(
281
+ `/v1/accounts/me/api-tokens/${id}`,
282
+ payload,
283
+ options
284
+ );
285
+ },
286
+ async revokeApiToken(id, options) {
287
+ return apiConfig.httpClient.delete(
288
+ `/v1/accounts/me/api-tokens/${id}`,
289
+ options
290
+ );
291
+ },
292
+ async listSessions(options) {
293
+ return apiConfig.httpClient.get(
294
+ "/v1/accounts/me/sessions",
295
+ options
296
+ );
297
+ },
298
+ async revokeSession(id, options) {
299
+ return apiConfig.httpClient.delete(
300
+ `/v1/accounts/me/sessions/${id}`,
301
+ options
302
+ );
303
+ }
304
+ });
263
305
 
264
306
  // src/api/auth.ts
265
307
  var createAuthApi = (apiConfig, updateSession) => {
308
+ const pendingEmails = /* @__PURE__ */ new Map();
266
309
  function applyAuthToken(result, email) {
267
310
  const next = {
268
311
  access_token: result.access_token,
@@ -274,7 +317,9 @@ var createAuthApi = (apiConfig, updateSession) => {
274
317
  }
275
318
  return {
276
319
  async code(params, options) {
277
- return apiConfig.httpClient.post("/v1/auth/code", params, options);
320
+ const result = await apiConfig.httpClient.post("/v1/auth/code", params, options);
321
+ pendingEmails.set(result.challenge_id, params.email);
322
+ return result;
278
323
  },
279
324
  async verify(params, options) {
280
325
  const result = await apiConfig.httpClient.post(
@@ -283,7 +328,8 @@ var createAuthApi = (apiConfig, updateSession) => {
283
328
  options
284
329
  );
285
330
  if (result?.access_token) {
286
- applyAuthToken(result, params.email);
331
+ applyAuthToken(result, pendingEmails.get(params.challenge_id));
332
+ pendingEmails.delete(params.challenge_id);
287
333
  }
288
334
  return result;
289
335
  },
@@ -291,7 +337,9 @@ var createAuthApi = (apiConfig, updateSession) => {
291
337
  return apiConfig.httpClient.post("/v1/auth/refresh", params, options);
292
338
  },
293
339
  async storeCode(storeId, params, options) {
294
- return apiConfig.httpClient.post(`/v1/stores/${storeId}/auth/code`, params, options);
340
+ const result = await apiConfig.httpClient.post(`/v1/stores/${storeId}/auth/code`, params, options);
341
+ pendingEmails.set(result.challenge_id, params.email);
342
+ return result;
295
343
  },
296
344
  async storeVerify(storeId, params, options) {
297
345
  const result = await apiConfig.httpClient.post(
@@ -300,7 +348,8 @@ var createAuthApi = (apiConfig, updateSession) => {
300
348
  options
301
349
  );
302
350
  if (result?.access_token) {
303
- applyAuthToken(result, params.email);
351
+ applyAuthToken(result, pendingEmails.get(params.challenge_id));
352
+ pendingEmails.delete(params.challenge_id);
304
353
  }
305
354
  return result;
306
355
  }
@@ -314,23 +363,10 @@ var createStoreApi = (apiConfig, _updateSession) => {
314
363
  return apiConfig.httpClient.post(`/v1/stores`, params, options);
315
364
  },
316
365
  async updateStore(params, options) {
317
- return apiConfig.httpClient.put(
318
- `/v1/stores/${params.id}`,
319
- params,
320
- options
321
- );
322
- },
323
- async deleteStore(params, options) {
324
- return apiConfig.httpClient.delete(
325
- `/v1/stores/${params.id}`,
326
- options
327
- );
366
+ return apiConfig.httpClient.put(`/v1/stores/${params.id}`, params, options);
328
367
  },
329
368
  async getStore(_params, options) {
330
- return apiConfig.httpClient.get(
331
- `/v1/stores/${apiConfig.storeId}`,
332
- options
333
- );
369
+ return apiConfig.httpClient.get(`/v1/stores/${apiConfig.storeId}`, options);
334
370
  },
335
371
  async getStores(params, options) {
336
372
  return apiConfig.httpClient.get(`/v1/stores`, {
@@ -339,20 +375,58 @@ var createStoreApi = (apiConfig, _updateSession) => {
339
375
  });
340
376
  },
341
377
  async getSubscriptionPlans(_params, options) {
342
- return apiConfig.httpClient.get(
343
- "/v1/stores/plans",
378
+ return apiConfig.httpClient.get("/v1/stores/plans", options);
379
+ },
380
+ async createSubscriptionAction(params, options) {
381
+ const { store_id, ...payload } = params;
382
+ const target_store_id = store_id || apiConfig.storeId;
383
+ const response = await apiConfig.httpClient.post(
384
+ `/v1/stores/${target_store_id}/subscription/actions`,
385
+ payload,
344
386
  options
345
387
  );
388
+ if (response.id !== params.action_id) {
389
+ throw new Error("Subscription response did not match the requested action_id");
390
+ }
391
+ return response;
346
392
  },
347
- async subscribe(params, options) {
348
- const { store_id, plan_id, action, success_url, cancel_url } = params;
349
- const target_store_id = store_id || apiConfig.storeId;
350
- return apiConfig.httpClient.put(
351
- `/v1/stores/${target_store_id}/subscribe`,
352
- { plan_id, action, success_url, cancel_url },
393
+ async getSubscription(params = {}, options) {
394
+ const store_id = params.store_id || apiConfig.storeId;
395
+ return apiConfig.httpClient.get(`/v1/stores/${store_id}/subscription`, options);
396
+ },
397
+ async retrySubscriptionAction(params, options) {
398
+ const store_id = params.store_id || apiConfig.storeId;
399
+ return apiConfig.httpClient.post(
400
+ `/v1/stores/${store_id}/subscription/actions/${params.action_id}/retry`,
401
+ {},
353
402
  options
354
403
  );
355
404
  },
405
+ async getSubscriptionAction(params, options) {
406
+ const store_id = params.store_id || apiConfig.storeId;
407
+ return apiConfig.httpClient.get(`/v1/stores/${store_id}/subscription/actions/${params.action_id}`, options);
408
+ },
409
+ async findSubscriptionActionEffects(params, options) {
410
+ const { store_id, action_id, ...query } = params;
411
+ return apiConfig.httpClient.get(
412
+ `/v1/stores/${store_id || apiConfig.storeId}/subscription/actions/${action_id}/effects`,
413
+ { ...options, params: query }
414
+ );
415
+ },
416
+ async getSubscriptionActionEffect(params, options) {
417
+ const store_id = params.store_id || apiConfig.storeId;
418
+ return apiConfig.httpClient.get(
419
+ `/v1/stores/${store_id}/subscription/actions/${params.action_id}/effects/${params.effect_id}`,
420
+ options
421
+ );
422
+ },
423
+ async findSubscriptionActions(params = {}, options) {
424
+ const { store_id, ...query } = params;
425
+ return apiConfig.httpClient.get(
426
+ `/v1/stores/${store_id || apiConfig.storeId}/subscription/actions`,
427
+ { ...options, params: query }
428
+ );
429
+ },
356
430
  async createPortalSession(params, options) {
357
431
  const store_id = params.store_id || apiConfig.storeId;
358
432
  return apiConfig.httpClient.post(
@@ -363,114 +437,61 @@ var createStoreApi = (apiConfig, _updateSession) => {
363
437
  },
364
438
  async addMember(params, options) {
365
439
  const { store_id, ...payload } = params;
366
- return apiConfig.httpClient.post(
367
- `/v1/stores/${store_id || apiConfig.storeId}/members`,
368
- payload,
369
- options
370
- );
440
+ return apiConfig.httpClient.post(`/v1/stores/${store_id || apiConfig.storeId}/members`, payload, options);
371
441
  },
372
442
  async inviteUser(params, options) {
373
443
  const { store_id, ...payload } = params;
374
- return apiConfig.httpClient.post(
375
- `/v1/stores/${store_id || apiConfig.storeId}/members`,
376
- payload,
377
- options
378
- );
444
+ return apiConfig.httpClient.post(`/v1/stores/${store_id || apiConfig.storeId}/invitation`, payload, options);
445
+ },
446
+ async findMembers(params = {}, options) {
447
+ const { store_id, ...query } = params;
448
+ return apiConfig.httpClient.get(`/v1/stores/${store_id || apiConfig.storeId}/members`, {
449
+ ...options,
450
+ params: query
451
+ });
452
+ },
453
+ async findOwnMemberships(options) {
454
+ return apiConfig.httpClient.get("/v1/stores/memberships", options);
379
455
  },
380
456
  async removeMember(params, options) {
381
457
  return apiConfig.httpClient.delete(
382
- `/v1/stores/${apiConfig.storeId}/members/${params.account_id}`,
458
+ `/v1/stores/${params.store_id || apiConfig.storeId}/members/${params.account_id}`,
383
459
  options
384
460
  );
385
461
  },
386
462
  async testWebhook(params, options) {
387
- return apiConfig.httpClient.post(
388
- `/v1/stores/${apiConfig.storeId}/webhooks/test`,
389
- params,
390
- options
391
- );
392
- },
393
- async getStoreMedia(params, options) {
394
- const queryParams = {
395
- limit: params.limit
396
- };
397
- if (params.cursor) queryParams.cursor = params.cursor;
398
- if (params.ids && params.ids.length > 0)
399
- queryParams.ids = JSON.stringify(params.ids);
400
- if (params.query) queryParams.query = params.query;
401
- if (params.mime_type) queryParams.mime_type = params.mime_type;
402
- if (params.sort_field) queryParams.sort_field = params.sort_field;
403
- if (params.sort_direction)
404
- queryParams.sort_direction = params.sort_direction;
405
- return apiConfig.httpClient.get(
406
- `/v1/stores/${params.id}/media`,
407
- {
408
- ...options,
409
- params: queryParams
410
- }
411
- );
463
+ return apiConfig.httpClient.post(`/v1/stores/${apiConfig.storeId}/webhooks/test`, params, options);
412
464
  },
413
465
  async listBuildHooks(params, options) {
414
- return apiConfig.httpClient.get(
415
- `/v1/stores/${params.store_id}/build-hooks`,
416
- options
417
- );
466
+ return apiConfig.httpClient.get(`/v1/stores/${params.store_id}/build-hooks`, options);
418
467
  },
419
468
  async createBuildHook(params, options) {
420
469
  const { store_id, ...payload } = params;
421
- return apiConfig.httpClient.post(
422
- `/v1/stores/${store_id}/build-hooks`,
423
- payload,
424
- options
425
- );
470
+ return apiConfig.httpClient.post(`/v1/stores/${store_id}/build-hooks`, payload, options);
426
471
  },
427
472
  async updateBuildHook(params, options) {
428
473
  const { store_id, id, ...payload } = params;
429
- return apiConfig.httpClient.put(
430
- `/v1/stores/${store_id}/build-hooks/${id}`,
431
- payload,
432
- options
433
- );
474
+ return apiConfig.httpClient.put(`/v1/stores/${store_id}/build-hooks/${id}`, payload, options);
434
475
  },
435
476
  async deleteBuildHook(params, options) {
436
- return apiConfig.httpClient.delete(
437
- `/v1/stores/${params.store_id}/build-hooks/${params.id}`,
438
- options
439
- );
477
+ return apiConfig.httpClient.delete(`/v1/stores/${params.store_id}/build-hooks/${params.id}`, options);
440
478
  },
441
- async getStoreConfig(params, options) {
442
- return apiConfig.httpClient.get(
443
- `/v1/stores/${params.store_id}/config/${params.type}`,
444
- options
445
- );
479
+ async getPaymentConfig(params, options) {
480
+ return apiConfig.httpClient.get(`/v1/stores/${params.store_id}/config/payment`, options);
446
481
  },
447
482
  async listWebhooks(params, options) {
448
- return apiConfig.httpClient.get(
449
- `/v1/stores/${params.store_id}/webhooks`,
450
- options
451
- );
483
+ return apiConfig.httpClient.get(`/v1/stores/${params.store_id}/webhooks`, options);
452
484
  },
453
485
  async createWebhook(params, options) {
454
486
  const { store_id, ...payload } = params;
455
- return apiConfig.httpClient.post(
456
- `/v1/stores/${store_id}/webhooks`,
457
- payload,
458
- options
459
- );
487
+ return apiConfig.httpClient.post(`/v1/stores/${store_id}/webhooks`, payload, options);
460
488
  },
461
489
  async updateWebhook(params, options) {
462
490
  const { store_id, id, ...payload } = params;
463
- return apiConfig.httpClient.put(
464
- `/v1/stores/${store_id}/webhooks/${id}`,
465
- payload,
466
- options
467
- );
491
+ return apiConfig.httpClient.put(`/v1/stores/${store_id}/webhooks/${id}`, payload, options);
468
492
  },
469
493
  async deleteWebhook(params, options) {
470
- return apiConfig.httpClient.delete(
471
- `/v1/stores/${params.store_id}/webhooks/${params.id}`,
472
- options
473
- );
494
+ return apiConfig.httpClient.delete(`/v1/stores/${params.store_id}/webhooks/${params.id}`, options);
474
495
  }
475
496
  };
476
497
  };
@@ -507,9 +528,10 @@ var createMediaApi = (apiConfig) => {
507
528
  return await response.json();
508
529
  },
509
530
  async deleteStoreMedia(params, options) {
510
- const { id, media_id } = params;
531
+ const { store_id, media_id } = params;
532
+ const target_store_id = store_id || apiConfig.storeId;
511
533
  return apiConfig.httpClient.delete(
512
- `/v1/stores/${id}/media/${media_id}`,
534
+ `/v1/stores/${target_store_id}/media/${media_id}`,
513
535
  options
514
536
  );
515
537
  },
@@ -553,16 +575,23 @@ var createMediaApi = (apiConfig) => {
553
575
  // src/api/notification.ts
554
576
  var createNotificationApi = (apiConfig) => {
555
577
  return {
556
- async trackEmailOpen(params, options) {
578
+ async sendEmail(request, options) {
579
+ return apiConfig.httpClient.post(
580
+ "/v1/notifications/email",
581
+ request,
582
+ options
583
+ );
584
+ },
585
+ async getEmailDelivery(params, options) {
557
586
  return apiConfig.httpClient.get(
558
- `/v1/notifications/track/pixel/${params.tracking_pixel_id}`,
587
+ `/v1/notifications/email-deliveries/${params.delivery_id}`,
559
588
  options
560
589
  );
561
590
  },
562
- async trigger(params, options) {
591
+ async retryEmailDelivery(params, options) {
563
592
  return apiConfig.httpClient.post(
564
- "/v1/notifications/trigger",
565
- params,
593
+ `/v1/notifications/email-deliveries/${params.delivery_id}/retry`,
594
+ { revision: params.revision },
566
595
  options
567
596
  );
568
597
  }
@@ -645,14 +674,7 @@ var createCmsApi = (apiConfig) => {
645
674
  },
646
675
  async getCollection(params, options) {
647
676
  const target_store_id = params.store_id || apiConfig.storeId;
648
- let identifier;
649
- if (params.id) {
650
- identifier = params.id;
651
- } else if (params.key) {
652
- identifier = `${target_store_id}:${params.key}`;
653
- } else {
654
- throw new Error("GetCollectionParams requires id or key");
655
- }
677
+ const identifier = params.id !== void 0 ? params.id : `${target_store_id}:${params.key}`;
656
678
  return apiConfig.httpClient.get(
657
679
  `/v1/stores/${target_store_id}/collections/${identifier}`,
658
680
  options
@@ -920,7 +942,7 @@ var createEshopApi = (apiConfig) => {
920
942
  const target_store_id = store_id || apiConfig.storeId;
921
943
  const payload = {
922
944
  ...rest,
923
- ...items ? { items: normalizeOrderCheckoutItems(items) } : {}
945
+ ...items ? { items } : {}
924
946
  };
925
947
  return apiConfig.httpClient.put(
926
948
  `/v1/stores/${target_store_id}/orders/${params.id}`,
@@ -971,7 +993,7 @@ var createEshopApi = (apiConfig) => {
971
993
  `/v1/stores/${target_store_id}/carts`,
972
994
  {
973
995
  ...payload,
974
- items: normalizeOrderCheckoutItems(payload.items || [])
996
+ items: payload.items || []
975
997
  },
976
998
  options
977
999
  );
@@ -983,7 +1005,7 @@ var createEshopApi = (apiConfig) => {
983
1005
  `/v1/stores/${target_store_id}/carts/${id}`,
984
1006
  {
985
1007
  ...payload,
986
- ...items ? { items: normalizeOrderCheckoutItems(items) } : {}
1008
+ ...items ? { items } : {}
987
1009
  },
988
1010
  options
989
1011
  );
@@ -993,7 +1015,7 @@ var createEshopApi = (apiConfig) => {
993
1015
  const target_store_id = store_id || apiConfig.storeId;
994
1016
  return apiConfig.httpClient.post(
995
1017
  `/v1/stores/${target_store_id}/carts/${id}/items`,
996
- { item: normalizeOrderCheckoutItems([item])[0] },
1018
+ { item },
997
1019
  options
998
1020
  );
999
1021
  },
@@ -1047,27 +1069,134 @@ var createEshopApi = (apiConfig) => {
1047
1069
  `/v1/stores/${target_store_id}/orders/quote`,
1048
1070
  {
1049
1071
  ...rest,
1050
- items: normalizeOrderQuoteItems(items),
1072
+ items,
1051
1073
  shipping_address,
1052
1074
  market: rest.market || apiConfig.market
1053
1075
  },
1054
1076
  options
1055
1077
  );
1056
1078
  },
1057
- async processRefund(params, options) {
1079
+ async createRefund(params, options) {
1080
+ const target_store_id = params.store_id || apiConfig.storeId;
1081
+ const response = await apiConfig.httpClient.post(
1082
+ `/v1/stores/${target_store_id}/orders/${params.order_id}/refunds`,
1083
+ {
1084
+ amount: params.amount,
1085
+ refund_id: params.refund_id
1086
+ },
1087
+ options
1088
+ );
1089
+ if (response.refund_id !== params.refund_id) {
1090
+ throw new Error(
1091
+ "Refund response did not match the requested refund_id"
1092
+ );
1093
+ }
1094
+ if (!Number.isSafeInteger(response.amount) || response.amount !== params.amount) {
1095
+ throw new Error("Refund response did not match the requested amount");
1096
+ }
1097
+ if (![
1098
+ "requested",
1099
+ "processing",
1100
+ "succeeded",
1101
+ "rejected",
1102
+ "failed",
1103
+ "unknown"
1104
+ ].includes(response.status)) {
1105
+ throw new Error("Refund response contained an invalid status");
1106
+ }
1107
+ return response;
1108
+ },
1109
+ async retryRefund(params, options) {
1110
+ const target_store_id = params.store_id || apiConfig.storeId;
1111
+ return apiConfig.httpClient.post(
1112
+ `/v1/stores/${target_store_id}/orders/${params.order_id}/refunds/${params.refund_id}/retry`,
1113
+ {},
1114
+ options
1115
+ );
1116
+ },
1117
+ async getPayment(params, options) {
1118
+ const target_store_id = params.store_id || apiConfig.storeId;
1119
+ return apiConfig.httpClient.get(
1120
+ `/v1/stores/${target_store_id}/orders/${params.order_id}/payment`,
1121
+ options
1122
+ );
1123
+ },
1124
+ async retryPaymentTransaction(params, options) {
1125
+ const target_store_id = params.store_id || apiConfig.storeId;
1058
1126
  return apiConfig.httpClient.post(
1059
- `/v1/stores/${apiConfig.storeId}/orders/${params.id}/refund`,
1060
- { amount: params.amount },
1127
+ `/v1/stores/${target_store_id}/orders/${params.order_id}/payment/transactions/${params.transaction_id}/retry`,
1128
+ {},
1061
1129
  options
1062
1130
  );
1063
1131
  },
1132
+ async getPaymentTransactions(params, options) {
1133
+ const { order_id, store_id, ...queryParams } = params;
1134
+ const target_store_id = store_id || apiConfig.storeId;
1135
+ return apiConfig.httpClient.get(
1136
+ `/v1/stores/${target_store_id}/orders/${order_id}/payment/transactions`,
1137
+ { ...options, params: queryParams }
1138
+ );
1139
+ },
1140
+ async getPaymentTransaction(params, options) {
1141
+ const target_store_id = params.store_id || apiConfig.storeId;
1142
+ return apiConfig.httpClient.get(
1143
+ `/v1/stores/${target_store_id}/orders/${params.order_id}/payment/transactions/${params.transaction_id}`,
1144
+ options
1145
+ );
1146
+ },
1147
+ async getRefund(params, options) {
1148
+ const target_store_id = params.store_id || apiConfig.storeId;
1149
+ return apiConfig.httpClient.get(
1150
+ `/v1/stores/${target_store_id}/orders/${params.order_id}/refunds/${params.refund_id}`,
1151
+ options
1152
+ );
1153
+ },
1154
+ async getRefunds(params, options) {
1155
+ const { order_id, store_id, ...queryParams } = params;
1156
+ const target_store_id = store_id || apiConfig.storeId;
1157
+ return apiConfig.httpClient.get(
1158
+ `/v1/stores/${target_store_id}/orders/${order_id}/refunds`,
1159
+ { ...options, params: queryParams }
1160
+ );
1161
+ },
1064
1162
  async downloadDigitalAccess(params, options) {
1065
1163
  const target_store_id = params.store_id || apiConfig.storeId;
1066
1164
  return apiConfig.httpClient.post(
1067
- `/v1/stores/${target_store_id}/orders/${params.id}/digital-access/${params.grant_id}/download`,
1165
+ `/v1/stores/${target_store_id}/orders/${params.order_id}/digital-access/${params.grant_id}/download`,
1166
+ {},
1167
+ options
1168
+ );
1169
+ },
1170
+ async activateDigitalAccess(params, options) {
1171
+ const target_store_id = params.store_id || apiConfig.storeId;
1172
+ return apiConfig.httpClient.post(
1173
+ `/v1/stores/${target_store_id}/orders/${params.order_id}/digital-access/${params.grant_id}/activate`,
1068
1174
  {},
1069
1175
  options
1070
1176
  );
1177
+ },
1178
+ async revokeDigitalAccess(params, options) {
1179
+ const target_store_id = params.store_id || apiConfig.storeId;
1180
+ return apiConfig.httpClient.post(
1181
+ `/v1/stores/${target_store_id}/orders/${params.order_id}/digital-access/${params.grant_id}/revoke`,
1182
+ {},
1183
+ options
1184
+ );
1185
+ },
1186
+ async findDigitalAccess(params, options) {
1187
+ const { order_id, store_id, ...queryParams } = params;
1188
+ const target_store_id = store_id || apiConfig.storeId;
1189
+ return apiConfig.httpClient.get(
1190
+ `/v1/stores/${target_store_id}/orders/${order_id}/digital-access`,
1191
+ { ...options, params: queryParams }
1192
+ );
1193
+ },
1194
+ async getDigitalAccess(params, options) {
1195
+ const target_store_id = params.store_id || apiConfig.storeId;
1196
+ return apiConfig.httpClient.get(
1197
+ `/v1/stores/${target_store_id}/orders/${params.order_id}/digital-access/${params.grant_id}`,
1198
+ options
1199
+ );
1071
1200
  }
1072
1201
  };
1073
1202
  };
@@ -1266,17 +1395,27 @@ var createContactApi = (apiConfig) => {
1266
1395
  options
1267
1396
  );
1268
1397
  },
1269
- async revokeToken(params, options) {
1398
+ async findSessions(params, options) {
1399
+ const store_id = params.store_id || apiConfig.storeId;
1400
+ const queryParams = {};
1401
+ if (params.limit !== void 0) queryParams.limit = params.limit;
1402
+ if (params.cursor) queryParams.cursor = params.cursor;
1403
+ return apiConfig.httpClient.get(
1404
+ `/v1/stores/${store_id}/contacts/${params.contact_id}/sessions`,
1405
+ { ...options, params: queryParams }
1406
+ );
1407
+ },
1408
+ async revokeSession(params, options) {
1270
1409
  const store_id = params.store_id || apiConfig.storeId;
1271
1410
  return apiConfig.httpClient.delete(
1272
- `/v1/stores/${store_id}/contacts/${params.id}/sessions/${params.token_id}`,
1411
+ `/v1/stores/${store_id}/contacts/${params.contact_id}/sessions/${params.session_id}`,
1273
1412
  options
1274
1413
  );
1275
1414
  },
1276
- async revokeAllTokens(params, options) {
1415
+ async revokeAllSessions(params, options) {
1277
1416
  const store_id = params.store_id || apiConfig.storeId;
1278
1417
  return apiConfig.httpClient.delete(
1279
- `/v1/stores/${store_id}/contacts/${params.id}/sessions`,
1418
+ `/v1/stores/${store_id}/contacts/${params.contact_id}/sessions`,
1280
1419
  options
1281
1420
  );
1282
1421
  },
@@ -1314,6 +1453,49 @@ var createContactApi = (apiConfig) => {
1314
1453
  { ...options, params: queryParams }
1315
1454
  );
1316
1455
  },
1456
+ plans: {
1457
+ async create(params, options) {
1458
+ const { store_id, contact_list_id, ...payload } = params;
1459
+ const target_store_id = store_id || apiConfig.storeId;
1460
+ return apiConfig.httpClient.post(
1461
+ `/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/plans`,
1462
+ payload,
1463
+ options
1464
+ );
1465
+ },
1466
+ async update(params, options) {
1467
+ const { id, store_id, contact_list_id, ...payload } = params;
1468
+ const target_store_id = store_id || apiConfig.storeId;
1469
+ return apiConfig.httpClient.put(
1470
+ `/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/plans/${id}`,
1471
+ payload,
1472
+ options
1473
+ );
1474
+ },
1475
+ async get(params, options) {
1476
+ const target_store_id = params.store_id || apiConfig.storeId;
1477
+ return apiConfig.httpClient.get(
1478
+ `/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/plans/${params.id}`,
1479
+ options
1480
+ );
1481
+ },
1482
+ async find(params, options) {
1483
+ const { store_id, contact_list_id, ...queryParams } = params;
1484
+ const target_store_id = store_id || apiConfig.storeId;
1485
+ return apiConfig.httpClient.get(
1486
+ `/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/plans`,
1487
+ { ...options, params: queryParams }
1488
+ );
1489
+ },
1490
+ async retryCatalog(params, options) {
1491
+ const target_store_id = params.store_id || apiConfig.storeId;
1492
+ return apiConfig.httpClient.post(
1493
+ `/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/plans/${params.plan_id}/catalog/retry`,
1494
+ {},
1495
+ options
1496
+ );
1497
+ }
1498
+ },
1317
1499
  async importContacts(params, options) {
1318
1500
  const { store_id, contact_list_id, ...payload } = params;
1319
1501
  const target_store_id = store_id || apiConfig.storeId;
@@ -1370,9 +1552,102 @@ var createContactApi = (apiConfig) => {
1370
1552
  { ...options, params: queryParams }
1371
1553
  );
1372
1554
  }
1555
+ },
1556
+ memberships: {
1557
+ async refund(params, options) {
1558
+ const { store_id, contact_list_id, membership_id, ...payload } = params;
1559
+ const target_store_id = store_id || apiConfig.storeId;
1560
+ const response = await apiConfig.httpClient.post(
1561
+ `/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/memberships/${membership_id}/refund`,
1562
+ payload,
1563
+ options
1564
+ );
1565
+ if (response.refund_id !== params.refund_id) {
1566
+ throw new Error(
1567
+ "Membership refund response did not match the requested refund_id"
1568
+ );
1569
+ }
1570
+ return response;
1571
+ },
1572
+ paymentAttempts: {
1573
+ async find(params, options) {
1574
+ const { store_id, contact_list_id, membership_id, ...queryParams } = params;
1575
+ const target_store_id = store_id || apiConfig.storeId;
1576
+ return apiConfig.httpClient.get(
1577
+ `/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/memberships/${membership_id}/payment-attempts`,
1578
+ { ...options, params: queryParams }
1579
+ );
1580
+ },
1581
+ async get(params, options) {
1582
+ const target_store_id = params.store_id || apiConfig.storeId;
1583
+ return apiConfig.httpClient.get(
1584
+ `/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/memberships/${params.membership_id}/payment-attempts/${params.id}`,
1585
+ options
1586
+ );
1587
+ }
1588
+ },
1589
+ refunds: {
1590
+ async find(params, options) {
1591
+ const { store_id, contact_list_id, membership_id, ...queryParams } = params;
1592
+ const target_store_id = store_id || apiConfig.storeId;
1593
+ return apiConfig.httpClient.get(
1594
+ `/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/memberships/${membership_id}/refunds`,
1595
+ { ...options, params: queryParams }
1596
+ );
1597
+ },
1598
+ async get(params, options) {
1599
+ const target_store_id = params.store_id || apiConfig.storeId;
1600
+ return apiConfig.httpClient.get(
1601
+ `/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/memberships/${params.membership_id}/refunds/${params.id}`,
1602
+ options
1603
+ );
1604
+ },
1605
+ async retry(params, options) {
1606
+ const target_store_id = params.store_id || apiConfig.storeId;
1607
+ return apiConfig.httpClient.post(
1608
+ `/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/memberships/${params.membership_id}/refunds/${params.id}/retry`,
1609
+ {},
1610
+ options
1611
+ );
1612
+ }
1613
+ },
1614
+ cancellations: {
1615
+ async find(params, options) {
1616
+ const { store_id, contact_list_id, membership_id, ...queryParams } = params;
1617
+ const target_store_id = store_id || apiConfig.storeId;
1618
+ return apiConfig.httpClient.get(
1619
+ `/v1/stores/${target_store_id}/contact-lists/${contact_list_id}/memberships/${membership_id}/cancellations`,
1620
+ { ...options, params: queryParams }
1621
+ );
1622
+ },
1623
+ async get(params, options) {
1624
+ const target_store_id = params.store_id || apiConfig.storeId;
1625
+ return apiConfig.httpClient.get(
1626
+ `/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/memberships/${params.membership_id}/cancellations/${params.id}`,
1627
+ options
1628
+ );
1629
+ },
1630
+ async retry(params, options) {
1631
+ const target_store_id = params.store_id || apiConfig.storeId;
1632
+ return apiConfig.httpClient.post(
1633
+ `/v1/stores/${target_store_id}/contact-lists/${params.contact_list_id}/memberships/${params.membership_id}/cancellations/${params.id}/retry`,
1634
+ {},
1635
+ options
1636
+ );
1637
+ }
1638
+ }
1373
1639
  }
1374
1640
  },
1375
1641
  mailbox: {
1642
+ async connectGoogle(params, options) {
1643
+ const { store_id, ...payload } = params;
1644
+ const target_store_id = store_id || apiConfig.storeId;
1645
+ return apiConfig.httpClient.post(
1646
+ `/v1/stores/${target_store_id}/mailboxes/google/connect-url`,
1647
+ payload,
1648
+ options
1649
+ );
1650
+ },
1376
1651
  async create(params, options) {
1377
1652
  const { store_id, ...payload } = params;
1378
1653
  const target_store_id = store_id || apiConfig.storeId;
@@ -1946,11 +2221,50 @@ var createSocialApi = (apiConfig) => {
1946
2221
  options
1947
2222
  );
1948
2223
  },
1949
- async replyToPublicationComment(params, options) {
1950
- const { store_id, publication_id, comment_id, text } = params;
2224
+ async createCommentReply(params, options) {
2225
+ const { store_id, publication_id, comment_id, ...payload } = params;
1951
2226
  return apiConfig.httpClient.post(
1952
- `/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/reply`,
1953
- { text },
2227
+ `/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/replies`,
2228
+ payload,
2229
+ options
2230
+ );
2231
+ },
2232
+ async listCommentReplies(params, options) {
2233
+ const { store_id, publication_id, comment_id, ...queryParams } = params;
2234
+ return apiConfig.httpClient.get(
2235
+ `/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/replies`,
2236
+ {
2237
+ ...options,
2238
+ params: Object.keys(queryParams).length > 0 ? queryParams : void 0
2239
+ }
2240
+ );
2241
+ },
2242
+ async getCommentReply(params, options) {
2243
+ return apiConfig.httpClient.get(
2244
+ `/v1/stores/${storeId(params.store_id)}/social-publications/${params.publication_id}/comments/${params.comment_id}/replies/${params.reply_id}`,
2245
+ options
2246
+ );
2247
+ },
2248
+ async retryCommentReply(params, options) {
2249
+ return apiConfig.httpClient.post(
2250
+ `/v1/stores/${storeId(params.store_id)}/social-publications/${params.publication_id}/comments/${params.comment_id}/replies/${params.reply_id}/retry`,
2251
+ {},
2252
+ options
2253
+ );
2254
+ },
2255
+ async listPublicationEffects(params, options) {
2256
+ const { store_id, publication_id, ...queryParams } = params;
2257
+ return apiConfig.httpClient.get(
2258
+ `/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/effects`,
2259
+ {
2260
+ ...options,
2261
+ params: Object.keys(queryParams).length > 0 ? queryParams : void 0
2262
+ }
2263
+ );
2264
+ },
2265
+ async getPublicationEffect(params, options) {
2266
+ return apiConfig.httpClient.get(
2267
+ `/v1/stores/${storeId(params.store_id)}/social-publications/${params.publication_id}/effects/${params.effect_id}`,
1954
2268
  options
1955
2269
  );
1956
2270
  },
@@ -1977,41 +2291,41 @@ var createSocialApi = (apiConfig) => {
1977
2291
  },
1978
2292
  async getCapabilities(params, options) {
1979
2293
  return apiConfig.httpClient.get(
1980
- `/v1/stores/${storeId(params?.store_id)}/social-accounts/capabilities`,
2294
+ `/v1/stores/${storeId(params?.store_id)}/social-connections/capabilities`,
1981
2295
  options
1982
2296
  );
1983
2297
  },
1984
- async listAccounts(params, options) {
2298
+ async listConnections(params, options) {
1985
2299
  return apiConfig.httpClient.get(
1986
- `/v1/stores/${storeId(params?.store_id)}/social-accounts`,
2300
+ `/v1/stores/${storeId(params?.store_id)}/social-connections`,
1987
2301
  options
1988
2302
  );
1989
2303
  },
1990
2304
  async connect(params, options) {
1991
2305
  const { store_id, ...payload } = params;
1992
2306
  return apiConfig.httpClient.post(
1993
- `/v1/stores/${storeId(store_id)}/social-accounts/oauth/connect`,
2307
+ `/v1/stores/${storeId(store_id)}/social-connections/oauth/connect`,
1994
2308
  payload,
1995
2309
  options
1996
2310
  );
1997
2311
  },
1998
2312
  async getOAuthAttempt(params, options) {
1999
2313
  return apiConfig.httpClient.get(
2000
- `/v1/stores/${storeId(params.store_id)}/social-accounts/oauth/attempts/${params.attempt_id}`,
2314
+ `/v1/stores/${storeId(params.store_id)}/social-connections/oauth/attempts/${params.attempt_id}`,
2001
2315
  options
2002
2316
  );
2003
2317
  },
2004
2318
  async selectDestination(params, options) {
2005
2319
  const { store_id, ...payload } = params;
2006
2320
  return apiConfig.httpClient.post(
2007
- `/v1/stores/${storeId(store_id)}/social-accounts/oauth/select-destination`,
2321
+ `/v1/stores/${storeId(store_id)}/social-connections/oauth/select-destination`,
2008
2322
  payload,
2009
2323
  options
2010
2324
  );
2011
2325
  },
2012
- async deleteAccount(params, options) {
2326
+ async deleteConnection(params, options) {
2013
2327
  return apiConfig.httpClient.delete(
2014
- `/v1/stores/${storeId(params.store_id)}/social-accounts/${params.id}`,
2328
+ `/v1/stores/${storeId(params.store_id)}/social-connections/${params.id}`,
2015
2329
  options
2016
2330
  );
2017
2331
  },
@@ -2097,26 +2411,44 @@ var createWorkflowApi = (apiConfig) => {
2097
2411
  options
2098
2412
  );
2099
2413
  },
2100
- async getWorkflowAccounts(params, options) {
2414
+ async getWorkflowEffects(params, options) {
2415
+ const store_id = params.store_id || apiConfig.storeId;
2416
+ const { store_id: _, workflow_id, execution_id, ...queryParams } = params;
2417
+ return apiConfig.httpClient.get(
2418
+ `/v1/stores/${store_id}/workflows/${workflow_id}/executions/${execution_id}/effects`,
2419
+ {
2420
+ ...options,
2421
+ params: Object.keys(queryParams).length > 0 ? queryParams : void 0
2422
+ }
2423
+ );
2424
+ },
2425
+ async getWorkflowEffect(params, options) {
2426
+ const store_id = params.store_id || apiConfig.storeId;
2427
+ return apiConfig.httpClient.get(
2428
+ `/v1/stores/${store_id}/workflows/${params.workflow_id}/executions/${params.execution_id}/effects/${params.effect_id}`,
2429
+ options
2430
+ );
2431
+ },
2432
+ async getWorkflowConnections(params, options) {
2101
2433
  const store_id = params?.store_id || apiConfig.storeId;
2102
2434
  return apiConfig.httpClient.get(
2103
- `/v1/stores/${store_id}/workflow-accounts`,
2435
+ `/v1/stores/${store_id}/workflow-connections`,
2104
2436
  options
2105
2437
  );
2106
2438
  },
2107
- async getWorkflowAccountConnectUrl(params, options) {
2439
+ async getWorkflowConnectionConnectUrl(params, options) {
2108
2440
  const { store_id, type, ...payload } = params;
2109
2441
  const target_store_id = store_id || apiConfig.storeId;
2110
2442
  return apiConfig.httpClient.post(
2111
- `/v1/stores/${target_store_id}/workflow-accounts/connect-url`,
2443
+ `/v1/stores/${target_store_id}/workflow-connections/connect-url`,
2112
2444
  { ...payload, type, store_id: target_store_id },
2113
2445
  options
2114
2446
  );
2115
2447
  },
2116
- async deleteWorkflowAccount(params, options) {
2448
+ async deleteWorkflowConnection(params, options) {
2117
2449
  const store_id = params.store_id || apiConfig.storeId;
2118
2450
  return apiConfig.httpClient.delete(
2119
- `/v1/stores/${store_id}/workflow-accounts/${params.id}`,
2451
+ `/v1/stores/${store_id}/workflow-connections/${params.id}`,
2120
2452
  options
2121
2453
  );
2122
2454
  }
@@ -2160,27 +2492,105 @@ var createPlatformApi = (apiConfig) => {
2160
2492
 
2161
2493
  // src/api/shipping.ts
2162
2494
  var createShippingApi = (apiConfig) => {
2495
+ const storeId = (value) => value || apiConfig.storeId;
2163
2496
  return {
2497
+ async findFulfillmentOrders(params, options) {
2498
+ const { store_id, order_id, ...queryParams } = params;
2499
+ return apiConfig.httpClient.get(
2500
+ `/v1/stores/${storeId(store_id)}/orders/${order_id}/fulfillment-orders`,
2501
+ { ...options, params: queryParams }
2502
+ );
2503
+ },
2504
+ async getFulfillmentOrder(params, options) {
2505
+ return apiConfig.httpClient.get(
2506
+ `/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/fulfillment-orders/${params.fulfillment_order_id}`,
2507
+ options
2508
+ );
2509
+ },
2164
2510
  async getRates(params, options) {
2165
- const { order_id, ...payload } = params;
2511
+ const { store_id, order_id, ...payload } = params;
2166
2512
  return apiConfig.httpClient.post(
2167
- `/v1/stores/${apiConfig.storeId}/orders/${order_id}/shipping/rates`,
2513
+ `/v1/stores/${storeId(store_id)}/orders/${order_id}/shipping/rates`,
2168
2514
  payload,
2169
2515
  options
2170
2516
  );
2171
2517
  },
2172
- async ship(params, options) {
2173
- const { order_id, ...payload } = params;
2174
- return apiConfig.httpClient.post(
2175
- `/v1/stores/${apiConfig.storeId}/orders/${order_id}/ship`,
2518
+ async findShipments(params, options) {
2519
+ const { store_id, order_id, ...queryParams } = params;
2520
+ return apiConfig.httpClient.get(
2521
+ `/v1/stores/${storeId(store_id)}/orders/${order_id}/shipments`,
2522
+ { ...options, params: queryParams }
2523
+ );
2524
+ },
2525
+ async getShipment(params, options) {
2526
+ return apiConfig.httpClient.get(
2527
+ `/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}`,
2528
+ options
2529
+ );
2530
+ },
2531
+ async createShipment(params, options) {
2532
+ const { store_id, order_id, ...payload } = params;
2533
+ const response = await apiConfig.httpClient.post(
2534
+ `/v1/stores/${storeId(store_id)}/orders/${order_id}/shipments`,
2176
2535
  payload,
2177
2536
  options
2178
2537
  );
2538
+ if (response.shipment_id !== params.shipment_id || response.shipment.id !== params.shipment_id) {
2539
+ throw new Error("Shipping response did not match the requested shipment_id");
2540
+ }
2541
+ return response;
2542
+ },
2543
+ async retryShipment(params, options) {
2544
+ return apiConfig.httpClient.post(
2545
+ `/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}/retry`,
2546
+ {},
2547
+ options
2548
+ );
2179
2549
  },
2180
- async refundLabel(params, options) {
2181
- const { order_id, shipment_id } = params;
2550
+ async requestRefund(params, options) {
2182
2551
  return apiConfig.httpClient.post(
2183
- `/v1/stores/${apiConfig.storeId}/orders/${order_id}/shipments/${shipment_id}/label/refund`,
2552
+ `/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}/refunds`,
2553
+ {},
2554
+ options
2555
+ );
2556
+ },
2557
+ async findRefunds(params, options) {
2558
+ const { store_id, order_id, shipment_id, ...queryParams } = params;
2559
+ return apiConfig.httpClient.get(
2560
+ `/v1/stores/${storeId(store_id)}/orders/${order_id}/shipments/${shipment_id}/refunds`,
2561
+ { ...options, params: queryParams }
2562
+ );
2563
+ },
2564
+ async getRefund(params, options) {
2565
+ return apiConfig.httpClient.get(
2566
+ `/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}/refunds/${params.refund_id}`,
2567
+ options
2568
+ );
2569
+ },
2570
+ async retryRefund(params, options) {
2571
+ return apiConfig.httpClient.post(
2572
+ `/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}/refunds/${params.refund_id}/retry`,
2573
+ {},
2574
+ options
2575
+ );
2576
+ },
2577
+ async findAdjustments(params, options) {
2578
+ const { store_id, order_id, shipment_id, ...queryParams } = params;
2579
+ return apiConfig.httpClient.get(
2580
+ `/v1/stores/${storeId(store_id)}/orders/${order_id}/shipments/${shipment_id}/adjustments`,
2581
+ { ...options, params: queryParams }
2582
+ );
2583
+ },
2584
+ async findSettlements(params, options) {
2585
+ const { store_id, order_id, shipment_id, ...queryParams } = params;
2586
+ return apiConfig.httpClient.get(
2587
+ `/v1/stores/${storeId(store_id)}/orders/${order_id}/shipments/${shipment_id}/settlements`,
2588
+ { ...options, params: queryParams }
2589
+ );
2590
+ },
2591
+ async retrySettlement(params, options) {
2592
+ return apiConfig.httpClient.post(
2593
+ `/v1/stores/${storeId(params.store_id)}/orders/${params.order_id}/shipments/${params.shipment_id}/settlements/${params.settlement_id}/retry`,
2184
2594
  {},
2185
2595
  options
2186
2596
  );
@@ -2489,155 +2899,230 @@ var createExperimentsApi = (apiConfig) => {
2489
2899
  };
2490
2900
 
2491
2901
  // src/utils/blocks.ts
2492
- function getBlockLabel(block) {
2493
- if (!block) return "";
2494
- return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) ?? "";
2902
+ function isRecord2(value) {
2903
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2495
2904
  }
2496
- function formatBlockValue(block) {
2497
- if (!block || block.value === null || block.value === void 0) return "";
2498
- const value = block.value;
2499
- switch (block.type) {
2500
- case "boolean":
2501
- return value ? "Yes" : "No";
2502
- case "number":
2503
- if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
2504
- return new Date(value).toLocaleDateString();
2505
- }
2506
- return String(value);
2507
- case "media":
2508
- if (value && typeof value === "object") {
2509
- return value.mime_type ? value.name || value.id : value.title || value.name || value.id;
2510
- }
2511
- return String(value);
2512
- default:
2513
- return String(value);
2514
- }
2905
+ function isBlock(value) {
2906
+ return isRecord2(value) && typeof value.key === "string" && typeof value.type === "string";
2515
2907
  }
2516
- function prepareBlocksForSubmission(formData, blockTypes) {
2517
- return Object.keys(formData).filter((key) => formData[key] !== null && formData[key] !== void 0).map((key) => ({
2518
- key,
2519
- value: (blockTypes?.[key] || "text") === "array" && !Array.isArray(formData[key]) ? [formData[key]] : formData[key]
2520
- }));
2908
+ function recordFromBlocks(values, locale) {
2909
+ const result = {};
2910
+ for (const value of values) {
2911
+ if (!isBlock(value)) continue;
2912
+ result[value.key] = unwrapBlock(value, locale);
2913
+ }
2914
+ return result;
2521
2915
  }
2522
- function extractBlockValues(blocks) {
2523
- const values = {};
2524
- blocks.forEach((block) => {
2525
- values[block.key] = block.value ?? null;
2526
- });
2527
- return values;
2916
+ function localizedValue(value, locale) {
2917
+ if (typeof value === "string") return value;
2918
+ if (!isRecord2(value)) return "";
2919
+ const selected = value[locale] ?? value.en;
2920
+ return typeof selected === "string" ? selected : "";
2528
2921
  }
2529
- var getBlockValue = (entry, blockKey) => {
2530
- const block = entry?.blocks?.find((f) => f.key === blockKey);
2531
- return block?.value ?? null;
2532
- };
2533
- var getBlockTextValue = (block, locale = "en") => {
2534
- if (!block || block.value === null || block.value === void 0) return "";
2535
- const blockType = block.type;
2536
- if (blockType === "localized_text" || blockType === "markdown") {
2537
- if (typeof block.value === "object" && block.value !== null) {
2538
- return block.value[locale] ?? block.value["en"] ?? "";
2539
- }
2922
+ function unwrapBlock(value, locale) {
2923
+ if (!isBlock(value)) return value;
2924
+ if (value.type === "localized_text" || value.type === "markdown") {
2925
+ return localizedValue(value.value, locale);
2540
2926
  }
2541
- if (typeof block.value === "string") return block.value;
2542
- return String(block.value ?? "");
2543
- };
2544
- var getBlockValues = (entry, blockKey) => {
2545
- const block = entry?.blocks?.find((f) => f.key === blockKey);
2546
- if (!block) return [];
2547
- if (block.type === "array" && Array.isArray(block.value)) {
2548
- return block.value;
2549
- }
2550
- return [];
2551
- };
2552
- function unwrapBlock(block, locale) {
2553
- if (!block?.type || block.value === void 0) return block;
2554
- const blockType = block.type;
2555
- if (blockType === "array") {
2556
- return block.value.map((obj) => {
2557
- const parsed = {};
2558
- for (const [k, v] of Object.entries(obj)) {
2559
- parsed[k] = unwrapBlock(v, locale);
2927
+ if (value.type === "array") {
2928
+ if (!Array.isArray(value.value)) return [];
2929
+ return value.value.map((item) => {
2930
+ if (isBlock(item)) return unwrapBlock(item, locale);
2931
+ if (isRecord2(item) && Array.isArray(item.value)) {
2932
+ return recordFromBlocks(item.value, locale);
2560
2933
  }
2561
- return parsed;
2934
+ if (!isRecord2(item)) return item;
2935
+ return Object.fromEntries(
2936
+ Object.entries(item).map(([key, nested]) => [key, unwrapBlock(nested, locale)])
2937
+ );
2562
2938
  });
2563
2939
  }
2564
- if (blockType === "object") {
2565
- const parsed = {};
2566
- for (const [k, v] of Object.entries(block.value || {})) {
2567
- parsed[k] = unwrapBlock(v, locale);
2568
- }
2569
- return parsed;
2940
+ if (value.type === "object") {
2941
+ if (Array.isArray(value.value)) return recordFromBlocks(value.value, locale);
2942
+ if (!isRecord2(value.value)) return {};
2943
+ return Object.fromEntries(
2944
+ Object.entries(value.value).map(([key, nested]) => [key, unwrapBlock(nested, locale)])
2945
+ );
2570
2946
  }
2571
- if (blockType === "localized_text" || blockType === "markdown") {
2572
- return block.value?.[locale];
2947
+ return value.value;
2948
+ }
2949
+ function blockContentArray(values, locale) {
2950
+ const blocks = values.filter(isBlock);
2951
+ if (blocks.length === 0) return [];
2952
+ if (blocks.every((block) => block.key === blocks[0].key)) {
2953
+ return blocks.map((block) => blockContentValue(block, locale));
2573
2954
  }
2574
- return block.value;
2955
+ return Object.fromEntries(
2956
+ blocks.map((block) => [block.key, blockContentValue(block, locale)])
2957
+ );
2575
2958
  }
2576
- var getBlockObjectValues = (entry, blockKey, locale = "en") => {
2577
- const block = entry?.blocks?.find((f) => f.key === blockKey);
2578
- if (!block || block.type !== "array" || !Array.isArray(block.value)) return [];
2579
- return block.value.map((obj) => {
2580
- if (!obj?.value || !Array.isArray(obj.value)) return {};
2581
- return obj.value.reduce((acc, current) => {
2582
- acc[current.key] = unwrapBlock(current, locale);
2583
- return acc;
2584
- }, {});
2585
- });
2586
- };
2587
- var getBlockFromArray = (entry, blockKey, locale = "en") => {
2588
- const block = entry?.blocks?.find((f) => f.key === blockKey);
2589
- if (!block) return {};
2590
- if (block.type === "array" && Array.isArray(block.value)) {
2591
- return block.value.reduce((acc, current) => {
2592
- acc[current.key] = unwrapBlock(current, locale);
2593
- return acc;
2594
- }, {});
2959
+ function blockContentValue(block, locale) {
2960
+ if (block.type === "localized_text" || block.type === "markdown") {
2961
+ return localizedValue(block.value, locale);
2962
+ }
2963
+ if (block.type === "media") return block.value ?? null;
2964
+ if (block.type === "array") {
2965
+ return Array.isArray(block.value) ? blockContentArray(block.value, locale) : [];
2595
2966
  }
2596
- if (block.type === "object" && block.value && typeof block.value === "object") {
2597
- const result = {};
2598
- for (const [k, v] of Object.entries(block.value)) {
2599
- result[k] = unwrapBlock(v, locale);
2967
+ if (block.type === "object") {
2968
+ if (Array.isArray(block.value)) return blockContentArray(block.value, locale);
2969
+ if (!isRecord2(block.value)) return {};
2970
+ return Object.fromEntries(
2971
+ Object.entries(block.value).map(([key, value]) => [
2972
+ key,
2973
+ isBlock(value) ? blockContentValue(value, locale) : value
2974
+ ])
2975
+ );
2976
+ }
2977
+ return block.value;
2978
+ }
2979
+ function findBlock(entry, key) {
2980
+ return entry?.blocks?.find((block) => block.key === key);
2981
+ }
2982
+ function getBlockLabel(block) {
2983
+ return block?.key.replace(/_/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase()) ?? "";
2984
+ }
2985
+ function formatBlockValue(block) {
2986
+ if (block?.value === null || block?.value === void 0) return "";
2987
+ if (block.type === "boolean") return block.value ? "Yes" : "No";
2988
+ if (block.type === "number") {
2989
+ const properties = isRecord2(block.properties) ? block.properties : {};
2990
+ if (properties.variant === "DATE" || properties.variant === "DATE_TIME") {
2991
+ return new Date(Number(block.value)).toLocaleDateString();
2600
2992
  }
2601
- return result;
2602
2993
  }
2603
- return { [block.key]: unwrapBlock(block, locale) };
2604
- };
2605
- var getImageUrl = (imageBlock, isBlock = true) => {
2606
- if (!imageBlock) return null;
2607
- if (imageBlock.type === "media") {
2608
- const mediaValue = imageBlock.value;
2609
- return mediaValue?.resolutions?.original?.url || mediaValue?.url || null;
2994
+ if (block.type === "media" && isRecord2(block.value)) {
2995
+ const label = block.value.name ?? block.value.title ?? block.value.id;
2996
+ return typeof label === "string" ? label : "";
2610
2997
  }
2611
- if (isBlock) {
2612
- if (typeof imageBlock === "string") return imageBlock;
2613
- if (imageBlock.url) return imageBlock.url;
2998
+ return String(block.value);
2999
+ }
3000
+ function prepareBlocksForSubmission(formData, blockTypes = {}) {
3001
+ return Object.entries(formData).filter(([, value]) => value !== null && value !== void 0).map(([key, value]) => ({
3002
+ key,
3003
+ value: blockTypes[key] === "array" && !Array.isArray(value) ? [value] : value
3004
+ }));
3005
+ }
3006
+ function extractBlockValues(blocks) {
3007
+ return Object.fromEntries(blocks.map((block) => [block.key, block.value ?? null]));
3008
+ }
3009
+ function getBlockValue(entry, key) {
3010
+ return findBlock(entry, key)?.value ?? null;
3011
+ }
3012
+ function getBlockTextValue(block, locale = "en") {
3013
+ if (!block || block.value === null || block.value === void 0) return "";
3014
+ if (block.type === "localized_text" || block.type === "markdown") {
3015
+ return localizedValue(block.value, locale);
2614
3016
  }
2615
- return imageBlock.resolutions?.original?.url || null;
2616
- };
3017
+ return typeof block.value === "string" ? block.value : String(block.value);
3018
+ }
3019
+ function getBlockContentValue(entry, key, locale = "en") {
3020
+ const block = findBlock(entry, key);
3021
+ return block ? blockContentValue(block, locale) : null;
3022
+ }
3023
+ function getBlockValues(entry, key) {
3024
+ const block = findBlock(entry, key);
3025
+ return block?.type === "array" && Array.isArray(block.value) ? block.value : [];
3026
+ }
3027
+ function getBlockObjectValues(entry, key, locale = "en") {
3028
+ return getBlockValues(entry, key).map((value) => {
3029
+ if (isRecord2(value) && Array.isArray(value.value)) {
3030
+ return recordFromBlocks(value.value, locale);
3031
+ }
3032
+ return isRecord2(value) ? Object.fromEntries(
3033
+ Object.entries(value).map(([field, nested]) => [field, unwrapBlock(nested, locale)])
3034
+ ) : {};
3035
+ });
3036
+ }
3037
+ function getBlockFromArray(entry, key, locale = "en") {
3038
+ const block = findBlock(entry, key);
3039
+ if (!block) return {};
3040
+ const value = unwrapBlock(block, locale);
3041
+ if (isRecord2(value)) return value;
3042
+ if (Array.isArray(block.value)) return recordFromBlocks(block.value, locale);
3043
+ return { [block.key]: value };
3044
+ }
3045
+ function nestedUrl(value) {
3046
+ const resolutions = isRecord2(value.resolutions) ? value.resolutions : null;
3047
+ const original = resolutions && isRecord2(resolutions.original) ? resolutions.original : null;
3048
+ if (typeof original?.url === "string") return original.url;
3049
+ return typeof value.url === "string" ? value.url : null;
3050
+ }
3051
+ function getImageUrl(value, isBlock2 = true) {
3052
+ if (typeof value === "string") return value;
3053
+ if (!isRecord2(value)) return null;
3054
+ if (value.type === "media" && isRecord2(value.value)) return nestedUrl(value.value);
3055
+ if (isBlock2 && typeof value.url === "string") return value.url;
3056
+ return nestedUrl(value);
3057
+ }
2617
3058
 
2618
3059
  // src/utils/price.ts
3060
+ var SUPPORTED_STORE_CURRENCIES = Object.freeze([
3061
+ "USD",
3062
+ "EUR",
3063
+ "GBP",
3064
+ "JPY",
3065
+ "CNY",
3066
+ "CHF",
3067
+ "AUD",
3068
+ "CAD",
3069
+ "HKD",
3070
+ "SGD",
3071
+ "NZD",
3072
+ "KRW",
3073
+ "SEK",
3074
+ "NOK",
3075
+ "DKK",
3076
+ "INR",
3077
+ "MXN",
3078
+ "BRL",
3079
+ "ZAR",
3080
+ "RUB",
3081
+ "TRY",
3082
+ "PLN",
3083
+ "THB",
3084
+ "IDR",
3085
+ "MYR",
3086
+ "PHP",
3087
+ "CZK",
3088
+ "ILS",
3089
+ "AED",
3090
+ "SAR",
3091
+ "HUF",
3092
+ "RON",
3093
+ "BGN",
3094
+ "HRK",
3095
+ "BAM",
3096
+ "RSD",
3097
+ "MKD",
3098
+ "ALL"
3099
+ ]);
3100
+ var SUPPORTED_STORE_CURRENCY_SET = Object.freeze(
3101
+ new Set(SUPPORTED_STORE_CURRENCIES)
3102
+ );
3103
+ var ZERO_MINOR_UNIT_STORE_CURRENCIES = Object.freeze(
3104
+ /* @__PURE__ */ new Set(["JPY", "KRW"])
3105
+ );
2619
3106
  function formatCurrency(amount, currencyCode, locale = "en") {
2620
- if (!currencyCode) return "";
3107
+ const normalized = currencyCode.trim().toUpperCase();
3108
+ if (!normalized) return "";
3109
+ const minorUnits = getCurrencyMinorUnits(normalized);
2621
3110
  return new Intl.NumberFormat(locale, {
2622
3111
  style: "currency",
2623
- currency: currencyCode.toUpperCase()
3112
+ currency: normalized,
3113
+ minimumFractionDigits: minorUnits,
3114
+ maximumFractionDigits: minorUnits
2624
3115
  }).format(amount);
2625
3116
  }
2626
- function getMinorUnits(currency) {
2627
- try {
2628
- const formatter = new Intl.NumberFormat("en", {
2629
- style: "currency",
2630
- currency: currency.toUpperCase()
2631
- });
2632
- const parts = formatter.formatToParts(1.11);
2633
- const fractionPart = parts.find((p) => p.type === "fraction");
2634
- return fractionPart?.value.length ?? 2;
2635
- } catch {
2636
- return 2;
3117
+ function getCurrencyMinorUnits(currency) {
3118
+ const normalized = currency.trim().toUpperCase();
3119
+ if (!SUPPORTED_STORE_CURRENCY_SET.has(normalized)) {
3120
+ throw new RangeError(`Unsupported currency '${currency}'`);
2637
3121
  }
3122
+ return ZERO_MINOR_UNIT_STORE_CURRENCIES.has(normalized) ? 0 : 2;
2638
3123
  }
2639
3124
  function convertToMajor(minorAmount, currency) {
2640
- const units = getMinorUnits(currency);
3125
+ const units = getCurrencyMinorUnits(currency);
2641
3126
  return minorAmount / Math.pow(10, units);
2642
3127
  }
2643
3128
  function getCurrencySymbol(currency) {
@@ -2659,22 +3144,24 @@ function getCurrencyName(currency) {
2659
3144
  }
2660
3145
  }
2661
3146
  function formatMinor(amountMinor, currency) {
2662
- if (!currency) return "";
3147
+ if (!Number.isSafeInteger(amountMinor)) {
3148
+ throw new RangeError("Minor-unit amount must be a safe integer");
3149
+ }
2663
3150
  return formatCurrency(convertToMajor(amountMinor, currency), currency);
2664
3151
  }
2665
3152
  function formatPayment(payment) {
2666
3153
  return formatMinor(payment.total, payment.currency);
2667
3154
  }
2668
3155
  function formatPrice(prices, marketId) {
2669
- if (!prices || prices.length === 0) return "";
2670
- const price = marketId ? prices.find((p) => p.market === marketId) || prices[0] : prices[0];
2671
- if (!price) return "";
3156
+ if (!prices || prices.length === 0 || !marketId) return "";
3157
+ const price = prices.find((p) => p.market === marketId);
3158
+ if (!price || !Number.isSafeInteger(price.amount) || price.amount < 0 || !price.currency) return "";
2672
3159
  return formatMinor(price.amount, price.currency);
2673
3160
  }
2674
3161
  function getPriceAmount(prices, marketId) {
2675
- if (!prices || prices.length === 0) return 0;
2676
- const price = prices.find((p) => p.market === marketId) || prices[0];
2677
- return price?.amount || 0;
3162
+ if (!prices || prices.length === 0 || !marketId) return null;
3163
+ const price = prices.find((p) => p.market === marketId);
3164
+ return price && Number.isSafeInteger(price.amount) && price.amount >= 0 ? price.amount : null;
2678
3165
  }
2679
3166
 
2680
3167
  // src/utils/validation.ts
@@ -2775,6 +3262,7 @@ function formatDate(date, locale) {
2775
3262
  async function fetchSvgContent(mediaObject) {
2776
3263
  if (!mediaObject) return null;
2777
3264
  const svgUrl = getImageUrl(mediaObject, false);
3265
+ if (!svgUrl) return null;
2778
3266
  try {
2779
3267
  const response = await fetch(svgUrl);
2780
3268
  if (!response.ok) {
@@ -2867,9 +3355,10 @@ function getFirstAvailableFCId(variant, quantity = 1) {
2867
3355
  // src/index.ts
2868
3356
  function createUtilitySurface(apiConfig) {
2869
3357
  return {
2870
- getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock),
3358
+ getImageUrl: (imageBlock, isBlock2 = true) => getImageUrl(imageBlock, isBlock2),
2871
3359
  getBlockValue,
2872
3360
  getBlockTextValue,
3361
+ getBlockContentValue,
2873
3362
  getBlockValues,
2874
3363
  getBlockLabel,
2875
3364
  getBlockObjectValues,
@@ -3020,9 +3509,11 @@ function createAdmin(config) {
3020
3509
  trigger: workflowApi.triggerWorkflow,
3021
3510
  getExecutions: workflowApi.getWorkflowExecutions,
3022
3511
  getExecution: workflowApi.getWorkflowExecution,
3023
- listAccounts: workflowApi.getWorkflowAccounts,
3024
- getAccountConnectUrl: workflowApi.getWorkflowAccountConnectUrl,
3025
- deleteAccount: workflowApi.deleteWorkflowAccount
3512
+ listEffects: workflowApi.getWorkflowEffects,
3513
+ getEffect: workflowApi.getWorkflowEffect,
3514
+ listConnections: workflowApi.getWorkflowConnections,
3515
+ getConnectionConnectUrl: workflowApi.getWorkflowConnectionConnectUrl,
3516
+ deleteConnection: workflowApi.deleteWorkflowConnection
3026
3517
  };
3027
3518
  const formApi = createFormApi(apiConfig);
3028
3519
  const taxonomyApi = createTaxonomyApi(apiConfig);
@@ -3035,22 +3526,43 @@ function createAdmin(config) {
3035
3526
  delete: accountApi.deleteAccount,
3036
3527
  getMe: accountApi.getMe,
3037
3528
  search: accountApi.searchAccounts,
3529
+ apiToken: {
3530
+ list: accountApi.listApiTokens,
3531
+ create: accountApi.createApiToken,
3532
+ update: accountApi.updateApiToken,
3533
+ revoke: accountApi.revokeApiToken
3534
+ },
3535
+ session: {
3536
+ list: accountApi.listSessions,
3537
+ revoke: accountApi.revokeSession
3538
+ },
3038
3539
  auth: authApi
3039
3540
  },
3040
3541
  store: {
3041
3542
  create: storeApi.createStore,
3042
3543
  update: storeApi.updateStore,
3043
- delete: storeApi.deleteStore,
3044
3544
  get: storeApi.getStore,
3045
3545
  find: storeApi.getStores,
3046
3546
  subscription: {
3547
+ get: storeApi.getSubscription,
3047
3548
  getPlans: storeApi.getSubscriptionPlans,
3048
- subscribe: storeApi.subscribe,
3549
+ action: {
3550
+ create: storeApi.createSubscriptionAction,
3551
+ find: storeApi.findSubscriptionActions,
3552
+ get: storeApi.getSubscriptionAction,
3553
+ retry: storeApi.retrySubscriptionAction,
3554
+ effect: {
3555
+ find: storeApi.findSubscriptionActionEffects,
3556
+ get: storeApi.getSubscriptionActionEffect
3557
+ }
3558
+ },
3049
3559
  createPortalSession: storeApi.createPortalSession
3050
3560
  },
3051
3561
  member: {
3052
3562
  add: storeApi.addMember,
3053
3563
  invite: storeApi.inviteUser,
3564
+ find: storeApi.findMembers,
3565
+ findOwn: storeApi.findOwnMemberships,
3054
3566
  remove: storeApi.removeMember
3055
3567
  },
3056
3568
  buildHook: {
@@ -3067,10 +3579,7 @@ function createAdmin(config) {
3067
3579
  delete: storeApi.deleteWebhook
3068
3580
  },
3069
3581
  config: {
3070
- get: storeApi.getStoreConfig
3071
- },
3072
- media: {
3073
- find: storeApi.getStoreMedia
3582
+ getPayment: storeApi.getPaymentConfig
3074
3583
  },
3075
3584
  location: locationApi,
3076
3585
  market: marketApi,
@@ -3079,22 +3588,21 @@ function createAdmin(config) {
3079
3588
  media: createMediaApi(apiConfig),
3080
3589
  notification: {
3081
3590
  email: {
3082
- trackOpen: notificationApi.trackEmailOpen
3083
- },
3084
- trigger: {
3085
- send: notificationApi.trigger
3591
+ send: notificationApi.sendEmail,
3592
+ getDelivery: notificationApi.getEmailDelivery,
3593
+ retryDelivery: notificationApi.retryEmailDelivery
3086
3594
  },
3087
3595
  mailbox: crmApi.mailbox
3088
3596
  },
3089
3597
  platform: platformApi,
3090
3598
  social: {
3091
- account: {
3599
+ connection: {
3092
3600
  getCapabilities: socialApi.getCapabilities,
3093
- list: socialApi.listAccounts,
3601
+ list: socialApi.listConnections,
3094
3602
  connect: socialApi.connect,
3095
3603
  getOAuthAttempt: socialApi.getOAuthAttempt,
3096
3604
  selectDestination: socialApi.selectDestination,
3097
- delete: socialApi.deleteAccount
3605
+ delete: socialApi.deleteConnection
3098
3606
  },
3099
3607
  publication: {
3100
3608
  create: socialApi.createPublication,
@@ -3110,7 +3618,16 @@ function createAdmin(config) {
3110
3618
  syncCommentThread: socialApi.syncPublicationCommentThread,
3111
3619
  findComments: socialApi.findPublicationComments,
3112
3620
  classifyComments: socialApi.classifyPublicationComments,
3113
- replyToComment: socialApi.replyToPublicationComment,
3621
+ commentReply: {
3622
+ create: socialApi.createCommentReply,
3623
+ list: socialApi.listCommentReplies,
3624
+ get: socialApi.getCommentReply,
3625
+ retry: socialApi.retryCommentReply
3626
+ },
3627
+ effect: {
3628
+ list: socialApi.listPublicationEffects,
3629
+ get: socialApi.getPublicationEffect
3630
+ },
3114
3631
  getMetrics: socialApi.getPublicationMetrics,
3115
3632
  syncMetrics: socialApi.syncPublicationMetrics,
3116
3633
  syncEngagement: socialApi.syncEngagement
@@ -3172,11 +3689,43 @@ function createAdmin(config) {
3172
3689
  get: eshopApi.getOrder,
3173
3690
  find: eshopApi.getOrders,
3174
3691
  getQuote: eshopApi.getQuote,
3175
- processRefund: eshopApi.processRefund,
3692
+ createRefund: eshopApi.createRefund,
3693
+ getRefund: eshopApi.getRefund,
3694
+ getRefunds: eshopApi.getRefunds,
3695
+ retryRefund: eshopApi.retryRefund,
3696
+ getPayment: eshopApi.getPayment,
3697
+ retryPaymentTransaction: eshopApi.retryPaymentTransaction,
3698
+ getPaymentTransactions: eshopApi.getPaymentTransactions,
3699
+ getPaymentTransaction: eshopApi.getPaymentTransaction,
3700
+ findDigitalAccess: eshopApi.findDigitalAccess,
3701
+ getDigitalAccess: eshopApi.getDigitalAccess,
3176
3702
  downloadDigitalAccess: eshopApi.downloadDigitalAccess,
3177
- getShippingRates: shippingApi.getRates,
3178
- ship: shippingApi.ship,
3179
- refundShippingLabel: shippingApi.refundLabel
3703
+ activateDigitalAccess: eshopApi.activateDigitalAccess,
3704
+ revokeDigitalAccess: eshopApi.revokeDigitalAccess
3705
+ },
3706
+ shipment: {
3707
+ getRates: shippingApi.getRates,
3708
+ create: shippingApi.createShipment,
3709
+ get: shippingApi.getShipment,
3710
+ find: shippingApi.findShipments,
3711
+ retry: shippingApi.retryShipment,
3712
+ fulfillment: {
3713
+ find: shippingApi.findFulfillmentOrders,
3714
+ get: shippingApi.getFulfillmentOrder
3715
+ },
3716
+ refund: {
3717
+ request: shippingApi.requestRefund,
3718
+ get: shippingApi.getRefund,
3719
+ find: shippingApi.findRefunds,
3720
+ retry: shippingApi.retryRefund
3721
+ },
3722
+ adjustment: {
3723
+ find: shippingApi.findAdjustments
3724
+ },
3725
+ settlement: {
3726
+ find: shippingApi.findSettlements,
3727
+ retry: shippingApi.retrySettlement
3728
+ }
3180
3729
  },
3181
3730
  cart: {
3182
3731
  create: eshopApi.createCart,
@@ -3218,8 +3767,9 @@ function createAdmin(config) {
3218
3767
  update: crmApi.update,
3219
3768
  merge: crmApi.merge,
3220
3769
  import: crmApi.import,
3221
- revokeToken: crmApi.revokeToken,
3222
- revokeAllTokens: crmApi.revokeAllTokens
3770
+ findSessions: crmApi.findSessions,
3771
+ revokeSession: crmApi.revokeSession,
3772
+ revokeAllSessions: crmApi.revokeAllSessions
3223
3773
  },
3224
3774
  contactList: {
3225
3775
  create: crmApi.contactList.create,
@@ -3231,7 +3781,14 @@ function createAdmin(config) {
3231
3781
  addMember: crmApi.contactList.members.add,
3232
3782
  updateMember: crmApi.contactList.members.update,
3233
3783
  removeMember: crmApi.contactList.members.remove,
3234
- findMembers: crmApi.contactList.members.find
3784
+ findMembers: crmApi.contactList.members.find,
3785
+ plans: crmApi.contactList.plans,
3786
+ memberships: {
3787
+ refund: crmApi.contactList.memberships.refund,
3788
+ paymentAttempts: crmApi.contactList.memberships.paymentAttempts,
3789
+ refunds: crmApi.contactList.memberships.refunds,
3790
+ cancellations: crmApi.contactList.memberships.cancellations
3791
+ }
3235
3792
  },
3236
3793
  action: crmApi.action
3237
3794
  },