@insignia-education/api-sdk-js 0.15.68 → 0.15.70

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 (70) hide show
  1. package/package.json +1 -1
  2. package/src/Client.js +5 -0
  3. package/src/api/v1/Users.js +2 -0
  4. package/tests/client.test.js +17 -0
  5. package/.env +0 -1
  6. package/.env.test +0 -5
  7. package/coverage/clover.xml +0 -1568
  8. package/coverage/coverage-final.json +0 -46
  9. package/coverage/lcov-report/Client.js.html +0 -463
  10. package/coverage/lcov-report/base.css +0 -224
  11. package/coverage/lcov-report/block-navigation.js +0 -87
  12. package/coverage/lcov-report/favicon.png +0 -0
  13. package/coverage/lcov-report/index.html +0 -161
  14. package/coverage/lcov-report/prettify.css +0 -1
  15. package/coverage/lcov-report/prettify.js +0 -2
  16. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  17. package/coverage/lcov-report/sorter.js +0 -210
  18. package/coverage/lcov-report/src/Client.js.html +0 -463
  19. package/coverage/lcov-report/src/api/index.html +0 -116
  20. package/coverage/lcov-report/src/api/index.js.html +0 -127
  21. package/coverage/lcov-report/src/api/v1/Accounts.js.html +0 -151
  22. package/coverage/lcov-report/src/api/v1/Admin.js.html +0 -121
  23. package/coverage/lcov-report/src/api/v1/Auth.js.html +0 -157
  24. package/coverage/lcov-report/src/api/v1/Categories.js.html +0 -121
  25. package/coverage/lcov-report/src/api/v1/Changelogs.js.html +0 -118
  26. package/coverage/lcov-report/src/api/v1/Configs.js.html +0 -121
  27. package/coverage/lcov-report/src/api/v1/ContactForms.js.html +0 -121
  28. package/coverage/lcov-report/src/api/v1/ConversationalTopics.js.html +0 -121
  29. package/coverage/lcov-report/src/api/v1/Countries.js.html +0 -112
  30. package/coverage/lcov-report/src/api/v1/Coupons.js.html +0 -175
  31. package/coverage/lcov-report/src/api/v1/Courses.js.html +0 -442
  32. package/coverage/lcov-report/src/api/v1/Currencies.js.html +0 -118
  33. package/coverage/lcov-report/src/api/v1/Dashboard.js.html +0 -115
  34. package/coverage/lcov-report/src/api/v1/EducationCenter.js.html +0 -115
  35. package/coverage/lcov-report/src/api/v1/Employee.js.html +0 -169
  36. package/coverage/lcov-report/src/api/v1/Files.js.html +0 -160
  37. package/coverage/lcov-report/src/api/v1/Forums.js.html +0 -175
  38. package/coverage/lcov-report/src/api/v1/Hashes.js.html +0 -121
  39. package/coverage/lcov-report/src/api/v1/Insignias.js.html +0 -121
  40. package/coverage/lcov-report/src/api/v1/Languages.js.html +0 -121
  41. package/coverage/lcov-report/src/api/v1/MailBlacklist.js.html +0 -118
  42. package/coverage/lcov-report/src/api/v1/MailingLists.js.html +0 -127
  43. package/coverage/lcov-report/src/api/v1/Offers.js.html +0 -142
  44. package/coverage/lcov-report/src/api/v1/Organizations.js.html +0 -199
  45. package/coverage/lcov-report/src/api/v1/PaymentMethods.js.html +0 -121
  46. package/coverage/lcov-report/src/api/v1/Payments.js.html +0 -310
  47. package/coverage/lcov-report/src/api/v1/Premiums.js.html +0 -121
  48. package/coverage/lcov-report/src/api/v1/Quizzes.js.html +0 -214
  49. package/coverage/lcov-report/src/api/v1/Sales.js.html +0 -148
  50. package/coverage/lcov-report/src/api/v1/Search.js.html +0 -115
  51. package/coverage/lcov-report/src/api/v1/ShortLinks.js.html +0 -127
  52. package/coverage/lcov-report/src/api/v1/Surveys.js.html +0 -181
  53. package/coverage/lcov-report/src/api/v1/Taxes.js.html +0 -121
  54. package/coverage/lcov-report/src/api/v1/Teacher.js.html +0 -322
  55. package/coverage/lcov-report/src/api/v1/Telegram.js.html +0 -142
  56. package/coverage/lcov-report/src/api/v1/TwoFactor.js.html +0 -145
  57. package/coverage/lcov-report/src/api/v1/UserSessionTypes.js.html +0 -112
  58. package/coverage/lcov-report/src/api/v1/UserTypes.js.html +0 -121
  59. package/coverage/lcov-report/src/api/v1/Users.js.html +0 -766
  60. package/coverage/lcov-report/src/api/v1/Utm.js.html +0 -151
  61. package/coverage/lcov-report/src/api/v1/Webauthn.js.html +0 -190
  62. package/coverage/lcov-report/src/api/v1/Zoom.js.html +0 -124
  63. package/coverage/lcov-report/src/api/v1/index.html +0 -716
  64. package/coverage/lcov-report/src/api/v1/index.js.html +0 -373
  65. package/coverage/lcov-report/src/index.html +0 -131
  66. package/coverage/lcov-report/src/index.js.html +0 -109
  67. package/coverage/lcov-report/tests/helpers.js.html +0 -145
  68. package/coverage/lcov-report/tests/index.html +0 -116
  69. package/coverage/lcov.info +0 -2541
  70. package/coverage/test-report.html +0 -427
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insignia-education/api-sdk-js",
3
- "version": "0.15.68",
3
+ "version": "0.15.70",
4
4
  "description": "JavaScript SDK for the Insignia Education API",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/Client.js CHANGED
@@ -6,6 +6,11 @@ export default class InsigniaClient {
6
6
  this.#baseUrl = InsigniaClient._resolve(baseUrl);
7
7
  }
8
8
 
9
+ /** For building direct links (e.g. a PDF endpoint meant for <a href>/window.open, not a JSON fetch) — see Users.js's payments().invoiceUrl(). */
10
+ get baseUrl() {
11
+ return this.#baseUrl;
12
+ }
13
+
9
14
  static _resolve(baseUrl) {
10
15
  const envBaseUrl = typeof process !== 'undefined'
11
16
  ? process.env?.INSIGNIA_EDUCATION_API_BASE_URL ?? null
@@ -108,6 +108,8 @@ export default class Users {
108
108
  quote: (data) => client.post(`${base}/quote`, data),
109
109
  /** Creates a Stripe PaymentIntent for this cart; returns { client_secret, publishable_key, amount } to mount Stripe Elements with. */
110
110
  stripeIntent: (data) => client.post(`${base}/stripe/intent`, data),
111
+ /** Direct link to the invoice PDF (application/pdf, inline) — not a fetch: open/href this URL directly, same as support_file. Auth is via the ambient JWT cookie. */
112
+ invoiceUrl: (id) => `${client.baseUrl}${base}/${id}/invoice`,
111
113
  };
112
114
  }
113
115
 
@@ -1,4 +1,5 @@
1
1
  import InsigniaClient from '../src/Client.js';
2
+ import Users from '../src/api/v1/Users.js';
2
3
 
3
4
  const BASE = 'http://localhost:8000';
4
5
 
@@ -49,6 +50,11 @@ describe('baseUrl resolution', () => {
49
50
  );
50
51
  });
51
52
 
53
+ test('baseUrl getter exposes the resolved base URL', () => {
54
+ const client = new InsigniaClient('https://custom.example.com/');
55
+ expect(client.baseUrl).toBe('https://custom.example.com');
56
+ });
57
+
52
58
  test('falls back to https://insigniaeducation.com when baseUrl is null and env var is not set', async () => {
53
59
  global.fetch = mockFetch();
54
60
  const client = new InsigniaClient(null);
@@ -246,3 +252,14 @@ describe('HTTP methods', () => {
246
252
  expect(result).toBeNull();
247
253
  });
248
254
  });
255
+
256
+ // ─── payments(userId).invoiceUrl ──────────────────────────────────────────────
257
+ // A direct link, not a fetch — no HTTP call to mock/assert on, just the URL shape.
258
+
259
+ describe('Users.payments(userId).invoiceUrl', () => {
260
+ test('builds a direct link to the invoice endpoint', () => {
261
+ const client = new InsigniaClient(BASE);
262
+ const users = new Users(client);
263
+ expect(users.payments(42).invoiceUrl(7)).toBe(`${BASE}/users/42/payments/7/invoice`);
264
+ });
265
+ });
package/.env DELETED
@@ -1 +0,0 @@
1
- INSIGNIA_EDUCATION_API_BASE_URL=http://localhost:8000
package/.env.test DELETED
@@ -1,5 +0,0 @@
1
- INSIGNIA_EDUCATION_API_BASE_URL=http://localhost:8001
2
- TEST_EMAIL=roquendo@insigniaeducation.com
3
- TEST_PASSWORD=12345678
4
- TEST_EMAIL_ADMIN=rodolfoquendo@gmail.com
5
- TEST_PASSWORD_ADMIN=12345678