@insignia-education/api-sdk-js 0.16.0 → 0.16.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insignia-education/api-sdk-js",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "description": "JavaScript SDK for the Insignia Education API",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -30,6 +30,13 @@ export default class Admin {
30
30
  return this.#client.get('/admin/statistics/paypal-transactions', { from_date: fromDate, to_date: toDate, slot });
31
31
  }
32
32
 
33
+ /** Direct download link for the same PayPal transaction list (format: 'csv' | 'xlsx') — open with <a href>, same convention as reportsSalesExportUrl(). Downloads a headers-only file rather than erroring if the account isn't available. */
34
+ statisticsPaypalTransactionsExportUrl({ fromDate, toDate, slot, format = 'csv' } = {}) {
35
+ return Admin.#buildUrl(this.#client.baseUrl, '/admin/statistics/paypal-transactions/export', {
36
+ from_date: fromDate, to_date: toDate, slot, format,
37
+ });
38
+ }
39
+
33
40
  /** Our wallet's live on-chain balance for every crypto asset/chain we accept payment in — [{ asset, chain, balance }]. Read straight from the chain, not a sum of recorded payments. */
34
41
  statisticsCryptoBalances() {
35
42
  return this.#client.get('/admin/statistics/crypto-balances');
@@ -45,6 +52,13 @@ export default class Admin {
45
52
  return this.#client.get('/admin/statistics/stripe-transactions', { from_date: fromDate, to_date: toDate });
46
53
  }
47
54
 
55
+ /** Direct download link for the same Stripe transaction list (format: 'csv' | 'xlsx'). */
56
+ statisticsStripeTransactionsExportUrl({ fromDate, toDate, format = 'csv' } = {}) {
57
+ return Admin.#buildUrl(this.#client.baseUrl, '/admin/statistics/stripe-transactions/export', {
58
+ from_date: fromDate, to_date: toDate, format,
59
+ });
60
+ }
61
+
48
62
  /**
49
63
  * Our Binance holdings and recent money movement — distinct from
50
64
  * statisticsCryptoBalances()' on-chain wallet balance. Resolves
@@ -72,6 +86,16 @@ export default class Admin {
72
86
  return this.#client.get('/admin/statistics/binance-balances');
73
87
  }
74
88
 
89
+ /**
90
+ * Direct download link for the same `transactions` list (format: 'csv' |
91
+ * 'xlsx') — no date-range params, unlike the PayPal/Stripe export links
92
+ * above: Binance's own API already caps history at 90 days, so this
93
+ * always exports the full set that's currently available.
94
+ */
95
+ statisticsBinanceTransactionsExportUrl({ format = 'csv' } = {}) {
96
+ return Admin.#buildUrl(this.#client.baseUrl, '/admin/statistics/binance-transactions/export', { format });
97
+ }
98
+
75
99
  /** Paginated sales-report rows for a date range, with optional course/seller/payment-method/currency filters. */
76
100
  reportsSales({ fromDate, toDate, courseId, sellerId, paymentMethodId, currencyId, page, perPage } = {}) {
77
101
  return this.#client.get('/admin/reports/sales', {
@@ -9,6 +9,11 @@ export default class Search {
9
9
  * Sales-and-above global search: users (name/email/dni) and courses (cod/title).
10
10
  * `offset` pages through the user results only (courses are always the first page) —
11
11
  * response includes `users_has_more` to know whether another page exists.
12
+ * `includeTrashed` opts into soft-deleted accounts (flagged via `deleted_at` on the
13
+ * returned row) — off by default, since this same endpoint also backs pickers (coupon
14
+ * grant, referrer) that must never offer a deleted account as a valid target.
12
15
  */
13
- query(q, offset = 0) { return this.#client.get('/search', { q, offset }); }
16
+ query(q, offset = 0, includeTrashed = false) {
17
+ return this.#client.get('/search', { q, offset, include_trashed: includeTrashed ? 1 : undefined });
18
+ }
14
19
  }
@@ -247,8 +247,20 @@ export default class Users {
247
247
  /** Admin-only: lifts a hard block. */
248
248
  unblock(userId) { return this.#client.post(`/users/${userId}/unblock`); }
249
249
 
250
- /** GDPR erasure request — self-service or sales-and-above, always confirmed with the ACTOR's own current password. Soft-deletes now; the API permanently purges it after a 1-year retention window. */
251
- delete(userId, password) { return this.#client.del(`/users/${userId}`, { password }); }
250
+ /**
251
+ * GDPR erasure request — self-service or sales-and-above. `data` is either
252
+ * `{ password, captcha_token }` or `{ webauthn_credential }`, same step-up
253
+ * shape as payments().verify()/reject(). Soft-deletes now; the API
254
+ * permanently purges it after a 1-year retention window, and immediately
255
+ * emails a one-time undo link to the account's own address.
256
+ */
257
+ delete(userId, data) { return this.#client.del(`/users/${userId}`, data); }
258
+
259
+ /** Sellers+: reverses a soft-deletion found via the global search (which includes trashed accounts). */
260
+ restore(userId) { return this.#client.post(`/users/${userId}/restore`); }
261
+
262
+ /** Public — the account is soft-deleted so its own session is already dead; this is the only way it gets back in. No auth. */
263
+ undoDeletionConfirm(hash) { return this.#client.post(`/accounts/undo-deletion/${hash}`); }
252
264
 
253
265
  /** GDPR access/portability request (Art. 15/20) — self-service or sales-and-above. Runs synchronously and returns the DataRequest with `pdf_url`/`json_url` already populated. */
254
266
  exportData(userId) { return this.#client.post(`/users/${userId}/data-export`); }