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