chishiki-core 0.8.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 (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +76 -0
  3. package/dist/index.d.mts +2 -0
  4. package/dist/index.d.mts.map +1 -0
  5. package/dist/index.mjs +2 -0
  6. package/dist/src/activities.d.ts +129 -0
  7. package/dist/src/activities.d.ts.map +1 -0
  8. package/dist/src/activities.js +7 -0
  9. package/dist/src/chishiki.d.ts +108 -0
  10. package/dist/src/chishiki.d.ts.map +1 -0
  11. package/dist/src/chishiki.js +59 -0
  12. package/dist/src/content.d.ts +102 -0
  13. package/dist/src/content.d.ts.map +1 -0
  14. package/dist/src/content.js +6 -0
  15. package/dist/src/impl/activity-manager.d.ts +24 -0
  16. package/dist/src/impl/activity-manager.d.ts.map +1 -0
  17. package/dist/src/impl/activity-manager.js +198 -0
  18. package/dist/src/impl/content-manager.d.ts +19 -0
  19. package/dist/src/impl/content-manager.d.ts.map +1 -0
  20. package/dist/src/impl/content-manager.js +124 -0
  21. package/dist/src/impl/index.d.ts +10 -0
  22. package/dist/src/impl/index.d.ts.map +1 -0
  23. package/dist/src/impl/index.js +9 -0
  24. package/dist/src/impl/lrs.d.ts +20 -0
  25. package/dist/src/impl/lrs.d.ts.map +1 -0
  26. package/dist/src/impl/lrs.js +291 -0
  27. package/dist/src/impl/plugin-manager.d.ts +16 -0
  28. package/dist/src/impl/plugin-manager.d.ts.map +1 -0
  29. package/dist/src/impl/plugin-manager.js +57 -0
  30. package/dist/src/impl/scheduler.d.ts +18 -0
  31. package/dist/src/impl/scheduler.d.ts.map +1 -0
  32. package/dist/src/impl/scheduler.js +188 -0
  33. package/dist/src/impl/sync-manager.d.ts +21 -0
  34. package/dist/src/impl/sync-manager.d.ts.map +1 -0
  35. package/dist/src/impl/sync-manager.js +70 -0
  36. package/dist/src/impl/utils/sm2.d.ts +28 -0
  37. package/dist/src/impl/utils/sm2.d.ts.map +1 -0
  38. package/dist/src/impl/utils/sm2.js +59 -0
  39. package/dist/src/impl/utils/sql-helpers.d.ts +30 -0
  40. package/dist/src/impl/utils/sql-helpers.d.ts.map +1 -0
  41. package/dist/src/impl/utils/sql-helpers.js +54 -0
  42. package/dist/src/impl/utils/statement-mappers.d.ts +68 -0
  43. package/dist/src/impl/utils/statement-mappers.d.ts.map +1 -0
  44. package/dist/src/impl/utils/statement-mappers.js +98 -0
  45. package/dist/src/impl/utils/type-mappers.d.ts +36 -0
  46. package/dist/src/impl/utils/type-mappers.d.ts.map +1 -0
  47. package/dist/src/impl/utils/type-mappers.js +62 -0
  48. package/dist/src/impl/utils/uuid.d.ts +10 -0
  49. package/dist/src/impl/utils/uuid.d.ts.map +1 -0
  50. package/dist/src/impl/utils/uuid.js +13 -0
  51. package/dist/src/index.d.ts +15 -0
  52. package/dist/src/index.d.ts.map +1 -0
  53. package/dist/src/index.js +8 -0
  54. package/dist/src/lrs.d.ts +164 -0
  55. package/dist/src/lrs.d.ts.map +1 -0
  56. package/dist/src/lrs.js +6 -0
  57. package/dist/src/plugins.d.ts +51 -0
  58. package/dist/src/plugins.d.ts.map +1 -0
  59. package/dist/src/plugins.js +6 -0
  60. package/dist/src/scheduler.d.ts +99 -0
  61. package/dist/src/scheduler.d.ts.map +1 -0
  62. package/dist/src/scheduler.js +6 -0
  63. package/dist/src/storage.d.ts +55 -0
  64. package/dist/src/storage.d.ts.map +1 -0
  65. package/dist/src/storage.js +7 -0
  66. package/dist/src/sync.d.ts +114 -0
  67. package/dist/src/sync.d.ts.map +1 -0
  68. package/dist/src/sync.js +6 -0
  69. package/dist/tsconfig.tsbuildinfo +1 -0
  70. package/package.json +33 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Seo Jong Hak
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,76 @@
1
+ # @chishiki/core
2
+
3
+ Platform-agnostic core for Chishiki learning platform.
4
+
5
+ ## Overview
6
+
7
+ `@chishiki/core` provides the core functionality of Chishiki in a platform-agnostic way. It includes:
8
+
9
+ - **Storage Adapter Interface**: Abstract storage layer for different backends (OPFS, SQLite, IndexedDB)
10
+ - **Content Manager**: Import and manage learning content
11
+ - **Activity Manager**: Create and run learning activities
12
+ - **Scheduler**: Spaced repetition scheduling (SM-2 algorithm)
13
+ - **LRS**: xAPI-compliant Learning Record Store
14
+ - **Sync Manager**: Synchronize data across devices/services
15
+ - **Plugin Manager**: Extend functionality with plugins
16
+
17
+ ## Architecture
18
+
19
+ The core is designed to be platform-agnostic. Platform-specific implementations (Chrome extension, PWA, Tauri) are provided as "shells" that use the core.
20
+
21
+ ```
22
+ ┌─────────────────────────────────────────────────────────────┐
23
+ │ @chishiki/core │
24
+ │ │
25
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
26
+ │ │ Storage │ │ Scheduler │ │ xAPI │ │
27
+ │ │ Adapter │ │ (SM-2+) │ │ Engine │ │
28
+ │ │ Interface │ │ │ │ │ │
29
+ │ └─────────────┘ └─────────────┘ └─────────────┘ │
30
+ │ │
31
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
32
+ │ │ Activity │ │ Content │ │ Sync │ │
33
+ │ │ Runner │ │ Manager │ │ Protocol │ │
34
+ │ │ │ │ │ │ │ │
35
+ │ └─────────────┘ └─────────────┘ └─────────────┘ │
36
+ └─────────────────────────────────────────────────────────────┘
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ```typescript
42
+ import { createChishiki } from '@chishiki/core';
43
+ import { OPFSAdapter } from '@chishiki/adapter-opfs';
44
+
45
+ // Create storage adapter
46
+ const storage = new OPFSAdapter('chishiki.db');
47
+
48
+ // Create Chishiki instance
49
+ const chishiki = createChishiki({ storage });
50
+
51
+ // Initialize
52
+ await chishiki.initialize();
53
+
54
+ // Use core features
55
+ const content = await chishiki.content.import({
56
+ type: 'text',
57
+ text: 'Hello, world!',
58
+ format: 'plain'
59
+ });
60
+
61
+ const activities = await chishiki.activities.listByContent(content.id);
62
+ const dueItems = await chishiki.scheduler.getDue();
63
+ ```
64
+
65
+ ## Status
66
+
67
+ **Phase 1.1**: ✅ Core interfaces defined
68
+ **Phase 1.2**: 🔄 Implementation in progress
69
+
70
+ ## Related Packages
71
+
72
+ - `@chishiki/adapter-opfs`: OPFS storage adapter for Chrome/PWA
73
+ - `@chishiki/adapter-tauri-sqlite`: Native SQLite adapter for Tauri
74
+ - `@chishiki/shell-chrome-extension`: Chrome extension shell
75
+ - `@chishiki/shell-pwa`: PWA shell
76
+ - `@chishiki/shell-tauri`: Tauri desktop shell
@@ -0,0 +1,2 @@
1
+ export * from './src/index.js';
2
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../index.mts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ // Main entry point for @chishiki/core
2
+ export * from './src/index.js';
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Activity Manager Interface
3
+ *
4
+ * Manages learning activities (flashcards, quizzes, etc.)
5
+ * Supports both TypeScript core activities and HTML/JS package activities.
6
+ */
7
+ /**
8
+ * Activity definition for TypeScript-based core activities.
9
+ */
10
+ export interface ActivityDefinition {
11
+ id: string;
12
+ name: string;
13
+ description: string;
14
+ version: string;
15
+ author?: string;
16
+ contentTypes: string[];
17
+ dataSchema?: unknown;
18
+ generate?: (content: unknown) => Promise<unknown[]>;
19
+ render?: (props: unknown) => unknown;
20
+ verbs: {
21
+ start: string;
22
+ complete: string;
23
+ success?: string;
24
+ failure?: string;
25
+ };
26
+ scheduling?: {
27
+ defaultInterval?: number;
28
+ minimumInterval?: number;
29
+ graduatingInterval?: number;
30
+ };
31
+ }
32
+ /**
33
+ * Activity instance (created from content).
34
+ */
35
+ export interface Activity {
36
+ id: string;
37
+ contentId: string;
38
+ typeId: string;
39
+ data: Record<string, unknown>;
40
+ createdAt: string;
41
+ }
42
+ /**
43
+ * Activity session (active learning session).
44
+ */
45
+ export interface ActivitySession {
46
+ activity: Activity;
47
+ startedAt: string;
48
+ /**
49
+ * Record an interaction result during the session.
50
+ * @param result Interaction result
51
+ */
52
+ recordInteraction(result: InteractionResult): Promise<void>;
53
+ /**
54
+ * Complete the activity session.
55
+ */
56
+ complete(): Promise<void>;
57
+ /**
58
+ * Abandon the activity session (user quit early).
59
+ */
60
+ abandon(): Promise<void>;
61
+ }
62
+ /**
63
+ * Result of an interaction within an activity.
64
+ */
65
+ export interface InteractionResult {
66
+ success: boolean;
67
+ score?: number;
68
+ responseTime?: number;
69
+ response?: string;
70
+ metadata?: Record<string, unknown>;
71
+ }
72
+ /**
73
+ * Activity manager interface.
74
+ */
75
+ export interface ActivityManager {
76
+ /**
77
+ * Register a core activity definition (TypeScript-based).
78
+ * @param definition Activity definition
79
+ */
80
+ register(definition: ActivityDefinition): void;
81
+ /**
82
+ * Unregister an activity type.
83
+ * @param typeId Activity type ID
84
+ */
85
+ unregister(typeId: string): void;
86
+ /**
87
+ * Get all registered activity types.
88
+ * @returns Array of activity definitions
89
+ */
90
+ getTypes(): ActivityDefinition[];
91
+ /**
92
+ * Get a specific activity type.
93
+ * @param typeId Activity type ID
94
+ * @returns Activity definition or null if not found
95
+ */
96
+ getType(typeId: string): ActivityDefinition | null;
97
+ /**
98
+ * Create an activity instance from content.
99
+ * @param contentId Content ID
100
+ * @param typeId Activity type ID
101
+ * @returns Created activity instance
102
+ */
103
+ create(contentId: string, typeId: string): Promise<Activity>;
104
+ /**
105
+ * Get an activity instance by ID.
106
+ * @param id Activity ID
107
+ * @returns Activity instance or null if not found
108
+ */
109
+ get(id: string): Promise<Activity | null>;
110
+ /**
111
+ * List activities by content.
112
+ * @param contentId Content ID
113
+ * @returns Array of activity instances
114
+ */
115
+ listByContent(contentId: string): Promise<Activity[]>;
116
+ /**
117
+ * List activities by type.
118
+ * @param typeId Activity type ID
119
+ * @returns Array of activity instances
120
+ */
121
+ listByType(typeId: string): Promise<Activity[]>;
122
+ /**
123
+ * Start an activity session.
124
+ * @param activityId Activity ID
125
+ * @returns Activity session
126
+ */
127
+ start(activityId: string): Promise<ActivitySession>;
128
+ }
129
+ //# sourceMappingURL=activities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/activities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAEjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,YAAY,EAAE,MAAM,EAAE,CAAC;IAGvB,UAAU,CAAC,EAAE,OAAO,CAAC;IAGrB,QA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AAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAE/C;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;;OAGG;IACH,QAAQ,IAAI,kBAAkB,EAAE,CAAC;IAEjC;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAAC;IAEnD;;;;;OAKG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE7D;;;;OAIG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAE1C;;;;OAIG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEtD;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEhD;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACrD"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Activity Manager Interface
3
+ *
4
+ * Manages learning activities (flashcards, quizzes, etc.)
5
+ * Supports both TypeScript core activities and HTML/JS package activities.
6
+ */
7
+ export {};
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Chishiki Core Factory
3
+ *
4
+ * Main factory function for creating a Chishiki instance.
5
+ */
6
+ import type { ActivityManager } from './activities.js';
7
+ import type { ContentManager } from './content.js';
8
+ import type { LRS } from './lrs.js';
9
+ import type { PluginManager } from './plugins.js';
10
+ import type { Scheduler } from './scheduler.js';
11
+ import type { StorageAdapter } from './storage.js';
12
+ import type { SyncManager } from './sync.js';
13
+ /**
14
+ * Configuration for creating a Chishiki instance.
15
+ */
16
+ export interface ChishikiConfig {
17
+ /**
18
+ * Storage adapter to use (required).
19
+ */
20
+ storage: StorageAdapter;
21
+ /**
22
+ * Optional configuration for components.
23
+ */
24
+ config?: {
25
+ /**
26
+ * Actor (learner) configuration for xAPI.
27
+ */
28
+ actor?: {
29
+ name?: string;
30
+ mbox?: string;
31
+ };
32
+ /**
33
+ * Scheduler configuration.
34
+ */
35
+ scheduler?: {
36
+ algorithm?: 'sm2' | 'sm2+' | 'custom';
37
+ newCardsPerDay?: number;
38
+ maxReviewsPerDay?: number;
39
+ };
40
+ /**
41
+ * Sync configuration.
42
+ */
43
+ sync?: {
44
+ type: 'file' | 'lrs' | 'custom';
45
+ [key: string]: unknown;
46
+ };
47
+ };
48
+ }
49
+ /**
50
+ * Chishiki Core interface.
51
+ *
52
+ * Main interface for the Chishiki learning platform.
53
+ * Provides access to all core subsystems.
54
+ */
55
+ export interface ChishikiCore {
56
+ /**
57
+ * Storage adapter (injected).
58
+ */
59
+ readonly storage: StorageAdapter;
60
+ /**
61
+ * Content manager.
62
+ */
63
+ readonly content: ContentManager;
64
+ /**
65
+ * Activity manager.
66
+ */
67
+ readonly activities: ActivityManager;
68
+ /**
69
+ * Scheduler (spaced repetition).
70
+ */
71
+ readonly scheduler: Scheduler;
72
+ /**
73
+ * LRS (xAPI Learning Record Store).
74
+ */
75
+ readonly lrs: LRS;
76
+ /**
77
+ * Sync manager.
78
+ */
79
+ readonly sync: SyncManager;
80
+ /**
81
+ * Plugin manager.
82
+ */
83
+ readonly plugins: PluginManager;
84
+ /**
85
+ * Initialize the Chishiki instance.
86
+ * Must be called before using any other methods.
87
+ */
88
+ initialize(): Promise<void>;
89
+ /**
90
+ * Close the Chishiki instance and clean up resources.
91
+ */
92
+ close(): Promise<void>;
93
+ }
94
+ /**
95
+ * Create a Chishiki instance.
96
+ *
97
+ * @param config Configuration for the Chishiki instance
98
+ * @returns Chishiki core instance
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const storage = new OPFSAdapter('chishiki.db');
103
+ * const chishiki = createChishiki({ storage });
104
+ * await chishiki.initialize();
105
+ * ```
106
+ */
107
+ export declare const createChishiki: (config: ChishikiConfig) => ChishikiCore;
108
+ //# sourceMappingURL=chishiki.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chishiki.d.ts","sourceRoot":"","sources":["../../src/chishiki.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,OAAO,EAAE,cAAc,CAAC;IAExB;;OAEG;IACH,MAAM,CAAC,EAAE;QACP;;WAEG;QACH,KAAK,CAAC,EAAE;YACN,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CAAC;QAEF;;WAEG;QACH,SAAS,CAAC,EAAE;YACV,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;YACtC,cAAc,CAAC,EAAE,MAAM,CAAC;YACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;SAC3B,CAAC;QAEF;;WAEG;QACH,IAAI,CAAC,EAAE;YACL,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;YAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;KACH,CAAC;CACH;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAEhC;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,cAAc,KAAG,YAqCvD,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Chishiki Core Factory
3
+ *
4
+ * Main factory function for creating a Chishiki instance.
5
+ */
6
+ import { ActivityManagerImpl } from './impl/activity-manager.js';
7
+ import { ContentManagerImpl } from './impl/content-manager.js';
8
+ import { LRSImpl } from './impl/lrs.js';
9
+ import { PluginManagerImpl } from './impl/plugin-manager.js';
10
+ import { SchedulerImpl } from './impl/scheduler.js';
11
+ import { SyncManagerImpl } from './impl/sync-manager.js';
12
+ /**
13
+ * Create a Chishiki instance.
14
+ *
15
+ * @param config Configuration for the Chishiki instance
16
+ * @returns Chishiki core instance
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const storage = new OPFSAdapter('chishiki.db');
21
+ * const chishiki = createChishiki({ storage });
22
+ * await chishiki.initialize();
23
+ * ```
24
+ */
25
+ export const createChishiki = (config) => {
26
+ const storage = config.storage;
27
+ const content = new ContentManagerImpl(storage);
28
+ const lrs = new LRSImpl(storage);
29
+ const activities = new ActivityManagerImpl(storage, lrs); // Pass LRS for statement recording
30
+ const scheduler = new SchedulerImpl(storage);
31
+ const sync = new SyncManagerImpl(storage);
32
+ const plugins = new PluginManagerImpl();
33
+ // Apply scheduler config if provided
34
+ if (config.config?.scheduler) {
35
+ scheduler.configure(config.config.scheduler);
36
+ }
37
+ // Apply sync config if provided
38
+ if (config.config?.sync) {
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ sync.configure(config.config.sync);
41
+ }
42
+ return {
43
+ storage,
44
+ content,
45
+ activities,
46
+ scheduler,
47
+ lrs,
48
+ sync,
49
+ plugins,
50
+ async initialize() {
51
+ await storage.initialize();
52
+ // TODO: Initialize other components as needed
53
+ },
54
+ async close() {
55
+ await storage.close();
56
+ // TODO: Clean up other components as needed
57
+ },
58
+ };
59
+ };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Content Manager Interface
3
+ *
4
+ * Manages learning content (courses, lessons, vocabulary, etc.)
5
+ */
6
+ /**
7
+ * Learning content types supported by Chishiki.
8
+ */
9
+ export type LearningContentType = 'course' | 'lesson' | 'vocabulary-set' | 'dialogue' | 'text' | 'youtube';
10
+ /**
11
+ * Learning content item.
12
+ */
13
+ export interface LearningContent {
14
+ id: string;
15
+ type: LearningContentType;
16
+ title: string;
17
+ parentId?: string;
18
+ sourceUrl?: string;
19
+ language?: string;
20
+ data: Record<string, unknown>;
21
+ createdAt: string;
22
+ updatedAt: string;
23
+ }
24
+ /**
25
+ * Filter options for listing content.
26
+ */
27
+ export interface ContentFilter {
28
+ type?: LearningContentType | LearningContentType[];
29
+ parentId?: string;
30
+ language?: string;
31
+ search?: string;
32
+ limit?: number;
33
+ offset?: number;
34
+ }
35
+ /**
36
+ * Source for importing content.
37
+ */
38
+ export type ImportSource = {
39
+ type: 'file';
40
+ file: File;
41
+ mimeType?: string;
42
+ } | {
43
+ type: 'url';
44
+ url: string;
45
+ } | {
46
+ type: 'text';
47
+ text: string;
48
+ format: string;
49
+ } | {
50
+ type: 'syllst';
51
+ mdx: string;
52
+ } | {
53
+ type: 'anki';
54
+ apkg: File;
55
+ };
56
+ /**
57
+ * Content manager interface.
58
+ */
59
+ export interface ContentManager {
60
+ /**
61
+ * Import content from various sources.
62
+ * @param source Import source (file, URL, text, etc.)
63
+ * @returns ID of the imported content
64
+ */
65
+ import(source: ImportSource): Promise<string>;
66
+ /**
67
+ * Get a single content item by ID.
68
+ * @param id Content ID
69
+ * @returns Content item or null if not found
70
+ */
71
+ get(id: string): Promise<LearningContent | null>;
72
+ /**
73
+ * List content items with optional filtering.
74
+ * @param filter Filter options
75
+ * @returns Array of content items
76
+ */
77
+ list(filter?: ContentFilter): Promise<LearningContent[]>;
78
+ /**
79
+ * Update a content item.
80
+ * @param id Content ID
81
+ * @param updates Partial content updates
82
+ */
83
+ update(id: string, updates: Partial<LearningContent>): Promise<void>;
84
+ /**
85
+ * Delete a content item.
86
+ * @param id Content ID
87
+ */
88
+ delete(id: string): Promise<void>;
89
+ /**
90
+ * Get child content items (e.g., lessons in a course).
91
+ * @param parentId Parent content ID
92
+ * @returns Array of child content items
93
+ */
94
+ getChildren(parentId: string): Promise<LearningContent[]>;
95
+ /**
96
+ * Get activities associated with content.
97
+ * @param contentId Content ID
98
+ * @returns Array of activity IDs
99
+ */
100
+ getActivities(contentId: string): Promise<string[]>;
101
+ }
102
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/content.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,QAAQ,GAAG,gBAAgB,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAE3G;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE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AAC,eAAe,GAAG,IAAI,CAAC,CAAC;IAEjD;;;;OAIG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAEzD;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErE;;;OAGG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAE1D;;;;OAIG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACrD"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Content Manager Interface
3
+ *
4
+ * Manages learning content (courses, lessons, vocabulary, etc.)
5
+ */
6
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Activity Manager Implementation
3
+ *
4
+ * Implements ActivityManager interface.
5
+ */
6
+ import type { ActivityManager, Activity, ActivitySession, ActivityDefinition } from '../activities.js';
7
+ import type { LRS } from '../lrs.js';
8
+ import type { StorageAdapter } from '../storage.js';
9
+ export declare class ActivityManagerImpl implements ActivityManager {
10
+ private storage;
11
+ private lrs?;
12
+ private registeredTypes;
13
+ constructor(storage: StorageAdapter, lrs?: LRS | undefined);
14
+ register(definition: ActivityDefinition): void;
15
+ unregister(typeId: string): void;
16
+ getTypes(): ActivityDefinition[];
17
+ getType(typeId: string): ActivityDefinition | null;
18
+ create(contentId: string, typeId: string): Promise<Activity>;
19
+ get(id: string): Promise<Activity | null>;
20
+ listByContent(contentId: string): Promise<Activity[]>;
21
+ listByType(typeId: string): Promise<Activity[]>;
22
+ start(activityId: string): Promise<ActivitySession>;
23
+ }
24
+ //# sourceMappingURL=activity-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity-manager.d.ts","sourceRoot":"","sources":["../../../src/impl/activity-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,QAAQ,EACR,eAAe,EACf,kBAAkB,EAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAYpD,qBAAa,mBAAoB,YAAW,eAAe;IAIvD,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,GAAG,CAAC;IAJd,OAAO,CAAC,eAAe,CAAyC;gBAGtD,OAAO,EAAE,cAAc,EACvB,GAAG,CAAC,EAAE,GAAG,YAAA;IAGnB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,IAAI;IAI9C,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIhC,QAAQ,IAAI,kBAAkB,EAAE;IAIhC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI;IAI5C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAyE5D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAoCzC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAerD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAe/C,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAqE1D"}