@nesso-how/formats 0.1.0-alpha.26 → 0.1.0-alpha.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nesso-how/formats",
3
- "version": "0.1.0-alpha.26",
3
+ "version": "0.1.0-alpha.28",
4
4
  "description": "Nesso graph serialization formats — JSON serialize/deserialize",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,6 +12,9 @@
12
12
  "publishConfig": {
13
13
  "access": "public"
14
14
  },
15
+ "files": [
16
+ "dist"
17
+ ],
15
18
  "exports": {
16
19
  ".": {
17
20
  "types": "./dist/index.d.ts",
@@ -19,14 +22,17 @@
19
22
  }
20
23
  },
21
24
  "dependencies": {
22
- "@xyflow/react": "^12.6.4",
23
- "@nesso-how/types": "0.1.0-alpha.26"
25
+ "@nesso-how/types": "0.1.0-alpha.28"
26
+ },
27
+ "peerDependencies": {
28
+ "@xyflow/react": "^12.6.4"
24
29
  },
25
30
  "devDependencies": {
31
+ "@xyflow/react": "^12.6.4",
26
32
  "typescript": "~5.8.3"
27
33
  },
28
34
  "scripts": {
29
- "build": "tsc",
35
+ "build": "rm -rf dist && tsc",
30
36
  "dev": "tsc --watch"
31
37
  }
32
38
  }
package/src/index.ts DELETED
@@ -1,53 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- import type { Node, Edge } from '@xyflow/react'
3
- import type { ConceptNodeData, GraphDisplaySettings } from '@nesso-how/types'
4
- import { defaultConceptReviewFields } from '@nesso-how/types'
5
-
6
- export interface NessoGraphFile {
7
- /** Internal graph id (desktop sync); omitted in manual exports. */
8
- id?: string
9
- /** Last save time (Unix ms); desktop sync metadata. */
10
- updatedAt?: number
11
- name: string
12
- nodes: Node<ConceptNodeData>[]
13
- edges: Edge[]
14
- display?: Partial<GraphDisplaySettings>
15
- }
16
-
17
- export function serializeGraph(file: NessoGraphFile): string {
18
- return JSON.stringify(file, null, 2)
19
- }
20
-
21
- export function deserializeGraph(json: string): NessoGraphFile {
22
- const data: unknown = JSON.parse(json)
23
- if (
24
- typeof data !== 'object' ||
25
- data === null ||
26
- !Array.isArray((data as Record<string, unknown>).nodes) ||
27
- !Array.isArray((data as Record<string, unknown>).edges)
28
- ) {
29
- throw new Error('Invalid Nesso graph file: missing nodes or edges array')
30
- }
31
- return data as NessoGraphFile
32
- }
33
-
34
- /** Strip personal FSRS / review history for shareable graph export. Keeps text, elaboration, layout. */
35
- export function nodesForGraphShareExport(nodes: Node<ConceptNodeData>[]): Node<ConceptNodeData>[] {
36
- const review = defaultConceptReviewFields()
37
- return nodes.map((node) => {
38
- const { text, elaboration } = node.data ?? { text: '' }
39
- return {
40
- ...node,
41
- data: {
42
- text: text ?? '',
43
- ...(elaboration ? { elaboration } : {}),
44
- ...review,
45
- },
46
- }
47
- })
48
- }
49
-
50
- /** Reset review fields on import so shared files never restore someone else's scheduling. */
51
- export function nodesFromGraphShareImport(nodes: Node<ConceptNodeData>[]): Node<ConceptNodeData>[] {
52
- return nodesForGraphShareExport(nodes)
53
- }
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
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
- }