@aastrika/ai-elements 0.2.0 → 0.3.0

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 ADDED
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ `@aastrika/ai-elements`. Newest first. One line per change, so a host team can
4
+ see at a glance what to expect when they upgrade.
5
+
6
+ Versions follow semver: a **minor** adds something, a **patch** fixes something,
7
+ and neither removes anything a host was using.
8
+
9
+ ## 0.3.0
10
+
11
+ **Added**
12
+ - `default-translate-into` on `<aastrika-assessment>` — produce the same
13
+ questions in other languages, comma-separated: `"ta,or,bn"`
14
+ - `assessmentReady` now carries `languages`, the translations actually produced
15
+ - Reviewers get a tab per language; Excel exports one sheet per language, CSV
16
+ one language at a time
17
+
18
+ **Fixed**
19
+ - `onError` was never called for hosts configuring through `provideAastrika()`
20
+
21
+ **Notes for integrators**
22
+ - Nothing is removed and nothing changes for a host that ignores the new input
23
+ - `languages` can be shorter than what was asked for: a translation that fails
24
+ its checks is dropped rather than stored wrong
25
+
26
+ ## 0.2.1
27
+
28
+ **Fixed**
29
+ - Documentation corrections in the published README
30
+
31
+ ## 0.2.0
32
+
33
+ **Added**
34
+ - Starting-value inputs (`default-language`, `default-difficulty` and others),
35
+ events (`planReady`, `videoReady`, `assessmentReady`, `reportLoaded`) and an
36
+ `onError` callback
37
+
38
+ ## 0.1.0
39
+
40
+ **Added**
41
+ - First release: `<aastrika-content-studio>`, `<aastrika-assessment>` and
42
+ `<aastrika-reports>` as custom elements, with `configure()`
package/README.md CHANGED
@@ -9,7 +9,7 @@ Svelte or plain HTML.
9
9
  | `<aastrika-assessment>` | Source material becomes a validated MCQ set |
10
10
  | `<aastrika-reports>` | Who used what, and what it cost *(admin only)* |
11
11
 
12
- One file, **86 kB** over the wire, **no dependencies**. Angular is compiled
12
+ One file, **~99 kB gzipped** (86 kB brotli), **no dependencies**. Angular is compiled
13
13
  inside, so you never install it and never upgrade because we did.
14
14
 
15
15
  ---
@@ -20,6 +20,8 @@ inside, so you never install it and never upgrade because we did.
20
20
  |---|---|
21
21
  | [The three features](#the-three-features) | What each element does |
22
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 |
23
25
  | [Framework notes](#framework-notes) | React · Angular · Plain HTML |
24
26
  | [Configuration](#configuration) | The three values, and why two are functions |
25
27
  | [Access](#access) | Which gateway groups each feature needs |
@@ -80,7 +82,7 @@ flowchart LR
80
82
  cfg -.->|apiBase · auth · creator| int
81
83
  tag --> el
82
84
  el --> int
83
- int -->|"Authorization<br/>x-aastrika-creator"| gw
85
+ int -->|"Authorization<br/>creator in the body"| gw
84
86
  gw --> api
85
87
  api -.->|JSON| el
86
88
  el -.->|onError| cfg
@@ -110,7 +112,7 @@ cost estimate, and can revise it in writing as many times as they like. Only
110
112
  While it renders they get five-phase progress and a live log; at the end they
111
113
  can play, download or delete it.
112
114
 
113
- [Full walkthrough →](features/content-studio/README.md)
115
+ [Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/frontend/src/lib/features/content-studio/README.md)
114
116
 
115
117
  ### `<aastrika-assessment>`
116
118
 
@@ -121,7 +123,7 @@ Every question is checked before it is returned: one correct option, no
121
123
  duplicates, nothing the source material does not support. The user can fix
122
124
  wording, re-tick the correct option, then export XLSX or CSV.
123
125
 
124
- [Full walkthrough →](features/assessment/README.md)
126
+ [Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/frontend/src/lib/features/assessment/README.md)
125
127
 
126
128
  ### `<aastrika-reports>`
127
129
 
@@ -133,7 +135,7 @@ spend figures are not for a partner's ordinary users. The service applies no
133
135
  role check of its own, so the gateway's ACL is the only thing keeping them
134
136
  apart.
135
137
 
136
- [Full walkthrough →](features/reports/README.md)
138
+ [Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/frontend/src/lib/features/reports/README.md)
137
139
 
138
140
  ---
139
141
 
@@ -260,7 +262,7 @@ Three things, and nothing else.
260
262
  |---|---|
261
263
  | `apiBase` | Where the service is, no trailing slash. Empty string means same-origin. |
262
264
  | `getAuthHeaders` | Headers proving the caller may use the service — in practice a bearer token. |
263
- | `creator` | The username of whoever is signed into **your** application. |
265
+ | `creator` | Who is signed into **your** application — their name or email, shown as-is in the usage report. |
264
266
  | `onError` | Optional. Called whenever a request fails, so your monitoring hears about it. |
265
267
 
266
268
  **Both are functions, and both are called on every request.** Tokens expire: a
@@ -268,6 +270,9 @@ string handed over at startup stops working mid-session and the package has no
268
270
  way to ask for a fresh one. A function lets you return whatever your own auth
269
271
  library currently holds, and lets you switch user without reloading.
270
272
 
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.
275
+
271
276
  `creator` is **attribution, not identity**. It is recorded against anything the
272
277
  call creates and the usage report groups by it. Nothing verifies it — the
273
278
  gateway decides whether the call is allowed at all.
@@ -284,8 +289,8 @@ needs:
284
289
 
285
290
  | Feature | Groups |
286
291
  |---|---|
287
- | `aastrika-content-studio` | `contentCreate`, `contentRead`, `contentUpdate` |
288
- | `aastrika-assessment` | `contentCreate`, `contentRead`, `contentUpdate` |
292
+ | `aastrika-content-studio` | `contentCreate`, `contentAccess`, `contentUpdate` |
293
+ | `aastrika-assessment` | `contentCreate`, `contentAccess`, `contentUpdate` |
289
294
  | `aastrika-reports` | `contentAdmin` |
290
295
 
291
296
  Deleting anything needs `contentAdmin` as well. Without `contentUpdate` the
@@ -363,6 +368,7 @@ All are **starting values** the user can still change.
363
368
  | `assessment` | `default-language` | |
364
369
  | | `default-question-count` | |
365
370
  | | `default-difficulty` | `mixed`, `easy`, `medium`, `hard` |
371
+ | | `default-translate-into` | Also produce the same questions in these languages, comma-separated: `"ta,or,bn"` |
366
372
  | `reports` | `creator-filter` | Opens filtered to one creator |
367
373
 
368
374
  ```html
@@ -370,6 +376,34 @@ All are **starting values** the user can still change.
370
376
  </aastrika-content-studio>
371
377
  ```
372
378
 
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:
394
+
395
+ ```js
396
+ el.addEventListener('assessmentReady', (e) => {
397
+ e.detail.language; // 'hi' — the one the questions were written in
398
+ e.detail.languages; // ['en','mr'] — the translations produced
399
+ });
400
+ ```
401
+
402
+ `languages` can be shorter than what was asked for. A translation is checked for
403
+ 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.
406
+
373
407
  ### Events
374
408
 
375
409
  | Element | Event | Fires when | `detail` |
@@ -377,7 +411,7 @@ All are **starting values** the user can still change.
377
411
  | `content-studio` | `planReady` | A plan comes back. **Repeatable** — free, so this can fire several times | `jobId`, `title`, `sceneCount`, `estimatedUsd` |
378
412
  | | `videoStarted` | The user commits to a render. **This is where money is spent** | `jobId` |
379
413
  | | `videoReady` | The video is finished | `jobId`, `videoUrl` |
380
- | `assessment` | `assessmentReady` | A validated question set comes back | `jobId`, `questionCount`, `language` |
414
+ | `assessment` | `assessmentReady` | A validated question set comes back | `jobId`, `questionCount`, `language`, `languages` |
381
415
  | `reports` | `reportLoaded` | The figures are on screen | `videos`, `assessments`, `users`, `spendUsd` |
382
416
 
383
417
  ```js
@@ -404,14 +438,14 @@ any DOM event: `(videoReady)="onReady($event)"`.
404
438
  | `403` on revise only | missing `contentUpdate` |
405
439
  | `403` on delete only | missing `contentAdmin` |
406
440
  | `429` on Generate video | the low rate limit, and it is intentional |
407
- | Creator recorded as `unknown` | the gateway's CORS config is dropping `x-aastrika-creator` — tell us |
441
+ | Everything recorded as `admin` | `creator` was not set, or it returned null |
408
442
  | Blank box, no errors | the module did not load, so the tag is an unknown element |
409
443
 
410
444
  ---
411
445
 
412
446
  ## Browser support
413
447
 
414
- Any browser with Custom Elements v1 and Shadow DOM — everything since 2018.
448
+ Any browser with Custom Elements v1 — everything since 2018.
415
449
 
416
450
  ## Server rendering
417
451
 
@@ -20,8 +20,15 @@
20
20
 
21
21
  /** What a request failure tells the host. Stable across features. */
22
22
  export interface AastrikaError {
23
- /** Which element the failure came from. */
24
- feature: 'content-studio' | 'assessment' | 'reports';
23
+ /**
24
+ * Which element the failure came from.
25
+ *
26
+ * The three shipped today, and open to more: a future feature emits a name
27
+ * not in this list, and narrowing the type to only these three would turn
28
+ * that into a compile error in every host's handler. The literals stay so
29
+ * an editor still suggests them.
30
+ */
31
+ feature: 'content-studio' | 'assessment' | 'reports' | (string & {});
25
32
  /** The sentence already shown to the user. */
26
33
  message: string;
27
34
  /** HTTP status. 0 means the request never left the browser — usually CORS. */
@@ -116,11 +123,29 @@ interface AastrikaAssessmentElement extends HTMLElement {
116
123
  defaultQuestionCount?: number;
117
124
  /** `'mixed'`, `'easy'`, `'medium'` or `'hard'`. */
118
125
  defaultDifficulty?: string;
126
+ /**
127
+ * Languages to render the same questions into, comma-separated
128
+ * (`"ta,or,bn"`), written as `default-translate-into` in HTML. The SAME
129
+ * assessment in each — same order, same options, same answer key — so one
130
+ * key marks every language.
131
+ *
132
+ * A starting value like the others: the user can change the selection before
133
+ * generating.
134
+ */
135
+ defaultTranslateInto?: string;
119
136
 
120
- /** A validated question set came back. */
137
+ /**
138
+ * A validated question set came back.
139
+ *
140
+ * `language` is the primary; `languages` lists the translations that were
141
+ * produced, which may be shorter than what was asked for — a language the
142
+ * model could not render faithfully is dropped rather than stored wrong.
143
+ */
121
144
  addEventListener(
122
145
  type: 'assessmentReady',
123
- listener: (e: CustomEvent<{ jobId: string; questionCount: number; language: string }>) => void,
146
+ listener: (e: CustomEvent<{
147
+ jobId: string; questionCount: number; language: string; languages: string[];
148
+ }>) => void,
124
149
  options?: boolean | AddEventListenerOptions,
125
150
  ): void;
126
151
  addEventListener(