arky-sdk 0.8.0 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/admin.js CHANGED
@@ -433,7 +433,7 @@ var createAuthApi = (apiConfig, updateSession) => {
433
433
  };
434
434
 
435
435
  // src/api/store.ts
436
- var createStoreApi = (apiConfig, updateSession) => {
436
+ var createStoreApi = (apiConfig, _updateSession) => {
437
437
  return {
438
438
  async createStore(params, options) {
439
439
  return apiConfig.httpClient.post(`/v1/stores`, params, options);
@@ -483,10 +483,19 @@ var createStoreApi = (apiConfig, updateSession) => {
483
483
  options
484
484
  );
485
485
  },
486
+ async addMember(params, options) {
487
+ const { store_id, ...payload } = params;
488
+ return apiConfig.httpClient.post(
489
+ `/v1/stores/${store_id || apiConfig.storeId}/members`,
490
+ payload,
491
+ options
492
+ );
493
+ },
486
494
  async inviteUser(params, options) {
495
+ const { store_id, ...payload } = params;
487
496
  return apiConfig.httpClient.post(
488
- `/v1/stores/${apiConfig.storeId}/invitation`,
489
- params,
497
+ `/v1/stores/${store_id || apiConfig.storeId}/members`,
498
+ payload,
490
499
  options
491
500
  );
492
501
  },
@@ -496,22 +505,6 @@ var createStoreApi = (apiConfig, updateSession) => {
496
505
  options
497
506
  );
498
507
  },
499
- async handleInvitation(params, options) {
500
- const { store_id, ...payload } = params;
501
- const result = await apiConfig.httpClient.put(
502
- `/v1/stores/${store_id || apiConfig.storeId}/invitation`,
503
- payload,
504
- options
505
- );
506
- if (params.action === "accept" && result?.auth?.access_token) {
507
- updateSession(() => ({
508
- access_token: result.auth.access_token,
509
- refresh_token: result.auth.refresh_token,
510
- access_expires_at: result.auth.access_expires_at
511
- }));
512
- }
513
- return result;
514
- },
515
508
  async testWebhook(params, options) {
516
509
  return apiConfig.httpClient.post(
517
510
  `/v1/stores/${apiConfig.storeId}/webhooks/test`,
@@ -524,7 +517,7 @@ var createStoreApi = (apiConfig, updateSession) => {
524
517
  limit: params.limit
525
518
  };
526
519
  if (params.cursor) queryParams.cursor = params.cursor;
527
- if (params.ids && params.ids.length > 0) queryParams.ids = params.ids.join(",");
520
+ if (params.ids && params.ids.length > 0) queryParams.ids = JSON.stringify(params.ids);
528
521
  if (params.query) queryParams.query = params.query;
529
522
  if (params.mime_type) queryParams.mime_type = params.mime_type;
530
523
  if (params.sort_field) queryParams.sort_field = params.sort_field;
@@ -656,7 +649,7 @@ var createMediaApi = (apiConfig) => {
656
649
  const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
657
650
  const queryParams = { limit: String(limit) };
658
651
  if (cursor) queryParams.cursor = cursor;
659
- if (ids && ids.length > 0) queryParams.ids = ids.join(",");
652
+ if (ids && ids.length > 0) queryParams.ids = JSON.stringify(ids);
660
653
  if (query) queryParams.query = query;
661
654
  if (mime_type) queryParams.mime_type = mime_type;
662
655
  if (sort_field) queryParams.sort_field = sort_field;
@@ -1276,7 +1269,7 @@ var createMarketApi = (apiConfig) => {
1276
1269
  var createActivityAdminApi = (apiConfig) => ({
1277
1270
  async timeline(params, options) {
1278
1271
  const store_id = params.store_id || apiConfig.storeId;
1279
- const queryParams = { customer_id: params.customer_id };
1272
+ const queryParams = { profile_id: params.profile_id };
1280
1273
  if (params.limit !== void 0) queryParams.limit = params.limit;
1281
1274
  if (params.cursor) queryParams.cursor = params.cursor;
1282
1275
  return apiConfig.httpClient.get(
@@ -1287,7 +1280,7 @@ var createActivityAdminApi = (apiConfig) => ({
1287
1280
  async find(params, options) {
1288
1281
  const store_id = params.store_id || apiConfig.storeId;
1289
1282
  const queryParams = {};
1290
- if (params.customer_id) queryParams.customer_id = params.customer_id;
1283
+ if (params.profile_id) queryParams.profile_id = params.profile_id;
1291
1284
  if (params.types && params.types.length > 0) queryParams.types = params.types;
1292
1285
  if (params.from !== void 0) queryParams.from = params.from;
1293
1286
  if (params.to !== void 0) queryParams.to = params.to;
@@ -1299,25 +1292,26 @@ var createActivityAdminApi = (apiConfig) => ({
1299
1292
  );
1300
1293
  }
1301
1294
  });
1302
- var createCustomerApi = (apiConfig) => {
1295
+ var createProfileApi = (apiConfig) => {
1303
1296
  return {
1304
1297
  async create(params, options) {
1305
1298
  const { store_id, ...payload } = params;
1306
1299
  return apiConfig.httpClient.post(
1307
- `/v1/stores/${store_id || apiConfig.storeId}/customers`,
1300
+ `/v1/stores/${store_id || apiConfig.storeId}/profiles`,
1308
1301
  payload,
1309
1302
  options
1310
1303
  );
1311
1304
  },
1312
1305
  async get(params, options) {
1313
1306
  return apiConfig.httpClient.get(
1314
- `/v1/stores/${params.store_id || apiConfig.storeId}/customers/${params.id}`,
1307
+ `/v1/stores/${params.store_id || apiConfig.storeId}/profiles/${params.id}`,
1315
1308
  options
1316
1309
  );
1317
1310
  },
1318
1311
  async find(params, options) {
1319
1312
  const store_id = params?.store_id || apiConfig.storeId;
1320
1313
  const queryParams = {};
1314
+ if (params?.ids && params.ids.length > 0) queryParams.ids = JSON.stringify(params.ids);
1321
1315
  if (params?.limit !== void 0) queryParams.limit = params.limit;
1322
1316
  if (params?.cursor) queryParams.cursor = params.cursor;
1323
1317
  if (params?.query) queryParams.query = params.query;
@@ -1328,7 +1322,7 @@ var createCustomerApi = (apiConfig) => {
1328
1322
  if (params?.sort_field) queryParams.sort_field = params.sort_field;
1329
1323
  if (params?.sort_direction) queryParams.sort_direction = params.sort_direction;
1330
1324
  return apiConfig.httpClient.get(
1331
- `/v1/stores/${store_id}/customers`,
1325
+ `/v1/stores/${store_id}/profiles`,
1332
1326
  {
1333
1327
  ...options,
1334
1328
  params: queryParams
@@ -1338,7 +1332,7 @@ var createCustomerApi = (apiConfig) => {
1338
1332
  async update(params, options) {
1339
1333
  const { id, store_id, ...body } = params;
1340
1334
  return apiConfig.httpClient.put(
1341
- `/v1/stores/${store_id || apiConfig.storeId}/customers/${id}`,
1335
+ `/v1/stores/${store_id || apiConfig.storeId}/profiles/${id}`,
1342
1336
  body,
1343
1337
  options
1344
1338
  );
@@ -1346,87 +1340,574 @@ var createCustomerApi = (apiConfig) => {
1346
1340
  async merge(params, options) {
1347
1341
  const store_id = params.store_id || apiConfig.storeId;
1348
1342
  return apiConfig.httpClient.post(
1349
- `/v1/stores/${store_id}/customers/${params.target_id}/merge`,
1343
+ `/v1/stores/${store_id}/profiles/${params.target_id}/merge`,
1350
1344
  { source_id: params.source_id, store_id },
1351
1345
  options
1352
1346
  );
1353
1347
  },
1348
+ "import": async (params, options) => {
1349
+ const { store_id, ...payload } = params;
1350
+ const target_store_id = store_id || apiConfig.storeId;
1351
+ return apiConfig.httpClient.post(
1352
+ `/v1/stores/${target_store_id}/profiles/import`,
1353
+ payload,
1354
+ options
1355
+ );
1356
+ },
1357
+ previewImport: async (params, options) => {
1358
+ const { store_id, ...payload } = params;
1359
+ const target_store_id = store_id || apiConfig.storeId;
1360
+ return apiConfig.httpClient.post(
1361
+ `/v1/stores/${target_store_id}/profiles/import/preview`,
1362
+ payload,
1363
+ options
1364
+ );
1365
+ },
1354
1366
  async revokeToken(params, options) {
1355
1367
  const store_id = params.store_id || apiConfig.storeId;
1356
1368
  return apiConfig.httpClient.delete(
1357
- `/v1/stores/${store_id}/customers/${params.id}/sessions/${params.token_id}`,
1369
+ `/v1/stores/${store_id}/profiles/${params.id}/sessions/${params.token_id}`,
1358
1370
  options
1359
1371
  );
1360
1372
  },
1361
1373
  async revokeAllTokens(params, options) {
1362
1374
  const store_id = params.store_id || apiConfig.storeId;
1363
1375
  return apiConfig.httpClient.delete(
1364
- `/v1/stores/${store_id}/customers/${params.id}/sessions`,
1376
+ `/v1/stores/${store_id}/profiles/${params.id}/sessions`,
1365
1377
  options
1366
1378
  );
1367
1379
  },
1368
- audiences: {
1380
+ profileList: {
1369
1381
  async create(params, options) {
1382
+ const { store_id, ...payload } = params;
1383
+ const target_store_id = store_id || apiConfig.storeId;
1370
1384
  return apiConfig.httpClient.post(
1371
- `/v1/stores/${apiConfig.storeId}/audiences`,
1372
- params,
1385
+ `/v1/stores/${target_store_id}/profile-lists`,
1386
+ payload,
1373
1387
  options
1374
1388
  );
1375
1389
  },
1376
1390
  async update(params, options) {
1391
+ const { id, store_id, ...payload } = params;
1392
+ const target_store_id = store_id || apiConfig.storeId;
1377
1393
  return apiConfig.httpClient.put(
1378
- `/v1/stores/${apiConfig.storeId}/audiences/${params.id}`,
1379
- params,
1394
+ `/v1/stores/${target_store_id}/profile-lists/${id}`,
1395
+ payload,
1380
1396
  options
1381
1397
  );
1382
1398
  },
1383
1399
  async get(params, options) {
1384
- let identifier;
1385
- if (params.id) {
1386
- identifier = params.id;
1387
- } else if (params.key) {
1388
- identifier = `${apiConfig.storeId}:${params.key}`;
1389
- } else {
1390
- throw new Error("GetAudienceParams requires id or key");
1400
+ const target_store_id = params.store_id || apiConfig.storeId;
1401
+ return apiConfig.httpClient.get(
1402
+ `/v1/stores/${target_store_id}/profile-lists/${params.id}`,
1403
+ options
1404
+ );
1405
+ },
1406
+ async find(params, options) {
1407
+ const { store_id, ...queryParams } = params || {};
1408
+ const target_store_id = store_id || apiConfig.storeId;
1409
+ return apiConfig.httpClient.get(
1410
+ `/v1/stores/${target_store_id}/profile-lists`,
1411
+ { ...options, params: queryParams }
1412
+ );
1413
+ },
1414
+ async importProfiles(params, options) {
1415
+ const { store_id, profile_list_id, ...payload } = params;
1416
+ const target_store_id = store_id || apiConfig.storeId;
1417
+ return apiConfig.httpClient.post(
1418
+ `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/profiles/import`,
1419
+ payload,
1420
+ options
1421
+ );
1422
+ },
1423
+ async previewImportProfiles(params, options) {
1424
+ const { store_id, profile_list_id, ...payload } = params;
1425
+ const target_store_id = store_id || apiConfig.storeId;
1426
+ return apiConfig.httpClient.post(
1427
+ `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/profiles/import/preview`,
1428
+ payload,
1429
+ options
1430
+ );
1431
+ },
1432
+ members: {
1433
+ async add(params, options) {
1434
+ const { store_id, profile_list_id, profile_id, fields, lead_description } = params;
1435
+ const target_store_id = store_id || apiConfig.storeId;
1436
+ return apiConfig.httpClient.post(
1437
+ `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
1438
+ { fields, lead_description },
1439
+ options
1440
+ );
1441
+ },
1442
+ async update(params, options) {
1443
+ const { store_id, profile_list_id, profile_id, status, fields, lead_description } = params;
1444
+ const target_store_id = store_id || apiConfig.storeId;
1445
+ return apiConfig.httpClient.patch(
1446
+ `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
1447
+ { status, fields, lead_description },
1448
+ options
1449
+ );
1450
+ },
1451
+ async remove(params, options) {
1452
+ const target_store_id = params.store_id || apiConfig.storeId;
1453
+ return apiConfig.httpClient.delete(
1454
+ `/v1/stores/${target_store_id}/profile-lists/${params.profile_list_id}/members/${params.profile_id}`,
1455
+ options
1456
+ );
1457
+ },
1458
+ async find(params, options) {
1459
+ const { store_id, profile_list_id, ...queryParams } = params;
1460
+ const target_store_id = store_id || apiConfig.storeId;
1461
+ const path = profile_list_id ? `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members` : `/v1/stores/${target_store_id}/profile-list-members`;
1462
+ return apiConfig.httpClient.get(
1463
+ path,
1464
+ { ...options, params: queryParams }
1465
+ );
1391
1466
  }
1467
+ },
1468
+ profiles: {
1469
+ async add(params, options) {
1470
+ const { store_id, profile_list_id, profile_id, fields, lead_description } = params;
1471
+ const target_store_id = store_id || apiConfig.storeId;
1472
+ return apiConfig.httpClient.post(
1473
+ `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
1474
+ { fields, lead_description },
1475
+ options
1476
+ );
1477
+ },
1478
+ async update(params, options) {
1479
+ const { store_id, profile_list_id, profile_id, status, fields, lead_description } = params;
1480
+ const target_store_id = store_id || apiConfig.storeId;
1481
+ return apiConfig.httpClient.patch(
1482
+ `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members/${profile_id}`,
1483
+ { status, fields, lead_description },
1484
+ options
1485
+ );
1486
+ },
1487
+ async remove(params, options) {
1488
+ const target_store_id = params.store_id || apiConfig.storeId;
1489
+ return apiConfig.httpClient.delete(
1490
+ `/v1/stores/${target_store_id}/profile-lists/${params.profile_list_id}/members/${params.profile_id}`,
1491
+ options
1492
+ );
1493
+ },
1494
+ async find(params, options) {
1495
+ const { store_id, profile_list_id, ...queryParams } = params;
1496
+ const target_store_id = store_id || apiConfig.storeId;
1497
+ const path = profile_list_id ? `/v1/stores/${target_store_id}/profile-lists/${profile_list_id}/members` : `/v1/stores/${target_store_id}/profile-list-members`;
1498
+ return apiConfig.httpClient.get(
1499
+ path,
1500
+ { ...options, params: queryParams }
1501
+ );
1502
+ }
1503
+ }
1504
+ },
1505
+ mailbox: {
1506
+ async create(params, options) {
1507
+ const { store_id, ...payload } = params;
1508
+ const target_store_id = store_id || apiConfig.storeId;
1509
+ return apiConfig.httpClient.post(
1510
+ `/v1/stores/${target_store_id}/mailboxes`,
1511
+ payload,
1512
+ options
1513
+ );
1514
+ },
1515
+ async update(params, options) {
1516
+ const { id, store_id, ...payload } = params;
1517
+ const target_store_id = store_id || apiConfig.storeId;
1518
+ return apiConfig.httpClient.put(
1519
+ `/v1/stores/${target_store_id}/mailboxes/${id}`,
1520
+ payload,
1521
+ options
1522
+ );
1523
+ },
1524
+ async get(params, options) {
1525
+ const target_store_id = params.store_id || apiConfig.storeId;
1526
+ return apiConfig.httpClient.get(
1527
+ `/v1/stores/${target_store_id}/mailboxes/${params.id}`,
1528
+ options
1529
+ );
1530
+ },
1531
+ async test(params, options) {
1532
+ const target_store_id = params.store_id || apiConfig.storeId;
1533
+ return apiConfig.httpClient.post(
1534
+ `/v1/stores/${target_store_id}/mailboxes/${params.id}/test`,
1535
+ {},
1536
+ options
1537
+ );
1538
+ },
1539
+ async prepare(params, options) {
1540
+ const target_store_id = params.store_id || apiConfig.storeId;
1541
+ return apiConfig.httpClient.post(
1542
+ `/v1/stores/${target_store_id}/mailboxes/${params.id}/prepare`,
1543
+ {},
1544
+ options
1545
+ );
1546
+ },
1547
+ async find(params, options) {
1548
+ const { store_id, ...queryParams } = params || {};
1549
+ const target_store_id = store_id || apiConfig.storeId;
1550
+ return apiConfig.httpClient.get(
1551
+ `/v1/stores/${target_store_id}/mailboxes`,
1552
+ { ...options, params: queryParams }
1553
+ );
1554
+ }
1555
+ },
1556
+ campaign: {
1557
+ async create(params, options) {
1558
+ const { store_id, ...payload } = params;
1559
+ const target_store_id = store_id || apiConfig.storeId;
1560
+ return apiConfig.httpClient.post(
1561
+ `/v1/stores/${target_store_id}/campaigns`,
1562
+ payload,
1563
+ options
1564
+ );
1565
+ },
1566
+ async update(params, options) {
1567
+ const { id, store_id, ...payload } = params;
1568
+ const target_store_id = store_id || apiConfig.storeId;
1569
+ return apiConfig.httpClient.put(
1570
+ `/v1/stores/${target_store_id}/campaigns/${id}`,
1571
+ payload,
1572
+ options
1573
+ );
1574
+ },
1575
+ async get(params, options) {
1576
+ const target_store_id = params.store_id || apiConfig.storeId;
1392
1577
  return apiConfig.httpClient.get(
1393
- `/v1/stores/${apiConfig.storeId}/audiences/${identifier}`,
1578
+ `/v1/stores/${target_store_id}/campaigns/${params.id}`,
1394
1579
  options
1395
1580
  );
1396
1581
  },
1397
1582
  async find(params, options) {
1583
+ const { store_id, ...queryParams } = params || {};
1584
+ const target_store_id = store_id || apiConfig.storeId;
1398
1585
  return apiConfig.httpClient.get(
1399
- `/v1/stores/${apiConfig.storeId}/audiences`,
1400
- { ...options, params }
1586
+ `/v1/stores/${target_store_id}/campaigns`,
1587
+ { ...options, params: queryParams }
1588
+ );
1589
+ },
1590
+ async launch(params, options) {
1591
+ const target_store_id = params.store_id || apiConfig.storeId;
1592
+ return apiConfig.httpClient.post(
1593
+ `/v1/stores/${target_store_id}/campaigns/${params.id}/launch`,
1594
+ {},
1595
+ options
1401
1596
  );
1402
1597
  },
1403
- async getSubscribers(params, options) {
1598
+ async duplicate(params, options) {
1599
+ const { id, store_id, ...payload } = params;
1600
+ const target_store_id = store_id || apiConfig.storeId;
1601
+ return apiConfig.httpClient.post(
1602
+ `/v1/stores/${target_store_id}/campaigns/${id}/duplicate`,
1603
+ payload,
1604
+ options
1605
+ );
1606
+ },
1607
+ async launchReadiness(params, options) {
1608
+ const target_store_id = params.store_id || apiConfig.storeId;
1404
1609
  return apiConfig.httpClient.get(
1405
- `/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers`,
1406
- {
1407
- ...options,
1408
- params: { limit: params.limit, cursor: params.cursor }
1409
- }
1610
+ `/v1/stores/${target_store_id}/campaigns/${params.id}/launch-readiness`,
1611
+ options
1410
1612
  );
1411
1613
  },
1412
- async addSubscriber(params, options) {
1614
+ async importRecipients(params, options) {
1615
+ const { id, store_id, ...payload } = params;
1616
+ const target_store_id = store_id || apiConfig.storeId;
1413
1617
  return apiConfig.httpClient.post(
1414
- `/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers`,
1415
- { customer_id: params.customer_id },
1618
+ `/v1/stores/${target_store_id}/campaigns/${id}/recipients/import`,
1619
+ payload,
1416
1620
  options
1417
1621
  );
1418
1622
  },
1419
- async removeSubscriber(params, options) {
1420
- return apiConfig.httpClient.delete(
1421
- `/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers/${params.customer_id}`,
1623
+ async generatePersonalizedDrafts(params, options) {
1624
+ const { id, store_id, ...payload } = params;
1625
+ const target_store_id = store_id || apiConfig.storeId;
1626
+ return apiConfig.httpClient.post(
1627
+ `/v1/stores/${target_store_id}/campaigns/${id}/personalized-drafts`,
1628
+ payload,
1422
1629
  options
1423
1630
  );
1424
1631
  }
1425
1632
  },
1633
+ campaignRecipient: {
1634
+ async find(params, options) {
1635
+ const { store_id, ...queryParams } = params || {};
1636
+ const target_store_id = store_id || apiConfig.storeId;
1637
+ return apiConfig.httpClient.get(
1638
+ `/v1/stores/${target_store_id}/campaign-recipients`,
1639
+ { ...options, params: queryParams }
1640
+ );
1641
+ },
1642
+ async get(params, options) {
1643
+ const { store_id, id, ...queryParams } = params;
1644
+ const target_store_id = store_id || apiConfig.storeId;
1645
+ return apiConfig.httpClient.get(
1646
+ `/v1/stores/${target_store_id}/campaign-recipients/${id}`,
1647
+ { ...options, params: { ...queryParams, store_id: target_store_id } }
1648
+ );
1649
+ },
1650
+ async update(params, options) {
1651
+ const { store_id, id, ...payload } = params;
1652
+ const target_store_id = store_id || apiConfig.storeId;
1653
+ return apiConfig.httpClient.put(
1654
+ `/v1/stores/${target_store_id}/campaign-recipients/${id}`,
1655
+ payload,
1656
+ options
1657
+ );
1658
+ },
1659
+ async updateDraft(params, options) {
1660
+ const { store_id, id, draft_id, ...payload } = params;
1661
+ const target_store_id = store_id || apiConfig.storeId;
1662
+ return apiConfig.httpClient.put(
1663
+ `/v1/stores/${target_store_id}/campaign-recipients/${id}/drafts/${draft_id}`,
1664
+ payload,
1665
+ options
1666
+ );
1667
+ },
1668
+ async reply(params, options) {
1669
+ const { store_id, id, ...payload } = params;
1670
+ const target_store_id = store_id || apiConfig.storeId;
1671
+ return apiConfig.httpClient.post(
1672
+ `/v1/stores/${target_store_id}/campaign-recipients/${id}/reply`,
1673
+ payload,
1674
+ options
1675
+ );
1676
+ },
1677
+ async stop(params, options) {
1678
+ const { store_id, id, ...payload } = params;
1679
+ const target_store_id = store_id || apiConfig.storeId;
1680
+ return apiConfig.httpClient.post(
1681
+ `/v1/stores/${target_store_id}/campaign-recipients/${id}/stop`,
1682
+ payload,
1683
+ options
1684
+ );
1685
+ }
1686
+ },
1687
+ campaignMessage: {
1688
+ async find(params, options) {
1689
+ const { store_id, ...queryParams } = params || {};
1690
+ const target_store_id = store_id || apiConfig.storeId;
1691
+ return apiConfig.httpClient.get(
1692
+ `/v1/stores/${target_store_id}/campaign-messages`,
1693
+ { ...options, params: queryParams }
1694
+ );
1695
+ },
1696
+ async update(params, options) {
1697
+ const { id, store_id, ...payload } = params;
1698
+ const target_store_id = store_id || apiConfig.storeId;
1699
+ return apiConfig.httpClient.put(
1700
+ `/v1/stores/${target_store_id}/campaign-messages/${id}`,
1701
+ payload,
1702
+ options
1703
+ );
1704
+ }
1705
+ },
1706
+ suppression: {
1707
+ async create(params, options) {
1708
+ const { store_id, ...payload } = params;
1709
+ const target_store_id = store_id || apiConfig.storeId;
1710
+ return apiConfig.httpClient.post(
1711
+ `/v1/stores/${target_store_id}/suppressions`,
1712
+ payload,
1713
+ options
1714
+ );
1715
+ },
1716
+ async update(params, options) {
1717
+ const { id, store_id, ...payload } = params;
1718
+ const target_store_id = store_id || apiConfig.storeId;
1719
+ return apiConfig.httpClient.put(
1720
+ `/v1/stores/${target_store_id}/suppressions/${id}`,
1721
+ payload,
1722
+ options
1723
+ );
1724
+ },
1725
+ async get(params, options) {
1726
+ const target_store_id = params.store_id || apiConfig.storeId;
1727
+ return apiConfig.httpClient.get(
1728
+ `/v1/stores/${target_store_id}/suppressions/${params.id}`,
1729
+ options
1730
+ );
1731
+ },
1732
+ async find(params, options) {
1733
+ const { store_id, ...queryParams } = params || {};
1734
+ const target_store_id = store_id || apiConfig.storeId;
1735
+ return apiConfig.httpClient.get(
1736
+ `/v1/stores/${target_store_id}/suppressions`,
1737
+ { ...options, params: queryParams }
1738
+ );
1739
+ }
1740
+ },
1426
1741
  activity: createActivityAdminApi(apiConfig)
1427
1742
  };
1428
1743
  };
1429
1744
 
1745
+ // src/api/support.ts
1746
+ function supportConversationQuery(params) {
1747
+ const qs = new URLSearchParams({ store_id: params.store_id });
1748
+ if (params.message_limit) qs.set("message_limit", String(params.message_limit));
1749
+ if (typeof params.after_created_at === "number") qs.set("after_created_at", String(params.after_created_at));
1750
+ if (params.after_id) qs.set("after_id", params.after_id);
1751
+ return qs.toString();
1752
+ }
1753
+ function createAdminSupportApi(config) {
1754
+ const { httpClient } = config;
1755
+ return {
1756
+ agent: {
1757
+ async create(params, opts) {
1758
+ return httpClient.post(
1759
+ `/v1/stores/${params.store_id}/support/agents`,
1760
+ params,
1761
+ opts
1762
+ );
1763
+ },
1764
+ async get(params, opts) {
1765
+ return httpClient.get(
1766
+ `/v1/stores/${params.store_id}/support/agents/${params.id}?store_id=${params.store_id}`,
1767
+ opts
1768
+ );
1769
+ },
1770
+ async find(params, opts) {
1771
+ const qs = new URLSearchParams({ store_id: params.store_id });
1772
+ if (params.status) qs.set("status", params.status);
1773
+ if (params.limit) qs.set("limit", String(params.limit));
1774
+ if (params.cursor) qs.set("cursor", params.cursor);
1775
+ return httpClient.get(
1776
+ `/v1/stores/${params.store_id}/support/agents?${qs}`,
1777
+ opts
1778
+ );
1779
+ },
1780
+ async update(params, opts) {
1781
+ return httpClient.put(
1782
+ `/v1/stores/${params.store_id}/support/agents/${params.id}`,
1783
+ params,
1784
+ opts
1785
+ );
1786
+ },
1787
+ async delete(params, opts) {
1788
+ return httpClient.delete(
1789
+ `/v1/stores/${params.store_id}/support/agents/${params.id}?store_id=${params.store_id}`,
1790
+ opts
1791
+ );
1792
+ }
1793
+ },
1794
+ conversation: {
1795
+ async find(params, opts) {
1796
+ const qs = new URLSearchParams({ store_id: params.store_id });
1797
+ if (params.status) qs.set("status", params.status);
1798
+ if (params.agent_id) qs.set("agent_id", params.agent_id);
1799
+ if (params.limit) qs.set("limit", String(params.limit));
1800
+ if (params.cursor) qs.set("cursor", params.cursor);
1801
+ return httpClient.get(
1802
+ `/v1/stores/${params.store_id}/support/conversations?${qs}`,
1803
+ opts
1804
+ );
1805
+ },
1806
+ async get(params, opts) {
1807
+ const qs = supportConversationQuery(params);
1808
+ return httpClient.get(
1809
+ `/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}?${qs}`,
1810
+ opts
1811
+ );
1812
+ },
1813
+ async sendMessage(params, opts) {
1814
+ return httpClient.post(
1815
+ `/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/messages`,
1816
+ params,
1817
+ opts
1818
+ );
1819
+ },
1820
+ async reply(params, opts) {
1821
+ return httpClient.post(
1822
+ `/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/reply`,
1823
+ params,
1824
+ opts
1825
+ );
1826
+ },
1827
+ async resolve(params, opts) {
1828
+ return httpClient.post(
1829
+ `/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/resolve`,
1830
+ params,
1831
+ opts
1832
+ );
1833
+ },
1834
+ async assign(params, opts) {
1835
+ return httpClient.post(
1836
+ `/v1/stores/${params.store_id}/support/conversations/${params.conversation_id}/assign`,
1837
+ params,
1838
+ opts
1839
+ );
1840
+ }
1841
+ }
1842
+ };
1843
+ }
1844
+
1845
+ // src/api/leadResearch.ts
1846
+ var createLeadResearchApi = (apiConfig) => {
1847
+ const storeId = (store_id) => store_id || apiConfig.storeId;
1848
+ return {
1849
+ async createRun(params, options) {
1850
+ const { store_id, ...payload } = params;
1851
+ return apiConfig.httpClient.post(
1852
+ `/v1/stores/${storeId(store_id)}/lead-research/runs`,
1853
+ payload,
1854
+ options
1855
+ );
1856
+ },
1857
+ async findRuns(params, options) {
1858
+ const { store_id, ...queryParams } = params || {};
1859
+ return apiConfig.httpClient.get(
1860
+ `/v1/stores/${storeId(store_id)}/lead-research/runs`,
1861
+ { ...options, params: queryParams }
1862
+ );
1863
+ },
1864
+ async getRun(params, options) {
1865
+ return apiConfig.httpClient.get(
1866
+ `/v1/stores/${storeId(params.store_id)}/lead-research/runs/${params.id}`,
1867
+ options
1868
+ );
1869
+ },
1870
+ async updateRun(params, options) {
1871
+ const { store_id, id, ...payload } = params;
1872
+ return apiConfig.httpClient.patch(
1873
+ `/v1/stores/${storeId(store_id)}/lead-research/runs/${id}`,
1874
+ payload,
1875
+ options
1876
+ );
1877
+ },
1878
+ async cancelRun(params, options) {
1879
+ return apiConfig.httpClient.post(
1880
+ `/v1/stores/${storeId(params.store_id)}/lead-research/runs/${params.id}/cancel`,
1881
+ {},
1882
+ options
1883
+ );
1884
+ },
1885
+ async sendMessage(params, options) {
1886
+ const { store_id, run_id, ...payload } = params;
1887
+ return apiConfig.httpClient.post(
1888
+ `/v1/stores/${storeId(store_id)}/lead-research/runs/${run_id}/messages`,
1889
+ payload,
1890
+ options
1891
+ );
1892
+ },
1893
+ async findMessages(params, options) {
1894
+ const { store_id, run_id, ...queryParams } = params;
1895
+ return apiConfig.httpClient.get(
1896
+ `/v1/stores/${storeId(store_id)}/lead-research/runs/${run_id}/messages`,
1897
+ { ...options, params: queryParams }
1898
+ );
1899
+ },
1900
+ async validateEmail(params, options) {
1901
+ const { store_id, ...payload } = params;
1902
+ return apiConfig.httpClient.post(
1903
+ `/v1/stores/${storeId(store_id)}/lead-research/validate-email`,
1904
+ payload,
1905
+ options
1906
+ );
1907
+ }
1908
+ };
1909
+ };
1910
+
1430
1911
  // src/api/workflow.ts
1431
1912
  var createWorkflowApi = (apiConfig) => {
1432
1913
  return {
@@ -1552,121 +2033,6 @@ var createShippingApi = (apiConfig) => {
1552
2033
  };
1553
2034
  };
1554
2035
 
1555
- // src/api/agent.ts
1556
- var createAgentApi = (apiConfig) => {
1557
- return {
1558
- async createAgent(params, options) {
1559
- const { store_id, ...payload } = params;
1560
- const target_store_id = store_id || apiConfig.storeId;
1561
- return apiConfig.httpClient.post(
1562
- `/v1/stores/${target_store_id}/agents`,
1563
- { ...payload, store_id: target_store_id },
1564
- options
1565
- );
1566
- },
1567
- async updateAgent(params, options) {
1568
- const { store_id, id, ...payload } = params;
1569
- const target_store_id = store_id || apiConfig.storeId;
1570
- return apiConfig.httpClient.put(
1571
- `/v1/stores/${target_store_id}/agents/${id}`,
1572
- payload,
1573
- options
1574
- );
1575
- },
1576
- async deleteAgent(params, options) {
1577
- const store_id = params.store_id || apiConfig.storeId;
1578
- return apiConfig.httpClient.delete(
1579
- `/v1/stores/${store_id}/agents/${params.id}`,
1580
- options
1581
- );
1582
- },
1583
- async getAgent(params, options) {
1584
- const store_id = params.store_id || apiConfig.storeId;
1585
- return apiConfig.httpClient.get(
1586
- `/v1/stores/${store_id}/agents/${params.id}`,
1587
- options
1588
- );
1589
- },
1590
- async getAgents(params, options) {
1591
- const store_id = params?.store_id || apiConfig.storeId;
1592
- const { store_id: _, ...queryParams } = params || {};
1593
- return apiConfig.httpClient.get(`/v1/stores/${store_id}/agents`, {
1594
- ...options,
1595
- params: Object.keys(queryParams).length > 0 ? queryParams : void 0
1596
- });
1597
- },
1598
- async sendMessage(params, options) {
1599
- const store_id = params.store_id || apiConfig.storeId;
1600
- const body = { message: params.message };
1601
- if (params.chat_id) body.chat_id = params.chat_id;
1602
- if (params.direct) body.direct = params.direct;
1603
- return apiConfig.httpClient.post(
1604
- `/v1/stores/${store_id}/agents/${params.id}/chats/messages`,
1605
- body,
1606
- options
1607
- );
1608
- },
1609
- async getChats(params, options) {
1610
- const store_id = params.store_id || apiConfig.storeId;
1611
- const queryParams = {};
1612
- if (params.limit) queryParams.limit = String(params.limit);
1613
- if (params.cursor) queryParams.cursor = params.cursor;
1614
- return apiConfig.httpClient.get(
1615
- `/v1/stores/${store_id}/agents/${params.id}/chats`,
1616
- {
1617
- ...options,
1618
- params: Object.keys(queryParams).length > 0 ? queryParams : void 0
1619
- }
1620
- );
1621
- },
1622
- async getChat(params, options) {
1623
- const store_id = params.store_id || apiConfig.storeId;
1624
- return apiConfig.httpClient.get(
1625
- `/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
1626
- options
1627
- );
1628
- },
1629
- async updateChat(params, options) {
1630
- const store_id = params.store_id || apiConfig.storeId;
1631
- return apiConfig.httpClient.put(
1632
- `/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
1633
- { status: params.status },
1634
- options
1635
- );
1636
- },
1637
- async rateChat(params, options) {
1638
- const store_id = params.store_id || apiConfig.storeId;
1639
- const body = { rating: params.rating };
1640
- if (params.comment) body.comment = params.comment;
1641
- return apiConfig.httpClient.post(
1642
- `/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}/rate`,
1643
- body,
1644
- options
1645
- );
1646
- },
1647
- async getStoreChats(params, options) {
1648
- const store_id = params.store_id || apiConfig.storeId;
1649
- const { store_id: _, ...queryParams } = params;
1650
- return apiConfig.httpClient.get(`/v1/stores/${store_id}/chats`, {
1651
- ...options,
1652
- params: Object.keys(queryParams).length > 0 ? queryParams : void 0
1653
- });
1654
- },
1655
- async getChatMessages(params, options) {
1656
- const store_id = params.store_id || apiConfig.storeId;
1657
- const queryParams = {};
1658
- if (params.limit) queryParams.limit = String(params.limit);
1659
- return apiConfig.httpClient.get(
1660
- `/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}/messages`,
1661
- {
1662
- ...options,
1663
- params: Object.keys(queryParams).length > 0 ? queryParams : void 0
1664
- }
1665
- );
1666
- }
1667
- };
1668
- };
1669
-
1670
2036
  // src/api/emailTemplate.ts
1671
2037
  var createEmailTemplateApi = (apiConfig) => {
1672
2038
  return {
@@ -1720,6 +2086,15 @@ var createEmailTemplateApi = (apiConfig) => {
1720
2086
  params: queryParams
1721
2087
  }
1722
2088
  );
2089
+ },
2090
+ async previewEmailTemplate(params, options) {
2091
+ const { store_id, id, ...payload } = params;
2092
+ const target_store_id = store_id || apiConfig.storeId;
2093
+ return apiConfig.httpClient.post(
2094
+ `/v1/stores/${target_store_id}/email-templates/${id}/preview`,
2095
+ payload,
2096
+ options
2097
+ );
1723
2098
  }
1724
2099
  };
1725
2100
  };
@@ -1882,20 +2257,13 @@ var createTaxonomyApi = (apiConfig) => {
1882
2257
  // src/api/analytics.ts
1883
2258
  var createAnalyticsApi = (apiConfig) => {
1884
2259
  return {
1885
- async query(spec, options) {
2260
+ async get(request, options) {
1886
2261
  const store_id = options?.store_id || apiConfig.storeId;
1887
2262
  return apiConfig.httpClient.post(
1888
- `/v1/stores/${store_id}/analytics/query`,
1889
- spec,
2263
+ `/v1/stores/${store_id}/analytics`,
2264
+ request,
1890
2265
  options
1891
2266
  );
1892
- },
1893
- async activityFeed(query = {}, options) {
1894
- const store_id = options?.store_id || apiConfig.storeId;
1895
- return apiConfig.httpClient.get(
1896
- `/v1/stores/${store_id}/analytics/activity-feed`,
1897
- { ...options, params: query }
1898
- );
1899
2267
  }
1900
2268
  };
1901
2269
  };
@@ -2275,15 +2643,42 @@ function createAdmin(config) {
2275
2643
  };
2276
2644
  const accountApi = createAccountApi(apiConfig);
2277
2645
  const authApi = createAuthApi(apiConfig, updateSession);
2278
- const storeApi = createStoreApi(apiConfig, updateSession);
2646
+ const storeApi = createStoreApi(apiConfig);
2279
2647
  const platformApi = createPlatformApi(apiConfig);
2280
2648
  const cmsApi = createCmsApi(apiConfig);
2281
2649
  const eshopApi = createEshopApi(apiConfig);
2282
2650
  const promoCodeApi = createPromoCodeApi(apiConfig);
2283
- const crmApi = createCustomerApi(apiConfig);
2651
+ const crmApi = createProfileApi(apiConfig);
2652
+ const supportApi = createAdminSupportApi(apiConfig);
2653
+ const leadResearchApi = createLeadResearchApi(apiConfig);
2654
+ const leadResearch = {
2655
+ run: {
2656
+ create: leadResearchApi.createRun,
2657
+ find: leadResearchApi.findRuns,
2658
+ get: leadResearchApi.getRun,
2659
+ update: leadResearchApi.updateRun,
2660
+ cancel: leadResearchApi.cancelRun,
2661
+ sendMessage: leadResearchApi.sendMessage,
2662
+ findMessages: leadResearchApi.findMessages
2663
+ },
2664
+ message: {
2665
+ send: leadResearchApi.sendMessage,
2666
+ find: leadResearchApi.findMessages
2667
+ },
2668
+ email: {
2669
+ validate: leadResearchApi.validateEmail
2670
+ },
2671
+ createRun: leadResearchApi.createRun,
2672
+ findRuns: leadResearchApi.findRuns,
2673
+ getRun: leadResearchApi.getRun,
2674
+ updateRun: leadResearchApi.updateRun,
2675
+ cancelRun: leadResearchApi.cancelRun,
2676
+ sendMessage: leadResearchApi.sendMessage,
2677
+ findMessages: leadResearchApi.findMessages,
2678
+ validateEmail: leadResearchApi.validateEmail
2679
+ };
2284
2680
  const locationApi = createLocationApi(apiConfig);
2285
2681
  const marketApi = createMarketApi(apiConfig);
2286
- const agentApi = createAgentApi(apiConfig);
2287
2682
  const workflowApi = createWorkflowApi(apiConfig);
2288
2683
  const formApi = createFormApi(apiConfig);
2289
2684
  const taxonomyApi = createTaxonomyApi(apiConfig);
@@ -2335,7 +2730,8 @@ function createAdmin(config) {
2335
2730
  update: emailTemplateApi.updateEmailTemplate,
2336
2731
  delete: emailTemplateApi.deleteEmailTemplate,
2337
2732
  get: emailTemplateApi.getEmailTemplate,
2338
- find: emailTemplateApi.getEmailTemplates
2733
+ find: emailTemplateApi.getEmailTemplates,
2734
+ preview: emailTemplateApi.previewEmailTemplate
2339
2735
  }
2340
2736
  },
2341
2737
  eshop: {
@@ -2386,41 +2782,27 @@ function createAdmin(config) {
2386
2782
  promoCode: promoCodeApi
2387
2783
  },
2388
2784
  crm: {
2389
- customer: {
2785
+ profile: {
2390
2786
  create: crmApi.create,
2391
2787
  get: crmApi.get,
2392
2788
  find: crmApi.find,
2393
2789
  update: crmApi.update,
2394
2790
  merge: crmApi.merge,
2791
+ import: crmApi.import,
2395
2792
  revokeToken: crmApi.revokeToken,
2396
2793
  revokeAllTokens: crmApi.revokeAllTokens
2397
2794
  },
2398
- audience: {
2399
- create: crmApi.audiences.create,
2400
- update: crmApi.audiences.update,
2401
- get: crmApi.audiences.get,
2402
- find: crmApi.audiences.find,
2403
- getSubscribers: crmApi.audiences.getSubscribers,
2404
- addSubscriber: crmApi.audiences.addSubscriber,
2405
- removeSubscriber: crmApi.audiences.removeSubscriber
2406
- },
2795
+ profileList: crmApi.profileList,
2796
+ mailbox: crmApi.mailbox,
2797
+ campaign: crmApi.campaign,
2798
+ campaignRecipient: crmApi.campaignRecipient,
2799
+ campaignMessage: crmApi.campaignMessage,
2800
+ suppression: crmApi.suppression,
2801
+ leadResearch,
2407
2802
  activity: crmApi.activity
2408
2803
  },
2804
+ leadResearch,
2409
2805
  automation: {
2410
- agent: {
2411
- create: agentApi.createAgent,
2412
- update: agentApi.updateAgent,
2413
- delete: agentApi.deleteAgent,
2414
- get: agentApi.getAgent,
2415
- find: agentApi.getAgents,
2416
- sendMessage: agentApi.sendMessage,
2417
- getChats: agentApi.getChats,
2418
- getChat: agentApi.getChat,
2419
- updateChat: agentApi.updateChat,
2420
- rateChat: agentApi.rateChat,
2421
- getStoreChats: agentApi.getStoreChats,
2422
- getChatMessages: agentApi.getChatMessages
2423
- },
2424
2806
  workflow: {
2425
2807
  create: workflowApi.createWorkflow,
2426
2808
  update: workflowApi.updateWorkflow,
@@ -2430,12 +2812,10 @@ function createAdmin(config) {
2430
2812
  trigger: workflowApi.triggerWorkflow,
2431
2813
  getExecutions: workflowApi.getWorkflowExecutions,
2432
2814
  getExecution: workflowApi.getWorkflowExecution
2433
- }
2434
- },
2435
- analytics: {
2436
- query: analyticsApi.query,
2437
- activityFeed: analyticsApi.activityFeed
2815
+ },
2816
+ support: supportApi
2438
2817
  },
2818
+ analytics: analyticsApi,
2439
2819
  setStoreId: (storeId) => {
2440
2820
  apiConfig.storeId = storeId;
2441
2821
  },