arky-sdk 0.3.126 → 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) => {
@@ -795,30 +801,11 @@ var createCmsApi = (apiConfig) => {
795
801
  options
796
802
  );
797
803
  },
798
- async sendNode(params, options) {
799
- const { nodeId, scheduledAt } = params;
800
- return apiConfig.httpClient.post(
801
- `/v1/businesses/${apiConfig.businessId}/nodes/${nodeId}/send`,
802
- {
803
- businessId: apiConfig.businessId,
804
- nodeId,
805
- scheduledAt: scheduledAt ?? Math.floor(Date.now() / 1e3)
806
- },
807
- options
808
- );
809
- },
810
804
  async getVariableMetadata(params, options) {
811
805
  return apiConfig.httpClient.get(
812
806
  `/v1/businesses/${apiConfig.businessId}/nodes/types/${params.nodeType}/variables`,
813
807
  options
814
808
  );
815
- },
816
- async getNodeSubscribers(params, options) {
817
- const formattedId = formatIdOrSlug(params.id, apiConfig);
818
- return apiConfig.httpClient.get(
819
- `/v1/businesses/${apiConfig.businessId}/nodes/${formattedId}/subscribers`,
820
- options
821
- );
822
809
  }
823
810
  };
824
811
  };
@@ -1278,6 +1265,387 @@ var createLocationApi = (apiConfig) => {
1278
1265
  };
1279
1266
  };
1280
1267
 
1268
+ // src/api/newsletter.ts
1269
+ var createNewsletterApi = (apiConfig) => {
1270
+ return {
1271
+ // ===== NEWSLETTER CRUD =====
1272
+ /**
1273
+ * Create a new newsletter
1274
+ */
1275
+ async createNewsletter(params, options) {
1276
+ return apiConfig.httpClient.post(
1277
+ `/v1/businesses/${apiConfig.businessId}/newsletters`,
1278
+ params,
1279
+ options
1280
+ );
1281
+ },
1282
+ /**
1283
+ * Get a newsletter by ID
1284
+ */
1285
+ async getNewsletter(params, options) {
1286
+ return apiConfig.httpClient.get(
1287
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${params.id}`,
1288
+ options
1289
+ );
1290
+ },
1291
+ /**
1292
+ * List all newsletters for the business
1293
+ */
1294
+ async getNewsletters(params, options) {
1295
+ return apiConfig.httpClient.get(
1296
+ `/v1/businesses/${apiConfig.businessId}/newsletters`,
1297
+ {
1298
+ ...options,
1299
+ params
1300
+ }
1301
+ );
1302
+ },
1303
+ /**
1304
+ * Update a newsletter
1305
+ */
1306
+ async updateNewsletter(params, options) {
1307
+ const { id, ...body } = params;
1308
+ return apiConfig.httpClient.put(
1309
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${id}`,
1310
+ body,
1311
+ options
1312
+ );
1313
+ },
1314
+ /**
1315
+ * Delete a newsletter
1316
+ */
1317
+ async deleteNewsletter(params, options) {
1318
+ return apiConfig.httpClient.delete(
1319
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${params.id}`,
1320
+ options
1321
+ );
1322
+ },
1323
+ /**
1324
+ * Get subscribers for a newsletter
1325
+ */
1326
+ async getSubscribers(params, options) {
1327
+ return apiConfig.httpClient.get(
1328
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${params.id}/subscribers`,
1329
+ options
1330
+ );
1331
+ },
1332
+ // ===== POST CRUD =====
1333
+ /**
1334
+ * Create a new post for a newsletter
1335
+ */
1336
+ async createPost(params, options) {
1337
+ const { newsletterId, ...body } = params;
1338
+ return apiConfig.httpClient.post(
1339
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${newsletterId}/posts`,
1340
+ body,
1341
+ options
1342
+ );
1343
+ },
1344
+ /**
1345
+ * Get a post by ID
1346
+ */
1347
+ async getPost(params, options) {
1348
+ return apiConfig.httpClient.get(
1349
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${params.newsletterId}/posts/${params.postId}`,
1350
+ options
1351
+ );
1352
+ },
1353
+ /**
1354
+ * List all posts for a newsletter
1355
+ */
1356
+ async getPosts(params, options) {
1357
+ const { newsletterId, ...queryParams } = params;
1358
+ return apiConfig.httpClient.get(
1359
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${newsletterId}/posts`,
1360
+ {
1361
+ ...options,
1362
+ params: queryParams
1363
+ }
1364
+ );
1365
+ },
1366
+ /**
1367
+ * Update a post
1368
+ */
1369
+ async updatePost(params, options) {
1370
+ const { newsletterId, postId, ...body } = params;
1371
+ return apiConfig.httpClient.put(
1372
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${newsletterId}/posts/${postId}`,
1373
+ body,
1374
+ options
1375
+ );
1376
+ },
1377
+ /**
1378
+ * Delete a post
1379
+ */
1380
+ async deletePost(params, options) {
1381
+ return apiConfig.httpClient.delete(
1382
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${params.newsletterId}/posts/${params.postId}`,
1383
+ options
1384
+ );
1385
+ },
1386
+ // ===== SEND OPERATIONS =====
1387
+ /**
1388
+ * Schedule a send for a post
1389
+ */
1390
+ async scheduleSend(params, options) {
1391
+ const { newsletterId, postId, ...body } = params;
1392
+ return apiConfig.httpClient.post(
1393
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${newsletterId}/posts/${postId}/send`,
1394
+ body,
1395
+ options
1396
+ );
1397
+ },
1398
+ /**
1399
+ * Cancel a scheduled send
1400
+ */
1401
+ async cancelSend(params, options) {
1402
+ const { newsletterId, postId, sendId } = params;
1403
+ return apiConfig.httpClient.post(
1404
+ `/v1/businesses/${apiConfig.businessId}/newsletters/${newsletterId}/posts/${postId}/send/${sendId}/cancel`,
1405
+ {},
1406
+ options
1407
+ );
1408
+ },
1409
+ // ===== CONVENIENCE METHODS =====
1410
+ /**
1411
+ * Publish a post (set status to PUBLISHED)
1412
+ */
1413
+ async publishPost(newsletterId, postId) {
1414
+ return this.updatePost({
1415
+ newsletterId,
1416
+ postId,
1417
+ status: "PUBLISHED"
1418
+ });
1419
+ },
1420
+ /**
1421
+ * Archive a post (set status to ARCHIVED)
1422
+ */
1423
+ async archivePost(newsletterId, postId) {
1424
+ return this.updatePost({
1425
+ newsletterId,
1426
+ postId,
1427
+ status: "ARCHIVED"
1428
+ });
1429
+ },
1430
+ /**
1431
+ * Send a post immediately
1432
+ */
1433
+ async sendNow(newsletterId, postId) {
1434
+ return this.scheduleSend({
1435
+ newsletterId,
1436
+ postId
1437
+ });
1438
+ }
1439
+ };
1440
+ };
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
+
1281
1649
  // src/utils/currency.ts
1282
1650
  function getCurrencySymbol(currency) {
1283
1651
  const currencySymbols = {
@@ -1634,6 +2002,35 @@ async function injectSvgIntoElement(mediaObject, targetElement, className) {
1634
2002
  }
1635
2003
  }
1636
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
+
1637
2034
  // src/index.ts
1638
2035
  var SDK_VERSION = "0.3.88";
1639
2036
  var SUPPORTED_FRAMEWORKS = [
@@ -1686,6 +2083,10 @@ async function createArkySDK(config) {
1686
2083
  database: createDatabaseApi(apiConfig),
1687
2084
  featureFlags: createFeatureFlagsApi(apiConfig),
1688
2085
  location: createLocationApi(apiConfig),
2086
+ newsletter: createNewsletterApi(apiConfig),
2087
+ emailTemplate: createEmailTemplateApi(apiConfig),
2088
+ taxonomy: createTaxonomyApi(apiConfig),
2089
+ form: createFormApi(apiConfig),
1689
2090
  setBusinessId: (businessId) => {
1690
2091
  apiConfig.businessId = businessId;
1691
2092
  },
@@ -1736,7 +2137,12 @@ async function createArkySDK(config) {
1736
2137
  // SVG utilities
1737
2138
  getSvgContentForAstro,
1738
2139
  fetchSvgContent,
1739
- injectSvgIntoElement
2140
+ injectSvgIntoElement,
2141
+ // Key validation utilities
2142
+ isValidKey,
2143
+ validateKey,
2144
+ toKey,
2145
+ nameToKey
1740
2146
  }
1741
2147
  };
1742
2148
  return sdk;
@@ -1745,6 +2151,7 @@ async function createArkySDK(config) {
1745
2151
  exports.PaymentMethodType = PaymentMethodType;
1746
2152
  exports.SDK_VERSION = SDK_VERSION;
1747
2153
  exports.SUPPORTED_FRAMEWORKS = SUPPORTED_FRAMEWORKS;
2154
+ exports.TaxonomyScope = TaxonomyScope;
1748
2155
  exports.createArkySDK = createArkySDK;
1749
2156
  //# sourceMappingURL=index.cjs.map
1750
2157
  //# sourceMappingURL=index.cjs.map