Skip to content

Commit

Permalink
[file] Generates JSON schema
Browse files Browse the repository at this point in the history
Details:
- Fixes two typings ambiguities
- Fixes some comments, that were poorly rendered in the output JSON
  schema
- Installs typescript-json-schema, and updates build task to generate
  the JSON schema for the GephiLiteFileFormat type, and put it in the
  build directory
  • Loading branch information
jacomyal committed Feb 7, 2025
1 parent 41685f6 commit cfdf415
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 16 deletions.
213 changes: 213 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/gephi-lite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
"license": "gpl-3.0",
"scripts": {
"start": "vite",
"build": "vite build",
"build": "vite build && npm run generate-json-schema",
"serve": "vite preview",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "vitest run src",
"test:e2e": "playwright test",
"translations-scan": "i18next-scanner --config ../../i18next-scanner.config.ts packages/gephi-lite/src/**/*.{ts,tsx}",
"generate-json-schema": "typescript-json-schema src/core/file/types.ts GephiLiteFileFormat -o build/gephi-lite-format.schema.json",
"prepare": "ts-patch install && typia patch"
},
"browserslist": {
Expand Down Expand Up @@ -111,6 +112,7 @@
"http-proxy-middleware": "^3.0.3",
"i18next-scanner": "^4.6.0",
"sass": "1.77.6",
"typescript-json-schema": "^0.65.1",
"ts-patch": "^3.3.0",
"typia": "^7.6.0",
"vite": "^6.0.11",
Expand Down
12 changes: 5 additions & 7 deletions packages/gephi-lite/src/core/file/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import { FiltersState } from "../filters/types";
import { GraphDataset } from "../graph/types";

/**
* Type for the file format of gephi-lite.
* We save :
* - the gephi-lite version for checking compatibilities in the futur
* - the full graph with its metadata
* - filters
* - appearance
* - selection
* A serializable structure, to allow Gephi Lite to load and save graphs, with their surrounding context.
* This includes:
* - The full graph dataset
* - The filters state
* - The appearance state
*/
export type GephiLiteFileFormat = {
type: "gephi-lite";
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/appearance/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ export interface ZIndexFieldAttr extends AppearanceBaseElement {
export type ZIndexAttr = NoFieldValue<"none"> | ZIndexFieldAttr;

/**
* This state contains everything needed to generate the visual getters:
* Describes how each visual variable should be used to render the graph in Gephi Lite.
*/

export interface AppearanceState {
showEdges: BooleanAppearance;
nodesSize: Size;
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/graph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export function serializeDataset(
): SerializedGraphDataset | Partial<SerializedGraphDataset> {
return dataset.fullGraph
? { ...dataset, fullGraph: dataset.fullGraph.export() }
: (dataset as Partial<SerializedGraphDataset>);
: (dataset as Omit<Partial<SerializedGraphDataset>, "fullGraph">);
}
export function deserializeDataset(dataset: SerializedGraphDataset): GraphDataset;
export function deserializeDataset(dataset: Partial<SerializedGraphDataset>): Partial<GraphDataset>;
export function deserializeDataset(
dataset: SerializedGraphDataset | Partial<SerializedGraphDataset>,
): Partial<GraphDataset> | GraphDataset {
if (!dataset.fullGraph) return dataset as Partial<GraphDataset>;
if (!dataset.fullGraph) return dataset as Omit<Partial<GraphDataset>, "fullGraph">;

const fullGraph = new MultiGraph();
fullGraph.import(dataset.fullGraph);
Expand Down
Loading

0 comments on commit cfdf415

Please sign in to comment.