@intellectif/lk-core 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.
Files changed (61) hide show
  1. package/README.md +70 -0
  2. package/dist/activity-zdcAMtFB.d.cts +626 -0
  3. package/dist/activity-zdcAMtFB.d.ts +626 -0
  4. package/dist/chunk-3YAVDV5F.js +47 -0
  5. package/dist/chunk-3YAVDV5F.js.map +1 -0
  6. package/dist/chunk-55O4M45K.js +57 -0
  7. package/dist/chunk-55O4M45K.js.map +1 -0
  8. package/dist/chunk-5GJJHGY5.js +576 -0
  9. package/dist/chunk-5GJJHGY5.js.map +1 -0
  10. package/dist/{chunk-ZHOX6TO4.js → chunk-HS7BYCGE.js} +65 -7
  11. package/dist/chunk-HS7BYCGE.js.map +1 -0
  12. package/dist/chunk-PIMX4B4D.cjs +47 -0
  13. package/dist/chunk-PIMX4B4D.cjs.map +1 -0
  14. package/dist/chunk-QOAORTA4.cjs +576 -0
  15. package/dist/chunk-QOAORTA4.cjs.map +1 -0
  16. package/dist/chunk-QSVBYTNM.js +94 -0
  17. package/dist/chunk-QSVBYTNM.js.map +1 -0
  18. package/dist/{chunk-PJFDAP54.cjs → chunk-RUGIOQZY.cjs} +66 -8
  19. package/dist/chunk-RUGIOQZY.cjs.map +1 -0
  20. package/dist/chunk-THSZMZND.cjs +94 -0
  21. package/dist/chunk-THSZMZND.cjs.map +1 -0
  22. package/dist/chunk-YNTYWHZI.cjs +57 -0
  23. package/dist/chunk-YNTYWHZI.cjs.map +1 -0
  24. package/dist/index.cjs +185 -6
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +253 -7
  27. package/dist/index.d.ts +253 -7
  28. package/dist/index.js +188 -9
  29. package/dist/index.js.map +1 -1
  30. package/dist/schemas.cjs +29 -2
  31. package/dist/schemas.cjs.map +1 -1
  32. package/dist/schemas.d.cts +312 -31
  33. package/dist/schemas.d.ts +312 -31
  34. package/dist/schemas.js +32 -5
  35. package/dist/scoring.cjs +13 -3
  36. package/dist/scoring.cjs.map +1 -1
  37. package/dist/scoring.d.cts +29 -5
  38. package/dist/scoring.d.ts +29 -5
  39. package/dist/scoring.js +12 -2
  40. package/dist/xapi.cjs +3 -3
  41. package/dist/xapi.cjs.map +1 -1
  42. package/dist/xapi.d.cts +40 -2
  43. package/dist/xapi.d.ts +40 -2
  44. package/dist/xapi.js +2 -2
  45. package/package.json +12 -2
  46. package/dist/activity-D5tqgx8A.d.cts +0 -330
  47. package/dist/activity-D5tqgx8A.d.ts +0 -330
  48. package/dist/chunk-2T3IL7VL.js +0 -147
  49. package/dist/chunk-2T3IL7VL.js.map +0 -1
  50. package/dist/chunk-3JMLUUFS.cjs +0 -124
  51. package/dist/chunk-3JMLUUFS.cjs.map +0 -1
  52. package/dist/chunk-6VOCV4EX.js +0 -25
  53. package/dist/chunk-6VOCV4EX.js.map +0 -1
  54. package/dist/chunk-DCDOTQNH.cjs +0 -147
  55. package/dist/chunk-DCDOTQNH.cjs.map +0 -1
  56. package/dist/chunk-DV466SBJ.cjs +0 -25
  57. package/dist/chunk-DV466SBJ.cjs.map +0 -1
  58. package/dist/chunk-GZ73G2TS.js +0 -124
  59. package/dist/chunk-GZ73G2TS.js.map +0 -1
  60. package/dist/chunk-PJFDAP54.cjs.map +0 -1
  61. package/dist/chunk-ZHOX6TO4.js.map +0 -1
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # @intellectif/lk-core
2
+
3
+ Framework-free TypeScript core of [learning-kit](https://github.com/intellectif/learning-kit): Zod-based **activity schemas**, a pure **scoring engine**, and an **xAPI 1.0.3 statement builder + validator**. Zero React, zero DOM — usable in Node, browsers, edge, or as the data layer behind `@intellectif/lk-react`.
4
+
5
+ ```bash
6
+ pnpm add @intellectif/lk-core
7
+ # or
8
+ npm install @intellectif/lk-core
9
+ ```
10
+
11
+ > Already using `@intellectif/lk-react`? It declares `@intellectif/lk-core` as a peer; install both together.
12
+
13
+ ## What's in the box
14
+
15
+ - **Activity schemas (Zod 4)** for `multiple-choice` and `fill-in-the-blanks` with semantic refinements (e.g. *at least one correct option*, *single-select ⇒ exactly one correct*, *passage ↔ blank-id bijection*, *image/embed require `alt`*).
16
+ - **`validateActivity(type, data)`** — the authoritative runtime validator. Returns a typed `{ success, data }` or a structured `{ success: false, errors[] }`.
17
+ - **JSON Schema (Draft-7) export** — `multipleChoiceJsonSchema` / `fillInTheBlanksJsonSchema`, suitable for form generators or AI prompting.
18
+ - **Scoring engine** — `score(activityType, data, response)` returning `{ score ∈ [0,1], maxScore: 1, passed, feedback, details }`. Pure, deterministic, 100 % test coverage enforced.
19
+ - **`computePassThreshold(data, score)`** — single source of truth for pass/fail (default `0.7`).
20
+ - **xAPI builder** — `xAPIBuilder.buildAnsweredStatement(...)` / `buildCompletedStatement(...)` emit well-formed xAPI 1.0.3 statements with `crypto.randomUUID()` ids and an ISO-8601 timestamp.
21
+ - **xAPI validator** — `validateXAPIStatement(statement)` (Zod-backed; throws in dev, warns in prod).
22
+ - **Errors** — `ActivitySchemaError`, `UnknownActivityTypeError` with structured payloads.
23
+ - **Types** — `ActivityData`, `ActivityResult`, `ScoringResult`, `XAPIStatement`, `ThemeTokens`, … all exported with JSDoc.
24
+
25
+ ## Quick example
26
+
27
+ ```ts
28
+ import { validateActivity, score, xAPIBuilder } from '@intellectif/lk-core';
29
+
30
+ const data = await fetch('/api/activities/capital-jp').then((r) => r.json());
31
+
32
+ const v = validateActivity('multiple-choice', data);
33
+ if (!v.success) throw new Error(JSON.stringify(v.errors));
34
+
35
+ const result = score('multiple-choice', v.data, {
36
+ type: 'multiple-choice',
37
+ selectedOptionIds: ['tokyo'],
38
+ });
39
+ // result.score === 1, result.passed === true
40
+
41
+ const statement = xAPIBuilder.buildAnsweredStatement({
42
+ actor: { objectType: 'Agent', mbox: 'mailto:learner@example.com' },
43
+ object: { id: 'urn:learning-kit:activity:capital-jp', name: { 'en-US': data.title } },
44
+ scoringResult: result,
45
+ timeSpentMs: 4200,
46
+ response: 'tokyo',
47
+ });
48
+ // statement is a valid xAPI 1.0.3 Statement
49
+ ```
50
+
51
+ ## Subpath exports
52
+
53
+ | Import | Contents |
54
+ |---|---|
55
+ | `@intellectif/lk-core` | Everything (barrel) |
56
+ | `@intellectif/lk-core/schemas` | Zod schemas + `validateActivity` + JSON Schema export |
57
+ | `@intellectif/lk-core/scoring` | `score`, `computePassThreshold` |
58
+ | `@intellectif/lk-core/xapi` | `xAPIBuilder`, `XAPIVerb`, `validateXAPIStatement` |
59
+
60
+ All exports ship as ESM + CJS with `.d.ts` types. Tree-shakeable.
61
+
62
+ ## Documentation
63
+
64
+ - [Authoring & content storage](https://github.com/intellectif/learning-kit/blob/main/docs/authoring.md) — data model, validation, fetch → validate → render flow.
65
+ - [Project README](https://github.com/intellectif/learning-kit#readme) — the full picture, including the React renderers.
66
+ - [Contributing](https://github.com/intellectif/learning-kit/blob/main/CONTRIBUTING.md) — adding a new activity type.
67
+
68
+ ## License
69
+
70
+ MIT © [Intellectif LLC](https://intellectif.com)