@insignia-education/api-sdk-js 0.15.88 → 0.15.94

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.15.88",
3
+ "version": "0.15.94",
4
4
  "description": "JavaScript SDK for the Insignia Education API",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/Client.js CHANGED
@@ -127,5 +127,5 @@ export default class InsigniaClient {
127
127
  post(path, body = null) { return this.#request('POST', path, body); }
128
128
  put(path, body = null) { return this.#request('PUT', path, body); }
129
129
  patch(path, body = null){ return this.#request('PATCH', path, body); }
130
- del(path) { return this.#request('DELETE', path); }
130
+ del(path, body = null) { return this.#request('DELETE', path, body); }
131
131
  }
@@ -15,6 +15,11 @@ export default class Admin {
15
15
  return this.#client.get('/admin/statistics/sales', { from_date: fromDate, to_date: toDate });
16
16
  }
17
17
 
18
+ /** Claude (Anthropic) token usage/spend for a date range, plus account balance. Each half resolves `{ available: false }` (not an error) when its required config (admin key / account balance) isn't set. */
19
+ statisticsClaudeUsage({ fromDate, toDate } = {}) {
20
+ return this.#client.get('/admin/statistics/claude-usage', { from_date: fromDate, to_date: toDate });
21
+ }
22
+
18
23
  /** Paginated sales-report rows for a date range, with optional course/seller/payment-method/currency filters. */
19
24
  reportsSales({ fromDate, toDate, courseId, sellerId, paymentMethodId, currencyId, page, perPage } = {}) {
20
25
  return this.#client.get('/admin/reports/sales', {
@@ -21,4 +21,6 @@ export default class Auth {
21
21
  emailVerify(data) { return this.#client.post('/auth/email-verify', data); }
22
22
  /** Second login step when two_factor_required: exchange { pin } for a session. */
23
23
  twoFactor(data) { return this.#client.post('/auth/2fa', data); }
24
+ /** GDPR Art. 8 — clicked by the guardian from the consent email, not the account holder; no session is created. */
25
+ guardianConsentConfirm(hash) { return this.#client.post(`/guardian-consent/${hash}`); }
24
26
  }
@@ -0,0 +1,12 @@
1
+ /** Admin-only: IP blocks (the blocks table — ip-scoped only, see App\Models\Block). */
2
+ export default class Blocks {
3
+ #client;
4
+
5
+ constructor(client) {
6
+ this.#client = client;
7
+ }
8
+
9
+ get(id = null) { return id ? this.#client.get(`/blocks/${id}`) : this.#client.get('/blocks'); }
10
+ create(data) { return this.#client.put('/blocks', data); }
11
+ delete(id) { return this.#client.del(`/blocks/${id}`); }
12
+ }
@@ -60,8 +60,8 @@ export default class Teacher {
60
60
  courseDateGradedQuizzes: (courseDateId, quizId = null) => this.#client.get(`${base}/course-dates/${courseDateId}/quizzes/graded`, quizId ? { quiz_id: quizId } : {}),
61
61
  /** Distinct { id, title } quizzes needing correction under this CourseDate's course — for the graded-tab quiz filter. */
62
62
  courseDateCorrectableQuizzes: (courseDateId) => this.#client.get(`${base}/course-dates/${courseDateId}/quizzes/correctable`),
63
- /** Ungraded quiz submissions grouped by course, for every course this teacher teaches. */
64
- ungradedQuizzes: () => this.#client.get(`${base}/quizzes/ungraded`),
63
+ /** Ungraded quiz submissions grouped by course, for every course this teacher teaches. hasCertificate (true/false) narrows to courses with/without Course.certificate_exam_enabled; omit for every course. */
64
+ ungradedQuizzes: (hasCertificate = null) => this.#client.get(`${base}/quizzes/ungraded`, hasCertificate === null ? {} : { has_certificate: hasCertificate ? 1 : 0 }),
65
65
  /** Ungraded quiz submissions for one course (any student, not just one CourseDate's) — for courses with no cohort scheduling, e.g. placement exams. */
66
66
  courseUngradedQuizzes: (courseId) => this.#client.get(`${base}/courses/${courseId}/quizzes/ungraded`),
67
67
  /** Already-graded quiz submissions for one course, optionally narrowed to one quiz. */
@@ -217,6 +217,18 @@ export default class Users {
217
217
  /** Sales-and-above: re-run the course/individual-session access reconciliation for this user on demand. */
218
218
  syncAccess(userId) { return this.#client.post(`/users/${userId}/sync-access`); }
219
219
 
220
+ /** Admin-only: total blockade — enforced on every authenticated route, not just new logins. */
221
+ block(userId, reason) { return this.#client.post(`/users/${userId}/block`, { reason }); }
222
+
223
+ /** Admin-only: lifts a hard block. */
224
+ unblock(userId) { return this.#client.post(`/users/${userId}/unblock`); }
225
+
226
+ /** 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. */
227
+ delete(userId, password) { return this.#client.del(`/users/${userId}`, { password }); }
228
+
229
+ /** 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. */
230
+ exportData(userId) { return this.#client.post(`/users/${userId}/data-export`); }
231
+
220
232
  /** Notifications are created by internal services, not over the API — `resend()` is the one exception (sales-and-above). */
221
233
  notifications(userId) {
222
234
  const base = `/users/${userId}/notifications`;
@@ -19,6 +19,7 @@ import Forums from './Forums.js';
19
19
  import Hashes from './Hashes.js';
20
20
  import Insignias from './Insignias.js';
21
21
  import Languages from './Languages.js';
22
+ import Blocks from './Blocks.js';
22
23
  import MailBlacklist from './MailBlacklist.js';
23
24
  import MailingLists from './MailingLists.js';
24
25
  import Offers from './Offers.js';
@@ -75,6 +76,7 @@ export default class InsigniaApiV1 extends InsigniaApi {
75
76
  this.insignias = new Insignias(this);
76
77
  this.languages = new Languages(this);
77
78
  this.mailBlacklist = new MailBlacklist(this);
79
+ this.blocks = new Blocks(this);
78
80
  this.mailingLists = new MailingLists(this);
79
81
  this.offers = new Offers(this);
80
82
  this.organizations = new Organizations(this);