@dakota-xyz/ts-sdk 2.0.0 → 2.1.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/README.md +33 -2
- package/dist/index.d.mts +20463 -1597
- package/dist/index.d.ts +20463 -1597
- package/dist/index.js +434 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +433 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -676,12 +676,87 @@ var CustomersResource = class extends BaseResource {
|
|
|
676
676
|
path: `/customers/${customerId}`
|
|
677
677
|
});
|
|
678
678
|
}
|
|
679
|
+
/**
|
|
680
|
+
* Delete a customer record.
|
|
681
|
+
*
|
|
682
|
+
* Soft-deletes the customer. Blocked with a 409 if the customer still has
|
|
683
|
+
* associated accounts, or is referenced as a sub-client by another customer.
|
|
684
|
+
*
|
|
685
|
+
* @param customerId - Customer ID (KSUID)
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* ```typescript
|
|
689
|
+
* await client.customers.delete('cust_abc123');
|
|
690
|
+
* ```
|
|
691
|
+
*/
|
|
692
|
+
async delete(customerId) {
|
|
693
|
+
await this.transport.request({
|
|
694
|
+
method: "DELETE",
|
|
695
|
+
path: `/customers/${customerId}`
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* List a customer's capabilities and what is still needed to unlock each.
|
|
700
|
+
*
|
|
701
|
+
* Returns the customer's rails (e.g. `international_wire`) with a status and
|
|
702
|
+
* the OUTSTANDING requirements — terms to accept, documents to upload — that
|
|
703
|
+
* gate them. Partner-agnostic: requirements are keyed by an opaque terms id
|
|
704
|
+
* or document type, never a provider or partner name.
|
|
705
|
+
*
|
|
706
|
+
* @param customerId - Customer ID (KSUID)
|
|
707
|
+
* @returns The customer's capabilities and their outstanding requirements
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```typescript
|
|
711
|
+
* const { capabilities } = await client.customers.getCapabilities(customerId);
|
|
712
|
+
* for (const cap of capabilities) {
|
|
713
|
+
* if (cap.status !== 'action_required') continue;
|
|
714
|
+
* for (const req of cap.requirements) {
|
|
715
|
+
* console.log(`${cap.capability}: ${req.title} → ${req.url}`);
|
|
716
|
+
* }
|
|
717
|
+
* }
|
|
718
|
+
* ```
|
|
719
|
+
*/
|
|
720
|
+
async getCapabilities(customerId) {
|
|
721
|
+
return this.transport.request({
|
|
722
|
+
method: "GET",
|
|
723
|
+
path: `/customers/${customerId}/capabilities`
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Mint a fresh application link for re-engaging an APPROVED customer.
|
|
728
|
+
*
|
|
729
|
+
* Issues a new onboarding token for an existing approved customer's
|
|
730
|
+
* application and returns the rebuilt `application_url` — use it when the
|
|
731
|
+
* original token has expired and the customer needs to come back through
|
|
732
|
+
* the hosted flow (e.g. to accept outstanding partner disclosures).
|
|
733
|
+
*
|
|
734
|
+
* @param customerId - Customer ID (KSUID)
|
|
735
|
+
* @param options - Request options (e.g., custom idempotency key)
|
|
736
|
+
* @returns The rebuilt application URL
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* ```typescript
|
|
740
|
+
* const { application_url } = await client.customers.reEngage(customerId);
|
|
741
|
+
* ```
|
|
742
|
+
*/
|
|
743
|
+
async reEngage(customerId, options) {
|
|
744
|
+
return this.transport.request({
|
|
745
|
+
method: "POST",
|
|
746
|
+
path: `/customers/${customerId}/re-engagement`,
|
|
747
|
+
idempotencyKey: options?.idempotencyKey
|
|
748
|
+
});
|
|
749
|
+
}
|
|
679
750
|
/**
|
|
680
751
|
* Update the sub-client association for a customer.
|
|
681
752
|
*
|
|
682
753
|
* Associates or disassociates a customer with a sub-client.
|
|
683
754
|
* Set `sub_client_id` to associate, or set it to `null` to disassociate.
|
|
684
755
|
*
|
|
756
|
+
* @deprecated The sub-client association can only be set when a customer is
|
|
757
|
+
* created (`is_sub_client` / `sub_client_id` on `create`) and can no longer
|
|
758
|
+
* be changed afterwards — this endpoint now returns 400.
|
|
759
|
+
*
|
|
685
760
|
* @param customerId - Customer ID (KSUID)
|
|
686
761
|
* @param data - Sub-client association data
|
|
687
762
|
* @param options - Request options (e.g., custom idempotency key)
|
|
@@ -758,6 +833,93 @@ var CustomersResource = class extends BaseResource {
|
|
|
758
833
|
idempotencyKey: options?.idempotencyKey
|
|
759
834
|
});
|
|
760
835
|
}
|
|
836
|
+
/**
|
|
837
|
+
* Import customers from Persona Connect share tokens (`cnst_...`).
|
|
838
|
+
*
|
|
839
|
+
* Unlike the Sumsub import, Persona redemption is asynchronous on Persona's
|
|
840
|
+
* side, so this returns a JOB immediately (HTTP 202). Poll
|
|
841
|
+
* `getPersonaImportJob` for per-token results. Up to 5,000 tokens per
|
|
842
|
+
* request — split larger migrations into multiple batches.
|
|
843
|
+
*
|
|
844
|
+
* Tokens are validated and de-duplicated up front, and a skipped token
|
|
845
|
+
* never blocks an accepted one. A `skipped` entry is about the token STRING
|
|
846
|
+
* (malformed, duplicated in the batch, or already imported) — it is never a
|
|
847
|
+
* compliance decision about a person or application.
|
|
848
|
+
*
|
|
849
|
+
* @param data - The share tokens to import
|
|
850
|
+
* @param options - Request options (e.g., custom idempotency key)
|
|
851
|
+
* @returns The queued job, with any tokens that could not be enqueued
|
|
852
|
+
*
|
|
853
|
+
* @example
|
|
854
|
+
* ```typescript
|
|
855
|
+
* const job = await client.customers.importPersonaTokens({
|
|
856
|
+
* tokens: ['cnst_ABC123def456', 'cnst_GHI789jkl012'],
|
|
857
|
+
* });
|
|
858
|
+
* console.log(`${job.accepted}/${job.total} queued as ${job.job_id}`);
|
|
859
|
+
* ```
|
|
860
|
+
*/
|
|
861
|
+
async importPersonaTokens(data, options) {
|
|
862
|
+
return this.transport.request({
|
|
863
|
+
method: "POST",
|
|
864
|
+
path: "/customers/import-persona-tokens",
|
|
865
|
+
body: data,
|
|
866
|
+
idempotencyKey: options?.idempotencyKey
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* List this client's Persona share-token import jobs, newest first.
|
|
871
|
+
*
|
|
872
|
+
* This endpoint pages on its own cursor (`starting_after` + `has_more`), not
|
|
873
|
+
* the standard list envelope, so it returns a single page rather than an
|
|
874
|
+
* async iterator.
|
|
875
|
+
*
|
|
876
|
+
* @param params - Optional `limit` and `starting_after` job-id cursor
|
|
877
|
+
* @returns One page of job summaries plus a `has_more` flag
|
|
878
|
+
*
|
|
879
|
+
* @example
|
|
880
|
+
* ```typescript
|
|
881
|
+
* const { jobs, has_more } = await client.customers.listPersonaImportJobs({ limit: 20 });
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
884
|
+
async listPersonaImportJobs(params) {
|
|
885
|
+
return this.transport.request({
|
|
886
|
+
method: "GET",
|
|
887
|
+
path: "/customers/persona-import-jobs",
|
|
888
|
+
query: { ...params }
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Get a Persona import job's status and its per-token results.
|
|
893
|
+
*
|
|
894
|
+
* Result rows page on a row-index cursor: pass the last row's `index` as
|
|
895
|
+
* `results_after_index` while `has_more_results` is true.
|
|
896
|
+
*
|
|
897
|
+
* @param jobId - Import job ID (`pij_...`)
|
|
898
|
+
* @param params - Optional `results_limit` (1-500) and `results_after_index`
|
|
899
|
+
* @returns Job status, row counts, and one page of result rows
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* ```typescript
|
|
903
|
+
* let after: number | undefined;
|
|
904
|
+
* do {
|
|
905
|
+
* const job = await client.customers.getPersonaImportJob(jobId, {
|
|
906
|
+
* results_after_index: after,
|
|
907
|
+
* });
|
|
908
|
+
* for (const row of job.results ?? []) {
|
|
909
|
+
* if (row.state === 'failed') console.error(row.token, row.error);
|
|
910
|
+
* after = row.index;
|
|
911
|
+
* }
|
|
912
|
+
* if (!job.has_more_results) break;
|
|
913
|
+
* } while (true);
|
|
914
|
+
* ```
|
|
915
|
+
*/
|
|
916
|
+
async getPersonaImportJob(jobId, params) {
|
|
917
|
+
return this.transport.request({
|
|
918
|
+
method: "GET",
|
|
919
|
+
path: `/customers/persona-import-jobs/${jobId}`,
|
|
920
|
+
query: { ...params }
|
|
921
|
+
});
|
|
922
|
+
}
|
|
761
923
|
};
|
|
762
924
|
|
|
763
925
|
// src/client/resources/recipients.ts
|
|
@@ -1522,8 +1684,18 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1522
1684
|
/**
|
|
1523
1685
|
* Submit an attestation for an application.
|
|
1524
1686
|
*
|
|
1687
|
+
* Additionally supplying `disclosure_id` (a terms key the provider
|
|
1688
|
+
* declared, e.g. `partner_disclosures`) and `disclosure_version` records the
|
|
1689
|
+
* attestation as a PARTNER DISCLOSURE acknowledgment instead of a standard
|
|
1690
|
+
* onboarding one: acceptance is stamped `customer_online`, the
|
|
1691
|
+
* partner-onboarding substatus advances, and an already-approved
|
|
1692
|
+
* application is reprovisioned. The API stays partner-agnostic — callers
|
|
1693
|
+
* supply a terms key and version, never a partner name. Get the outstanding
|
|
1694
|
+
* ones from `customers.getCapabilities(customerId)`.
|
|
1695
|
+
*
|
|
1525
1696
|
* @param applicationId - Application ID
|
|
1526
|
-
* @param data - Attestation data (type, timestamp, applicant_id)
|
|
1697
|
+
* @param data - Attestation data (type, timestamp, applicant_id), plus
|
|
1698
|
+
* `disclosure_id` + `disclosure_version` to accept a partner disclosure
|
|
1527
1699
|
*/
|
|
1528
1700
|
async submitAttestation(applicationId, data, options) {
|
|
1529
1701
|
await this.transport.request({
|
|
@@ -1895,13 +2067,27 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
1895
2067
|
/**
|
|
1896
2068
|
* Get a signer group by ID.
|
|
1897
2069
|
*
|
|
2070
|
+
* Pass `{ include_removed: true }` to also get a `removed_members` array of
|
|
2071
|
+
* signers that were removed from this group, each carrying its `removed_at`
|
|
2072
|
+
* timestamp. Defaults to active members only.
|
|
2073
|
+
*
|
|
1898
2074
|
* @param signerGroupId - Signer group ID
|
|
2075
|
+
* @param params - Optional `{ include_removed }`
|
|
1899
2076
|
* @returns Signer group record
|
|
2077
|
+
*
|
|
2078
|
+
* @example
|
|
2079
|
+
* ```typescript
|
|
2080
|
+
* const group = await client.signerGroups.get(groupId, { include_removed: true });
|
|
2081
|
+
* for (const s of group.removed_members ?? []) {
|
|
2082
|
+
* console.log(s.name, 'removed at', s.removed_at);
|
|
2083
|
+
* }
|
|
2084
|
+
* ```
|
|
1900
2085
|
*/
|
|
1901
|
-
async get(signerGroupId) {
|
|
2086
|
+
async get(signerGroupId, params) {
|
|
1902
2087
|
return this.transport.request({
|
|
1903
2088
|
method: "GET",
|
|
1904
|
-
path: `/signer-groups/${signerGroupId}
|
|
2089
|
+
path: `/signer-groups/${signerGroupId}`,
|
|
2090
|
+
query: { ...params }
|
|
1905
2091
|
});
|
|
1906
2092
|
}
|
|
1907
2093
|
/**
|
|
@@ -1927,7 +2113,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
1927
2113
|
* Remove a signer from a group.
|
|
1928
2114
|
*
|
|
1929
2115
|
* @param signerGroupId - Signer group ID
|
|
1930
|
-
* @param signerId -
|
|
2116
|
+
* @param signerId - The signer's KSUID `signer_id` — NOT its public key.
|
|
2117
|
+
* (The standalone `client.signers.delete()` takes the public key instead.)
|
|
1931
2118
|
* @param options - Optional request options (e.g. an explicit idempotency
|
|
1932
2119
|
* key — the platform requires one on this DELETE)
|
|
1933
2120
|
*/
|
|
@@ -2632,6 +2819,74 @@ var SelfServeResource = class extends BaseResource {
|
|
|
2632
2819
|
}
|
|
2633
2820
|
};
|
|
2634
2821
|
|
|
2822
|
+
// src/client/resources/fee-payout-destination.ts
|
|
2823
|
+
var FeePayoutDestinationResource = class extends BaseResource {
|
|
2824
|
+
/**
|
|
2825
|
+
* Get the destination registered to receive your developer-fee payouts.
|
|
2826
|
+
*
|
|
2827
|
+
* @returns The registered destination
|
|
2828
|
+
*
|
|
2829
|
+
* @example
|
|
2830
|
+
* ```typescript
|
|
2831
|
+
* const dest = await client.feePayoutDestination.get();
|
|
2832
|
+
* console.log(dest.chain, dest.wallet_address);
|
|
2833
|
+
* ```
|
|
2834
|
+
*/
|
|
2835
|
+
async get() {
|
|
2836
|
+
return this.transport.request({
|
|
2837
|
+
method: "GET",
|
|
2838
|
+
path: "/fee-payout-destination"
|
|
2839
|
+
});
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2842
|
+
* Register or replace your fee payout destination.
|
|
2843
|
+
*
|
|
2844
|
+
* There is exactly one destination per organization, so this REPLACES any
|
|
2845
|
+
* existing one. Emits `fee_payout_destination.updated`.
|
|
2846
|
+
*
|
|
2847
|
+
* `chain` is a CAIP-2 chain id (e.g. `eip155:8453`) from the supported
|
|
2848
|
+
* networks list — see `client.info.getNetworks()`.
|
|
2849
|
+
*
|
|
2850
|
+
* @param data - The USDC wallet to pay fees to
|
|
2851
|
+
* @param options - Request options (e.g., custom idempotency key)
|
|
2852
|
+
* @returns The stored destination
|
|
2853
|
+
*
|
|
2854
|
+
* @example
|
|
2855
|
+
* ```typescript
|
|
2856
|
+
* const dest = await client.feePayoutDestination.set({
|
|
2857
|
+
* usdc_wallet: {
|
|
2858
|
+
* chain: 'eip155:8453',
|
|
2859
|
+
* address: '0x1234567890123456789012345678901234567890',
|
|
2860
|
+
* },
|
|
2861
|
+
* });
|
|
2862
|
+
* ```
|
|
2863
|
+
*/
|
|
2864
|
+
async set(data, options) {
|
|
2865
|
+
return this.transport.request({
|
|
2866
|
+
method: "PUT",
|
|
2867
|
+
path: "/fee-payout-destination",
|
|
2868
|
+
body: data,
|
|
2869
|
+
idempotencyKey: options?.idempotencyKey
|
|
2870
|
+
});
|
|
2871
|
+
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Remove the registered fee payout destination, if one exists.
|
|
2874
|
+
*
|
|
2875
|
+
* Emits `fee_payout_destination.deleted`.
|
|
2876
|
+
*
|
|
2877
|
+
* @example
|
|
2878
|
+
* ```typescript
|
|
2879
|
+
* await client.feePayoutDestination.delete();
|
|
2880
|
+
* ```
|
|
2881
|
+
*/
|
|
2882
|
+
async delete() {
|
|
2883
|
+
await this.transport.request({
|
|
2884
|
+
method: "DELETE",
|
|
2885
|
+
path: "/fee-payout-destination"
|
|
2886
|
+
});
|
|
2887
|
+
}
|
|
2888
|
+
};
|
|
2889
|
+
|
|
2635
2890
|
// src/client/resources/payment-agents.ts
|
|
2636
2891
|
var PaymentAgentsResource = class extends BaseResource {
|
|
2637
2892
|
/**
|
|
@@ -2708,6 +2963,41 @@ var PaymentAgentsResource = class extends BaseResource {
|
|
|
2708
2963
|
idempotencyKey: options?.idempotencyKey
|
|
2709
2964
|
});
|
|
2710
2965
|
}
|
|
2966
|
+
/**
|
|
2967
|
+
* Live progress of an in-flight drafting turn.
|
|
2968
|
+
*
|
|
2969
|
+
* A multi-payee drafting turn legitimately runs minutes (several sequential
|
|
2970
|
+
* model calls). While a `createProposals` call is in flight, poll this every
|
|
2971
|
+
* few seconds to show the customer what the agent is doing right now.
|
|
2972
|
+
*
|
|
2973
|
+
* Advisory display only. `active: false` means no turn is currently
|
|
2974
|
+
* publishing progress for this agent — idle, just finished, or served by
|
|
2975
|
+
* another instance — so fall back to a generic spinner. Never gate any
|
|
2976
|
+
* behaviour on this endpoint.
|
|
2977
|
+
*
|
|
2978
|
+
* The snapshot is coarse and customer-safe: a phase enum, one human
|
|
2979
|
+
* sentence, and the model round. Tool counts only — never payee names,
|
|
2980
|
+
* amounts, or addresses.
|
|
2981
|
+
*
|
|
2982
|
+
* @param paymentAgentId - Payment agent ID
|
|
2983
|
+
* @returns The current progress snapshot
|
|
2984
|
+
*
|
|
2985
|
+
* @example
|
|
2986
|
+
* ```typescript
|
|
2987
|
+
* const pending = client.paymentAgents.createProposals(agentId, { prompt });
|
|
2988
|
+
* const poll = setInterval(async () => {
|
|
2989
|
+
* const p = await client.paymentAgents.getProposalsProgress(agentId);
|
|
2990
|
+
* if (p.active) console.log(p.detail);
|
|
2991
|
+
* }, 3000);
|
|
2992
|
+
* const result = await pending.finally(() => clearInterval(poll));
|
|
2993
|
+
* ```
|
|
2994
|
+
*/
|
|
2995
|
+
async getProposalsProgress(paymentAgentId) {
|
|
2996
|
+
return this.transport.request({
|
|
2997
|
+
method: "GET",
|
|
2998
|
+
path: `/payment-agents/${paymentAgentId}/proposals/progress`
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
2711
3001
|
};
|
|
2712
3002
|
|
|
2713
3003
|
// src/client/resources/instructions.ts
|
|
@@ -2824,6 +3114,102 @@ var MandatesResource = class extends BaseResource {
|
|
|
2824
3114
|
idempotencyKey: options?.idempotencyKey
|
|
2825
3115
|
});
|
|
2826
3116
|
}
|
|
3117
|
+
/**
|
|
3118
|
+
* Amend a mandate — append a new signed version of its rule.
|
|
3119
|
+
*
|
|
3120
|
+
* Carries a changed rule into force with ONE signature and WITHOUT resetting
|
|
3121
|
+
* the spend already made in the current window: usage accrues to the
|
|
3122
|
+
* MANDATE, so an agent that has spent 9,000 of a 10,000 monthly limit and is
|
|
3123
|
+
* amended to 20,000 has 11,000 left, not 20,000.
|
|
3124
|
+
*
|
|
3125
|
+
* The `rule` is stored and verified VERBATIM — this endpoint does not
|
|
3126
|
+
* normalize it. It must already be canonical: `window` present and non-empty
|
|
3127
|
+
* (send `'NONE'` for a lifetime window), `targets` as recipient ids rather
|
|
3128
|
+
* than payee names, and `asset` uppercase. `target_type`, `window`, `asset`
|
|
3129
|
+
* and `network_id` must also match the current version exactly; only the
|
|
3130
|
+
* amount fields and `targets` may differ. Anything else is a 400 naming the
|
|
3131
|
+
* offending field.
|
|
3132
|
+
*
|
|
3133
|
+
* Build `signature` from `mandateAmendSignPayload(mandate, version, rule)` —
|
|
3134
|
+
* the amend payload commits to the version being created, so a signature for
|
|
3135
|
+
* v2 can never be replayed to append v3.
|
|
3136
|
+
*
|
|
3137
|
+
* @param mandateId - Mandate ID
|
|
3138
|
+
* @param data - Amending signer public key + signature + the complete NEW rule
|
|
3139
|
+
* @returns The mandate at its new current version
|
|
3140
|
+
*
|
|
3141
|
+
* @example
|
|
3142
|
+
* ```typescript
|
|
3143
|
+
* const mandate = await client.mandates.get(mandateId);
|
|
3144
|
+
* const nextVersion = (mandate.version ?? 1) + 1;
|
|
3145
|
+
* const rule = { ...mandate.rule, max_amount_in_window: '20000' };
|
|
3146
|
+
* const payload = mandateAmendSignPayload(mandate, nextVersion, rule);
|
|
3147
|
+
*
|
|
3148
|
+
* const amended = await client.mandates.amend(mandateId, {
|
|
3149
|
+
* signer_public_key: signer.publicKeyBase64(),
|
|
3150
|
+
* signature: await signer.sign(payload),
|
|
3151
|
+
* rule,
|
|
3152
|
+
* });
|
|
3153
|
+
* ```
|
|
3154
|
+
*/
|
|
3155
|
+
async amend(mandateId, data, options) {
|
|
3156
|
+
return this.transport.request({
|
|
3157
|
+
method: "POST",
|
|
3158
|
+
path: `/mandates/${mandateId}/amend`,
|
|
3159
|
+
body: data,
|
|
3160
|
+
idempotencyKey: options?.idempotencyKey
|
|
3161
|
+
});
|
|
3162
|
+
}
|
|
3163
|
+
/**
|
|
3164
|
+
* List a mandate's versions, oldest first.
|
|
3165
|
+
*
|
|
3166
|
+
* The append-only history of every rule that was ever in force under this
|
|
3167
|
+
* mandate, and the §8 signer that put each one there. Versions are
|
|
3168
|
+
* immutable, so a rule listed here never changes — this is what makes an
|
|
3169
|
+
* executed payment's `mandate_version` audit stamp legible.
|
|
3170
|
+
*
|
|
3171
|
+
* @param mandateId - Mandate ID
|
|
3172
|
+
* @returns Every version, oldest first
|
|
3173
|
+
*/
|
|
3174
|
+
async listVersions(mandateId) {
|
|
3175
|
+
return this.transport.request({
|
|
3176
|
+
method: "GET",
|
|
3177
|
+
path: `/mandates/${mandateId}/versions`
|
|
3178
|
+
});
|
|
3179
|
+
}
|
|
3180
|
+
/**
|
|
3181
|
+
* Get a mandate's remaining budget right now.
|
|
3182
|
+
*
|
|
3183
|
+
* The mandate's `rule` gives the ceilings; this gives the CONSUMPTION — what
|
|
3184
|
+
* has already been spent, what is earmarked by scheduled payments that have
|
|
3185
|
+
* not fired yet, and therefore what is left. Read it before scheduling:
|
|
3186
|
+
* otherwise an over-budget payment is only discovered when the gate denies
|
|
3187
|
+
* it at its due date, days later, with the payee unpaid.
|
|
3188
|
+
*
|
|
3189
|
+
* Advisory — nothing here reserves budget, and the gate remains the
|
|
3190
|
+
* authority at fire time. Two things to honour when reading a line:
|
|
3191
|
+
* an ABSENT `remaining_amount` / `remaining_count` means "not capped", never
|
|
3192
|
+
* "nothing left"; a `remaining_amount` of `'?'` means the figure could not
|
|
3193
|
+
* be summed and MUST be treated as no headroom (the gate fails closed on the
|
|
3194
|
+
* same data).
|
|
3195
|
+
*
|
|
3196
|
+
* @param mandateId - Mandate ID
|
|
3197
|
+
* @returns Per-target and aggregate budget lines, as of a stated instant
|
|
3198
|
+
*
|
|
3199
|
+
* @example
|
|
3200
|
+
* ```typescript
|
|
3201
|
+
* const budget = await client.mandates.getBudget(mandateId);
|
|
3202
|
+
* for (const line of budget.aggregate) {
|
|
3203
|
+
* console.log(line.bucket, line.remaining_amount ?? 'uncapped');
|
|
3204
|
+
* }
|
|
3205
|
+
* ```
|
|
3206
|
+
*/
|
|
3207
|
+
async getBudget(mandateId) {
|
|
3208
|
+
return this.transport.request({
|
|
3209
|
+
method: "GET",
|
|
3210
|
+
path: `/mandates/${mandateId}/budget`
|
|
3211
|
+
});
|
|
3212
|
+
}
|
|
2827
3213
|
};
|
|
2828
3214
|
|
|
2829
3215
|
// src/client/resources/scheduled-payments.ts
|
|
@@ -2927,10 +3313,12 @@ var InsightsResource = class extends BaseResource {
|
|
|
2927
3313
|
var AgentConversation = class {
|
|
2928
3314
|
client;
|
|
2929
3315
|
paymentAgentId;
|
|
3316
|
+
timezone;
|
|
2930
3317
|
history = [];
|
|
2931
|
-
constructor(client, paymentAgentId, history) {
|
|
3318
|
+
constructor(client, paymentAgentId, history, options) {
|
|
2932
3319
|
this.client = client;
|
|
2933
3320
|
this.paymentAgentId = paymentAgentId;
|
|
3321
|
+
this.timezone = options?.timezone;
|
|
2934
3322
|
if (history && history.length > 0) {
|
|
2935
3323
|
this.history = history.map(cloneMessage);
|
|
2936
3324
|
}
|
|
@@ -2972,7 +3360,10 @@ var AgentConversation = class {
|
|
|
2972
3360
|
let result;
|
|
2973
3361
|
try {
|
|
2974
3362
|
result = await this.client.paymentAgents.createProposals(this.paymentAgentId, {
|
|
2975
|
-
messages
|
|
3363
|
+
messages,
|
|
3364
|
+
// Resent on EVERY turn — the endpoint is stateless, so a zone given
|
|
3365
|
+
// once would be forgotten on the next one.
|
|
3366
|
+
...this.timezone ? { timezone: this.timezone } : {}
|
|
2976
3367
|
});
|
|
2977
3368
|
} catch (err) {
|
|
2978
3369
|
this.history.pop();
|
|
@@ -3113,6 +3504,8 @@ var DakotaClient = class {
|
|
|
3113
3504
|
sandbox;
|
|
3114
3505
|
/** Self-Serve Credits API - manage prepaid transfer credits */
|
|
3115
3506
|
selfServe;
|
|
3507
|
+
/** Fee Payout Destination API - where Dakota pays your accrued developer fees */
|
|
3508
|
+
feePayoutDestination;
|
|
3116
3509
|
/** Payment Agents API (ALPHA) - hosted signing agents that draft payments */
|
|
3117
3510
|
paymentAgents;
|
|
3118
3511
|
/** Instructions API (ALPHA) - accept and inspect actuated proposals */
|
|
@@ -3176,6 +3569,7 @@ var DakotaClient = class {
|
|
|
3176
3569
|
this.info = new InfoResource(this.transport);
|
|
3177
3570
|
this.sandbox = new SandboxResource(this.transport);
|
|
3178
3571
|
this.selfServe = new SelfServeResource(this.transport);
|
|
3572
|
+
this.feePayoutDestination = new FeePayoutDestinationResource(this.transport);
|
|
3179
3573
|
this.paymentAgents = new PaymentAgentsResource(this.transport);
|
|
3180
3574
|
this.instructions = new InstructionsResource(this.transport);
|
|
3181
3575
|
this.mandates = new MandatesResource(this.transport);
|
|
@@ -3192,17 +3586,24 @@ var DakotaClient = class {
|
|
|
3192
3586
|
/**
|
|
3193
3587
|
* Start a fresh multi-turn conversation with a payment agent.
|
|
3194
3588
|
*
|
|
3589
|
+
* Pass `{ timezone }` (an IANA zone) so the agent resolves "tomorrow" and
|
|
3590
|
+
* "10 am" in the customer's local time rather than UTC. The conversation
|
|
3591
|
+
* resends it on every turn.
|
|
3592
|
+
*
|
|
3195
3593
|
* @see AgentConversation
|
|
3196
3594
|
*/
|
|
3197
|
-
newAgentConversation(paymentAgentId) {
|
|
3198
|
-
return new AgentConversation(this, paymentAgentId);
|
|
3595
|
+
newAgentConversation(paymentAgentId, options) {
|
|
3596
|
+
return new AgentConversation(this, paymentAgentId, void 0, options);
|
|
3199
3597
|
}
|
|
3200
3598
|
/**
|
|
3201
3599
|
* Rebuild a conversation from a persisted transcript (oldest first) —
|
|
3202
3600
|
* for backends that store the history between requests.
|
|
3601
|
+
*
|
|
3602
|
+
* A stateless backend must pass `{ timezone }` again here: the transcript
|
|
3603
|
+
* carries the messages, not the zone.
|
|
3203
3604
|
*/
|
|
3204
|
-
resumeAgentConversation(paymentAgentId, history) {
|
|
3205
|
-
return new AgentConversation(this, paymentAgentId, history);
|
|
3605
|
+
resumeAgentConversation(paymentAgentId, history, options) {
|
|
3606
|
+
return new AgentConversation(this, paymentAgentId, history, options);
|
|
3206
3607
|
}
|
|
3207
3608
|
/**
|
|
3208
3609
|
* Grant a principal (user or agent — both are just signers) permission to
|
|
@@ -3289,6 +3690,27 @@ function mandateSignPayload(mandate, action) {
|
|
|
3289
3690
|
});
|
|
3290
3691
|
return new TextEncoder().encode(encoded);
|
|
3291
3692
|
}
|
|
3693
|
+
function mandateAmendSignPayload(mandate, version, rule) {
|
|
3694
|
+
if (!mandate.id) {
|
|
3695
|
+
throw new Error("mandate has no id");
|
|
3696
|
+
}
|
|
3697
|
+
if (!mandate.bound_signer_id) {
|
|
3698
|
+
throw new Error("mandate has no bound_signer_id");
|
|
3699
|
+
}
|
|
3700
|
+
if (!Number.isInteger(version) || version < 2) {
|
|
3701
|
+
throw new Error("amend version must be an integer >= 2 (the version being created)");
|
|
3702
|
+
}
|
|
3703
|
+
const encoded = canonicalJSON({
|
|
3704
|
+
action: "amend",
|
|
3705
|
+
id: mandate.id,
|
|
3706
|
+
bound_signer: mandate.bound_signer_id,
|
|
3707
|
+
rule,
|
|
3708
|
+
valid_from: mandate.valid_from ?? 0,
|
|
3709
|
+
valid_until: mandate.valid_until ?? 0,
|
|
3710
|
+
version
|
|
3711
|
+
});
|
|
3712
|
+
return new TextEncoder().encode(encoded);
|
|
3713
|
+
}
|
|
3292
3714
|
function attachGroupPayload(walletId, groupId, idempotencyKey) {
|
|
3293
3715
|
return textBytes(
|
|
3294
3716
|
canonicalJSON({
|
|
@@ -3454,6 +3876,6 @@ function verifyMandateSignature(publicKeyBase64, payload, signatureBase64) {
|
|
|
3454
3876
|
}
|
|
3455
3877
|
}
|
|
3456
3878
|
|
|
3457
|
-
export { APIError, AccountsResource, AgentConversation, ApiKeysResource, ApplicationsResource, AuthMode, AutoTransactionsResource, ConfigurationError, CustomersResource, DEFAULT_RETRY_POLICY, DakotaClient, DestinationsResource, Environment, EventsResource, InfoResource, InsightsResource, InstructionsResource, MandatesResource, P256MandateSigner, PaginatedIterator, PaymentAgentsResource, PoliciesResource, RecipientsResource, SandboxResource, ScheduledPaymentsResource, SelfServeResource, SignerGroupsResource, SignersResource, TransactionsResource, TransportError, UsersResource, WalletsResource, WebhooksResource, addPolicyRulePayload, attachGroupPayload, attachPolicyPayload, attachUserToWallet, canonicalJSON, consoleLogger, deletePolicyPayload, detachGroupPayload, detachPolicyPayload, detachUserFromWallet, getEnvironmentURL, mandateSignPayload, noopLogger, paginate, removePolicyRulePayload, updatePolicyRulePayload, verifyMandateSignature };
|
|
3879
|
+
export { APIError, AccountsResource, AgentConversation, ApiKeysResource, ApplicationsResource, AuthMode, AutoTransactionsResource, ConfigurationError, CustomersResource, DEFAULT_RETRY_POLICY, DakotaClient, DestinationsResource, Environment, EventsResource, FeePayoutDestinationResource, InfoResource, InsightsResource, InstructionsResource, MandatesResource, P256MandateSigner, PaginatedIterator, PaymentAgentsResource, PoliciesResource, RecipientsResource, SandboxResource, ScheduledPaymentsResource, SelfServeResource, SignerGroupsResource, SignersResource, TransactionsResource, TransportError, UsersResource, WalletsResource, WebhooksResource, addPolicyRulePayload, attachGroupPayload, attachPolicyPayload, attachUserToWallet, canonicalJSON, consoleLogger, deletePolicyPayload, detachGroupPayload, detachPolicyPayload, detachUserFromWallet, getEnvironmentURL, mandateAmendSignPayload, mandateSignPayload, noopLogger, paginate, removePolicyRulePayload, updatePolicyRulePayload, verifyMandateSignature };
|
|
3458
3880
|
//# sourceMappingURL=index.mjs.map
|
|
3459
3881
|
//# sourceMappingURL=index.mjs.map
|