@aastrika/ai-elements 0.3.0 → 0.4.1

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/CHANGELOG.md CHANGED
@@ -6,6 +6,29 @@ see at a glance what to expect when they upgrade.
6
6
  Versions follow semver: a **minor** adds something, a **patch** fixes something,
7
7
  and neither removes anything a host was using.
8
8
 
9
+ ## 0.4.1
10
+
11
+ **Fixed**
12
+ - This page now renders on npm. The architecture diagram was mermaid, which npm
13
+ shows as raw source, and the callouts used GitHub alert syntax. No code change
14
+
15
+ ## 0.4.0
16
+
17
+ **Changed**
18
+ - Generating a quiz now starts the work and polls for it, instead of waiting on
19
+ one long request. Nothing to change in your code — same tag, same inputs, same
20
+ `assessmentReady` firing once with the finished set
21
+
22
+ **Why it matters**
23
+ - No 60-second ceiling: gateways and proxies commonly close a request at one
24
+ minute, which capped how many languages could be asked for at once
25
+ - The progress shown is the server's own, not an estimate
26
+ - Closing the tab no longer loses the work
27
+
28
+ **Notes for integrators**
29
+ - Upgrade the service and the package together. A 0.3.0 element cannot read what
30
+ a 0.4.0 service answers, and the reverse leaves the element waiting
31
+
9
32
  ## 0.3.0
10
33
 
11
34
  **Added**
package/README.md CHANGED
@@ -1,44 +1,37 @@
1
+ <div align="center">
2
+
1
3
  # @aastrika/ai-elements
2
4
 
3
- **Three Aastrika features as custom elements.** Works in React, Vue, Angular,
4
- Svelte or plain HTML.
5
+ **Three AI features. Three HTML tags. Any framework.**
5
6
 
6
- | Tag | What it does |
7
- |---|---|
8
- | `<aastrika-content-studio>` | A document becomes a narrated, illustrated training video |
9
- | `<aastrika-assessment>` | Source material becomes a validated MCQ set |
10
- | `<aastrika-reports>` | Who used what, and what it cost *(admin only)* |
7
+ [![npm](https://img.shields.io/npm/v/@aastrika/ai-elements?color=A98229&label=npm)](https://www.npmjs.com/package/@aastrika/ai-elements)
8
+ [![size](https://img.shields.io/badge/gzipped-99%20kB-A98229)](https://www.npmjs.com/package/@aastrika/ai-elements)
9
+ [![deps](https://img.shields.io/badge/dependencies-0-A98229)](https://www.npmjs.com/package/@aastrika/ai-elements)
10
+ [![licence](https://img.shields.io/npm/l/@aastrika/ai-elements?color=A98229)](https://github.com/Sphere/aastrika-ai-service/blob/master/LICENSE)
11
11
 
12
- One file, **~99 kB gzipped** (86 kB brotli), **no dependencies**. Angular is compiled
13
- inside, so you never install it and never upgrade because we did.
12
+ </div>
14
13
 
15
- ---
16
-
17
- ## Contents
14
+ ```html
15
+ <aastrika-content-studio></aastrika-content-studio> <!-- document → narrated video -->
16
+ <aastrika-assessment></aastrika-assessment> <!-- material → MCQ set, translated -->
17
+ <aastrika-reports></aastrika-reports> <!-- who used what, and what it cost -->
18
+ ```
18
19
 
19
- | | |
20
- |---|---|
21
- | [The three features](#the-three-features) | What each element does |
22
- | [Setup](#setup) | Install, access, configure, mount |
23
- | [Integration guide](../../../docs/INTEGRATION.md) | Step by step, both auth paths |
24
- | [Angular example](../../lib-demo-app/) | A runnable app |
25
- | [Framework notes](#framework-notes) | React · Angular · Plain HTML |
26
- | [Configuration](#configuration) | The three values, and why two are functions |
27
- | [Access](#access) | Which gateway groups each feature needs |
28
- | [Theming](#theming) | CSS custom properties |
29
- | [Knowing when something failed](#knowing-when-something-failed) | Routing errors to your monitoring |
30
- | [Inputs and events](#inputs-and-events) | Opening the form set up, and acting on the result |
31
- | [When it does not work](#when-it-does-not-work) | Symptom → cause |
32
- | [Browser support](#browser-support) · [Server rendering](#server-rendering) | Constraints |
20
+ Works in **React, Vue, Angular, Svelte or plain HTML**. Angular is compiled
21
+ inside the package, so you never install it and never upgrade because we did.
33
22
 
34
23
  ---
35
24
 
36
- ## Quick start
25
+ ## Ship it in three steps
26
+
27
+ **1 — Install.** No peer dependencies, nothing to match.
37
28
 
38
29
  ```bash
39
30
  npm i @aastrika/ai-elements
40
31
  ```
41
32
 
33
+ **2 — Configure once**, before anything renders.
34
+
42
35
  ```js
43
36
  import { configure } from '@aastrika/ai-elements';
44
37
 
@@ -49,53 +42,41 @@ configure({
49
42
  });
50
43
  ```
51
44
 
45
+ **3 — Write the tag.** Importing the package registers it, so there is no step 4.
46
+
52
47
  ```html
53
- <aastrika-content-studio></aastrika-content-studio>
48
+ <aastrika-assessment default-language="hi" default-translate-into="ta,or"></aastrika-assessment>
54
49
  ```
55
50
 
56
- That is the whole integration. The rest of this file is detail.
51
+ <div align="center">
52
+
53
+ **That is the whole integration.**
54
+ A trainer uploads a PDF and gets a validated quiz in Hindi, Tamil and Odia —
55
+ same questions, same answer key, ready to download.
56
+
57
+ </div>
57
58
 
58
- > **You also need gateway access.** The package authenticates nobody — see
59
- > [Access](#access) for the groups each feature requires.
59
+ > **You also need gateway access.** This package authenticates nobody — your
60
+ > gateway decides. See [Access](#access) for the groups each feature needs.
60
61
 
61
62
  ---
62
63
 
63
- ## How it fits together
64
+ ## Where to look
64
65
 
65
- ```mermaid
66
- flowchart LR
67
- subgraph host["Your application"]
68
- cfg["configure()"]
69
- tag["&lt;aastrika-content-studio&gt;"]
70
- end
71
-
72
- subgraph pkg["@aastrika/ai-elements"]
73
- el["Custom element"]
74
- int["Interceptor"]
75
- end
76
-
77
- subgraph svc["Aastrika"]
78
- gw["Gateway<br/>checks the token"]
79
- api["AI service"]
80
- end
81
-
82
- cfg -.->|apiBase · auth · creator| int
83
- tag --> el
84
- el --> int
85
- int -->|"Authorization<br/>creator in the body"| gw
86
- gw --> api
87
- api -.->|JSON| el
88
- el -.->|onError| cfg
89
-
90
- classDef a fill:#0F766E,stroke:none,color:#fff
91
- classDef b fill:#f1f5f4,stroke:#cbd5d3,color:#16181d
92
- class el,int a
93
- class cfg,tag,gw,api b
94
- ```
66
+ | | |
67
+ |---|---|
68
+ | **[The three features](#the-three-features)** | What each element actually does |
69
+ | **[Configuration](#configuration)** | The three values, and why two are functions |
70
+ | **[Access](#access)** | Which gateway groups each feature needs |
71
+ | **[Inputs and events](#inputs-and-events)** | Open the form set up, act on the result |
72
+ | **[Error reporting](#knowing-when-something-failed)** | Route failures to your monitoring |
73
+ | | |
74
+ | [Integration guide ↗](https://github.com/Sphere/aastrika-ai-service/blob/master/docs/INTEGRATION.md) | Step by step, both auth paths |
75
+ | [Runnable Angular app ↗](https://github.com/Sphere/aastrika-ai-service/tree/master/frontend/lib-demo-app) | Clone it, change one line, run it |
76
+ | [Changelog ↗](./CHANGELOG.md) | What changed in each version |
95
77
 
96
- **Your application supplies three values. The package does the rest** — builds
97
- every request from `apiBase`, calls your two functions on each one, and renders
98
- into your page, styled through CSS custom properties.
78
+ *Framework notes, theming, troubleshooting and server rendering are collapsed
79
+ below — open the one you need.*
99
80
 
100
81
  ---
101
82
 
@@ -103,57 +84,63 @@ into your page, styled through CSS custom properties.
103
84
 
104
85
  ### `<aastrika-content-studio>`
105
86
 
106
- Upload a PDF, pick a style, language and voice, and get back a narrated,
107
- illustrated training video.
87
+ **A PDF goes in. A narrated, illustrated training video comes out.**
108
88
 
109
- Planning is free and repeatable — the user sees the scene-by-scene plan and a
110
- cost estimate, and can revise it in writing as many times as they like. Only
111
- **Generate video** spends money, and the user sees what it will cost first.
112
- While it renders they get five-phase progress and a live log; at the end they
113
- can play, download or delete it.
89
+ ```
90
+ upload ──▶ pick style ──▶ review the plan ──▶ generate ──▶ play / download
91
+ language free, revisable the only
92
+ voice cost shown first paid step
93
+ ```
114
94
 
115
- [Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/frontend/src/lib/features/content-studio/README.md)
95
+ The user uploads source material, picks a style, language and voice, and sees a
96
+ scene-by-scene plan with an estimated cost. **Planning is free and repeatable** —
97
+ they can rewrite it in plain words as often as they like. Only *Generate video*
98
+ spends money, and the estimate is on screen before they commit.
116
99
 
117
- ### `<aastrika-assessment>`
100
+ While it renders they see five-phase progress and a live log. At the end they
101
+ can play it, download it, or delete it.
118
102
 
119
- Files and links in, a validated multiple-choice set out — with control over
120
- language, question count, difficulty and Bloom level.
103
+ [Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/docs/API.md)
121
104
 
122
- Every question is checked before it is returned: one correct option, no
123
- duplicates, nothing the source material does not support. The user can fix
124
- wording, re-tick the correct option, then export XLSX or CSV.
105
+ ### `<aastrika-assessment>`
125
106
 
126
- [Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/frontend/src/lib/features/assessment/README.md)
107
+ **Training material goes in. A validated MCQ set comes out — in as many
108
+ languages as you need.**
127
109
 
128
- ### `<aastrika-reports>`
110
+ ```
111
+ files & links ──▶ settings ──▶ questions ──▶ review each ──▶ export
112
+ language checked language on xlsx / csv
113
+ count before you its own tab
114
+ difficulty see them
115
+ ```
129
116
 
130
- Who used what, and what it cost — totals for videos, assessments, people and
131
- estimated spend, split by tool, with a searchable table of creators.
117
+ Every question is checked before it reaches the user: exactly one correct
118
+ option, no duplicates, nothing the source material does not support.
132
119
 
133
- **Needs `contentAdmin` at the gateway**, and most consumers should not have it:
134
- spend figures are not for a partner's ordinary users. The service applies no
135
- role check of its own, so the gateway's ACL is the only thing keeping them
136
- apart.
120
+ Ask for other languages and you get the **same** questions translated — same
121
+ order, same options, same answer key — so one answer key marks every paper and
122
+ scores compare across them. The reviewer reads each language on its own tab and
123
+ fixes wording in place; the correct option is shared, so it is set once.
137
124
 
138
- [Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/frontend/src/lib/features/reports/README.md)
125
+ [Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/docs/API.md)
139
126
 
140
- ---
127
+ ### `<aastrika-reports>`
141
128
 
142
- ## Setup
129
+ **Who made what, and what it cost.**
143
130
 
144
- The [Quick start](#quick-start) above is the whole integration. What each step
145
- is actually doing:
131
+ Totals for videos, assessments, people and estimated spend, split by tool, with
132
+ a searchable table of creators.
146
133
 
147
- | | Step | Notes |
148
- |---|---|---|
149
- | **1** | `npm i @aastrika/ai-elements` | No peer dependencies, no framework to match. Any bundler, or none |
150
- | **2** | Get gateway access | The package authenticates nobody — your gateway decides. See [Access](#access), then ask the Aastrika platform team |
151
- | **3** | `configure({ ... })` | Once, before the first element renders. Two of the three values are **functions** — see [Configuration](#configuration) |
152
- | **4** | Write the tag | Registration happens on import, so there is no third step |
134
+ > **Needs `contentAdmin`, and most consumers should not have it.** Spend figures
135
+ > are not for a partner's ordinary users. The service applies no role check of
136
+ > its own — the gateway's ACL is the only thing keeping them apart.
137
+
138
+ [Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/docs/API.md)
153
139
 
154
140
  ---
155
141
 
156
- ## Framework notes
142
+ <details>
143
+ <summary><b>React · Angular · Vue · plain HTML</b></summary>
157
144
 
158
145
  ### React
159
146
 
@@ -254,31 +241,57 @@ calling it, as above, prevents both.
254
241
 
255
242
  ---
256
243
 
244
+ </details>
245
+
246
+ ---
247
+
248
+ ## How it fits together
249
+
250
+ ```
251
+ Your application @aastrika/ai-elements Aastrika
252
+ ──────────────── ───────────────────── ────────
253
+ configure() ─────── apiBase ───▶ interceptor ─── Authorization ───▶ gateway
254
+ auth ▲ creator in body │
255
+ creator │ ▼
256
+ <aastrika-… > ────────────────▶ element ◀────────── JSON ──────── AI service
257
+ ▲ │
258
+ └──── onError ────┘
259
+ ```
260
+
261
+ Your application supplies three values. The package builds every request from
262
+ `apiBase`, calls your two functions on each one, and renders into your page.
263
+
264
+ ---
265
+
257
266
  ## Configuration
258
267
 
259
- Three things, and nothing else.
268
+ Three values. That is the whole contract.
260
269
 
261
- | | |
262
- |---|---|
263
- | `apiBase` | Where the service is, no trailing slash. Empty string means same-origin. |
264
- | `getAuthHeaders` | Headers proving the caller may use the service — in practice a bearer token. |
265
- | `creator` | Who is signed into **your** application — their name or email, shown as-is in the usage report. |
266
- | `onError` | Optional. Called whenever a request fails, so your monitoring hears about it. |
270
+ | | | |
271
+ |---|---|---|
272
+ | `apiBase` | **required** | Where the service is, no trailing slash. `''` means same-origin |
273
+ | `getAuthHeaders` | **required** | Headers proving the caller may use the service — a bearer token in practice |
274
+ | `creator` | **required** | Who is signed into *your* app. A name or email, shown as-is in the usage report |
275
+ | `onError` | optional | Called whenever a request fails, so your monitoring hears about it |
267
276
 
268
- **Both are functions, and both are called on every request.** Tokens expire: a
269
- string handed over at startup stops working mid-session and the package has no
270
- way to ask for a fresh one. A function lets you return whatever your own auth
271
- library currently holds, and lets you switch user without reloading.
277
+ ### Why two of them are functions
272
278
 
273
- `creator` should be a **name or email** — it is displayed as-is in the usage
274
- report, so `asha.kumari` reads well and a UUID does not.
279
+ Tokens expire. A string handed over at startup stops working mid-session, and
280
+ the package has no way to ask for a fresh one.
275
281
 
276
- `creator` is **attribution, not identity**. It is recorded against anything the
277
- call creates and the usage report groups by it. Nothing verifies it — the
278
- gateway decides whether the call is allowed at all.
282
+ ```js
283
+ getAuthHeaders: async () => ({ Authorization: `Bearer ${await auth.token()}` }),
284
+ // ^^^^^ called on every request, so a refreshed token just works
285
+ ```
279
286
 
280
- The package authenticates nobody and has no login of its own. You are already
281
- signed in, and you know who that is better than we could.
287
+ The same goes for `creator`: a function lets you switch user without reloading
288
+ the page.
289
+
290
+ > **`creator` is attribution, not identity.** It is recorded against whatever
291
+ > the call creates and the usage report groups by it. Nothing verifies it — the
292
+ > gateway decides whether the call is allowed at all.
293
+ >
294
+ > Use `asha.kumari`, not a UUID. It appears as-is in the report.
282
295
 
283
296
  ---
284
297
 
@@ -301,7 +314,8 @@ features still work, but the revise step returns 403.
301
314
 
302
315
  ---
303
316
 
304
- ## Theming
317
+ <details>
318
+ <summary><b>Theming with CSS custom properties</b></summary>
305
319
 
306
320
  CSS custom properties are the styling surface:
307
321
 
@@ -321,6 +335,10 @@ stylesheet is broad, scope it away from the three tags.
321
335
 
322
336
  ---
323
337
 
338
+ </details>
339
+
340
+ ---
341
+
324
342
  ## Knowing when something failed
325
343
 
326
344
  The elements show their own error to the user. `onError` is the second copy, for
@@ -376,21 +394,7 @@ All are **starting values** the user can still change.
376
394
  </aastrika-content-studio>
377
395
  ```
378
396
 
379
- ### One quiz, several languages
380
-
381
- `default-translate-into` produces the **same** questions in other languages —
382
- same order, same options, same answer key — so one answer key marks every
383
- language and scores compare across them.
384
-
385
- ```html
386
- <aastrika-assessment default-language="hi" default-translate-into="en,mr">
387
- </aastrika-assessment>
388
- ```
389
-
390
- The reviewer gets a tab per language. Excel holds every language, one sheet
391
- each; CSV holds one language at a time.
392
-
393
- `assessmentReady` reports what came back:
397
+ ### Translations, in the event
394
398
 
395
399
  ```js
396
400
  el.addEventListener('assessmentReady', (e) => {
@@ -401,8 +405,8 @@ el.addEventListener('assessmentReady', (e) => {
401
405
 
402
406
  `languages` can be shorter than what was asked for. A translation is checked for
403
407
  question count, ids, answer key, clinical numbers and script; one that fails is
404
- dropped rather than stored wrong. What is **not** checked is whether the
405
- translation reads well — that still needs someone who speaks the language.
408
+ dropped rather than stored wrong. What is **not** checked is whether it reads
409
+ well — that still needs someone who speaks the language.
406
410
 
407
411
  ### Events
408
412
 
@@ -429,7 +433,8 @@ any DOM event: `(videoReady)="onReady($event)"`.
429
433
 
430
434
  ---
431
435
 
432
- ## When it does not work
436
+ <details>
437
+ <summary><b>Troubleshooting — symptom → cause</b></summary>
433
438
 
434
439
  | Symptom | Cause |
435
440
  |---|---|
@@ -443,11 +448,16 @@ any DOM event: `(videoReady)="onReady($event)"`.
443
448
 
444
449
  ---
445
450
 
451
+ </details>
452
+
453
+ ---
454
+
446
455
  ## Browser support
447
456
 
448
457
  Any browser with Custom Elements v1 — everything since 2018.
449
458
 
450
- ## Server rendering
459
+ <details>
460
+ <summary><b>Server rendering (Next.js, Angular Universal)</b></summary>
451
461
 
452
462
  **Import this package only in browser code.** It is not server-renderable, and
453
463
  the failure is a crash rather than an empty box: `@angular/elements` declares a
@@ -471,3 +481,8 @@ Angular Universal: keep the import inside a browser-only guard, or load it in
471
481
  Nothing is lost by this. The elements have no server-rendered output to hydrate
472
482
  — they fetch everything at runtime — so a client-only import renders exactly the
473
483
  same page.
484
+
485
+ </details>
486
+
487
+ ---
488
+