arky-sdk 0.9.13 → 0.9.17

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