arky-sdk 0.3.127 → 0.3.128

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -7,6 +7,12 @@ var PaymentMethodType = /* @__PURE__ */ ((PaymentMethodType2) => {
7
7
  PaymentMethodType2["Free"] = "FREE";
8
8
  return PaymentMethodType2;
9
9
  })(PaymentMethodType || {});
10
+ var TaxonomyScope = /* @__PURE__ */ ((TaxonomyScope2) => {
11
+ TaxonomyScope2["SERVICE"] = "SERVICE";
12
+ TaxonomyScope2["PROVIDER"] = "PROVIDER";
13
+ TaxonomyScope2["PRODUCT"] = "PRODUCT";
14
+ return TaxonomyScope2;
15
+ })(TaxonomyScope || {});
10
16
 
11
17
  // src/utils/errors.ts
12
18
  var convertServerErrorToRequestError = (serverError, renameRules) => {
@@ -1268,8 +1274,8 @@ var createNewsletterApi = (apiConfig) => {
1268
1274
  */
1269
1275
  async createNewsletter(params, options) {
1270
1276
  return apiConfig.httpClient.post(
1271
- `/v1/newsletters`,
1272
- { ...params, businessId: apiConfig.businessId },
1277
+ `/v1/businesses/${apiConfig.businessId}/newsletters`,
1278
+ params,
1273
1279
  options
1274
1280
  );
1275
1281
  },
@@ -1278,7 +1284,7 @@ var createNewsletterApi = (apiConfig) => {
1278
1284
  */
1279
1285
  async getNewsletter(params, options) {
1280
1286
  return apiConfig.httpClient.get(
1281
- `/v1/newsletters/${params.id}`,
1287
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${params.id}`,
1282
1288
  options
1283
1289
  );
1284
1290
  },
@@ -1286,24 +1292,31 @@ var createNewsletterApi = (apiConfig) => {
1286
1292
  * List all newsletters for the business
1287
1293
  */
1288
1294
  async getNewsletters(params, options) {
1289
- return apiConfig.httpClient.get(`/v1/newsletters`, {
1290
- ...options,
1291
- params: { ...params, businessId: apiConfig.businessId }
1292
- });
1295
+ return apiConfig.httpClient.get(
1296
+ `/v1/businesses/${apiConfig.businessId}/newsletters`,
1297
+ {
1298
+ ...options,
1299
+ params
1300
+ }
1301
+ );
1293
1302
  },
1294
1303
  /**
1295
1304
  * Update a newsletter
1296
1305
  */
1297
1306
  async updateNewsletter(params, options) {
1298
1307
  const { id, ...body } = params;
1299
- return apiConfig.httpClient.put(`/v1/newsletters/${id}`, body, options);
1308
+ return apiConfig.httpClient.put(
1309
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${id}`,
1310
+ body,
1311
+ options
1312
+ );
1300
1313
  },
1301
1314
  /**
1302
1315
  * Delete a newsletter
1303
1316
  */
1304
1317
  async deleteNewsletter(params, options) {
1305
1318
  return apiConfig.httpClient.delete(
1306
- `/v1/newsletters/${params.id}`,
1319
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${params.id}`,
1307
1320
  options
1308
1321
  );
1309
1322
  },
@@ -1312,7 +1325,7 @@ var createNewsletterApi = (apiConfig) => {
1312
1325
  */
1313
1326
  async getSubscribers(params, options) {
1314
1327
  return apiConfig.httpClient.get(
1315
- `/v1/newsletters/${params.id}/subscribers`,
1328
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${params.id}/subscribers`,
1316
1329
  options
1317
1330
  );
1318
1331
  },
@@ -1323,8 +1336,8 @@ var createNewsletterApi = (apiConfig) => {
1323
1336
  async createPost(params, options) {
1324
1337
  const { newsletterId, ...body } = params;
1325
1338
  return apiConfig.httpClient.post(
1326
- `/v1/newsletters/${newsletterId}/posts`,
1327
- { ...body, businessId: apiConfig.businessId },
1339
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${newsletterId}/posts`,
1340
+ body,
1328
1341
  options
1329
1342
  );
1330
1343
  },
@@ -1333,7 +1346,7 @@ var createNewsletterApi = (apiConfig) => {
1333
1346
  */
1334
1347
  async getPost(params, options) {
1335
1348
  return apiConfig.httpClient.get(
1336
- `/v1/newsletters/${params.newsletterId}/posts/${params.postId}`,
1349
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${params.newsletterId}/posts/${params.postId}`,
1337
1350
  options
1338
1351
  );
1339
1352
  },
@@ -1343,10 +1356,10 @@ var createNewsletterApi = (apiConfig) => {
1343
1356
  async getPosts(params, options) {
1344
1357
  const { newsletterId, ...queryParams } = params;
1345
1358
  return apiConfig.httpClient.get(
1346
- `/v1/newsletters/${newsletterId}/posts`,
1359
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${newsletterId}/posts`,
1347
1360
  {
1348
1361
  ...options,
1349
- params: { ...queryParams, businessId: apiConfig.businessId }
1362
+ params: queryParams
1350
1363
  }
1351
1364
  );
1352
1365
  },
@@ -1356,7 +1369,7 @@ var createNewsletterApi = (apiConfig) => {
1356
1369
  async updatePost(params, options) {
1357
1370
  const { newsletterId, postId, ...body } = params;
1358
1371
  return apiConfig.httpClient.put(
1359
- `/v1/newsletters/${newsletterId}/posts/${postId}`,
1372
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${newsletterId}/posts/${postId}`,
1360
1373
  body,
1361
1374
  options
1362
1375
  );
@@ -1366,7 +1379,7 @@ var createNewsletterApi = (apiConfig) => {
1366
1379
  */
1367
1380
  async deletePost(params, options) {
1368
1381
  return apiConfig.httpClient.delete(
1369
- `/v1/newsletters/${params.newsletterId}/posts/${params.postId}`,
1382
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${params.newsletterId}/posts/${params.postId}`,
1370
1383
  options
1371
1384
  );
1372
1385
  },
@@ -1377,7 +1390,7 @@ var createNewsletterApi = (apiConfig) => {
1377
1390
  async scheduleSend(params, options) {
1378
1391
  const { newsletterId, postId, ...body } = params;
1379
1392
  return apiConfig.httpClient.post(
1380
- `/v1/newsletters/${newsletterId}/posts/${postId}/send`,
1393
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${newsletterId}/posts/${postId}/send`,
1381
1394
  body,
1382
1395
  options
1383
1396
  );
@@ -1388,7 +1401,7 @@ var createNewsletterApi = (apiConfig) => {
1388
1401
  async cancelSend(params, options) {
1389
1402
  const { newsletterId, postId, sendId } = params;
1390
1403
  return apiConfig.httpClient.post(
1391
- `/v1/newsletters/${newsletterId}/posts/${postId}/send/${sendId}/cancel`,
1404
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${newsletterId}/posts/${postId}/send/${sendId}/cancel`,
1392
1405
  {},
1393
1406
  options
1394
1407
  );
@@ -1426,6 +1439,213 @@ var createNewsletterApi = (apiConfig) => {
1426
1439
  };
1427
1440
  };
1428
1441
 
1442
+ // src/api/emailTemplate.ts
1443
+ var createEmailTemplateApi = (apiConfig) => {
1444
+ return {
1445
+ /**
1446
+ * List all email templates for the business
1447
+ * Returns paginated list of email templates
1448
+ */
1449
+ async getTemplates(params, options) {
1450
+ const businessId = params?.businessId || apiConfig.businessId;
1451
+ const queryParams = {};
1452
+ if (params?.key) queryParams.key = params.key;
1453
+ if (params?.keys) queryParams.keys = params.keys;
1454
+ if (params?.query) queryParams.query = params.query;
1455
+ if (params?.limit) queryParams.limit = params.limit;
1456
+ if (params?.cursor) queryParams.cursor = params.cursor;
1457
+ return apiConfig.httpClient.get(
1458
+ `/v1/businesses/${businessId}/email-templates`,
1459
+ { ...options, params: queryParams }
1460
+ );
1461
+ },
1462
+ /**
1463
+ * Get a specific email template by ID
1464
+ */
1465
+ async getTemplate(params, options) {
1466
+ const businessId = params.businessId || apiConfig.businessId;
1467
+ return apiConfig.httpClient.get(
1468
+ `/v1/businesses/${businessId}/email-templates/${params.id}`,
1469
+ options
1470
+ );
1471
+ },
1472
+ /**
1473
+ * Get a specific email template by key
1474
+ */
1475
+ async getTemplateByKey(params, options) {
1476
+ const businessId = params.businessId || apiConfig.businessId;
1477
+ return apiConfig.httpClient.get(
1478
+ `/v1/businesses/${businessId}/email-templates/by-key/${params.key}`,
1479
+ options
1480
+ );
1481
+ },
1482
+ /**
1483
+ * Create a new email template
1484
+ */
1485
+ async createTemplate(params, options) {
1486
+ const { businessId: paramBusinessId, ...body } = params;
1487
+ const businessId = paramBusinessId || apiConfig.businessId;
1488
+ return apiConfig.httpClient.post(
1489
+ `/v1/businesses/${businessId}/email-templates`,
1490
+ body,
1491
+ options
1492
+ );
1493
+ },
1494
+ /**
1495
+ * Update an existing email template
1496
+ */
1497
+ async updateTemplate(params, options) {
1498
+ const { id, businessId: paramBusinessId, ...body } = params;
1499
+ const businessId = paramBusinessId || apiConfig.businessId;
1500
+ return apiConfig.httpClient.put(
1501
+ `/v1/businesses/${businessId}/email-templates/${id}`,
1502
+ body,
1503
+ options
1504
+ );
1505
+ },
1506
+ /**
1507
+ * Delete an email template
1508
+ */
1509
+ async deleteTemplate(params, options) {
1510
+ const businessId = params.businessId || apiConfig.businessId;
1511
+ return apiConfig.httpClient.delete(
1512
+ `/v1/businesses/${businessId}/email-templates/${params.id}`,
1513
+ options
1514
+ );
1515
+ }
1516
+ };
1517
+ };
1518
+
1519
+ // src/api/taxonomy.ts
1520
+ var createTaxonomyApi = (apiConfig) => {
1521
+ return {
1522
+ async getTaxonomies(params, options) {
1523
+ return apiConfig.httpClient.get(
1524
+ `/v1/businesses/${apiConfig.businessId}/taxonomies`,
1525
+ {
1526
+ ...options,
1527
+ params
1528
+ }
1529
+ );
1530
+ },
1531
+ async getTaxonomy(params, options) {
1532
+ return apiConfig.httpClient.get(
1533
+ `/v1/businesses/${apiConfig.businessId}/taxonomies/${params.id}`,
1534
+ options
1535
+ );
1536
+ },
1537
+ async createTaxonomy(params, options) {
1538
+ return apiConfig.httpClient.post(
1539
+ `/v1/businesses/${apiConfig.businessId}/taxonomies`,
1540
+ params,
1541
+ options
1542
+ );
1543
+ },
1544
+ async updateTaxonomy(params, options) {
1545
+ return apiConfig.httpClient.put(
1546
+ `/v1/businesses/${apiConfig.businessId}/taxonomies/${params.id}`,
1547
+ params,
1548
+ options
1549
+ );
1550
+ },
1551
+ async deleteTaxonomy(params, options) {
1552
+ return apiConfig.httpClient.delete(
1553
+ `/v1/businesses/${apiConfig.businessId}/taxonomies/${params.id}`,
1554
+ options
1555
+ );
1556
+ },
1557
+ async getTaxonomyChildren(params, options) {
1558
+ return apiConfig.httpClient.get(
1559
+ `/v1/businesses/${apiConfig.businessId}/taxonomies/${params.id}/children`,
1560
+ options
1561
+ );
1562
+ },
1563
+ async getRootTaxonomies(scope, options) {
1564
+ const result = await apiConfig.httpClient.get(
1565
+ `/v1/businesses/${apiConfig.businessId}/taxonomies`,
1566
+ {
1567
+ ...options,
1568
+ params: { scope, root: true }
1569
+ }
1570
+ );
1571
+ return result.items || [];
1572
+ }
1573
+ };
1574
+ };
1575
+
1576
+ // src/api/form.ts
1577
+ var createFormApi = (apiConfig) => {
1578
+ return {
1579
+ // Form CRUD
1580
+ async getForms(params, options) {
1581
+ return apiConfig.httpClient.get(
1582
+ `/v1/businesses/${apiConfig.businessId}/forms`,
1583
+ {
1584
+ ...options,
1585
+ params
1586
+ }
1587
+ );
1588
+ },
1589
+ async getForm(params, options) {
1590
+ return apiConfig.httpClient.get(
1591
+ `/v1/businesses/${apiConfig.businessId}/forms/${params.id}`,
1592
+ options
1593
+ );
1594
+ },
1595
+ async createForm(params, options) {
1596
+ return apiConfig.httpClient.post(
1597
+ `/v1/businesses/${apiConfig.businessId}/forms`,
1598
+ params,
1599
+ options
1600
+ );
1601
+ },
1602
+ async updateForm(params, options) {
1603
+ return apiConfig.httpClient.put(
1604
+ `/v1/businesses/${apiConfig.businessId}/forms/${params.id}`,
1605
+ params,
1606
+ options
1607
+ );
1608
+ },
1609
+ async deleteForm(params, options) {
1610
+ return apiConfig.httpClient.delete(
1611
+ `/v1/businesses/${apiConfig.businessId}/forms/${params.id}`,
1612
+ options
1613
+ );
1614
+ },
1615
+ // Form Entry CRUD
1616
+ async getEntries(params, options) {
1617
+ const { formId, ...queryParams } = params;
1618
+ return apiConfig.httpClient.get(
1619
+ `/v1/businesses/${apiConfig.businessId}/forms/${formId}/entries`,
1620
+ {
1621
+ ...options,
1622
+ params: queryParams
1623
+ }
1624
+ );
1625
+ },
1626
+ async createEntry(params, options) {
1627
+ const { formId, ...body } = params;
1628
+ return apiConfig.httpClient.post(
1629
+ `/v1/businesses/${apiConfig.businessId}/forms/${formId}/entries`,
1630
+ body,
1631
+ options
1632
+ );
1633
+ },
1634
+ async getEntry(params, options) {
1635
+ return apiConfig.httpClient.get(
1636
+ `/v1/businesses/${apiConfig.businessId}/forms/${params.formId}/entries/${params.entryId}`,
1637
+ options
1638
+ );
1639
+ },
1640
+ async deleteEntry(params, options) {
1641
+ return apiConfig.httpClient.delete(
1642
+ `/v1/businesses/${apiConfig.businessId}/forms/${params.formId}/entries/${params.entryId}`,
1643
+ options
1644
+ );
1645
+ }
1646
+ };
1647
+ };
1648
+
1429
1649
  // src/utils/currency.ts
1430
1650
  function getCurrencySymbol(currency) {
1431
1651
  const currencySymbols = {
@@ -1782,6 +2002,35 @@ async function injectSvgIntoElement(mediaObject, targetElement, className) {
1782
2002
  }
1783
2003
  }
1784
2004
 
2005
+ // src/utils/keyValidation.ts
2006
+ var KEY_PATTERN = /^[a-zA-Z0-9_-]+$/;
2007
+ function isValidKey(key) {
2008
+ if (!key || key.length === 0) return false;
2009
+ return KEY_PATTERN.test(key);
2010
+ }
2011
+ function validateKey(key) {
2012
+ if (!key || key.length === 0) {
2013
+ return { valid: false, error: "Key is required" };
2014
+ }
2015
+ if (key.length > 255) {
2016
+ return { valid: false, error: "Key must be 255 characters or less" };
2017
+ }
2018
+ if (!KEY_PATTERN.test(key)) {
2019
+ return {
2020
+ valid: false,
2021
+ error: "Key can only contain letters, numbers, underscores (_) and hyphens (-)"
2022
+ };
2023
+ }
2024
+ return { valid: true };
2025
+ }
2026
+ function toKey(input) {
2027
+ if (!input) return "";
2028
+ return input.toLowerCase().trim().replace(/\s+/g, "_").replace(/[^a-z0-9_-]/g, "").replace(/^[-_]+|[-_]+$/g, "").replace(/[-_]{2,}/g, "_");
2029
+ }
2030
+ function nameToKey(name) {
2031
+ return toKey(name);
2032
+ }
2033
+
1785
2034
  // src/index.ts
1786
2035
  var SDK_VERSION = "0.3.88";
1787
2036
  var SUPPORTED_FRAMEWORKS = [
@@ -1835,6 +2084,9 @@ async function createArkySDK(config) {
1835
2084
  featureFlags: createFeatureFlagsApi(apiConfig),
1836
2085
  location: createLocationApi(apiConfig),
1837
2086
  newsletter: createNewsletterApi(apiConfig),
2087
+ emailTemplate: createEmailTemplateApi(apiConfig),
2088
+ taxonomy: createTaxonomyApi(apiConfig),
2089
+ form: createFormApi(apiConfig),
1838
2090
  setBusinessId: (businessId) => {
1839
2091
  apiConfig.businessId = businessId;
1840
2092
  },
@@ -1885,7 +2137,12 @@ async function createArkySDK(config) {
1885
2137
  // SVG utilities
1886
2138
  getSvgContentForAstro,
1887
2139
  fetchSvgContent,
1888
- injectSvgIntoElement
2140
+ injectSvgIntoElement,
2141
+ // Key validation utilities
2142
+ isValidKey,
2143
+ validateKey,
2144
+ toKey,
2145
+ nameToKey
1889
2146
  }
1890
2147
  };
1891
2148
  return sdk;
@@ -1894,6 +2151,7 @@ async function createArkySDK(config) {
1894
2151
  exports.PaymentMethodType = PaymentMethodType;
1895
2152
  exports.SDK_VERSION = SDK_VERSION;
1896
2153
  exports.SUPPORTED_FRAMEWORKS = SUPPORTED_FRAMEWORKS;
2154
+ exports.TaxonomyScope = TaxonomyScope;
1897
2155
  exports.createArkySDK = createArkySDK;
1898
2156
  //# sourceMappingURL=index.cjs.map
1899
2157
  //# sourceMappingURL=index.cjs.map