@aura-payments/sdk 2.1.1 → 2.2.0

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.mjs CHANGED
@@ -477,6 +477,74 @@ var Escrows = class {
477
477
  );
478
478
  }
479
479
  };
480
+
481
+ // src/resources/insights.ts
482
+ var Insights = class {
483
+ constructor(client) {
484
+ this.client = client;
485
+ }
486
+ /**
487
+ * Revenue, transactions, active escrows and commissions for a period, each
488
+ * with its change against the prior period.
489
+ *
490
+ * The route defaults to `7d`. `start` and `end` are ISO 8601 datetimes and are
491
+ * both required when `period` is `'custom'`.
492
+ */
493
+ async overview(period, start, end) {
494
+ const query = new URLSearchParams();
495
+ if (period !== void 0) query.set("period", period);
496
+ if (start !== void 0) query.set("start", start);
497
+ if (end !== void 0) query.set("end", end);
498
+ const qs = query.toString();
499
+ return this.client["request"](
500
+ "GET",
501
+ qs ? `/v1/insights/overview?${qs}` : "/v1/insights/overview"
502
+ );
503
+ }
504
+ /**
505
+ * Forecast a metric over a horizon. Gated to Growth+ plans; lower tiers
506
+ * surface a 403 `AuraAPIError`.
507
+ */
508
+ async forecast(params) {
509
+ const query = new URLSearchParams();
510
+ query.set("metric", params.metric);
511
+ if (params.algorithm !== void 0) query.set("algorithm", params.algorithm);
512
+ if (params.period !== void 0) query.set("period", params.period);
513
+ if (params.horizon !== void 0) query.set("horizon", params.horizon.toString());
514
+ if (params.includeHistory !== void 0) {
515
+ query.set("includeHistory", String(params.includeHistory));
516
+ }
517
+ if (params.historyPeriods !== void 0) {
518
+ query.set("historyPeriods", params.historyPeriods.toString());
519
+ }
520
+ return this.client["request"](
521
+ "GET",
522
+ `/v1/insights/forecast?${query.toString()}`
523
+ );
524
+ }
525
+ /**
526
+ * Query the account audit log by action, actor, resource and date range.
527
+ *
528
+ * The route defaults to `range: '30d'`, `page: 1`, `limit: 50`.
529
+ */
530
+ async audit(params) {
531
+ const query = new URLSearchParams();
532
+ if (params?.action !== void 0) query.set("action", params.action);
533
+ if (params?.actor !== void 0) query.set("actor", params.actor);
534
+ if (params?.resourceType !== void 0) query.set("resourceType", params.resourceType);
535
+ if (params?.resourceId !== void 0) query.set("resourceId", params.resourceId);
536
+ if (params?.range !== void 0) query.set("range", params.range);
537
+ if (params?.start !== void 0) query.set("start", params.start);
538
+ if (params?.end !== void 0) query.set("end", params.end);
539
+ if (params?.page !== void 0) query.set("page", params.page.toString());
540
+ if (params?.limit !== void 0) query.set("limit", params.limit.toString());
541
+ const qs = query.toString();
542
+ return this.client["request"](
543
+ "GET",
544
+ qs ? `/v1/insights/audit?${qs}` : "/v1/insights/audit"
545
+ );
546
+ }
547
+ };
480
548
  var Mandates = class {
481
549
  constructor(client) {
482
550
  this.client = client;
@@ -602,6 +670,24 @@ var Policies = class {
602
670
  }
603
671
  };
604
672
 
673
+ // src/resources/treasury.ts
674
+ var Treasury = class {
675
+ constructor(client) {
676
+ this.client = client;
677
+ }
678
+ /**
679
+ * Analyze treasury balances, escrow exposure and pending payouts, and return
680
+ * an AI recommendation. Moves no funds.
681
+ *
682
+ * A POST with no body — the platform derives everything from the authenticated
683
+ * account. Gated to Growth+ plans; lower tiers surface a 403 `AuraAPIError`
684
+ * with code `feature_not_available`.
685
+ */
686
+ async optimize() {
687
+ return this.client["request"]("POST", "/v1/treasury/optimize");
688
+ }
689
+ };
690
+
605
691
  // src/resources/wallets.ts
606
692
  var Wallets = class {
607
693
  constructor(client) {
@@ -804,6 +890,73 @@ var Webhooks = class {
804
890
  }
805
891
  };
806
892
 
893
+ // src/resources/withdrawals.ts
894
+ var Withdrawals = class {
895
+ constructor(client) {
896
+ this.client = client;
897
+ }
898
+ /**
899
+ * Get a single withdrawal, including status, fees, destination and tx hash.
900
+ */
901
+ async get(withdrawalId) {
902
+ return this.client["request"](
903
+ "GET",
904
+ `/v1/withdrawals/${encodeURIComponent(withdrawalId)}`
905
+ );
906
+ }
907
+ /**
908
+ * List withdrawals for the account, most recent first.
909
+ *
910
+ * Returns the whole `{withdrawals, pagination}` envelope — this route does not
911
+ * use the `{success,data}` wrapper, so pagination metadata is preserved.
912
+ */
913
+ async list(params) {
914
+ const query = new URLSearchParams();
915
+ if (params?.limit !== void 0) query.set("limit", params.limit.toString());
916
+ if (params?.offset !== void 0) query.set("offset", params.offset.toString());
917
+ if (params?.status !== void 0) query.set("status", params.status);
918
+ if (params?.chain !== void 0) query.set("chain", params.chain);
919
+ if (params?.fromDate !== void 0) query.set("fromDate", params.fromDate);
920
+ if (params?.toDate !== void 0) query.set("toDate", params.toDate);
921
+ const qs = query.toString();
922
+ return this.client["request"](
923
+ "GET",
924
+ qs ? `/v1/withdrawals?${qs}` : "/v1/withdrawals"
925
+ );
926
+ }
927
+ /**
928
+ * Preview fees and net amount for a withdrawal WITHOUT creating it.
929
+ *
930
+ * `params.exchange` is required by the route when `destinationType` is
931
+ * `'exchange'`; cross-chain estimates (source ≠ destination) add a CCTP
932
+ * bridge fee and only the supported routes are accepted.
933
+ */
934
+ async estimate(params) {
935
+ return this.client["request"](
936
+ "POST",
937
+ "/v1/withdrawals/estimate",
938
+ params
939
+ );
940
+ }
941
+ /**
942
+ * Get the account's KYC-tier withdrawal limits and remaining allowance.
943
+ */
944
+ async limits() {
945
+ return this.client["request"]("GET", "/v1/withdrawals/limits");
946
+ }
947
+ /**
948
+ * Validate a destination address for a chain. Moves no funds; when `amount` is
949
+ * supplied the response also carries a fee preview.
950
+ */
951
+ async validate(params) {
952
+ return this.client["request"](
953
+ "POST",
954
+ "/v1/withdrawals/validate",
955
+ params
956
+ );
957
+ }
958
+ };
959
+
807
960
  // src/client.ts
808
961
  var AuraClient = class _AuraClient {
809
962
  constructor(config) {
@@ -821,6 +974,9 @@ var AuraClient = class _AuraClient {
821
974
  this.agents = new Agents(this);
822
975
  this.policies = new Policies(this);
823
976
  this.mandates = new Mandates(this);
977
+ this.withdrawals = new Withdrawals(this);
978
+ this.treasury = new Treasury(this);
979
+ this.insights = new Insights(this);
824
980
  }
825
981
  /**
826
982
  * Normalize the base URL so resource paths like `/v1/escrow` reach the
@@ -983,4 +1139,4 @@ var AuraClient = class _AuraClient {
983
1139
  }
984
1140
  };
985
1141
 
986
- export { Agents, AuraAPIError, AuraAuthenticationError, AuraClient, AuraError, AuraFaucetUnavailableError, AuraNetworkError, AuraNotFoundError, AuraRateLimitError, AuraTimeoutError, AuraValidationError, Escrows, MandateSignature, Mandates, Policies, Wallets, Webhooks, calculateBackoff, generateIdempotencyKey, isAuraAPIError, isAuraError, isAuraFaucetUnavailableError, isAuraNetworkError, isAuraTimeoutError, isRetryableError, retryWithBackoff, withTimeout };
1142
+ export { Agents, AuraAPIError, AuraAuthenticationError, AuraClient, AuraError, AuraFaucetUnavailableError, AuraNetworkError, AuraNotFoundError, AuraRateLimitError, AuraTimeoutError, AuraValidationError, Escrows, Insights, MandateSignature, Mandates, Policies, Treasury, Wallets, Webhooks, Withdrawals, calculateBackoff, generateIdempotencyKey, isAuraAPIError, isAuraError, isAuraFaucetUnavailableError, isAuraNetworkError, isAuraTimeoutError, isRetryableError, retryWithBackoff, withTimeout };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aura-payments/sdk",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "TypeScript SDK for Aura Payments Platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",