@aastrika/ai-elements 0.3.0 → 0.4.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/README.md +177 -108
- package/aastrika-elements.js +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,44 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Svelte or plain HTML.
|
|
3
|
+
# @aastrika/ai-elements
|
|
5
4
|
|
|
6
|
-
|
|
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)* |
|
|
5
|
+
**Three AI features. Three HTML tags. Any framework.**
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
[](https://www.npmjs.com/package/@aastrika/ai-elements)
|
|
8
|
+
[](https://www.npmjs.com/package/@aastrika/ai-elements)
|
|
9
|
+
[](https://www.npmjs.com/package/@aastrika/ai-elements)
|
|
10
|
+
[](https://github.com/Sphere/aastrika-ai-service/blob/master/LICENSE)
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
</div>
|
|
16
13
|
|
|
17
|
-
|
|
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
|
-
##
|
|
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,43 @@ 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-
|
|
48
|
+
<aastrika-assessment default-language="hi" default-translate-into="ta,or"></aastrika-assessment>
|
|
54
49
|
```
|
|
55
50
|
|
|
56
|
-
|
|
51
|
+
<div align="center">
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
|
|
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.
|
|
60
56
|
|
|
61
|
-
|
|
57
|
+
</div>
|
|
62
58
|
|
|
63
|
-
|
|
59
|
+
> [!IMPORTANT]
|
|
60
|
+
> **You also need gateway access.** This package authenticates nobody — your
|
|
61
|
+
> gateway decides. See [Access](#access) for the groups each feature needs.
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
flowchart LR
|
|
67
|
-
subgraph host["Your application"]
|
|
68
|
-
cfg["configure()"]
|
|
69
|
-
tag["<aastrika-content-studio>"]
|
|
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
|
|
63
|
+
---
|
|
81
64
|
|
|
82
|
-
|
|
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
|
|
65
|
+
## Where to look
|
|
89
66
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
67
|
+
| | |
|
|
68
|
+
|---|---|
|
|
69
|
+
| **[The three features](#the-three-features)** | What each element actually does |
|
|
70
|
+
| **[Setup](#setup)** | Install · access · configure · mount |
|
|
71
|
+
| **[Configuration](#configuration)** | The three values, and why two are functions |
|
|
72
|
+
| **[Access](#access)** | Which gateway groups each feature needs |
|
|
73
|
+
| **[Inputs and events](#inputs-and-events)** | Open the form set up, act on the result |
|
|
74
|
+
| **[Error reporting](#knowing-when-something-failed)** | Route failures to your monitoring |
|
|
75
|
+
| | |
|
|
76
|
+
| [Integration guide ↗](https://github.com/Sphere/aastrika-ai-service/blob/master/docs/INTEGRATION.md) | Step by step, both auth paths |
|
|
77
|
+
| [Runnable Angular app ↗](https://github.com/Sphere/aastrika-ai-service/tree/master/frontend/lib-demo-app) | Clone it, change one line, run it |
|
|
78
|
+
| [Changelog ↗](./CHANGELOG.md) | What changed in each version |
|
|
95
79
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
into your page, styled through CSS custom properties.
|
|
80
|
+
*Framework notes, theming, troubleshooting and server rendering are collapsed
|
|
81
|
+
below — open the one you need.*
|
|
99
82
|
|
|
100
83
|
---
|
|
101
84
|
|
|
@@ -103,45 +86,65 @@ into your page, styled through CSS custom properties.
|
|
|
103
86
|
|
|
104
87
|
### `<aastrika-content-studio>`
|
|
105
88
|
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
**A PDF goes in. A narrated, illustrated training video comes out.**
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
upload ──▶ pick style ──▶ review the plan ──▶ generate ──▶ play / download
|
|
93
|
+
language free, revisable the only
|
|
94
|
+
voice cost shown first paid step
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The user uploads source material, picks a style, language and voice, and sees a
|
|
98
|
+
scene-by-scene plan with an estimated cost. **Planning is free and repeatable** —
|
|
99
|
+
they can rewrite it in plain words as often as they like. Only *Generate video*
|
|
100
|
+
spends money, and the estimate is on screen before they commit.
|
|
108
101
|
|
|
109
|
-
|
|
110
|
-
|
|
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.
|
|
102
|
+
While it renders they see five-phase progress and a live log. At the end they
|
|
103
|
+
can play it, download it, or delete it.
|
|
114
104
|
|
|
115
|
-
[Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/
|
|
105
|
+
[Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/docs/API.md)
|
|
116
106
|
|
|
117
107
|
### `<aastrika-assessment>`
|
|
118
108
|
|
|
119
|
-
|
|
120
|
-
|
|
109
|
+
**Training material goes in. A validated MCQ set comes out — in as many
|
|
110
|
+
languages as you need.**
|
|
121
111
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
112
|
+
```
|
|
113
|
+
files & links ──▶ settings ──▶ questions ──▶ review each ──▶ export
|
|
114
|
+
language checked language on xlsx / csv
|
|
115
|
+
count before you its own tab
|
|
116
|
+
difficulty see them
|
|
117
|
+
```
|
|
125
118
|
|
|
126
|
-
|
|
119
|
+
Every question is checked before it reaches the user: exactly one correct
|
|
120
|
+
option, no duplicates, nothing the source material does not support.
|
|
121
|
+
|
|
122
|
+
Ask for other languages and you get the **same** questions translated — same
|
|
123
|
+
order, same options, same answer key — so one answer key marks every paper and
|
|
124
|
+
scores compare across them. The reviewer reads each language on its own tab and
|
|
125
|
+
fixes wording in place; the correct option is shared, so it is set once.
|
|
126
|
+
|
|
127
|
+
[Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/docs/API.md)
|
|
127
128
|
|
|
128
129
|
### `<aastrika-reports>`
|
|
129
130
|
|
|
130
|
-
Who
|
|
131
|
-
estimated spend, split by tool, with a searchable table of creators.
|
|
131
|
+
**Who made what, and what it cost.**
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
role check of its own, so the gateway's ACL is the only thing keeping them
|
|
136
|
-
apart.
|
|
133
|
+
Totals for videos, assessments, people and estimated spend, split by tool, with
|
|
134
|
+
a searchable table of creators.
|
|
137
135
|
|
|
138
|
-
[
|
|
136
|
+
> [!WARNING]
|
|
137
|
+
> **Needs `contentAdmin`, and most consumers should not have it.** Spend figures
|
|
138
|
+
> are not for a partner's ordinary users. The service applies no role check of
|
|
139
|
+
> its own — the gateway's ACL is the only thing keeping them apart.
|
|
140
|
+
|
|
141
|
+
[Full walkthrough →](https://github.com/Sphere/aastrika-ai-service/blob/master/docs/API.md)
|
|
139
142
|
|
|
140
143
|
---
|
|
141
144
|
|
|
142
145
|
## Setup
|
|
143
146
|
|
|
144
|
-
The [Quick start](#
|
|
147
|
+
The [Quick start](#ship-it-in-three-steps) above is the whole integration. What each step
|
|
145
148
|
is actually doing:
|
|
146
149
|
|
|
147
150
|
| | Step | Notes |
|
|
@@ -153,7 +156,8 @@ is actually doing:
|
|
|
153
156
|
|
|
154
157
|
---
|
|
155
158
|
|
|
156
|
-
|
|
159
|
+
<details>
|
|
160
|
+
<summary><b>React · Angular · Vue · plain HTML</b></summary>
|
|
157
161
|
|
|
158
162
|
### React
|
|
159
163
|
|
|
@@ -254,31 +258,79 @@ calling it, as above, prevents both.
|
|
|
254
258
|
|
|
255
259
|
---
|
|
256
260
|
|
|
261
|
+
</details>
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## How it fits together
|
|
266
|
+
|
|
267
|
+
```mermaid
|
|
268
|
+
flowchart LR
|
|
269
|
+
subgraph host["Your application"]
|
|
270
|
+
cfg["configure()"]
|
|
271
|
+
tag["<aastrika-content-studio>"]
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
subgraph pkg["@aastrika/ai-elements"]
|
|
275
|
+
el["Custom element"]
|
|
276
|
+
int["Interceptor"]
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
subgraph svc["Aastrika"]
|
|
280
|
+
gw["Gateway<br/>checks the token"]
|
|
281
|
+
api["AI service"]
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
cfg -.->|apiBase · auth · creator| int
|
|
285
|
+
tag --> el
|
|
286
|
+
el --> int
|
|
287
|
+
int -->|"Authorization<br/>creator in the body"| gw
|
|
288
|
+
gw --> api
|
|
289
|
+
api -.->|JSON| el
|
|
290
|
+
el -.->|onError| cfg
|
|
291
|
+
|
|
292
|
+
classDef a fill:#0F766E,stroke:none,color:#fff
|
|
293
|
+
classDef b fill:#f1f5f4,stroke:#cbd5d3,color:#16181d
|
|
294
|
+
class el,int a
|
|
295
|
+
class cfg,tag,gw,api b
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Your application supplies three values. The package does the rest** — builds
|
|
299
|
+
every request from `apiBase`, calls your two functions on each one, and renders
|
|
300
|
+
into your page, styled through CSS custom properties.
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
257
304
|
## Configuration
|
|
258
305
|
|
|
259
|
-
Three
|
|
306
|
+
Three values. That is the whole contract.
|
|
260
307
|
|
|
261
|
-
| | |
|
|
262
|
-
|
|
263
|
-
| `apiBase` | Where the service is, no trailing slash.
|
|
264
|
-
| `getAuthHeaders` | Headers proving the caller may use the service —
|
|
265
|
-
| `creator` | Who is signed into
|
|
266
|
-
| `onError` |
|
|
308
|
+
| | | |
|
|
309
|
+
|---|---|---|
|
|
310
|
+
| `apiBase` | **required** | Where the service is, no trailing slash. `''` means same-origin |
|
|
311
|
+
| `getAuthHeaders` | **required** | Headers proving the caller may use the service — a bearer token in practice |
|
|
312
|
+
| `creator` | **required** | Who is signed into *your* app. A name or email, shown as-is in the usage report |
|
|
313
|
+
| `onError` | optional | Called whenever a request fails, so your monitoring hears about it |
|
|
267
314
|
|
|
268
|
-
|
|
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.
|
|
315
|
+
### Why two of them are functions
|
|
272
316
|
|
|
273
|
-
|
|
274
|
-
|
|
317
|
+
Tokens expire. A string handed over at startup stops working mid-session, and
|
|
318
|
+
the package has no way to ask for a fresh one.
|
|
275
319
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
320
|
+
```js
|
|
321
|
+
getAuthHeaders: async () => ({ Authorization: `Bearer ${await auth.token()}` }),
|
|
322
|
+
// ^^^^^ called on every request, so a refreshed token just works
|
|
323
|
+
```
|
|
279
324
|
|
|
280
|
-
The
|
|
281
|
-
|
|
325
|
+
The same goes for `creator`: a function lets you switch user without reloading
|
|
326
|
+
the page.
|
|
327
|
+
|
|
328
|
+
> [!NOTE]
|
|
329
|
+
> **`creator` is attribution, not identity.** It is recorded against whatever
|
|
330
|
+
> the call creates and the usage report groups by it. Nothing verifies it — the
|
|
331
|
+
> gateway decides whether the call is allowed at all.
|
|
332
|
+
>
|
|
333
|
+
> Use `asha.kumari`, not a UUID. It appears as-is in the report.
|
|
282
334
|
|
|
283
335
|
---
|
|
284
336
|
|
|
@@ -296,12 +348,14 @@ needs:
|
|
|
296
348
|
Deleting anything needs `contentAdmin` as well. Without `contentUpdate` the
|
|
297
349
|
features still work, but the revise step returns 403.
|
|
298
350
|
|
|
351
|
+
> [!CAUTION]
|
|
299
352
|
> **`generate-video` is the only call that spends real money**, and it sits on a
|
|
300
353
|
> deliberately low rate limit. Users see a cost estimate before triggering it.
|
|
301
354
|
|
|
302
355
|
---
|
|
303
356
|
|
|
304
|
-
|
|
357
|
+
<details>
|
|
358
|
+
<summary><b>Theming with CSS custom properties</b></summary>
|
|
305
359
|
|
|
306
360
|
CSS custom properties are the styling surface:
|
|
307
361
|
|
|
@@ -321,6 +375,10 @@ stylesheet is broad, scope it away from the three tags.
|
|
|
321
375
|
|
|
322
376
|
---
|
|
323
377
|
|
|
378
|
+
</details>
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
324
382
|
## Knowing when something failed
|
|
325
383
|
|
|
326
384
|
The elements show their own error to the user. `onError` is the second copy, for
|
|
@@ -429,7 +487,8 @@ any DOM event: `(videoReady)="onReady($event)"`.
|
|
|
429
487
|
|
|
430
488
|
---
|
|
431
489
|
|
|
432
|
-
|
|
490
|
+
<details>
|
|
491
|
+
<summary><b>Troubleshooting — symptom → cause</b></summary>
|
|
433
492
|
|
|
434
493
|
| Symptom | Cause |
|
|
435
494
|
|---|---|
|
|
@@ -443,11 +502,16 @@ any DOM event: `(videoReady)="onReady($event)"`.
|
|
|
443
502
|
|
|
444
503
|
---
|
|
445
504
|
|
|
505
|
+
</details>
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
446
509
|
## Browser support
|
|
447
510
|
|
|
448
511
|
Any browser with Custom Elements v1 — everything since 2018.
|
|
449
512
|
|
|
450
|
-
|
|
513
|
+
<details>
|
|
514
|
+
<summary><b>Server rendering (Next.js, Angular Universal)</b></summary>
|
|
451
515
|
|
|
452
516
|
**Import this package only in browser code.** It is not server-renderable, and
|
|
453
517
|
the failure is a crash rather than an empty box: `@angular/elements` declares a
|
|
@@ -471,3 +535,8 @@ Angular Universal: keep the import inside a browser-only guard, or load it in
|
|
|
471
535
|
Nothing is lost by this. The elements have no server-rendered output to hydrate
|
|
472
536
|
— they fetch everything at runtime — so a client-only import renders exactly the
|
|
473
537
|
same page.
|
|
538
|
+
|
|
539
|
+
</details>
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|