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