vesant-sdk 1.5.0 → 1.5.2

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.
Files changed (66) hide show
  1. package/README.md +5 -3
  2. package/dist/{client-3cBb_Pp-.d.ts → client-B8pFrXx_.d.ts} +9 -3
  3. package/dist/{client-DKqyESgT.d.mts → client-BZxzOidG.d.mts} +9 -3
  4. package/dist/{client-BQRONu8q.d.mts → client-CIon-bGS.d.mts} +1 -1
  5. package/dist/{client-BQRONu8q.d.ts → client-CIon-bGS.d.ts} +1 -1
  6. package/dist/compliance/index.d.mts +5 -5
  7. package/dist/compliance/index.d.ts +5 -5
  8. package/dist/compliance/index.js +3 -1
  9. package/dist/compliance/index.js.map +1 -1
  10. package/dist/compliance/index.mjs +3 -1
  11. package/dist/compliance/index.mjs.map +1 -1
  12. package/dist/decisions/index.d.mts +2 -2
  13. package/dist/decisions/index.d.ts +2 -2
  14. package/dist/decisions/index.js +3 -1
  15. package/dist/decisions/index.js.map +1 -1
  16. package/dist/decisions/index.mjs +3 -1
  17. package/dist/decisions/index.mjs.map +1 -1
  18. package/dist/geolocation/index.d.mts +4 -4
  19. package/dist/geolocation/index.d.ts +4 -4
  20. package/dist/geolocation/index.js +3 -1
  21. package/dist/geolocation/index.js.map +1 -1
  22. package/dist/geolocation/index.mjs +3 -1
  23. package/dist/geolocation/index.mjs.map +1 -1
  24. package/dist/index.d.mts +537 -9
  25. package/dist/index.d.ts +537 -9
  26. package/dist/index.js +274 -110
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +273 -108
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/kyc/core.d.mts +3 -3
  31. package/dist/kyc/core.d.ts +3 -3
  32. package/dist/kyc/core.js +3 -1
  33. package/dist/kyc/core.js.map +1 -1
  34. package/dist/kyc/core.mjs +3 -1
  35. package/dist/kyc/core.mjs.map +1 -1
  36. package/dist/kyc/index.d.mts +7 -3
  37. package/dist/kyc/index.d.ts +7 -3
  38. package/dist/kyc/index.js +3 -1
  39. package/dist/kyc/index.js.map +1 -1
  40. package/dist/kyc/index.mjs +3 -1
  41. package/dist/kyc/index.mjs.map +1 -1
  42. package/dist/react.d.mts +4 -4
  43. package/dist/react.d.ts +4 -4
  44. package/dist/react.js +1 -1
  45. package/dist/react.js.map +1 -1
  46. package/dist/react.mjs +1 -1
  47. package/dist/react.mjs.map +1 -1
  48. package/dist/risk-profile/index.d.mts +4 -4
  49. package/dist/risk-profile/index.d.ts +4 -4
  50. package/dist/risk-profile/index.js +3 -1
  51. package/dist/risk-profile/index.js.map +1 -1
  52. package/dist/risk-profile/index.mjs +3 -1
  53. package/dist/risk-profile/index.mjs.map +1 -1
  54. package/dist/scores/index.d.mts +2 -2
  55. package/dist/scores/index.d.ts +2 -2
  56. package/dist/scores/index.js +3 -1
  57. package/dist/scores/index.js.map +1 -1
  58. package/dist/scores/index.mjs +3 -1
  59. package/dist/scores/index.mjs.map +1 -1
  60. package/dist/{types-_hsTA3Ez.d.mts → types-1RzYeSal.d.mts} +1 -1
  61. package/dist/{types-B1OzEQR3.d.mts → types-B4Ezqo7V.d.mts} +1 -1
  62. package/dist/{types-B1OzEQR3.d.ts → types-B4Ezqo7V.d.ts} +1 -1
  63. package/dist/{types-BnL66DB3.d.ts → types-X5Md_dD_.d.ts} +1 -1
  64. package/dist/webhooks/index.d.mts +1 -1
  65. package/dist/webhooks/index.d.ts +1 -1
  66. package/package.json +6 -1
package/dist/index.mjs CHANGED
@@ -240,7 +240,7 @@ var noopLogger = {
240
240
  };
241
241
 
242
242
  // src/core/version.ts
243
- var SDK_VERSION = "1.5.0";
243
+ var SDK_VERSION = "1.5.2";
244
244
 
245
245
  // src/shared/browser-utils.ts
246
246
  function generateUUID() {
@@ -528,6 +528,8 @@ var BaseClient = class {
528
528
  return new VesantError(message, "FORBIDDEN", 403);
529
529
  case 404:
530
530
  return new VesantError(message, "NOT_FOUND", 404);
531
+ case 409:
532
+ return new VesantError(message, "DUPLICATE_PROFILE", 409);
531
533
  case 429: {
532
534
  const retryAfter = data.retry_after || data.retryAfter;
533
535
  return new RateLimitError(retryAfter);
@@ -2836,152 +2838,315 @@ var KycClient = class extends BaseClient {
2836
2838
  // ============================================================================
2837
2839
  };
2838
2840
 
2839
- // src/decisions/client.ts
2840
- var DecisionsClient = class extends BaseClient {
2841
+ // src/tax/client.ts
2842
+ var TaxClient = class extends BaseClient {
2843
+ constructor(config) {
2844
+ const baseConfig = {
2845
+ baseURL: config.baseURL,
2846
+ tenantId: config.tenantId,
2847
+ apiKey: config.apiKey,
2848
+ headers: config.headers,
2849
+ timeout: config.timeout,
2850
+ retries: 3,
2851
+ debug: config.debug,
2852
+ environment: config.environment
2853
+ };
2854
+ super(baseConfig);
2855
+ }
2856
+ // ============================================================================
2857
+ // Tax Enable / Disable Configuration
2858
+ // ============================================================================
2841
2859
  /**
2842
- * Record a new decision for a customer.
2860
+ * Get the tax enabled/disabled state for the tenant
2861
+ *
2862
+ * @returns The current tax config (tax_enabled flag)
2863
+ *
2864
+ * @example
2865
+ * ```typescript
2866
+ * const config = await client.getTaxConfig();
2867
+ * console.log(`Tax enabled: ${config.tax_enabled}`);
2868
+ * ```
2843
2869
  */
2844
- async recordDecision(request, requestOptions) {
2845
- return this.requestWithRetry(
2846
- "/api/v1/decisions",
2847
- { method: "POST", body: JSON.stringify(request) },
2848
- void 0,
2849
- void 0,
2850
- requestOptions
2851
- );
2870
+ async getTaxConfig() {
2871
+ const res = await this.request("/api/v1/tax/config");
2872
+ return res.tax_config;
2852
2873
  }
2853
2874
  /**
2854
- * Get decisions for a customer.
2875
+ * Enable or disable tax compliance features for the tenant
2876
+ *
2877
+ * @param request - Object with tax_enabled boolean
2878
+ * @returns Updated tax config
2879
+ *
2880
+ * @example
2881
+ * ```typescript
2882
+ * // Enable tax
2883
+ * const config = await client.updateTaxConfig({ tax_enabled: true });
2884
+ *
2885
+ * // Disable tax
2886
+ * const config = await client.updateTaxConfig({ tax_enabled: false });
2887
+ * ```
2855
2888
  */
2856
- async getDecisions(customerId, filters, requestOptions) {
2857
- const queryString = this.buildQueryString({
2858
- customer_id: customerId,
2859
- ...filters
2889
+ async updateTaxConfig(request) {
2890
+ const res = await this.request("/api/v1/tax/config", {
2891
+ method: "PUT",
2892
+ body: JSON.stringify({ tax_config: request })
2860
2893
  });
2861
- return this.requestWithRetry(
2862
- `/api/v1/decisions${queryString}`,
2863
- { method: "GET" },
2864
- void 0,
2865
- void 0,
2866
- requestOptions
2867
- );
2894
+ return res.tax_config;
2868
2895
  }
2896
+ // ============================================================================
2897
+ // Solicitation Trigger Configuration
2898
+ // ============================================================================
2869
2899
  /**
2870
- * Get a specific decision by ID.
2900
+ * Get solicitation triggers for the tenant
2901
+ *
2902
+ * @returns List of solicitation triggers with their enabled state
2903
+ *
2904
+ * @example
2905
+ * ```typescript
2906
+ * const triggers = await client.getSolicitationTriggers();
2907
+ * triggers.forEach(t => console.log(`${t.label}: ${t.enabled}`));
2908
+ * ```
2871
2909
  */
2872
- async getDecision(decisionId, requestOptions) {
2873
- return this.requestWithRetry(
2874
- `/api/v1/decisions/${encodeURIComponent(decisionId)}`,
2875
- { method: "GET" },
2876
- void 0,
2877
- void 0,
2878
- requestOptions
2910
+ async getSolicitationTriggers() {
2911
+ const res = await this.request(
2912
+ "/api/v1/tax/solicitation/config"
2879
2913
  );
2914
+ return res.solicitation_triggers;
2880
2915
  }
2881
2916
  /**
2882
- * Apply a label to a customer.
2917
+ * Update solicitation triggers for the tenant
2918
+ *
2919
+ * @param triggers - Array of triggers with updated enabled/threshold values
2920
+ * @returns Updated triggers
2921
+ *
2922
+ * @example
2923
+ * ```typescript
2924
+ * const triggers = await client.updateSolicitationTriggers([
2925
+ * { type: 'first_withdrawal', enabled: true, label: 'First Withdrawal', description: '...' },
2926
+ * { type: 'threshold_based', enabled: true, label: 'Threshold', description: '...', threshold_amount: 600 },
2927
+ * ]);
2928
+ * ```
2883
2929
  */
2884
- async applyLabel(request, requestOptions) {
2885
- return this.requestWithRetry(
2886
- "/api/v1/labels",
2887
- { method: "POST", body: JSON.stringify(request) },
2888
- void 0,
2889
- void 0,
2890
- requestOptions
2930
+ async updateSolicitationTriggers(triggers) {
2931
+ const res = await this.request(
2932
+ "/api/v1/tax/solicitation/config",
2933
+ {
2934
+ method: "PUT",
2935
+ body: JSON.stringify({ solicitation_triggers: triggers })
2936
+ }
2891
2937
  );
2938
+ return res.solicitation_triggers;
2892
2939
  }
2940
+ // ============================================================================
2941
+ // Reminder Configuration
2942
+ // ============================================================================
2893
2943
  /**
2894
- * Remove a label from a customer.
2944
+ * Get the reminder configuration for the tenant
2945
+ *
2946
+ * @returns Reminder config (enabled, max_reminders, frequency_days)
2947
+ *
2948
+ * @example
2949
+ * ```typescript
2950
+ * const config = await client.getReminderConfig();
2951
+ * console.log(`Reminders enabled: ${config.enabled}, every ${config.frequency_days} days`);
2952
+ * ```
2895
2953
  */
2896
- async removeLabel(customerId, requestOptions) {
2897
- return this.requestWithRetry(
2898
- `/api/v1/labels/${encodeURIComponent(customerId)}`,
2899
- { method: "DELETE" },
2900
- void 0,
2901
- void 0,
2902
- requestOptions
2954
+ async getReminderConfig() {
2955
+ const res = await this.request(
2956
+ "/api/v1/tax/solicitation/reminder-config"
2903
2957
  );
2958
+ return res.reminder_config;
2904
2959
  }
2905
2960
  /**
2906
- * Get labels for a customer.
2961
+ * Update the reminder configuration for the tenant
2962
+ *
2963
+ * @param config - Reminder configuration to set
2964
+ * @returns Updated reminder config
2965
+ *
2966
+ * @example
2967
+ * ```typescript
2968
+ * const updated = await client.updateReminderConfig({
2969
+ * enabled: true,
2970
+ * max_reminders: 3,
2971
+ * frequency_days: 7,
2972
+ * });
2973
+ * ```
2907
2974
  */
2908
- async getLabels(customerId, requestOptions) {
2909
- const queryString = this.buildQueryString({ customer_id: customerId });
2910
- return this.requestWithRetry(
2911
- `/api/v1/labels${queryString}`,
2912
- { method: "GET" },
2913
- void 0,
2914
- void 0,
2915
- requestOptions
2975
+ async updateReminderConfig(config) {
2976
+ const res = await this.request(
2977
+ "/api/v1/tax/solicitation/reminder-config",
2978
+ {
2979
+ method: "PUT",
2980
+ body: JSON.stringify({ reminder_config: config })
2981
+ }
2916
2982
  );
2983
+ return res.reminder_config;
2917
2984
  }
2918
- };
2919
-
2920
- // src/scores/client.ts
2921
- var ScoresClient = class extends BaseClient {
2985
+ // ============================================================================
2986
+ // Tax Forms
2987
+ // ============================================================================
2922
2988
  /**
2923
- * Get the current risk score for a customer.
2989
+ * List tax forms with optional filters and pagination
2990
+ *
2991
+ * @param filters - Optional filters (customer_id, form_type, form_status, etc.)
2992
+ * @returns Paginated list of tax forms
2993
+ *
2994
+ * @example
2995
+ * ```typescript
2996
+ * const result = await client.listTaxForms({ form_type: 'W-9', form_status: 'Pending' });
2997
+ * console.log(`Found ${result.total} forms`);
2998
+ * ```
2924
2999
  */
2925
- async getScore(customerId, requestOptions) {
2926
- return this.requestWithRetry(
2927
- `/api/v1/scores/${encodeURIComponent(customerId)}`,
2928
- { method: "GET" },
2929
- void 0,
2930
- void 0,
2931
- requestOptions
2932
- );
3000
+ async listTaxForms(filters) {
3001
+ const params = {};
3002
+ if (filters) {
3003
+ if (filters.customer_id) params.customer_id = filters.customer_id;
3004
+ if (filters.form_type) params.form_type = filters.form_type;
3005
+ if (filters.form_status) params.form_status = filters.form_status;
3006
+ if (filters.tin_status) params.tin_status = filters.tin_status;
3007
+ if (filters.avalara_company_id) params.avalara_company_id = filters.avalara_company_id;
3008
+ if (filters.search) params.search = filters.search;
3009
+ if (filters.start_date) params.start_date = filters.start_date;
3010
+ if (filters.end_date) params.end_date = filters.end_date;
3011
+ if (filters.page) params.page = filters.page;
3012
+ if (filters.page_size) params.limit = filters.page_size;
3013
+ }
3014
+ return this.request(`/api/v1/tax/forms${this.buildQueryString(params)}`);
2933
3015
  }
2934
3016
  /**
2935
- * Get a detailed score breakdown for a customer.
3017
+ * Get a tax form by ID
3018
+ *
3019
+ * @param formId - Tax form UUID
3020
+ * @returns Tax form details
2936
3021
  */
2937
- async getScoreBreakdown(customerId, requestOptions) {
2938
- return this.requestWithRetry(
2939
- `/api/v1/scores/${encodeURIComponent(customerId)}/breakdown`,
2940
- { method: "GET" },
2941
- void 0,
2942
- void 0,
2943
- requestOptions
2944
- );
3022
+ async getTaxForm(formId) {
3023
+ return this.request(`/api/v1/tax/forms/${formId}`);
2945
3024
  }
2946
- };
2947
- var WorkflowClient = class extends BaseClient {
2948
3025
  /**
2949
- * Get the current workflow status for a customer.
3026
+ * Get lifecycle events for a tax form
3027
+ *
3028
+ * @param formId - Tax form UUID
3029
+ * @returns List of lifecycle events
2950
3030
  */
2951
- async getWorkflowStatus(customerId, requestOptions) {
2952
- return this.requestWithRetry(
2953
- `/api/v1/workflows/${encodeURIComponent(customerId)}/status`,
2954
- { method: "GET" },
2955
- void 0,
2956
- void 0,
2957
- requestOptions
3031
+ async getTaxFormLifecycleEvents(formId) {
3032
+ const res = await this.request(
3033
+ `/api/v1/tax/forms/${formId}/lifecycle`
2958
3034
  );
3035
+ return res.lifecycle_events;
2959
3036
  }
3037
+ // ============================================================================
3038
+ // Customer Tax Profile
3039
+ // ============================================================================
2960
3040
  /**
2961
- * List workflows with optional filters.
3041
+ * Get the full tax profile for a customer (all forms + lifecycle events)
3042
+ *
3043
+ * @param customerID - Customer ID
3044
+ * @returns Customer tax profile with all forms and events
3045
+ *
3046
+ * @example
3047
+ * ```typescript
3048
+ * const profile = await client.getCustomerTaxProfile('cust_123');
3049
+ * console.log(`Customer has ${profile.tax_forms.length} tax forms`);
3050
+ * ```
2962
3051
  */
2963
- async listWorkflows(filters, requestOptions) {
2964
- const queryString = this.buildQueryString(filters || {});
2965
- return this.requestWithRetry(
2966
- `/api/v1/workflows${queryString}`,
2967
- { method: "GET" },
2968
- void 0,
2969
- void 0,
2970
- requestOptions
2971
- );
3052
+ async getCustomerTaxProfile(customerID) {
3053
+ return this.request(`/api/v1/tax/profile/${customerID}`);
2972
3054
  }
3055
+ // ============================================================================
3056
+ // Tax Companies
3057
+ // ============================================================================
2973
3058
  /**
2974
- * Get a specific workflow by ID.
3059
+ * List Avalara tax companies for the tenant
3060
+ *
3061
+ * @param page - Page number (default: 1)
3062
+ * @param pageSize - Items per page (default: 20)
3063
+ * @returns Paginated list of tax companies
2975
3064
  */
2976
- async getWorkflow(workflowId, requestOptions) {
2977
- return this.requestWithRetry(
2978
- `/api/v1/workflows/${encodeURIComponent(workflowId)}`,
2979
- { method: "GET" },
2980
- void 0,
2981
- void 0,
2982
- requestOptions
3065
+ async listTaxCompanies(page, pageSize) {
3066
+ const params = {};
3067
+ if (page) params.page = page;
3068
+ if (pageSize) params.limit = pageSize;
3069
+ return this.request(
3070
+ `/api/v1/tax/companies${this.buildQueryString(params)}`
2983
3071
  );
2984
3072
  }
3073
+ /**
3074
+ * Get a tax company by ID
3075
+ *
3076
+ * @param companyId - Tax company UUID
3077
+ * @returns Tax company details
3078
+ */
3079
+ async getTaxCompany(companyId) {
3080
+ return this.request(`/api/v1/tax/companies/${companyId}`);
3081
+ }
3082
+ // ============================================================================
3083
+ // Utility Methods (inherited from BaseClient: healthCheck, updateConfig, getConfig, buildQueryString)
3084
+ // ============================================================================
3085
+ };
3086
+
3087
+ // src/transaction/client.ts
3088
+ var TransactionClient = class extends BaseClient {
3089
+ constructor(config) {
3090
+ super(config);
3091
+ }
3092
+ // ==========================================================================
3093
+ // Transaction creation
3094
+ // ==========================================================================
3095
+ /**
3096
+ * Submit a new transaction record to the monitoring service.
3097
+ *
3098
+ * The gateway endpoint is `POST /api/v1/tm/transactions` and returns 201
3099
+ * with no body on success. The SDK method resolves to `void` to reflect
3100
+ * that behaviour.
3101
+ *
3102
+ * @param request - Data required to create the transaction
3103
+ * @param requestOptions - Optional request options (e.g. AbortSignal)
3104
+ *
3105
+ * @example
3106
+ * ```ts
3107
+ * const client = new TransactionClient({
3108
+ * baseURL: process.env.API_GATEWAY_URL!,
3109
+ * tenantId: 'tenant-123',
3110
+ * apiKey: 'pk_test_...',
3111
+ * });
3112
+ *
3113
+ * await client.createTransaction({
3114
+ * tx_id: 'tx-1',
3115
+ * reference: 'ref-1',
3116
+ * tenant_id: 'tenant-123',
3117
+ * customer_id: 'cust-1',
3118
+ * transaction_type: 'deposit',
3119
+ * transaction_mode: 'ach',
3120
+ * amount: '100.00',
3121
+ * currency: 'USD',
3122
+ * status: 'pending',
3123
+ * source_account: 'acct-1',
3124
+ * destination_account: 'acct-2',
3125
+ * country: 'US',
3126
+ * ip_address: '10.0.0.1',
3127
+ * metadata: {},
3128
+ * benificiary_comment: '',
3129
+ * transaction_date: new Date().toISOString(),
3130
+ * });
3131
+ * ```
3132
+ */
3133
+ async createTransaction(request, requestOptions) {
3134
+ const data = await this.requestWithRetry("/api/v1/tm/transactions", {
3135
+ method: "POST",
3136
+ body: JSON.stringify(request)
3137
+ }, void 0, void 0, requestOptions);
3138
+ return data;
3139
+ }
3140
+ /**
3141
+ *
3142
+ * @param transactionId tx_id of the transaction
3143
+ * @param requestOptions optional request options (e.g. AbortSignal)
3144
+ */
3145
+ async getTransaction(transactionId, requestOptions) {
3146
+ await this.requestWithRetry(`/api/v1/tm/transactions/status/${transactionId}`, {
3147
+ method: "GET"
3148
+ }, void 0, void 0, requestOptions);
3149
+ }
2985
3150
  };
2986
3151
 
2987
3152
  // src/webhooks/handler.ts
@@ -3127,6 +3292,6 @@ function buildHandler(options) {
3127
3292
  return handler;
3128
3293
  }
3129
3294
 
3130
- export { AuthenticationError, BaseClient, CGSError, CircuitBreaker, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceClient, ComplianceError, DEFAULT_CURRENCY_RATES, DecisionsClient, GeolocationClient, KycClient, NetworkError, RateLimitError, RateLimitTracker, RiskProfileClient, SDK_VERSION, ScoresClient, ServiceUnavailableError, TimeoutError, ValidationError, VesantError, WebhookHandler, WorkflowClient, createConsoleLogger, createNextWebhookHandler, createWebhookMiddleware, decodeCipherText, generateCipherText, isCipherTextExpired, noopLogger, verifyWebhookSignature };
3295
+ export { AuthenticationError, BaseClient, CGSError, CircuitBreaker, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceClient, ComplianceError, DEFAULT_CURRENCY_RATES, GeolocationClient, KycClient, NetworkError, RateLimitError, RateLimitTracker, RiskProfileClient, SDK_VERSION, ServiceUnavailableError, TaxClient, TimeoutError, TransactionClient, ValidationError, VesantError, WebhookHandler, createConsoleLogger, createNextWebhookHandler, createWebhookMiddleware, decodeCipherText, generateCipherText, isCipherTextExpired, noopLogger, verifyWebhookSignature };
3131
3296
  //# sourceMappingURL=index.mjs.map
3132
3297
  //# sourceMappingURL=index.mjs.map