arky-sdk 0.9.12 → 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 +980 -433
  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 +980 -433
  9. package/dist/admin.js.map +1 -1
  10. package/dist/{api-D4lMmvF0.d.cts → api-D37IpMSq.d.cts} +1415 -671
  11. package/dist/{api-D4lMmvF0.d.ts → api-D37IpMSq.d.ts} +1415 -671
  12. package/dist/index.cjs +1315 -547
  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 +1315 -547
  17. package/dist/index.js.map +1 -1
  18. package/dist/{index-Be8suRwP.d.ts → inventory-DdN96PX3.d.cts} +6 -4
  19. package/dist/{index-BS2x278C.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-D8HiRDCl.d.cts +0 -1536
  38. package/dist/admin-Dnnv18wN.d.ts +0 -1536
  39. package/scripts/contract-admin.mjs +0 -137
  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`,
1172
+ {},
1173
+ options
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`,
1066
1180
  {},
1067
1181
  options
1068
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;
2224
+ return apiConfig.httpClient.post(
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) {
1949
2247
  return apiConfig.httpClient.post(
1950
- `/v1/stores/${storeId(store_id)}/social-publications/${publication_id}/comments/${comment_id}/reply`,
1951
- { text },
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,35 +2409,44 @@ var createWorkflowApi = (apiConfig) => {
2095
2409
  options
2096
2410
  );
2097
2411
  },
2098
- async getWorkflowAccounts(params, options) {
2099
- const store_id = params?.store_id || apiConfig.storeId;
2412
+ async getWorkflowEffects(params, options) {
2413
+ const store_id = params.store_id || apiConfig.storeId;
2414
+ const { store_id: _, workflow_id, execution_id, ...queryParams } = params;
2100
2415
  return apiConfig.httpClient.get(
2101
- `/v1/stores/${store_id}/workflow-accounts`,
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}`,
2102
2427
  options
2103
2428
  );
2104
2429
  },
2105
- async getWorkflowAccountConnectUrl(params, options) {
2106
- const { store_id, type, ...payload } = params;
2107
- const target_store_id = store_id || apiConfig.storeId;
2108
- return apiConfig.httpClient.post(
2109
- `/v1/stores/${target_store_id}/workflow-accounts/connect-url`,
2110
- { ...payload, type, store_id: target_store_id },
2430
+ async getWorkflowConnections(params, options) {
2431
+ const store_id = params?.store_id || apiConfig.storeId;
2432
+ return apiConfig.httpClient.get(
2433
+ `/v1/stores/${store_id}/workflow-connections`,
2111
2434
  options
2112
2435
  );
2113
2436
  },
2114
- async connectWorkflowAccount(params, options) {
2437
+ async getWorkflowConnectionConnectUrl(params, options) {
2115
2438
  const { store_id, type, ...payload } = params;
2116
2439
  const target_store_id = store_id || apiConfig.storeId;
2117
2440
  return apiConfig.httpClient.post(
2118
- `/v1/stores/${target_store_id}/workflow-accounts/connect`,
2441
+ `/v1/stores/${target_store_id}/workflow-connections/connect-url`,
2119
2442
  { ...payload, type, store_id: target_store_id },
2120
2443
  options
2121
2444
  );
2122
2445
  },
2123
- async deleteWorkflowAccount(params, options) {
2446
+ async deleteWorkflowConnection(params, options) {
2124
2447
  const store_id = params.store_id || apiConfig.storeId;
2125
2448
  return apiConfig.httpClient.delete(
2126
- `/v1/stores/${store_id}/workflow-accounts/${params.id}`,
2449
+ `/v1/stores/${store_id}/workflow-connections/${params.id}`,
2127
2450
  options
2128
2451
  );
2129
2452
  }
@@ -2167,27 +2490,105 @@ var createPlatformApi = (apiConfig) => {
2167
2490
 
2168
2491
  // src/api/shipping.ts
2169
2492
  var createShippingApi = (apiConfig) => {
2493
+ const storeId = (value) => value || apiConfig.storeId;
2170
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
+ },
2171
2508
  async getRates(params, options) {
2172
- const { order_id, ...payload } = params;
2509
+ const { store_id, order_id, ...payload } = params;
2173
2510
  return apiConfig.httpClient.post(
2174
- `/v1/stores/${apiConfig.storeId}/orders/${order_id}/shipping/rates`,
2511
+ `/v1/stores/${storeId(store_id)}/orders/${order_id}/shipping/rates`,
2175
2512
  payload,
2176
2513
  options
2177
2514
  );
2178
2515
  },
2179
- async ship(params, options) {
2180
- const { order_id, ...payload } = params;
2181
- return apiConfig.httpClient.post(
2182
- `/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`,
2183
2533
  payload,
2184
2534
  options
2185
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
+ );
2186
2547
  },
2187
- async refundLabel(params, options) {
2188
- const { order_id, shipment_id } = params;
2548
+ async requestRefund(params, options) {
2189
2549
  return apiConfig.httpClient.post(
2190
- `/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`,
2191
2592
  {},
2192
2593
  options
2193
2594
  );
@@ -2496,155 +2897,230 @@ var createExperimentsApi = (apiConfig) => {
2496
2897
  };
2497
2898
 
2498
2899
  // src/utils/blocks.ts
2499
- function getBlockLabel(block) {
2500
- if (!block) return "";
2501
- 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);
2502
2902
  }
2503
- function formatBlockValue(block) {
2504
- if (!block || block.value === null || block.value === void 0) return "";
2505
- const value = block.value;
2506
- switch (block.type) {
2507
- case "boolean":
2508
- return value ? "Yes" : "No";
2509
- case "number":
2510
- if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
2511
- return new Date(value).toLocaleDateString();
2512
- }
2513
- return String(value);
2514
- case "media":
2515
- if (value && typeof value === "object") {
2516
- return value.mime_type ? value.name || value.id : value.title || value.name || value.id;
2517
- }
2518
- return String(value);
2519
- default:
2520
- return String(value);
2521
- }
2903
+ function isBlock(value) {
2904
+ return isRecord2(value) && typeof value.key === "string" && typeof value.type === "string";
2522
2905
  }
2523
- function prepareBlocksForSubmission(formData, blockTypes) {
2524
- return Object.keys(formData).filter((key) => formData[key] !== null && formData[key] !== void 0).map((key) => ({
2525
- key,
2526
- value: (blockTypes?.[key] || "text") === "array" && !Array.isArray(formData[key]) ? [formData[key]] : formData[key]
2527
- }));
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;
2528
2913
  }
2529
- function extractBlockValues(blocks) {
2530
- const values = {};
2531
- blocks.forEach((block) => {
2532
- values[block.key] = block.value ?? null;
2533
- });
2534
- 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 : "";
2535
2919
  }
2536
- var getBlockValue = (entry, blockKey) => {
2537
- const block = entry?.blocks?.find((f) => f.key === blockKey);
2538
- return block?.value ?? null;
2539
- };
2540
- var getBlockTextValue = (block, locale = "en") => {
2541
- if (!block || block.value === null || block.value === void 0) return "";
2542
- const blockType = block.type;
2543
- if (blockType === "localized_text" || blockType === "markdown") {
2544
- if (typeof block.value === "object" && block.value !== null) {
2545
- return block.value[locale] ?? block.value["en"] ?? "";
2546
- }
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);
2547
2924
  }
2548
- if (typeof block.value === "string") return block.value;
2549
- return String(block.value ?? "");
2550
- };
2551
- var getBlockValues = (entry, blockKey) => {
2552
- const block = entry?.blocks?.find((f) => f.key === blockKey);
2553
- if (!block) return [];
2554
- if (block.type === "array" && Array.isArray(block.value)) {
2555
- return block.value;
2556
- }
2557
- return [];
2558
- };
2559
- function unwrapBlock(block, locale) {
2560
- if (!block?.type || block.value === void 0) return block;
2561
- const blockType = block.type;
2562
- if (blockType === "array") {
2563
- return block.value.map((obj) => {
2564
- const parsed = {};
2565
- for (const [k, v] of Object.entries(obj)) {
2566
- 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);
2567
2931
  }
2568
- return parsed;
2932
+ if (!isRecord2(item)) return item;
2933
+ return Object.fromEntries(
2934
+ Object.entries(item).map(([key, nested]) => [key, unwrapBlock(nested, locale)])
2935
+ );
2569
2936
  });
2570
2937
  }
2571
- if (blockType === "object") {
2572
- const parsed = {};
2573
- for (const [k, v] of Object.entries(block.value || {})) {
2574
- parsed[k] = unwrapBlock(v, locale);
2575
- }
2576
- 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
+ );
2577
2944
  }
2578
- if (blockType === "localized_text" || blockType === "markdown") {
2579
- 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));
2580
2952
  }
2581
- return block.value;
2953
+ return Object.fromEntries(
2954
+ blocks.map((block) => [block.key, blockContentValue(block, locale)])
2955
+ );
2582
2956
  }
2583
- var getBlockObjectValues = (entry, blockKey, locale = "en") => {
2584
- const block = entry?.blocks?.find((f) => f.key === blockKey);
2585
- if (!block || block.type !== "array" || !Array.isArray(block.value)) return [];
2586
- return block.value.map((obj) => {
2587
- if (!obj?.value || !Array.isArray(obj.value)) return {};
2588
- return obj.value.reduce((acc, current) => {
2589
- acc[current.key] = unwrapBlock(current, locale);
2590
- return acc;
2591
- }, {});
2592
- });
2593
- };
2594
- var getBlockFromArray = (entry, blockKey, locale = "en") => {
2595
- const block = entry?.blocks?.find((f) => f.key === blockKey);
2596
- if (!block) return {};
2597
- if (block.type === "array" && Array.isArray(block.value)) {
2598
- return block.value.reduce((acc, current) => {
2599
- acc[current.key] = unwrapBlock(current, locale);
2600
- return acc;
2601
- }, {});
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) : [];
2964
+ }
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
+ );
2602
2974
  }
2603
- if (block.type === "object" && block.value && typeof block.value === "object") {
2604
- const result = {};
2605
- for (const [k, v] of Object.entries(block.value)) {
2606
- result[k] = unwrapBlock(v, locale);
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();
2607
2990
  }
2608
- return result;
2609
2991
  }
2610
- return { [block.key]: unwrapBlock(block, locale) };
2611
- };
2612
- var getImageUrl = (imageBlock, isBlock = true) => {
2613
- if (!imageBlock) return null;
2614
- if (imageBlock.type === "media") {
2615
- const mediaValue = imageBlock.value;
2616
- 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 : "";
2617
2995
  }
2618
- if (isBlock) {
2619
- if (typeof imageBlock === "string") return imageBlock;
2620
- 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);
2621
3014
  }
2622
- return imageBlock.resolutions?.original?.url || null;
2623
- };
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
+ }
2624
3056
 
2625
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
+ );
2626
3104
  function formatCurrency(amount, currencyCode, locale = "en") {
2627
- if (!currencyCode) return "";
3105
+ const normalized = currencyCode.trim().toUpperCase();
3106
+ if (!normalized) return "";
3107
+ const minorUnits = getCurrencyMinorUnits(normalized);
2628
3108
  return new Intl.NumberFormat(locale, {
2629
3109
  style: "currency",
2630
- currency: currencyCode.toUpperCase()
3110
+ currency: normalized,
3111
+ minimumFractionDigits: minorUnits,
3112
+ maximumFractionDigits: minorUnits
2631
3113
  }).format(amount);
2632
3114
  }
2633
- function getMinorUnits(currency) {
2634
- try {
2635
- const formatter = new Intl.NumberFormat("en", {
2636
- style: "currency",
2637
- currency: currency.toUpperCase()
2638
- });
2639
- const parts = formatter.formatToParts(1.11);
2640
- const fractionPart = parts.find((p) => p.type === "fraction");
2641
- return fractionPart?.value.length ?? 2;
2642
- } catch {
2643
- 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}'`);
2644
3119
  }
3120
+ return ZERO_MINOR_UNIT_STORE_CURRENCIES.has(normalized) ? 0 : 2;
2645
3121
  }
2646
3122
  function convertToMajor(minorAmount, currency) {
2647
- const units = getMinorUnits(currency);
3123
+ const units = getCurrencyMinorUnits(currency);
2648
3124
  return minorAmount / Math.pow(10, units);
2649
3125
  }
2650
3126
  function getCurrencySymbol(currency) {
@@ -2666,22 +3142,24 @@ function getCurrencyName(currency) {
2666
3142
  }
2667
3143
  }
2668
3144
  function formatMinor(amountMinor, currency) {
2669
- if (!currency) return "";
3145
+ if (!Number.isSafeInteger(amountMinor)) {
3146
+ throw new RangeError("Minor-unit amount must be a safe integer");
3147
+ }
2670
3148
  return formatCurrency(convertToMajor(amountMinor, currency), currency);
2671
3149
  }
2672
3150
  function formatPayment(payment) {
2673
3151
  return formatMinor(payment.total, payment.currency);
2674
3152
  }
2675
3153
  function formatPrice(prices, marketId) {
2676
- if (!prices || prices.length === 0) return "";
2677
- const price = marketId ? prices.find((p) => p.market === marketId) || prices[0] : prices[0];
2678
- 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 "";
2679
3157
  return formatMinor(price.amount, price.currency);
2680
3158
  }
2681
3159
  function getPriceAmount(prices, marketId) {
2682
- if (!prices || prices.length === 0) return 0;
2683
- const price = prices.find((p) => p.market === marketId) || prices[0];
2684
- 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;
2685
3163
  }
2686
3164
 
2687
3165
  // src/utils/validation.ts
@@ -2782,6 +3260,7 @@ function formatDate(date, locale) {
2782
3260
  async function fetchSvgContent(mediaObject) {
2783
3261
  if (!mediaObject) return null;
2784
3262
  const svgUrl = getImageUrl(mediaObject, false);
3263
+ if (!svgUrl) return null;
2785
3264
  try {
2786
3265
  const response = await fetch(svgUrl);
2787
3266
  if (!response.ok) {
@@ -2874,9 +3353,10 @@ function getFirstAvailableFCId(variant, quantity = 1) {
2874
3353
  // src/index.ts
2875
3354
  function createUtilitySurface(apiConfig) {
2876
3355
  return {
2877
- getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock),
3356
+ getImageUrl: (imageBlock, isBlock2 = true) => getImageUrl(imageBlock, isBlock2),
2878
3357
  getBlockValue,
2879
3358
  getBlockTextValue,
3359
+ getBlockContentValue,
2880
3360
  getBlockValues,
2881
3361
  getBlockLabel,
2882
3362
  getBlockObjectValues,
@@ -3027,10 +3507,11 @@ function createAdmin(config) {
3027
3507
  trigger: workflowApi.triggerWorkflow,
3028
3508
  getExecutions: workflowApi.getWorkflowExecutions,
3029
3509
  getExecution: workflowApi.getWorkflowExecution,
3030
- listAccounts: workflowApi.getWorkflowAccounts,
3031
- getAccountConnectUrl: workflowApi.getWorkflowAccountConnectUrl,
3032
- connectAccount: workflowApi.connectWorkflowAccount,
3033
- deleteAccount: workflowApi.deleteWorkflowAccount
3510
+ listEffects: workflowApi.getWorkflowEffects,
3511
+ getEffect: workflowApi.getWorkflowEffect,
3512
+ listConnections: workflowApi.getWorkflowConnections,
3513
+ getConnectionConnectUrl: workflowApi.getWorkflowConnectionConnectUrl,
3514
+ deleteConnection: workflowApi.deleteWorkflowConnection
3034
3515
  };
3035
3516
  const formApi = createFormApi(apiConfig);
3036
3517
  const taxonomyApi = createTaxonomyApi(apiConfig);
@@ -3043,22 +3524,43 @@ function createAdmin(config) {
3043
3524
  delete: accountApi.deleteAccount,
3044
3525
  getMe: accountApi.getMe,
3045
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
+ },
3046
3537
  auth: authApi
3047
3538
  },
3048
3539
  store: {
3049
3540
  create: storeApi.createStore,
3050
3541
  update: storeApi.updateStore,
3051
- delete: storeApi.deleteStore,
3052
3542
  get: storeApi.getStore,
3053
3543
  find: storeApi.getStores,
3054
3544
  subscription: {
3545
+ get: storeApi.getSubscription,
3055
3546
  getPlans: storeApi.getSubscriptionPlans,
3056
- 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
+ },
3057
3557
  createPortalSession: storeApi.createPortalSession
3058
3558
  },
3059
3559
  member: {
3060
3560
  add: storeApi.addMember,
3061
3561
  invite: storeApi.inviteUser,
3562
+ find: storeApi.findMembers,
3563
+ findOwn: storeApi.findOwnMemberships,
3062
3564
  remove: storeApi.removeMember
3063
3565
  },
3064
3566
  buildHook: {
@@ -3075,10 +3577,7 @@ function createAdmin(config) {
3075
3577
  delete: storeApi.deleteWebhook
3076
3578
  },
3077
3579
  config: {
3078
- get: storeApi.getStoreConfig
3079
- },
3080
- media: {
3081
- find: storeApi.getStoreMedia
3580
+ getPayment: storeApi.getPaymentConfig
3082
3581
  },
3083
3582
  location: locationApi,
3084
3583
  market: marketApi,
@@ -3087,22 +3586,21 @@ function createAdmin(config) {
3087
3586
  media: createMediaApi(apiConfig),
3088
3587
  notification: {
3089
3588
  email: {
3090
- trackOpen: notificationApi.trackEmailOpen
3091
- },
3092
- trigger: {
3093
- send: notificationApi.trigger
3589
+ send: notificationApi.sendEmail,
3590
+ getDelivery: notificationApi.getEmailDelivery,
3591
+ retryDelivery: notificationApi.retryEmailDelivery
3094
3592
  },
3095
3593
  mailbox: crmApi.mailbox
3096
3594
  },
3097
3595
  platform: platformApi,
3098
3596
  social: {
3099
- account: {
3597
+ connection: {
3100
3598
  getCapabilities: socialApi.getCapabilities,
3101
- list: socialApi.listAccounts,
3599
+ list: socialApi.listConnections,
3102
3600
  connect: socialApi.connect,
3103
3601
  getOAuthAttempt: socialApi.getOAuthAttempt,
3104
3602
  selectDestination: socialApi.selectDestination,
3105
- delete: socialApi.deleteAccount
3603
+ delete: socialApi.deleteConnection
3106
3604
  },
3107
3605
  publication: {
3108
3606
  create: socialApi.createPublication,
@@ -3118,7 +3616,16 @@ function createAdmin(config) {
3118
3616
  syncCommentThread: socialApi.syncPublicationCommentThread,
3119
3617
  findComments: socialApi.findPublicationComments,
3120
3618
  classifyComments: socialApi.classifyPublicationComments,
3121
- 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
+ },
3122
3629
  getMetrics: socialApi.getPublicationMetrics,
3123
3630
  syncMetrics: socialApi.syncPublicationMetrics,
3124
3631
  syncEngagement: socialApi.syncEngagement
@@ -3180,11 +3687,43 @@ function createAdmin(config) {
3180
3687
  get: eshopApi.getOrder,
3181
3688
  find: eshopApi.getOrders,
3182
3689
  getQuote: eshopApi.getQuote,
3183
- 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,
3184
3700
  downloadDigitalAccess: eshopApi.downloadDigitalAccess,
3185
- getShippingRates: shippingApi.getRates,
3186
- ship: shippingApi.ship,
3187
- 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
+ }
3188
3727
  },
3189
3728
  cart: {
3190
3729
  create: eshopApi.createCart,
@@ -3226,8 +3765,9 @@ function createAdmin(config) {
3226
3765
  update: crmApi.update,
3227
3766
  merge: crmApi.merge,
3228
3767
  import: crmApi.import,
3229
- revokeToken: crmApi.revokeToken,
3230
- revokeAllTokens: crmApi.revokeAllTokens
3768
+ findSessions: crmApi.findSessions,
3769
+ revokeSession: crmApi.revokeSession,
3770
+ revokeAllSessions: crmApi.revokeAllSessions
3231
3771
  },
3232
3772
  contactList: {
3233
3773
  create: crmApi.contactList.create,
@@ -3239,7 +3779,14 @@ function createAdmin(config) {
3239
3779
  addMember: crmApi.contactList.members.add,
3240
3780
  updateMember: crmApi.contactList.members.update,
3241
3781
  removeMember: crmApi.contactList.members.remove,
3242
- 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
+ }
3243
3790
  },
3244
3791
  action: crmApi.action
3245
3792
  },