@insignia-education/api-sdk-js 0.9.12

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 (87) hide show
  1. package/.github/hooks/pre-commit +13 -0
  2. package/.github/workflows/npm-publish-github-packages.yml +30 -0
  3. package/Cart.js +40 -0
  4. package/LICENSE +21 -0
  5. package/README.md +444 -0
  6. package/babel.config.cjs +1 -0
  7. package/coverage/clover.xml +703 -0
  8. package/coverage/coverage-final.json +30 -0
  9. package/coverage/lcov-report/base.css +224 -0
  10. package/coverage/lcov-report/block-navigation.js +87 -0
  11. package/coverage/lcov-report/favicon.png +0 -0
  12. package/coverage/lcov-report/index.html +131 -0
  13. package/coverage/lcov-report/prettify.css +1 -0
  14. package/coverage/lcov-report/prettify.js +2 -0
  15. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  16. package/coverage/lcov-report/sorter.js +210 -0
  17. package/coverage/lcov-report/src/Client.js.html +202 -0
  18. package/coverage/lcov-report/src/api/v1/Accounts.js.html +151 -0
  19. package/coverage/lcov-report/src/api/v1/Auth.js.html +130 -0
  20. package/coverage/lcov-report/src/api/v1/Categories.js.html +121 -0
  21. package/coverage/lcov-report/src/api/v1/Changelogs.js.html +118 -0
  22. package/coverage/lcov-report/src/api/v1/Configs.js.html +121 -0
  23. package/coverage/lcov-report/src/api/v1/ContactForms.js.html +121 -0
  24. package/coverage/lcov-report/src/api/v1/ConversationalTopics.js.html +121 -0
  25. package/coverage/lcov-report/src/api/v1/Countries.js.html +112 -0
  26. package/coverage/lcov-report/src/api/v1/Coupons.js.html +121 -0
  27. package/coverage/lcov-report/src/api/v1/Courses.js.html +328 -0
  28. package/coverage/lcov-report/src/api/v1/Currencies.js.html +115 -0
  29. package/coverage/lcov-report/src/api/v1/Files.js.html +115 -0
  30. package/coverage/lcov-report/src/api/v1/Forums.js.html +157 -0
  31. package/coverage/lcov-report/src/api/v1/Hashes.js.html +118 -0
  32. package/coverage/lcov-report/src/api/v1/Insignias.js.html +121 -0
  33. package/coverage/lcov-report/src/api/v1/Languages.js.html +121 -0
  34. package/coverage/lcov-report/src/api/v1/MailBlacklist.js.html +118 -0
  35. package/coverage/lcov-report/src/api/v1/Organizations.js.html +118 -0
  36. package/coverage/lcov-report/src/api/v1/Quizzes.js.html +181 -0
  37. package/coverage/lcov-report/src/api/v1/ShortLinks.js.html +121 -0
  38. package/coverage/lcov-report/src/api/v1/Surveys.js.html +181 -0
  39. package/coverage/lcov-report/src/api/v1/Tags.js.html +121 -0
  40. package/coverage/lcov-report/src/api/v1/Taxes.js.html +121 -0
  41. package/coverage/lcov-report/src/api/v1/Teacher.js.html +196 -0
  42. package/coverage/lcov-report/src/api/v1/Translations.js.html +121 -0
  43. package/coverage/lcov-report/src/api/v1/UserTypes.js.html +121 -0
  44. package/coverage/lcov-report/src/api/v1/Users.js.html +331 -0
  45. package/coverage/lcov-report/src/api/v1/Zoom.js.html +154 -0
  46. package/coverage/lcov-report/src/api/v1/index.html +521 -0
  47. package/coverage/lcov-report/src/index.html +116 -0
  48. package/coverage/lcov.info +1822 -0
  49. package/index.js +4 -0
  50. package/jest.config.mjs +201 -0
  51. package/package.json +36 -0
  52. package/scss/Services/_notification.scss +0 -0
  53. package/scss/index.scss +2 -0
  54. package/src/Client.js +39 -0
  55. package/src/api/index.js +20 -0
  56. package/src/api/v1/Accounts.js +22 -0
  57. package/src/api/v1/Auth.js +15 -0
  58. package/src/api/v1/Categories.js +12 -0
  59. package/src/api/v1/Changelogs.js +11 -0
  60. package/src/api/v1/Configs.js +12 -0
  61. package/src/api/v1/ContactForms.js +12 -0
  62. package/src/api/v1/ConversationalTopics.js +12 -0
  63. package/src/api/v1/Countries.js +9 -0
  64. package/src/api/v1/Coupons.js +12 -0
  65. package/src/api/v1/Courses.js +81 -0
  66. package/src/api/v1/Currencies.js +10 -0
  67. package/src/api/v1/Files.js +10 -0
  68. package/src/api/v1/Forums.js +24 -0
  69. package/src/api/v1/Hashes.js +11 -0
  70. package/src/api/v1/Insignias.js +12 -0
  71. package/src/api/v1/Languages.js +12 -0
  72. package/src/api/v1/MailBlacklist.js +11 -0
  73. package/src/api/v1/Organizations.js +11 -0
  74. package/src/api/v1/Quizzes.js +32 -0
  75. package/src/api/v1/ShortLinks.js +12 -0
  76. package/src/api/v1/Surveys.js +32 -0
  77. package/src/api/v1/Tags.js +12 -0
  78. package/src/api/v1/Taxes.js +12 -0
  79. package/src/api/v1/Teacher.js +37 -0
  80. package/src/api/v1/Translations.js +12 -0
  81. package/src/api/v1/UserTypes.js +12 -0
  82. package/src/api/v1/Users.js +82 -0
  83. package/src/api/v1/Zoom.js +23 -0
  84. package/src/api/v1/index.js +74 -0
  85. package/src/index.js +21 -0
  86. package/tests/api/v1.test.js +480 -0
  87. package/tests/client.test.js +214 -0
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+
3
+ PACKAGE=$(node -p "require('./package.json').name")
4
+ VERSION=$(node -p "require('./package.json').version")
5
+
6
+ STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://registry.npmjs.org/${PACKAGE}/${VERSION}")
7
+ if [ "$STATUS" = "200" ]; then
8
+ echo "Error: ${PACKAGE}@${VERSION} is already published on NPM."
9
+ echo "Bump the version in package.json before committing."
10
+ exit 1
11
+ fi
12
+
13
+ exit 0
@@ -0,0 +1,30 @@
1
+ name: Node.js Package
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Setup node
16
+ uses: actions/setup-node@v4
17
+ with:
18
+ node-version: 25
19
+ registry-url: 'https://registry.npmjs.org/'
20
+
21
+ - name: Install dependencies
22
+ run: npm install
23
+
24
+ - name: Run tests
25
+ run: npm test
26
+
27
+ - name: Publish to NPM
28
+ run: npm publish --access public
29
+ env:
30
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/Cart.js ADDED
@@ -0,0 +1,40 @@
1
+ import Store from 'node_modules/@insignia-education/js-core/Store.js'
2
+ export default class Cart{
3
+ #__LOCAL_STORAGE_KEY__ = 'cart';
4
+ #__CART_TYPES__ = [
5
+ 'sessions',
6
+ 'courses',
7
+ 'premiums',
8
+ 'products',
9
+ 'coupons',
10
+ 'exams',
11
+ ];
12
+ #getFromStore(){
13
+ Store._store(this.#__LOCAL_STORAGE_KEY__);
14
+ }
15
+ #setInStore(cart){
16
+ Store._store(this.#__LOCAL_STORAGE_KEY__, cart);
17
+ }
18
+ get(){
19
+ let cart = this.#getFromStore();
20
+ if(cart == null){
21
+ cart = {};
22
+ }
23
+ this.#__CART_TYPES__.forEach(type => {
24
+ if(typeof cart[type] === typeof undefined){
25
+ cart[type] = [];
26
+ }
27
+ });
28
+ this.#setInStore(cart);
29
+ return this.#getFromStore();
30
+ }
31
+ getFromServer(){
32
+
33
+ }
34
+ static init(){
35
+ console.log("cart init");
36
+ const instance = new Cart();
37
+ instance.get();
38
+ console.log()
39
+ }
40
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Insignia Education
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,444 @@
1
+ # @insignia-education/api-sdk-js
2
+
3
+ JavaScript SDK for the [Insignia Education](https://insigniaeducation.com) API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @insignia-education/api-sdk-js
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ ### Environment variable (recommended)
14
+
15
+ Set `INSIGNIA_EDUCATION_API_BASE_URL` in your environment and construct with no arguments:
16
+
17
+ ```bash
18
+ export INSIGNIA_EDUCATION_API_BASE_URL=https://your-instance.com
19
+ ```
20
+
21
+ ```js
22
+ import Insignia from '@insignia-education/api-sdk-js/src/index.js';
23
+
24
+ const sdk = new Insignia(); // uses INSIGNIA_EDUCATION_API_BASE_URL or defaults to https://insigniaeducation.com
25
+ ```
26
+
27
+ ### Explicit base URL
28
+
29
+ ```js
30
+ const sdk = new Insignia('https://your-instance.com');
31
+ ```
32
+
33
+ ### With authentication token
34
+
35
+ ```js
36
+ const sdk = new Insignia(null, 'your-bearer-token');
37
+ // or
38
+ const sdk = new Insignia('https://your-instance.com', 'your-bearer-token');
39
+ ```
40
+
41
+ **URL resolution priority:** explicit `baseUrl` → `INSIGNIA_EDUCATION_API_BASE_URL` → `https://insigniaeducation.com`
42
+
43
+ ## Token management
44
+
45
+ ```js
46
+ sdk.setToken('your-bearer-token');
47
+ sdk.getToken(); // 'your-bearer-token'
48
+ ```
49
+
50
+ ## Usage
51
+
52
+ All resources live under `sdk.api.v1`:
53
+
54
+ ```js
55
+ const { v1 } = sdk.api;
56
+ ```
57
+
58
+ ---
59
+
60
+ ## Authentication
61
+
62
+ ```js
63
+ // Check if email belongs to an existing user or a new registration
64
+ await v1.auth.loginOrRegister('user@example.com');
65
+
66
+ // Register a new user
67
+ await v1.auth.register({ email: 'user@example.com', password: 'secret', name: 'John' });
68
+
69
+ // Login
70
+ const { token } = await v1.auth.login({ email: 'user@example.com', password: 'secret' });
71
+ sdk.setToken(token);
72
+
73
+ // Login with Google
74
+ await v1.auth.googleLogin({ id_token: 'google-id-token' });
75
+
76
+ // Refresh token
77
+ await v1.auth.refresh();
78
+
79
+ // Logout
80
+ await v1.auth.logout();
81
+
82
+ // Get authenticated user
83
+ await v1.auth.user();
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Resources
89
+
90
+ ### Accounts
91
+
92
+ ```js
93
+ await v1.accounts.get(); // list all
94
+ await v1.accounts.get(5); // get by id
95
+ await v1.accounts.create(data);
96
+ await v1.accounts.edit(5, data);
97
+ await v1.accounts.delete(5);
98
+
99
+ // Nested: account moves
100
+ await v1.accounts.moves(5).get();
101
+ await v1.accounts.moves(5).get(10);
102
+ await v1.accounts.moves(5).create(data);
103
+ await v1.accounts.moves(5).edit(10, data);
104
+ await v1.accounts.moves(5).delete(10);
105
+ ```
106
+
107
+ ### Categories
108
+
109
+ ```js
110
+ await v1.categories.get();
111
+ await v1.categories.get(1);
112
+ await v1.categories.create(data);
113
+ await v1.categories.edit(1, data);
114
+ await v1.categories.delete(1);
115
+ ```
116
+
117
+ ### Changelogs
118
+
119
+ ```js
120
+ await v1.changelogs.get();
121
+ await v1.changelogs.get(1);
122
+ await v1.changelogs.approve(1);
123
+ await v1.changelogs.reject(1, { reason: 'Invalid data' });
124
+ ```
125
+
126
+ ### Configs
127
+
128
+ ```js
129
+ await v1.configs.get();
130
+ await v1.configs.get(1);
131
+ await v1.configs.create(data);
132
+ await v1.configs.edit(1, data);
133
+ await v1.configs.delete(1);
134
+ ```
135
+
136
+ ### Contact Forms
137
+
138
+ ```js
139
+ await v1.contactForms.get();
140
+ await v1.contactForms.get(1);
141
+ await v1.contactForms.create(data);
142
+ await v1.contactForms.answer(1, { message: 'Reply text' });
143
+ await v1.contactForms.delete(1);
144
+ ```
145
+
146
+ ### Conversational Topics
147
+
148
+ ```js
149
+ await v1.conversationalTopics.get();
150
+ await v1.conversationalTopics.create(data);
151
+ await v1.conversationalTopics.edit(1, data);
152
+ await v1.conversationalTopics.delete(1);
153
+ ```
154
+
155
+ ### Countries
156
+
157
+ ```js
158
+ await v1.countries.get();
159
+ await v1.countries.get(1);
160
+ ```
161
+
162
+ ### Coupons
163
+
164
+ ```js
165
+ await v1.coupons.get();
166
+ await v1.coupons.get(1);
167
+ await v1.coupons.create(data);
168
+ await v1.coupons.edit(1, data);
169
+ await v1.coupons.delete(1);
170
+ ```
171
+
172
+ ### Courses
173
+
174
+ ```js
175
+ await v1.courses.get();
176
+ await v1.courses.get(1);
177
+ await v1.courses.create(data);
178
+ await v1.courses.edit(1, data);
179
+ await v1.courses.delete(1);
180
+
181
+ // Dates
182
+ await v1.courses.dates(1).get();
183
+ await v1.courses.dates(1).create(data);
184
+ await v1.courses.dates(1).edit(2, data);
185
+ await v1.courses.dates(1).delete(2);
186
+
187
+ // Sessions
188
+ await v1.courses.sessions(1).get();
189
+ await v1.courses.sessions(1).create(data);
190
+
191
+ // Premiums
192
+ await v1.courses.premiums(1).get();
193
+ await v1.courses.premiums(1).create(data);
194
+
195
+ // Premium items
196
+ await v1.courses.premiums(1).items(2).get();
197
+ await v1.courses.premiums(1).items(2).create(data);
198
+
199
+ // Levels -> Lessons -> Materials (deep nesting)
200
+ await v1.courses.levels(1).get();
201
+ await v1.courses.levels(1).lessons(2).get();
202
+ await v1.courses.levels(1).lessons(2).materials(3).get();
203
+ await v1.courses.levels(1).lessons(2).materials(3).create(data);
204
+ ```
205
+
206
+ ### Currencies
207
+
208
+ ```js
209
+ await v1.currencies.get();
210
+ await v1.currencies.get(1);
211
+ await v1.currencies.getValues();
212
+ ```
213
+
214
+ ### Files
215
+
216
+ ```js
217
+ await v1.files.get();
218
+ await v1.files.get(1);
219
+ await v1.files.delete(1);
220
+ ```
221
+
222
+ ### Forums
223
+
224
+ ```js
225
+ await v1.forums.get();
226
+ await v1.forums.create(data);
227
+ await v1.forums.edit(1, data);
228
+ await v1.forums.delete(1);
229
+ await v1.forums.approve(1);
230
+
231
+ // Responses
232
+ await v1.forums.responses(1).get();
233
+ await v1.forums.responses(1).create(data);
234
+ await v1.forums.responses(1).approve(2);
235
+ ```
236
+
237
+ ### Hashes
238
+
239
+ ```js
240
+ await v1.hashes.get();
241
+ await v1.hashes.generate({ purpose: 'recover', user_id: 5 });
242
+ await v1.hashes.delete(1);
243
+ ```
244
+
245
+ ### Insignias
246
+
247
+ ```js
248
+ await v1.insignias.get();
249
+ await v1.insignias.create(data);
250
+ await v1.insignias.edit(1, data);
251
+ await v1.insignias.delete(1);
252
+ ```
253
+
254
+ ### Languages
255
+
256
+ ```js
257
+ await v1.languages.get();
258
+ await v1.languages.create(data);
259
+ await v1.languages.edit(1, data);
260
+ await v1.languages.delete(1);
261
+ ```
262
+
263
+ ### Mail Blacklist
264
+
265
+ ```js
266
+ await v1.mailBlacklist.get();
267
+ await v1.mailBlacklist.create({ email: 'spam@example.com' });
268
+ await v1.mailBlacklist.delete(1);
269
+ ```
270
+
271
+ ### Organizations
272
+
273
+ ```js
274
+ await v1.organizations.get();
275
+ await v1.organizations.create(data);
276
+ await v1.organizations.edit(1, data);
277
+ ```
278
+
279
+ ### Quizzes
280
+
281
+ ```js
282
+ await v1.quizzes.get();
283
+ await v1.quizzes.create(data);
284
+ await v1.quizzes.edit(1, data);
285
+ await v1.quizzes.delete(1);
286
+
287
+ // Questions -> Answers
288
+ await v1.quizzes.questions(1).get();
289
+ await v1.quizzes.questions(1).create(data);
290
+ await v1.quizzes.questions(1).answers(2).get();
291
+ await v1.quizzes.questions(1).answers(2).create(data);
292
+ ```
293
+
294
+ ### Short Links
295
+
296
+ ```js
297
+ await v1.shortLinks.get();
298
+ await v1.shortLinks.create({ url: 'https://long-url.com' });
299
+ await v1.shortLinks.edit(1, data);
300
+ await v1.shortLinks.delete(1);
301
+ ```
302
+
303
+ ### Surveys
304
+
305
+ ```js
306
+ await v1.surveys.get();
307
+ await v1.surveys.create(data);
308
+
309
+ // Questions -> Answers
310
+ await v1.surveys.questions(1).get();
311
+ await v1.surveys.questions(1).answers(2).get();
312
+ ```
313
+
314
+ ### Tags
315
+
316
+ ```js
317
+ await v1.tags.get();
318
+ await v1.tags.create(data);
319
+ await v1.tags.edit(1, data);
320
+ await v1.tags.delete(1);
321
+ ```
322
+
323
+ ### Taxes
324
+
325
+ ```js
326
+ await v1.taxes.get();
327
+ await v1.taxes.create(data);
328
+ await v1.taxes.edit(1, data);
329
+ await v1.taxes.delete(1);
330
+ ```
331
+
332
+ ### Teacher
333
+
334
+ ```js
335
+ await v1.teacher.absences().get();
336
+ await v1.teacher.absences().create(data);
337
+
338
+ await v1.teacher.configSets().get();
339
+ await v1.teacher.configSets().create(data);
340
+
341
+ await v1.teacher.configs().get();
342
+ await v1.teacher.configs().create(data);
343
+ ```
344
+
345
+ ### Translations
346
+
347
+ ```js
348
+ await v1.translations.get();
349
+ await v1.translations.create(data);
350
+ await v1.translations.delete(1);
351
+ await v1.translations.editText(1, { text: 'Translated text' });
352
+ ```
353
+
354
+ ### User Types
355
+
356
+ ```js
357
+ await v1.userTypes.get();
358
+ await v1.userTypes.create(data);
359
+ await v1.userTypes.edit(1, data);
360
+ await v1.userTypes.delete(1);
361
+ ```
362
+
363
+ ### Users
364
+
365
+ ```js
366
+ await v1.users.get();
367
+ await v1.users.get(1);
368
+ await v1.users.edit(1, data);
369
+
370
+ // Nested resources
371
+ await v1.users.courses(1).get();
372
+ await v1.users.courseNotes(1).get();
373
+ await v1.users.quizzes(1).get();
374
+ await v1.users.sessions(1).get();
375
+ await v1.users.surveys(1).get();
376
+ await v1.users.cart(1).get();
377
+
378
+ // Payments
379
+ await v1.users.payments(1).get();
380
+ await v1.users.payments(1).create(data);
381
+ await v1.users.payments(1).verify(2);
382
+ await v1.users.payments(1).reject(2, { reason: 'Fraud' });
383
+
384
+ // Points
385
+ await v1.users.points(1).get();
386
+ await v1.users.points(1).create(data);
387
+ await v1.users.points(1).delete(2);
388
+
389
+ // Money moves
390
+ await v1.users.moneyMoves(1).get();
391
+ await v1.users.moneyMoves(1).create(data);
392
+
393
+ // Statistics
394
+ await v1.users.statistics(1).get();
395
+
396
+ // Organizations
397
+ await v1.users.organizations(1).get();
398
+ await v1.users.organizations(1).create(data);
399
+ await v1.users.organizations(1).delete(2);
400
+
401
+ // Push endpoints
402
+ await v1.users.pushEndpoints(1).get();
403
+ await v1.users.pushEndpoints(1).create(data);
404
+ await v1.users.pushEndpoints(1).delete(2);
405
+ ```
406
+
407
+ ### Zoom
408
+
409
+ ```js
410
+ await v1.zoom.meetings().get();
411
+ await v1.zoom.meetings().get(1);
412
+
413
+ await v1.zoom.tokens().get();
414
+ await v1.zoom.tokens().create(data);
415
+ await v1.zoom.tokens().edit(1, data);
416
+ await v1.zoom.tokens().delete(1);
417
+ ```
418
+
419
+ ---
420
+
421
+ ## Error handling
422
+
423
+ All methods return promises. Wrap calls in try/catch:
424
+
425
+ ```js
426
+ try {
427
+ const user = await v1.auth.user();
428
+ console.log(user);
429
+ } catch (err) {
430
+ console.error('API error:', err);
431
+ }
432
+ ```
433
+
434
+ ---
435
+
436
+ ## Running tests
437
+
438
+ ```bash
439
+ npm test
440
+ ```
441
+
442
+ ## License
443
+
444
+ MIT
@@ -0,0 +1 @@
1
+ module.exports = {presets: [['@babel/preset-env', {targets: {node: 'current'}}]]}