@delopay/sdk 0.5.0 → 0.6.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.cjs CHANGED
@@ -55,8 +55,11 @@ var DelopayAuthenticationError = class extends DelopayError {
55
55
  constructor(message = "Invalid API key", options) {
56
56
  super(message, {
57
57
  status: 401,
58
- code: "AUTH_01",
59
- type: "authentication_error",
58
+ // Default to the generic "invalid API key" code, but let callers pass
59
+ // through the server-reported code (e.g. `UR_05` for unverified-email
60
+ // 401s) so they can differentiate between auth failure reasons.
61
+ code: options?.code || "AUTH_01",
62
+ type: options?.type || "authentication_error",
60
63
  requestId: options?.requestId,
61
64
  rawBody: options?.rawBody
62
65
  });
@@ -65,103 +68,6 @@ var DelopayAuthenticationError = class extends DelopayError {
65
68
  }
66
69
  };
67
70
 
68
- // src/resources/admin.ts
69
- var Admin = class {
70
- constructor(request) {
71
- this.request = request;
72
- }
73
- async signIn(params) {
74
- return this.request("POST", "/admin/signin", { body: params });
75
- }
76
- async createInternalUser(params) {
77
- return this.request("POST", "/admin/internal_signup", { body: params });
78
- }
79
- async createTenant(params) {
80
- return this.request("POST", "/admin/tenant_signup", { body: params });
81
- }
82
- /**
83
- * Create a new merchant admin user and merchant account atomically.
84
- *
85
- * This is the correct endpoint for bootstrapping the first admin user in a
86
- * fresh deployment — `internal_signup`/`tenant_signup` both require
87
- * pre-existing merchant records that don't exist on a clean database.
88
- *
89
- * `POST /admin/signup_with_merchant_id`
90
- */
91
- async signupWithMerchantId(params) {
92
- return this.request("POST", "/admin/signup_with_merchant_id", { body: params });
93
- }
94
- /** Toggle public signup on/off. `POST /admin/settings/signup` */
95
- async setSignupSettings(params) {
96
- return this.request("POST", "/admin/settings/signup", { body: params });
97
- }
98
- /** Read current public-signup status. `GET /admin/settings/signup` */
99
- async getSignupSettings() {
100
- return this.request("GET", "/admin/settings/signup");
101
- }
102
- /** Full merchant bootstrap — user + merchant + project + profile + keys. `POST /admin/onboard_merchant` */
103
- async onboardMerchant(params) {
104
- return this.request("POST", "/admin/onboard_merchant", { body: params });
105
- }
106
- };
107
-
108
- // src/resources/adminPortal.ts
109
- var AdminPortal = class {
110
- constructor(request) {
111
- this.request = request;
112
- }
113
- async listCustomers(params) {
114
- return this.request("GET", "/admin-portal/customers", {
115
- query: params
116
- });
117
- }
118
- async getCustomer(customerId) {
119
- return this.request("GET", `/admin-portal/customers/${encodeURIComponent(customerId)}`);
120
- }
121
- async listTransactions(params) {
122
- return this.request("GET", "/admin-portal/transactions", {
123
- query: params
124
- });
125
- }
126
- async analytics(params) {
127
- return this.request("GET", "/admin-portal/analytics", {
128
- query: params
129
- });
130
- }
131
- async overviewStats() {
132
- return this.request("GET", "/admin-portal/overview-stats");
133
- }
134
- async paymentAnalytics(params) {
135
- return this.request("GET", "/admin-portal/payment-analytics", {
136
- query: params
137
- });
138
- }
139
- /**
140
- * Retrieve a merchant account via the admin portal. Unlike
141
- * `merchantAccounts.retrieve`, this route accepts an admin JWT (or admin API
142
- * key) and does not require the JWT to be scoped to the target merchant.
143
- */
144
- async retrieveAccount(merchantId) {
145
- return this.request("GET", `/admin-portal/accounts/${encodeURIComponent(merchantId)}`);
146
- }
147
- /**
148
- * Update a merchant account via the admin portal. Authenticated via admin JWT
149
- * or admin API key.
150
- */
151
- async updateAccount(merchantId, params) {
152
- return this.request("POST", `/admin-portal/accounts/${encodeURIComponent(merchantId)}`, {
153
- body: params
154
- });
155
- }
156
- /**
157
- * Delete a merchant account via the admin portal. Authenticated via admin JWT
158
- * or admin API key.
159
- */
160
- async deleteAccount(merchantId) {
161
- return this.request("DELETE", `/admin-portal/accounts/${encodeURIComponent(merchantId)}`);
162
- }
163
- };
164
-
165
71
  // src/resources/apiKeys.ts
166
72
  var ApiKeys = class {
167
73
  constructor(request) {
@@ -234,21 +140,6 @@ var ApiKeys = class {
234
140
  }
235
141
  };
236
142
 
237
- // src/resources/auditLogs.ts
238
- var AuditLogs = class {
239
- constructor(request) {
240
- this.request = request;
241
- }
242
- async list(params) {
243
- return this.request("GET", "/admin-portal/audit", {
244
- query: params
245
- });
246
- }
247
- async retrieve(logId) {
248
- return this.request("GET", `/admin-portal/audit/${encodeURIComponent(logId)}`);
249
- }
250
- };
251
-
252
143
  // src/resources/authentication.ts
253
144
  var Authentication = class {
254
145
  constructor(request) {
@@ -2102,8 +1993,7 @@ var Users = class {
2102
1993
  * `generateRecoveryCodes`, `terminate2fa`) and setting it on the client
2103
1994
  * via `setJwtToken` before calling this method. `body.token` must still
2104
1995
  * be the original `EmailToken` from the reset-link URL — the handler
2105
- * decodes it a second time to find the user
2106
- * (`delopay-backend/crates/router/src/core/user.rs:687`).
1996
+ * decodes it a second time to find the user.
2107
1997
  */
2108
1998
  async resetPassword(params) {
2109
1999
  return this.request("POST", "/user/reset_password", { body: params });
@@ -2196,14 +2086,6 @@ var Users = class {
2196
2086
  async deleteUserRole(params) {
2197
2087
  return this.request("DELETE", "/user/user/delete", { body: params });
2198
2088
  }
2199
- async getDashboardMetadata(params) {
2200
- return this.request("GET", "/user/data", {
2201
- query: params
2202
- });
2203
- }
2204
- async setDashboardMetadata(params) {
2205
- return this.request("POST", "/user/data", { body: params });
2206
- }
2207
2089
  // --- Advanced methods (Task 4.7) ---
2208
2090
  /** Sign in (v2). `POST /user/v2/signin` */
2209
2091
  async signInV2(params) {
@@ -2293,10 +2175,6 @@ var Users = class {
2293
2175
  async resendInvite(params) {
2294
2176
  return this.request("POST", "/user/user/resend_invite", { body: params });
2295
2177
  }
2296
- /** Clone connector. `POST /user/clone_connector` */
2297
- async cloneConnector(params) {
2298
- return this.request("POST", "/user/clone_connector", { body: params });
2299
- }
2300
2178
  /** Get role (v2). `GET /user/role/v2` */
2301
2179
  async getRoleV2() {
2302
2180
  return this.request("GET", "/user/role/v2");
@@ -2853,10 +2731,7 @@ var Delopay = class {
2853
2731
  this.authentication = new Authentication(request);
2854
2732
  this.verification = new Verification(request);
2855
2733
  this.users = new Users(request);
2856
- this.admin = new Admin(request);
2857
- this.adminPortal = new AdminPortal(request);
2858
2734
  this.apiKeys = new ApiKeys(request);
2859
- this.auditLogs = new AuditLogs(request);
2860
2735
  this.billing = new Billing(request);
2861
2736
  this.blocklist = new Blocklist(request);
2862
2737
  this.cardIssuers = new CardIssuers(request);
@@ -3004,6 +2879,8 @@ var Delopay = class {
3004
2879
  const truncatedRaw = truncateRawBody(rawBody);
3005
2880
  if (response.status === 401) {
3006
2881
  throw new DelopayAuthenticationError(message, {
2882
+ code,
2883
+ type,
3007
2884
  requestId,
3008
2885
  rawBody: truncatedRaw
3009
2886
  });