@nesso-how/types 0.1.0-alpha.19

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.
@@ -0,0 +1,62 @@
1
+ export type { EdgeCategory, EdgeTypeDef, EdgeTypeName, GlyphKind } from '@nesso-how/relation-types';
2
+ import type { Card } from 'ts-fsrs';
3
+ import type { EdgeTypeName } from '@nesso-how/relation-types';
4
+ export interface ConceptElaboration {
5
+ definition: string;
6
+ examples: string;
7
+ notes: string;
8
+ imageUrl?: string;
9
+ imageTitle?: string;
10
+ imageDescriptionUrl?: string;
11
+ }
12
+ export interface ConceptNodeData extends Record<string, unknown> {
13
+ text: string;
14
+ stability: number;
15
+ difficulty: number;
16
+ reps: number;
17
+ lapses: number;
18
+ fsrsState: number;
19
+ due: number;
20
+ lastReview: number;
21
+ lastRating: number;
22
+ elaboration?: ConceptElaboration;
23
+ }
24
+ export declare function nodeToCard(data: ConceptNodeData): Card;
25
+ export type EdgeEncoding = 'full' | 'category' | 'minimal';
26
+ export type CurveStyle = 'arc' | 'straight';
27
+ export interface NessoEdgeData extends Record<string, unknown> {
28
+ type: EdgeTypeName;
29
+ siblingIdx?: number;
30
+ curveFlip?: boolean;
31
+ curveFlipPinned?: boolean;
32
+ }
33
+ export type CategoryPalette = 'default' | 'vivid' | 'muted' | 'monoCat';
34
+ export type Language = 'en' | 'it';
35
+ export interface GraphDisplaySettings {
36
+ edgeEncoding: EdgeEncoding;
37
+ showHeatmap: boolean;
38
+ curveStyle: CurveStyle;
39
+ autoCurveFlip: boolean;
40
+ }
41
+ export declare function defaultGraphDisplay(settings?: Pick<NessoSettings, 'edgeEncoding' | 'showHeatmap' | 'curveStyle' | 'autoCurveFlip'>): GraphDisplaySettings;
42
+ export declare function mergeGraphDisplay(stored: Partial<GraphDisplaySettings> | undefined, settings: NessoSettings): GraphDisplaySettings;
43
+ export interface NessoSettings {
44
+ dark: boolean;
45
+ accent: string;
46
+ language: Language;
47
+ edgeEncoding: EdgeEncoding;
48
+ showLabels: boolean;
49
+ showConfidence: boolean;
50
+ showHeatmap: boolean;
51
+ curveStyle: CurveStyle;
52
+ autoCurveFlip: boolean;
53
+ categoryPalette: CategoryPalette;
54
+ aiMode: 'remote' | 'local';
55
+ aiBaseUrl: string;
56
+ aiModel: string;
57
+ aiApiKey: string;
58
+ fsrsRetention: number;
59
+ maximumInterval: number;
60
+ inspectorExamplesOpen: boolean;
61
+ inspectorRelationsOpen: boolean;
62
+ }
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ export function nodeToCard(data) {
2
+ return {
3
+ due: new Date(data.due || Date.now()),
4
+ stability: data.stability,
5
+ difficulty: data.difficulty,
6
+ elapsed_days: 0,
7
+ scheduled_days: 0,
8
+ learning_steps: 0,
9
+ reps: data.reps,
10
+ lapses: data.lapses,
11
+ state: data.fsrsState,
12
+ last_review: data.lastReview ? new Date(data.lastReview) : undefined,
13
+ };
14
+ }
15
+ export function defaultGraphDisplay(settings) {
16
+ return {
17
+ edgeEncoding: settings?.edgeEncoding ?? 'full',
18
+ showHeatmap: settings?.showHeatmap ?? true,
19
+ curveStyle: settings?.curveStyle ?? 'arc',
20
+ autoCurveFlip: settings?.autoCurveFlip !== false,
21
+ };
22
+ }
23
+ export function mergeGraphDisplay(stored, settings) {
24
+ const base = defaultGraphDisplay(settings);
25
+ if (!stored)
26
+ return base;
27
+ return {
28
+ edgeEncoding: stored.edgeEncoding ?? base.edgeEncoding,
29
+ showHeatmap: stored.showHeatmap ?? base.showHeatmap,
30
+ curveStyle: stored.curveStyle ?? base.curveStyle,
31
+ autoCurveFlip: stored.autoCurveFlip !== undefined ? stored.autoCurveFlip : base.autoCurveFlip,
32
+ };
33
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@nesso-how/types",
3
+ "version": "0.1.0-alpha.19",
4
+ "description": "Nesso shared TypeScript types — graph, node, edge, settings, FSRS",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "prepublishOnly": "pnpm build",
19
+ "dev": "tsc --watch"
20
+ },
21
+ "dependencies": {
22
+ "@nesso-how/relation-types": "workspace:*",
23
+ "ts-fsrs": "^5.3.2"
24
+ },
25
+ "devDependencies": {
26
+ "typescript": "~5.8.3"
27
+ }
28
+ }
package/src/index.ts ADDED
@@ -0,0 +1,108 @@
1
+ // SPDX-License-Identifier: MIT
2
+ export type { EdgeCategory, EdgeTypeDef, EdgeTypeName, GlyphKind } from '@nesso-how/relation-types'
3
+ import type { Card, State } from 'ts-fsrs'
4
+ import type { EdgeTypeName } from '@nesso-how/relation-types'
5
+
6
+ export interface ConceptElaboration {
7
+ definition: string
8
+ examples: string
9
+ notes: string
10
+ imageUrl?: string
11
+ imageTitle?: string
12
+ imageDescriptionUrl?: string
13
+ }
14
+
15
+ export interface ConceptNodeData extends Record<string, unknown> {
16
+ text: string
17
+ stability: number
18
+ difficulty: number
19
+ reps: number
20
+ lapses: number
21
+ fsrsState: number // State: 0=New 1=Learning 2=Review 3=Relearning
22
+ due: number // ms timestamp; 0 = due immediately (new card)
23
+ lastReview: number // ms timestamp; 0 = never reviewed
24
+ lastRating: number // 0=unrated, 1=Again 2=Hard 3=Good 4=Easy
25
+ elaboration?: ConceptElaboration
26
+ }
27
+
28
+ export function nodeToCard(data: ConceptNodeData): Card {
29
+ return {
30
+ due: new Date(data.due || Date.now()),
31
+ stability: data.stability,
32
+ difficulty: data.difficulty,
33
+ elapsed_days: 0,
34
+ scheduled_days: 0,
35
+ learning_steps: 0,
36
+ reps: data.reps,
37
+ lapses: data.lapses,
38
+ state: data.fsrsState as State,
39
+ last_review: data.lastReview ? new Date(data.lastReview) : undefined,
40
+ }
41
+ }
42
+
43
+ export type EdgeEncoding = 'full' | 'category' | 'minimal'
44
+ export type CurveStyle = 'arc' | 'straight'
45
+
46
+ export interface NessoEdgeData extends Record<string, unknown> {
47
+ type: EdgeTypeName
48
+ siblingIdx?: number
49
+ curveFlip?: boolean
50
+ curveFlipPinned?: boolean
51
+ }
52
+
53
+ export type CategoryPalette = 'default' | 'vivid' | 'muted' | 'monoCat'
54
+
55
+ export type Language = 'en' | 'it'
56
+
57
+ export interface GraphDisplaySettings {
58
+ edgeEncoding: EdgeEncoding
59
+ showHeatmap: boolean
60
+ curveStyle: CurveStyle
61
+ autoCurveFlip: boolean
62
+ }
63
+
64
+ export function defaultGraphDisplay(
65
+ settings?: Pick<NessoSettings, 'edgeEncoding' | 'showHeatmap' | 'curveStyle' | 'autoCurveFlip'>,
66
+ ): GraphDisplaySettings {
67
+ return {
68
+ edgeEncoding: settings?.edgeEncoding ?? 'full',
69
+ showHeatmap: settings?.showHeatmap ?? true,
70
+ curveStyle: settings?.curveStyle ?? 'arc',
71
+ autoCurveFlip: settings?.autoCurveFlip !== false,
72
+ }
73
+ }
74
+
75
+ export function mergeGraphDisplay(
76
+ stored: Partial<GraphDisplaySettings> | undefined,
77
+ settings: NessoSettings,
78
+ ): GraphDisplaySettings {
79
+ const base = defaultGraphDisplay(settings)
80
+ if (!stored) return base
81
+ return {
82
+ edgeEncoding: stored.edgeEncoding ?? base.edgeEncoding,
83
+ showHeatmap: stored.showHeatmap ?? base.showHeatmap,
84
+ curveStyle: stored.curveStyle ?? base.curveStyle,
85
+ autoCurveFlip: stored.autoCurveFlip !== undefined ? stored.autoCurveFlip : base.autoCurveFlip,
86
+ }
87
+ }
88
+
89
+ export interface NessoSettings {
90
+ dark: boolean
91
+ accent: string
92
+ language: Language
93
+ edgeEncoding: EdgeEncoding
94
+ showLabels: boolean
95
+ showConfidence: boolean
96
+ showHeatmap: boolean
97
+ curveStyle: CurveStyle
98
+ autoCurveFlip: boolean
99
+ categoryPalette: CategoryPalette
100
+ aiMode: 'remote' | 'local'
101
+ aiBaseUrl: string
102
+ aiModel: string
103
+ aiApiKey: string
104
+ fsrsRetention: number
105
+ maximumInterval: number
106
+ inspectorExamplesOpen: boolean
107
+ inspectorRelationsOpen: boolean
108
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "outDir": "dist",
7
+ "rootDir": "src",
8
+ "strict": true,
9
+ "declaration": true,
10
+ "skipLibCheck": true
11
+ },
12
+ "include": ["src"]
13
+ }