diff --git a/DEV-GUIDE.md b/DEV-GUIDE.md index d7a8269..bbc76a3 100644 --- a/DEV-GUIDE.md +++ b/DEV-GUIDE.md @@ -8,3 +8,41 @@ The file open size limit is configured in [src/toolbarActions/toolbarFunctions.j - `MAX_FILE_SIZE` is derived from it as bytes. To change the limit, update `MAX_FILE_SIZE_MB` only. + +## Workspace persistence (hybrid storage) + +Workspace persistence now uses a hybrid model: + +- Files/binary artifacts (imports/exports) stay on the browser filesystem path. +- Graph/session metadata is stored in IndexedDB (`concore-editor-storage`) when available. +- Local storage is used as a fallback if IndexedDB is unavailable. + +### IndexedDB schema (v1) + +- `graphs` store (key: `id`): graph snapshot payloads used by autosave/recovery. +- `meta` store (key: `key`): + - `graph_order` + - `session` + - `author_name` + - `migrated_local_storage_v1` + +### Migration behavior + +On first successful IndexedDB init, legacy localStorage data is migrated once: + +- all graph snapshots from `ALL_GRAPHS` +- session metadata from `SESSION_STATE` (if present) +- author metadata from `AUTHOR_NAME` + +### Fallback behavior + +If IndexedDB cannot be initialized, the app stays functional with localStorage fallback. +The same public storage manager API is used in both cases. + +### Manual verification checklist + +1. Open multiple graphs, switch active tab, reload page. +2. Confirm open tabs and active tab are restored. +3. Edit graphs and verify autosave keeps action history. +4. Corrupt one graph record manually and confirm app still loads remaining workspace. +5. Simulate IndexedDB unavailability and verify fallback load/save still works. diff --git a/package-lock.json b/package-lock.json index 03d9628..fd4545e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", - "axios": "^1.13.5", + "axios": "^1.20.0", "buffer": "^6.0.3", "chokidar": "^3.5.3", "cytoscape": "^3.19.0", @@ -27,7 +27,7 @@ "konva": "^7.0.3", "lucide-react": "^0.487.0", "md5": "^2.3.0", - "moment": "^2.29.4", + "moment": "^2.31.0", "png-chunk-text": "^1.0.0", "png-chunks-encode": "^1.0.0", "png-chunks-extract": "^1.0.0", @@ -96,25 +96,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@ampproject/remapping": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", - "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", - "license": "Apache-2.0", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/@babel/code-frame": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", - "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.27.1", + "@babel/helper-validator-identifier": "^7.29.7", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" }, @@ -123,30 +111,30 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.26.8", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.8.tgz", - "integrity": "sha512-oH5UPLMWR3L2wEFLnFJ1TZXqHufiTKAiLfqw5zkhS4dKXLJ10yVztfil/twG8EDTA4F/tvVNw9nOl4ZMslB8rQ==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.26.10", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.10.tgz", - "integrity": "sha512-vMqyb7XCDMPvJFFOaT9kxtiRh42GwlZEg1/uIgtZshS5a/8OaduUfCi7kynKgc3Tw/6Uo2D+db9qBttghhmxwQ==", - "license": "MIT", - "dependencies": { - "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.26.2", - "@babel/generator": "^7.26.10", - "@babel/helper-compilation-targets": "^7.26.5", - "@babel/helper-module-transforms": "^7.26.0", - "@babel/helpers": "^7.26.10", - "@babel/parser": "^7.26.10", - "@babel/template": "^7.26.9", - "@babel/traverse": "^7.26.10", - "@babel/types": "^7.26.10", + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.13.tgz", + "integrity": "sha512-j1nvOQCZYSgp7HLmisnCXFTpVvFODiijQ9QHkORfGKWH6YDtskTEeCJS7eV545GZ9UBzrq0e2xsOd5QQ5PjIqw==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.13", + "@babel/helper-compilation-targets": "^7.29.13", + "@babel/helper-module-transforms": "^7.29.13", + "@babel/helpers": "^7.29.13", + "@babel/parser": "^7.29.13", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.13", + "@babel/types": "^7.29.11", + "@jridgewell/remapping": "^2.3.5", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -197,12 +185,13 @@ } }, "node_modules/@babel/generator": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.28.5.tgz", - "integrity": "sha512-3EwLFhZ38J4VyIP6WNtt2kUdW9dokXA9Cr4IVIFHuCpZ3H8/YFOl5JjZHisrn1fATPBmKKqXzDFvh9fUwHz6CQ==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.14.tgz", + "integrity": "sha512-qSY56jgW5JnSXzuekLVil6zaOQxOCtOHidr65KkaMBw772IuAY28Qx4ZykAcDn8+FRF15qk80XzKwgSc/RYW6g==", + "license": "MIT", "dependencies": { - "@babel/parser": "^7.28.5", - "@babel/types": "^7.28.5", + "@babel/parser": "^7.29.14", + "@babel/types": "^7.29.14", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" @@ -223,13 +212,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.26.5", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.26.5.tgz", - "integrity": "sha512-IXuyn5EkouFJscIDuFF5EsiSolseme1s0CZB+QxVugqJLYmKdxI1VfIBOst0SUu4rnk2Z7kqTwmoO1lp3HIfnA==", + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.13.tgz", + "integrity": "sha512-8WxJ4/Vmes3ghacj8VOJy3NW8eyHiFY/4thU/LSBuBE470+igjR/j1ZTNn8fV5VdNrLx6iXUwig526UdOvfP0w==", "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.26.5", - "@babel/helper-validator-option": "^7.25.9", + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", "semver": "^6.3.1" @@ -320,9 +309,10 @@ } }, "node_modules/@babel/helper-globals": { - "version": "7.28.0", - "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz", - "integrity": "sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -341,26 +331,27 @@ } }, "node_modules/@babel/helper-module-imports": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz", - "integrity": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", + "license": "MIT", "dependencies": { - "@babel/traverse": "^7.27.1", - "@babel/types": "^7.27.1" + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.26.0", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz", - "integrity": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.14.tgz", + "integrity": "sha512-2XDvQVd9JESaOgGc4jT2/jquTAO7ppA5noTZQqH+MmZ89yjCzScLwtCPbWtkPZylL+TLWR49IwWmk+QkRR4GsA==", "license": "MIT", "dependencies": { - "@babel/helper-module-imports": "^7.25.9", - "@babel/helper-validator-identifier": "^7.25.9", - "@babel/traverse": "^7.25.9" + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.14" }, "engines": { "node": ">=6.9.0" @@ -382,9 +373,10 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz", - "integrity": "sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz", + "integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==", + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -437,25 +429,28 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", - "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.14.tgz", + "integrity": "sha512-CXvKMFvM80ihI7Vox9jb+kQjnyjESQNPM+vB7U0Zz6TWuZA+Z/FL0QPMH300h33qJtIx+REeBhXqWOPW48TcAQ==", + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", - "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", - "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -475,13 +470,13 @@ } }, "node_modules/@babel/helpers": { - "version": "7.26.10", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.10.tgz", - "integrity": "sha512-UPYc3SauzZ3JGgj87GgZ89JVdC5dj0AoetR5Bw6wj4niittNyFh6+eOGonYvJ1ao6B8lEa3Q3klS7ADZ53bc5g==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.14.tgz", + "integrity": "sha512-6E3Mi1r0B0umq6vmZa4/78q+64fqO2YY0THUdjDPKUCKhNb0yQy5NQIaPHCSD3ryTgiTss//P4JsWS80AsZ6LQ==", "license": "MIT", "dependencies": { - "@babel/template": "^7.26.9", - "@babel/types": "^7.26.10" + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.14" }, "engines": { "node": ">=6.9.0" @@ -574,11 +569,12 @@ } }, "node_modules/@babel/parser": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.5.tgz", - "integrity": "sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.14.tgz", + "integrity": "sha512-VL220vXuyO2z3rNIQwY7ftj9UwpqOt+33sH+sBWkOekbsSR2g7EEMnOx24ZlCH0xOA3DM/33SifVFGbnJD8r/w==", + "license": "MIT", "dependencies": { - "@babel/types": "^7.28.5" + "@babel/types": "^7.29.14" }, "bin": { "parser": "bin/babel-parser.js" @@ -1468,15 +1464,15 @@ } }, "node_modules/@babel/plugin-transform-modules-systemjs": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.25.9.tgz", - "integrity": "sha512-hyss7iIlH/zLHaehT+xwiymtPOpsiwIIRlCAOwBB04ta5Tt+lNItADdlXw3jAWZ96VJ2jlhl/c+PNIQPKNfvcA==", + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.29.8.tgz", + "integrity": "sha512-6iSnEK0zlkLKU4heofK/AdmRD4e2SHVpJMtrwnTCzhnaM98ria4rTrOXBBi45BTTYnJtO8txnPsX4fChYXkmeA==", "license": "MIT", "dependencies": { - "@babel/helper-module-transforms": "^7.25.9", - "@babel/helper-plugin-utils": "^7.25.9", - "@babel/helper-validator-identifier": "^7.25.9", - "@babel/traverse": "^7.25.9" + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.8" }, "engines": { "node": ">=6.9.0" @@ -2169,29 +2165,31 @@ } }, "node_modules/@babel/template": { - "version": "7.27.2", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz", - "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/parser": "^7.27.2", - "@babel/types": "^7.27.1" + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.28.5.tgz", - "integrity": "sha512-TCCj4t55U90khlYkVV/0TfkJkAkUg3jZFA3Neb7unZT8CPok7iiRfaX0F+WnqWqt7OxhOn0uBKXCw4lbL8W0aQ==", - "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/generator": "^7.28.5", - "@babel/helper-globals": "^7.28.0", - "@babel/parser": "^7.28.5", - "@babel/template": "^7.27.2", - "@babel/types": "^7.28.5", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.14.tgz", + "integrity": "sha512-RAdQJrBgmIH1FWvN0X+1hoDxzMzlP4cv/1Zi4dn4tG1H0cTb+rw7CzUxQJhp1f4ANd8j5vH3fy8BAWFGkBDEsA==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.14", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.14", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.14", "debug": "^4.3.1" }, "engines": { @@ -2199,12 +2197,13 @@ } }, "node_modules/@babel/types": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.5.tgz", - "integrity": "sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.14.tgz", + "integrity": "sha512-UjI/dKmwJwT9pOszJitq2G6EObZPnsZUfdCr92z2TlF3EZK9J3EdfOKUrCzHl6wFthbzwhzl1Soc/UIwxRiq6w==", + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.27.1", - "@babel/helper-validator-identifier": "^7.28.5" + "@babel/helper-string-parser": "^7.29.14", + "@babel/helper-validator-identifier": "^7.29.7" }, "engines": { "node": ">=6.9.0" @@ -3498,6 +3497,16 @@ "@jridgewell/trace-mapping": "^0.3.24" } }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", @@ -5714,14 +5723,15 @@ } }, "node_modules/axios": { - "version": "1.13.5", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.5.tgz", - "integrity": "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.20.0.tgz", + "integrity": "sha512-r8aOh8j9cGKpgQAqpzrUHnSIc6a59Y3Xf/cv8sy1DrHCkZHzQGEuoq1tARk6qSyDdtQGSDgpb9kFlruzPvrgwg==", "license": "MIT", "dependencies": { - "follow-redirects": "^1.15.11", - "form-data": "^4.0.5", - "proxy-from-env": "^1.1.0" + "follow-redirects": "^1.16.0", + "form-data": "^4.0.6", + "https-proxy-agent": "^5.0.1", + "proxy-from-env": "^2.1.0" } }, "node_modules/axobject-query": { @@ -6048,9 +6058,9 @@ ] }, "node_modules/baseline-browser-mapping": { - "version": "2.10.13", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.13.tgz", - "integrity": "sha512-BL2sTuHOdy0YT1lYieUxTw/QMtPBC3pmlJC6xk8BBYVv6vcw3SGdKemQ+Xsx9ik2F/lYDO9tqsFQH1r9PFuHKw==", + "version": "2.11.37", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.37.tgz", + "integrity": "sha512-QYph+vfurmaxhNwi9FprfmtkT5cx2Keg8FzZ0vnjO8ukscIybVyZGMFwdllKGlTI6qyU8ck43OM9UXh+IFJihQ==", "license": "Apache-2.0", "bin": { "baseline-browser-mapping": "dist/cli.cjs" @@ -6109,23 +6119,23 @@ "license": "MIT" }, "node_modules/body-parser": { - "version": "1.20.3", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", - "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", + "version": "1.20.9", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.9.tgz", + "integrity": "sha512-FISIQxV5u91Y9gvuFq3q/tA/qTqLJn3AhRcEvyozyhJTh5OBFFtv827AdHU7Rbyct4r+Ba1/99oFa1Y3yuFsdw==", "license": "MIT", "dependencies": { - "bytes": "3.1.2", + "bytes": "~3.1.2", "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.13.0", - "raw-body": "2.5.2", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.16.0", + "raw-body": "~2.5.3", "type-is": "~1.6.18", - "unpipe": "1.0.0" + "unpipe": "~1.0.0" }, "engines": { "node": ">= 0.8", @@ -6141,6 +6151,26 @@ "ms": "2.0.0" } }, + "node_modules/body-parser/node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/body-parser/node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -6159,6 +6189,15 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, + "node_modules/body-parser/node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/bonjour-service": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.3.0.tgz", @@ -6176,9 +6215,9 @@ "license": "ISC" }, "node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "version": "1.1.22", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.22.tgz", + "integrity": "sha512-CKLDTuSsN0+r1ThM0WkzzBI7dnPI6xEGfa/JnVYIK9JNBA1N1NyPwXVHor//NKD/y3sDxp764sZdLhFK7pH8XQ==", "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", @@ -6204,9 +6243,9 @@ "license": "BSD-2-Clause" }, "node_modules/browserslist": { - "version": "4.28.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.2.tgz", - "integrity": "sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==", + "version": "4.29.5", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.5.tgz", + "integrity": "sha512-khTmKu5NGYTotqcYo8Bew2k4RAE9PuXRSFRXG2lQBrCEQHyeQ/vX6gKMxfokwywBsLiXZMnHsmWMG1pnO8J7uQ==", "funding": [ { "type": "opencollective", @@ -6223,11 +6262,11 @@ ], "license": "MIT", "dependencies": { - "baseline-browser-mapping": "^2.10.12", - "caniuse-lite": "^1.0.30001782", - "electron-to-chromium": "^1.5.328", - "node-releases": "^2.0.36", - "update-browserslist-db": "^1.2.3" + "baseline-browser-mapping": "^2.11.33", + "caniuse-lite": "^1.0.30001819", + "electron-to-chromium": "^1.5.464", + "node-releases": "^2.0.60", + "update-browserslist-db": "^1.3.4" }, "bin": { "browserslist": "cli.js" @@ -6395,9 +6434,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001784", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001784.tgz", - "integrity": "sha512-WU346nBTklUV9YfUl60fqRbU5ZqyXlqvo1SgigE1OAXK5bFL8LL9q1K7aap3N739l4BvNqnkm3YrGHiY9sfUQw==", + "version": "1.0.30001826", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001826.tgz", + "integrity": "sha512-wTB+9tIbLro/BCXwLuNV1meHE4L9dS6dArMDwgYfNBPMYScqClHyGunhkCSDtHhe/69Xl0sHlKgBVZ+fNsYtWA==", "funding": [ { "type": "opencollective", @@ -6698,9 +6737,9 @@ "license": "MIT" }, "node_modules/colord": { - "version": "2.9.3", - "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", - "integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/colord/-/colord-2.13.0.tgz", + "integrity": "sha512-2g8RPH6UvoD1ZXYmccAuo0zfMw4mxqzXbeToeVoMSm6na0QEDXggahcZdlTFnFdahlV3I158ipRb2AIvCcwiAQ==", "license": "MIT" }, "node_modules/colorette": { @@ -6768,14 +6807,15 @@ } }, "node_modules/compression": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/compression/-/compression-1.8.1.tgz", - "integrity": "sha512-9mAqGPHLakhCLeNyxPkK4xVo746zQ/czLH1Ky+vkitMnWfWZps8r0qXuwhwizagCRttsL4lfG4pIOvaWLpAP0w==", + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.8.2.tgz", + "integrity": "sha512-o8vI5RE5A6EVVOd9o41jKp41aJom+QTEO/Bx8MYNjexMo/Bv2WOjUfZr+aL0WnYSgymUy6zeguqLTsIhV0gMvQ==", "license": "MIT", "dependencies": { "bytes": "3.1.2", "compressible": "~2.0.18", "debug": "2.6.9", + "destroy": "1.2.0", "negotiator": "~0.6.4", "on-headers": "~1.1.0", "safe-buffer": "5.2.1", @@ -6783,6 +6823,10 @@ }, "engines": { "node": ">= 0.8.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/compression/node_modules/debug": { @@ -7189,18 +7233,6 @@ ], "license": "CC0-1.0" }, - "node_modules/cssesc": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", - "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", - "license": "MIT", - "bin": { - "cssesc": "bin/cssesc" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/cssnano": { "version": "5.1.15", "resolved": "https://registry.npmjs.org/cssnano/-/cssnano-5.1.15.tgz", @@ -7915,9 +7947,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.331", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.331.tgz", - "integrity": "sha512-IbxXrsTlD3hRodkLnbxAPP4OuJYdWCeM3IOdT+CpcMoIwIoDfCmRpEtSPfwBXxVkg9xmBeY7Lz2Eo2TDn/HC3Q==", + "version": "1.5.486", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.486.tgz", + "integrity": "sha512-rpybw4Ac4ak/An6G1Me2+61xzwobowDGyuJe71QHHOVpkZv4fPVobsLl7WH6zHSKusAMpaHxGKTpOvpy7+r3dQ==", "license": "ISC" }, "node_modules/emittery": { @@ -8998,9 +9030,9 @@ "license": "MIT" }, "node_modules/fast-uri": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.6.tgz", - "integrity": "sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==", + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz", + "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==", "funding": [ { "type": "github", @@ -9109,9 +9141,9 @@ } }, "node_modules/filelist/node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.8.tgz", + "integrity": "sha512-BnlDzDYQoplTsZSvPi86CNzmbcb07X8ufR8fk1zivaiEJlXJkiq1MQyDCVmlWcsWbj6aWXqHnrwwevbrm/Saig==", "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" @@ -9242,9 +9274,9 @@ "license": "ISC" }, "node_modules/follow-redirects": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", - "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.3.tgz", + "integrity": "sha512-toOSoqN6d51Wjf1aOFJYcoVv1aND9rj/CwjLU0Vz40oDuSpWDayCeKe4JpL5NL0WdFvoOOCI3BRo69HahjbR1A==", "funding": [ { "type": "individual", @@ -9402,16 +9434,16 @@ } }, "node_modules/form-data": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", - "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", - "hasown": "^2.0.2", - "mime-types": "^2.1.12" + "hasown": "^2.0.4", + "mime-types": "^2.1.35" }, "engines": { "node": ">= 6" @@ -9895,9 +9927,9 @@ } }, "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -10169,9 +10201,9 @@ } }, "node_modules/http-proxy-middleware": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.9.tgz", - "integrity": "sha512-c1IyJYLYppU574+YI7R4QyX2ystMtVXZwIdzazUIPIJsHuWNd+mho2j+bKoHftndicGj9yh+xjd+l0yj7VeT1Q==", + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.11.tgz", + "integrity": "sha512-vTR6+QTUDDOQ3a5RI5YwSwSx3roJjLLAi+PBNFmBWDfrfk7zVteTFSMq6E8+FhnJ8yjMOTZfk71fRAFv1gl2OQ==", "license": "MIT", "dependencies": { "@types/http-proxy": "^1.17.8", @@ -13081,9 +13113,9 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", - "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", + "version": "3.15.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.15.2.tgz", + "integrity": "sha512-6EuL879VkRA+1Cz578mKMiKvjPNEuk6+r1JaFzoSWejZmtf7xWbIyw1e3KkxlkzTIt9Taw6JBhEppG7utc1P+w==", "license": "MIT", "dependencies": { "argparse": "^1.0.7", @@ -13152,15 +13184,15 @@ } }, "node_modules/jsdom/node_modules/form-data": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.4.tgz", - "integrity": "sha512-f0cRzm6dkyVYV3nPoooP8XlccPQukegwhAnpoLcXy+X+A8KfpGOoXwDr9FLZd3wzgLaBGQBE3lY93Zm/i1JvIQ==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.5.tgz", + "integrity": "sha512-j23EibVLnp4zNXGW7LjryXYa2X6U/M96yoOX+ybZxwkYajdxRNEqYY3zhh7y0i6kfISKS2jr+EJq1YTUDEv5+w==", "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", - "hasown": "^2.0.2", + "hasown": "^2.0.4", "mime-types": "^2.1.35" }, "engines": { @@ -13355,13 +13387,13 @@ } }, "node_modules/launch-editor": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.10.0.tgz", - "integrity": "sha512-D7dBRJo/qcGX9xlvt/6wUYzQxjh5G1RvZPgPv8vi4KRU99DVQL/oW7tnVOCCTm2HGeo3C5HvGE5Yrh6UBoZ0vA==", + "version": "2.14.2", + "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.14.2.tgz", + "integrity": "sha512-NHJEb30MGBCkmZXLZwz25t37QR4aY03ZzPYUJXOJaOa92uWwExI9SBQUuIznBYc1xkD7cJNGX7oc3Nl3sq2kQQ==", "license": "MIT", "dependencies": { - "picocolors": "^1.0.0", - "shell-quote": "^1.8.1" + "picocolors": "^1.1.1", + "shell-quote": "^1.10.0" } }, "node_modules/leven": { @@ -14328,9 +14360,9 @@ } }, "node_modules/moment": { - "version": "2.30.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", - "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", + "version": "2.31.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.31.0.tgz", + "integrity": "sha512-0acOTfMiWOheYS4eoWb80yYMb/JLvVv9SHbs2PehaDzfUG0Bw855SKyk0IKTnPGa5+U2bmi3W68l1+sGLX/pvw==", "license": "MIT", "engines": { "node": "*" @@ -14383,9 +14415,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.11", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", - "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", "funding": [ { "type": "github", @@ -14438,9 +14470,9 @@ } }, "node_modules/node-forge": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.0.tgz", - "integrity": "sha512-LarFH0+6VfriEhqMMcLX2F7SwSXeWwnEAJEsYm5QKWchiVYVvJyV9v7UDvUv+w5HO23ZpQTXDv/GxdDdMyOuoQ==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.3.tgz", + "integrity": "sha512-P6wzfh6t70avmV8FrVEAd/36sOPJQ+hkaJVX1Laap9J/77m7M0eyozDvc8SwnDf4P7MP94gwbAAo0rg3YVXT+g==", "license": "(BSD-3-Clause OR GPL-2.0)", "engines": { "node": ">= 6.13.0" @@ -14453,10 +14485,13 @@ "license": "MIT" }, "node_modules/node-releases": { - "version": "2.0.36", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.36.tgz", - "integrity": "sha512-TdC8FSgHz8Mwtw9g5L4gR/Sh9XhSP/0DEkQxfEFXOpiul5IiHgHan2VhYYb6agDSfp4KuvltmGApc8HMgUrIkA==", - "license": "MIT" + "version": "2.0.64", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.64.tgz", + "integrity": "sha512-zAPCKqMcnqs2nGy6nlkm7JduFseiBJy3EXHGLh+8pFR+TxGCBxxiEN21+UROU5CKwX/f4TlUcYjiM+vs/tsyxw==", + "license": "MIT", + "engines": { + "node": ">=18" + } }, "node_modules/normalize-path": { "version": "3.0.0", @@ -14941,9 +14976,9 @@ "license": "ISC" }, "node_modules/path-to-regexp": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", - "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz", + "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==", "license": "MIT" }, "node_modules/path-type": { @@ -14968,9 +15003,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", "license": "MIT", "engines": { "node": ">=8.6" @@ -15635,15 +15670,18 @@ } }, "node_modules/postcss-load-config/node_modules/yaml": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz", - "integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==", + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", + "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", "license": "ISC", "bin": { "yaml": "bin.mjs" }, "engines": { - "node": ">= 14" + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" } }, "node_modules/postcss-loader": { @@ -15820,12 +15858,11 @@ } }, "node_modules/postcss-modules-local-by-default/node_modules/postcss-selector-parser": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", - "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.2.1.tgz", + "integrity": "sha512-GwxlMgTTXwIom+ebC7an3k6RaJDwklRQQnfiXsLPGicu8FYV/k/+1/9YY2OU2+r938H2t4X0TDxoif+HP2rjzQ==", "license": "MIT", "dependencies": { - "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" }, "engines": { @@ -15848,12 +15885,11 @@ } }, "node_modules/postcss-modules-scope/node_modules/postcss-selector-parser": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", - "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.2.1.tgz", + "integrity": "sha512-GwxlMgTTXwIom+ebC7an3k6RaJDwklRQQnfiXsLPGicu8FYV/k/+1/9YY2OU2+r938H2t4X0TDxoif+HP2rjzQ==", "license": "MIT", "dependencies": { - "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" }, "engines": { @@ -16303,12 +16339,11 @@ } }, "node_modules/postcss-selector-parser": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", - "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", + "version": "6.1.6", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.6.tgz", + "integrity": "sha512-BK87/Qgti3DIcgS2PaCVoteFIkjIFvCJBizZDIVSjdlFNg4Jv+SRqbN2JONb/qQUH4ZFqfXYF+izg15W2HVRvA==", "license": "MIT", "dependencies": { - "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" }, "engines": { @@ -16540,9 +16575,9 @@ } }, "node_modules/proxy-addr": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz", + "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==", "license": "MIT", "dependencies": { "forwarded": "0.2.0", @@ -16550,6 +16585,10 @@ }, "engines": { "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/proxy-addr/node_modules/ipaddr.js": { @@ -16562,10 +16601,13 @@ } }, "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "license": "MIT" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } }, "node_modules/psl": { "version": "1.15.0", @@ -16600,12 +16642,13 @@ } }, "node_modules/qs": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", - "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "version": "6.16.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.2.tgz", + "integrity": "sha512-VYdnB5S7/0IeXzBacUtwNAaM6d7Y/PgYnNC7bJCI6meqA/OgnsQbZMtVW8Dt2D1PHgbHGtYmhSoEIgvt7xZ2ZA==", "license": "BSD-3-Clause", "dependencies": { - "side-channel": "^1.0.6" + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" }, "engines": { "node": ">=0.6" @@ -16668,18 +16711,62 @@ } }, "node_modules/raw-body": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", - "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", "license": "MIT", "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" }, "engines": { "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/raw-body/node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/raw-body/node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/raw-body/node_modules/iconv-lite": { @@ -16694,6 +16781,15 @@ "node": ">=0.10.0" } }, + "node_modules/raw-body/node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/rc-align": { "version": "4.0.15", "resolved": "https://registry.npmjs.org/rc-align/-/rc-align-4.0.15.tgz", @@ -17455,9 +17551,19 @@ } }, "node_modules/react-scripts/node_modules/js-yaml": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", - "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", + "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -18023,9 +18129,9 @@ } }, "node_modules/rollup": { - "version": "2.79.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz", - "integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==", + "version": "2.80.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.80.0.tgz", + "integrity": "sha512-cIFJOD1DESzpjOBl763Kp1AH7UE/0fcdHe6rZXUdQ9c50uvgigvW97u3IcSeBwOkgqL/PXPBktBCh0KEu5L8XQ==", "license": "MIT", "bin": { "rollup": "dist/bin/rollup" @@ -18590,9 +18696,9 @@ } }, "node_modules/shell-quote": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.2.tgz", - "integrity": "sha512-AzqKpGKjrj7EM6rKVQEPpB288oCfnrEIuyoT9cyF4nmGa7V8Zk6f7RRqYisX8X9m+Q7bd632aZW4ky7EhbQztA==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.12.0.tgz", + "integrity": "sha512-PcByqNyT/38F2kDNi006HAMRJaULuBzq/FOsw3qdZvX/GA9W/jamDaRskgHjubHiftXK5sIFxLNkvrXUwcof6Q==", "license": "MIT", "engines": { "node": ">= 0.4" @@ -18602,14 +18708,14 @@ } }, "node_modules/side-channel": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", - "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", "license": "MIT", "dependencies": { "es-errors": "^1.3.0", - "object-inspect": "^1.13.3", - "side-channel-list": "^1.0.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", "side-channel-map": "^1.0.1", "side-channel-weakmap": "^1.0.2" }, @@ -18621,13 +18727,13 @@ } }, "node_modules/side-channel-list": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", - "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", "license": "MIT", "dependencies": { "es-errors": "^1.3.0", - "object-inspect": "^1.13.3" + "object-inspect": "^1.13.4" }, "engines": { "node": ">= 0.4" @@ -18744,9 +18850,9 @@ } }, "node_modules/source-map-js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", - "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" @@ -19233,9 +19339,9 @@ } }, "node_modules/sucrase/node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.8.tgz", + "integrity": "sha512-BnlDzDYQoplTsZSvPi86CNzmbcb07X8ufR8fk1zivaiEJlXJkiq1MQyDCVmlWcsWbj6aWXqHnrwwevbrm/Saig==", "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" @@ -20428,9 +20534,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz", - "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.4.tgz", + "integrity": "sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==", "funding": [ { "type": "opencollective", @@ -20865,9 +20971,9 @@ } }, "node_modules/webpack-dev-server/node_modules/ws": { - "version": "8.18.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.1.tgz", - "integrity": "sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==", + "version": "8.23.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.23.0.tgz", + "integrity": "sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==", "license": "MIT", "engines": { "node": ">=10.0.0" @@ -20960,9 +21066,9 @@ } }, "node_modules/websocket-driver": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.4.tgz", - "integrity": "sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg==", + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.5.tgz", + "integrity": "sha512-ZL2+3c7kMBdIRCMz6l8jQMHyGVxj+UL+xVk74Ombiciboca8rHa15L86B19E5oh1pL9Ii/uj54gtsIrZGMo6zA==", "license": "Apache-2.0", "dependencies": { "http-parser-js": ">=0.5.1", @@ -21683,9 +21789,9 @@ } }, "node_modules/ws": { - "version": "7.5.10", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", - "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", + "version": "7.5.14", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.14.tgz", + "integrity": "sha512-u9Oi2nQ8SZnTUAf6spLLKF5TyqoG3Nbbrd4ai6Sjo4P24bycDewhQqtNMIg4bFpnpH/TD4qk4IuAVhT0HIIqug==", "license": "MIT", "engines": { "node": ">=8.3.0" @@ -21753,9 +21859,9 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.3.tgz", + "integrity": "sha512-vIYeF1u3CjlhAFekPPAk2h/Kv4T3mAkMox5OymRiJQB0spDP10LHvt+K7G9Ny6NuuMAb25/6n1qyUjAcGNf/AA==", "license": "ISC", "engines": { "node": ">= 6" diff --git a/package.json b/package.json index 3627c88..5a09fbc 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", - "axios": "^1.13.5", + "axios": "^1.20.0", "buffer": "^6.0.3", "chokidar": "^3.5.3", "cytoscape": "^3.19.0", @@ -23,7 +23,7 @@ "konva": "^7.0.3", "lucide-react": "^0.487.0", "md5": "^2.3.0", - "moment": "^2.29.4", + "moment": "^2.31.0", "png-chunk-text": "^1.0.0", "png-chunks-encode": "^1.0.0", "png-chunks-extract": "^1.0.0", diff --git a/server/controller/workflow.py b/server/controller/workflow.py index ed79375..6df2389 100644 --- a/server/controller/workflow.py +++ b/server/controller/workflow.py @@ -1,5 +1,5 @@ from model.workflows import WorkFlowModel -from flask import request, make_response, Blueprint +from flask import request, make_response, Blueprint, jsonify import defusedxml.ElementTree as ET workFlow = Blueprint('workflow', __name__) @@ -26,6 +26,15 @@ def getAllActionHash(root): return list(map(lambda ah: ah.find(f'{{{xmlns}}}hash').text, root.find(f'{{{xmlns}}}graph').findall(f'{{{xmlns}}}actionHistory'))) +def syncConflict(message='Different History'): + return jsonify({'code': 'SYNC_CONFLICT', 'message': message}), 400 + + +def isConflictMessage(message): + msg = (message or '').lower() + return 'latest changes' in msg or 'different history' in msg + + @workFlow.route("/", methods=['POST']) def postWorkflow(): try: @@ -45,7 +54,7 @@ def getWorkflow(serverID): latestHash = request.headers['X-Latest-Hash'] allHash = getAllActionHash(ET.fromstring(graphml)) if(latestHash not in allHash): - return 'Different History', 400 + return syncConflict() r = make_response(graphml) r.headers.set('Content-Type', "application/xml") return r @@ -67,4 +76,8 @@ def updateWorkflow(serverID): res = workFlowModel.forceUpdate(serverID, graphML, latestHash) else: res = workFlowModel.update(serverID, graphML, latestHash, allHash) - return res[1], 200 if res[0] else 400 + if res[0]: + return res[1], 200 + if isConflictMessage(res[1]): + return syncConflict(res[1]) + return res[1], 400 diff --git a/server/requirements.txt b/server/requirements.txt index f702e51..c5bfca8 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -1,6 +1,6 @@ dnspython==2.6.1 Flask==3.1.3 -python-dotenv==0.19.0 +python-dotenv==1.2.2 pymongo==4.6.3 gunicorn==23.0.0 flask-cors==6.0.0 diff --git a/server/tests/test_workflow_controller.py b/server/tests/test_workflow_controller.py index 38c5ab0..c964e02 100644 --- a/server/tests/test_workflow_controller.py +++ b/server/tests/test_workflow_controller.py @@ -32,6 +32,11 @@ def forceUpdate(self, serverID, graphml, latestHash): return (True, latestHash) +class FakeWorkFlowModelUpdateMissing(FakeWorkFlowModel): + def update(self, serverID, graphml, latestHash, allHash): + return (False, 'serverID do not exists.') + + class WorkflowControllerTests(unittest.TestCase): @classmethod def setUpClass(cls): @@ -62,6 +67,12 @@ def make_client(self, graph_response): app.register_blueprint(self.workflow_module.workFlow, url_prefix='/workflow') return app.test_client() + def make_client_with_model(self, model): + self.workflow_module.workFlowModel = model + app = Flask(__name__) + app.register_blueprint(self.workflow_module.workFlow, url_prefix='/workflow') + return app.test_client() + def test_missing_workflow_returns_404_for_none(self): client = self.make_client(None) response = client.get('/workflow/missing-id') @@ -78,7 +89,8 @@ def test_hash_header_returns_400_for_different_history(self): client = self.make_client(VALID_GRAPHML) response = client.get('/workflow/existing-id', headers={'X-Latest-Hash': 'unknown-hash'}) self.assertEqual(response.status_code, 400) - self.assertEqual(response.get_data(as_text=True), 'Different History') + self.assertEqual(response.get_json()['code'], 'SYNC_CONFLICT') + self.assertEqual(response.get_json()['message'], 'Different History') def test_hash_header_returns_200_for_matching_history(self): client = self.make_client(VALID_GRAPHML) @@ -117,6 +129,13 @@ def test_force_update_workflow_returns_200(self): content_type='application/xml') self.assertEqual(response.status_code, 200) + def test_update_workflow_non_conflict_error_returns_plain_400(self): + client = self.make_client_with_model(FakeWorkFlowModelUpdateMissing(None)) + response = client.post('/workflow/test01', data=VALID_GRAPHML, + content_type='application/xml') + self.assertEqual(response.status_code, 400) + self.assertEqual(response.get_data(as_text=True), 'serverID do not exists.') + if __name__ == '__main__': unittest.main() diff --git a/src/GraphWorkspace.jsx b/src/GraphWorkspace.jsx index 53e3504..78c85f6 100644 --- a/src/GraphWorkspace.jsx +++ b/src/GraphWorkspace.jsx @@ -1,6 +1,7 @@ import React from 'react'; import ZoomComp from './component/ZoomSetter'; import ConfirmModal from './component/modals/ConfirmModal'; +import SyncStatusPanel from './component/SyncStatusPanel'; import SearchPanel from './component/SearchPanel'; import { actionType as T } from './reducer'; import './graphWorkspace.css'; @@ -13,15 +14,65 @@ const GraphComp = (props) => { const { dispatcher, superState } = props; React.useEffect(() => { - const allIDs = localStorageManager.getAllGraphs(); - const validIDs = allIDs.filter((id) => typeof id === 'string' && id && localStorageManager.get(id) !== null); - if (validIDs.length !== allIDs.length) { - allIDs.filter((id) => !validIDs.includes(id)).forEach((id) => localStorageManager.remove(id)); - } - if (validIDs.length === 0) return; - dispatcher({ type: T.ADD_GRAPH_BULK, payload: validIDs.map((graphID) => ({ graphID })) }); + let mounted = true; + const restoreWorkspace = async () => { + await localStorageManager.initialize(); + if (!mounted) return; + + const session = localStorageManager.getSession(); + const allIDs = Array.isArray(session?.openGraphIDs) && session.openGraphIDs.length + ? session.openGraphIDs + : localStorageManager.getAllGraphs(); + const validIDs = allIDs.filter( + (id) => typeof id === 'string' && id && localStorageManager.get(id) !== null, + ); + if (validIDs.length !== allIDs.length) { + allIDs.filter((id) => !validIDs.includes(id)).forEach((id) => localStorageManager.remove(id)); + } + + if (Array.isArray(session?.fileState)) { + dispatcher({ type: T.SET_FILE_STATE, payload: session.fileState }); + } + if (typeof session?.uploadedDirName === 'string') { + dispatcher({ type: T.SET_DIR_NAME, payload: session.uploadedDirName }); + } + + if (validIDs.length === 0) return; + dispatcher({ + type: T.ADD_GRAPH_BULK, + payload: { + graphs: validIDs.map((graphID) => ({ graphID })), + activeGraphID: session?.activeGraphID || null, + }, + }); + }; + restoreWorkspace(); + + return () => { + mounted = false; + }; }, []); + React.useEffect(() => { + const openGraphIDs = superState.graphs + .map((graph) => graph.graphID) + .filter((graphID) => typeof graphID === 'string' && graphID); + const activeGraphID = superState.curGraphIndex >= 0 && superState.curGraphIndex < superState.graphs.length + ? superState.graphs[superState.curGraphIndex].graphID + : null; + localStorageManager.saveSession({ + openGraphIDs, + activeGraphID, + fileState: superState.fileState, + uploadedDirName: superState.uploadedDirName, + }); + }, [ + superState.graphs, + superState.curGraphIndex, + superState.fileState, + superState.uploadedDirName, + ]); + // Remote server implementation - Not being used. // useEffect(() => { // if (!loadedFromStorage) return; @@ -79,11 +130,13 @@ const GraphComp = (props) => { ))} + { if (superState.confirmModal.onConfirm) superState.confirmModal.onConfirm(); dispatcher({ type: T.SET_CONFIRM_MODAL, payload: { open: false, message: '', onConfirm: null } }); diff --git a/src/component/SyncStatusPanel.jsx b/src/component/SyncStatusPanel.jsx new file mode 100644 index 0000000..add5f06 --- /dev/null +++ b/src/component/SyncStatusPanel.jsx @@ -0,0 +1,82 @@ +import React from 'react'; +import './syncStatusPanel.css'; + +const stateLabel = { + synced: 'Synced', + dirty: 'Dirty', + conflict: 'Conflict', + syncing: 'Syncing', + error: 'Error', +}; + +const SyncStatusPanel = ({ superState }) => { + if (superState.curGraphIndex === -1) return null; + + const graph = superState.graphs[superState.curGraphIndex]; + if (!graph) return null; + + const syncStatus = graph.syncStatus || {}; + const { + state = 'dirty', + localHash = '', + remoteHash = '', + lastResult = 'Not synced yet', + } = syncStatus; + + const instance = superState.curGraphInstance; + const isConflict = state === 'conflict'; + + return ( +
+
+ Sync + {stateLabel[state] || state} +
+
+
+ Local: + {localHash || '-'} +
+
+ Remote: + {remoteHash || '-'} +
+
+
{lastResult}
+ {isConflict && ( +
+ + + + +
+ )} +
+ ); +}; + +export default SyncStatusPanel; diff --git a/src/component/fileBrowser.jsx b/src/component/fileBrowser.jsx index 1ab72c1..e46cf80 100644 --- a/src/component/fileBrowser.jsx +++ b/src/component/fileBrowser.jsx @@ -53,6 +53,10 @@ const LocalFileBrowser = ({ superState, dispatcher }) => { }, [superState.fileState]); const handleSelectFile = (data) => { + if (!data.fileObj) { + toast.info('File handle is not available after reload. Re-open the file/directory.'); + return; + } const fileExtensions = ['exe']; const fileExt = data.fileObj.name.split('.').pop().toLowerCase(); if (fileExtensions.includes(fileExt)) { diff --git a/src/component/modals/ConfirmModal.jsx b/src/component/modals/ConfirmModal.jsx index 787ab33..e564dbf 100644 --- a/src/component/modals/ConfirmModal.jsx +++ b/src/component/modals/ConfirmModal.jsx @@ -3,14 +3,34 @@ import ParentModal from './ParentModal'; import './confirmModal.css'; const ConfirmModal = ({ - isOpen, title, message, onConfirm, onCancel, + isOpen, title, message, onConfirm, onCancel, actions, }) => (
{message}
- - + { + actions && actions.length + ? actions.map((action) => ( + + )) + : ( + <> + + + + ) + }
diff --git a/src/component/modals/ContributeDetails.jsx b/src/component/modals/ContributeDetails.jsx index 8f4649d..d718b68 100644 --- a/src/component/modals/ContributeDetails.jsx +++ b/src/component/modals/ContributeDetails.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import { toast } from 'react-toastify'; import axios from 'axios'; import { EXECUTION_ENGINE_URL } from '../../serverCon/config'; @@ -10,13 +10,36 @@ const ContributeDetails = ({ superState, dispatcher }) => { const closeModal = () => { dispatcher({ type: T.SET_CONTRIBUTE_MODAL, payload: false }); }; - const [study, setStudy] = useState(''); - const [path, setPath] = useState(''); - const [auth, setAuth] = useState(''); + + const curGraph = superState.graphs[superState.curGraphIndex] ?? {}; + + const [study, setStudy] = useState(curGraph.projectName ?? ''); + const [path, setPath] = useState(superState.uploadedDirName ?? ''); + const [auth, setAuth] = useState(curGraph.authorName ?? ''); const [title, setTitle] = useState(''); const [desc, setDesc] = useState(''); const [branch, setBranch] = useState(''); const [showAdvanceOptions, setShowAdvanceOptions] = useState(false); + const prevOpenRef = useRef(false); + + useEffect(() => { + if (superState.contributeModal && !prevOpenRef.current) { + const activeGraph = superState.graphs[superState.curGraphIndex] ?? {}; + setStudy(activeGraph.projectName ?? ''); + setPath(superState.uploadedDirName ?? ''); + setAuth(activeGraph.authorName ?? ''); + setTitle(''); + setDesc(''); + setBranch(''); + setShowAdvanceOptions(false); + } + prevOpenRef.current = superState.contributeModal; + }, [ + superState.contributeModal, + superState.graphs, + superState.curGraphIndex, + superState.uploadedDirName, + ]); const submit = async (e) => { if (study === '' || path === '' || auth === '') { toast.info('Please Provide necessary inputs'); diff --git a/src/component/modals/confirmModal.css b/src/component/modals/confirmModal.css index 5402b8b..e03e316 100644 --- a/src/component/modals/confirmModal.css +++ b/src/component/modals/confirmModal.css @@ -5,6 +5,7 @@ .confirm-modal-message { margin-bottom: 20px; font-size: 1.1em; + white-space: pre-line; } .confirm-modal-actions { display: flex; diff --git a/src/component/syncStatusPanel.css b/src/component/syncStatusPanel.css new file mode 100644 index 0000000..308200b --- /dev/null +++ b/src/component/syncStatusPanel.css @@ -0,0 +1,81 @@ +.sync-status-panel { + position: absolute; + right: 12px; + bottom: 12px; + z-index: 5; + width: 320px; + background: var(--bg-secondary); + color: var(--text-primary); + border: 1px solid var(--border-primary); + border-radius: 8px; + padding: 10px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); + font-size: 12px; +} + +.sync-status-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; +} + +.sync-status-badge { + font-size: 11px; + border-radius: 10px; + padding: 2px 8px; + background: #666; +} + +.sync-status-badge.synced { + background: #2e7d32; +} + +.sync-status-badge.dirty { + background: #ef6c00; +} + +.sync-status-badge.conflict { + background: #c62828; +} + +.sync-status-badge.syncing { + background: #1565c0; +} + +.sync-status-badge.error { + background: #7b1fa2; +} + +.sync-status-meta { + display: grid; + grid-template-columns: 1fr; + row-gap: 4px; + margin-bottom: 8px; +} + +.sync-key { + color: var(--text-primary); + opacity: 0.75; + margin-right: 4px; +} + +.sync-value { + word-break: break-all; +} + +.sync-status-result { + margin-bottom: 10px; +} + +.sync-status-actions { + display: flex; + flex-wrap: wrap; + gap: 6px; +} + +.sync-status-actions .confirm-btn, +.sync-status-actions .cancel-btn { + padding: 6px 8px; + font-size: 12px; +} diff --git a/src/graph-builder/graph-core/6-server.js b/src/graph-builder/graph-core/6-server.js index d396bbb..29c7982 100644 --- a/src/graph-builder/graph-core/6-server.js +++ b/src/graph-builder/graph-core/6-server.js @@ -1,7 +1,7 @@ import { toast } from 'react-toastify'; import Axios from 'axios'; import { actionType as T } from '../../reducer'; -import { EXECUTION_ENGINE_URL } from '../../serverCon/config'; +import serverConConfig, { EXECUTION_ENGINE_URL } from '../../serverCon/config'; import GraphLoadSave from './5-load-save'; // import { // postGraph, updateGraph, forceUpdateGraph, getGraph, getGraphWithHashCheck, @@ -11,12 +11,188 @@ import { } from '../../serverCon/crud_http'; class GraphServer extends GraphLoadSave { + static getLatestHashFromGraphML(graphXML) { + if (!graphXML) return ''; + try { + const doc = new DOMParser().parseFromString(graphXML, 'application/xml'); + const hashes = doc.getElementsByTagName('hash'); + if (!hashes.length) return ''; + return hashes[hashes.length - 1].textContent || ''; + } catch { + return ''; + } + } + + static getErrorMessage(err) { + return err?.data?.message || err?.response?.data?.message || err?.message || 'Sync failed'; + } + + static isSyncConflictError(err) { + return err?.code === 'SYNC_CONFLICT' + || err?.data?.code === 'SYNC_CONFLICT' + || (err?.status === 400 && err?.body === 'Different History'); + } + + getLocalHash() { + return this.actionArr.length ? this.actionArr.at(-1).hash : ''; + } + + setSyncStatus(syncStatus) { + this.dispatcher({ + type: T.SET_GRAPH_SYNC_STATE, + payload: { + graphID: this.id, + syncStatus, + }, + }); + } + + setSyncStateFromSavedFlag() { + const state = this.serverID && this.isSaved ? 'synced' : 'dirty'; + let lastResult = 'Local workflow.'; + if (this.serverID) { + lastResult = this.isSaved ? 'Synced.' : 'Local changes pending sync.'; + } + this.setSyncStatus({ + state, + localHash: this.getLocalHash(), + lastResult, + }); + } + + setSyncError(err) { + const message = GraphServer.getErrorMessage(err); + this.setSyncStatus({ + state: 'error', + localHash: this.getLocalHash(), + lastResult: message, + reason: message, + }); + toast.error(message); + } + + syncSuccessFromGraphML(resultText, graphXML) { + const remoteHash = GraphServer.getLatestHashFromGraphML(graphXML); + this.setSyncStatus({ + state: 'synced', + localHash: remoteHash || this.getLocalHash(), + remoteHash: remoteHash || this.getLocalHash(), + lastResult: resultText, + reason: '', + }); + } + + openRemoteInNewTab() { + if (!this.serverID) return; + const remotePath = serverConConfig.getGraph(this.serverID); + const remoteURL = `${serverConConfig.baseURL}${remotePath}`; + window.open(remoteURL, '_blank', 'noopener,noreferrer'); + } + + cancelSyncConflict() { + const state = this.serverID && this.isSaved ? 'synced' : 'dirty'; + this.setSyncStatus({ + state, + localHash: this.getLocalHash(), + lastResult: 'Conflict dismissed.', + reason: '', + }); + } + + showSyncConflictModal(reason) { + const localHash = this.getLocalHash() || 'None'; + const setModal = (remoteHash) => { + this.setSyncStatus({ + state: 'conflict', + localHash: this.getLocalHash(), + remoteHash: remoteHash || '', + lastResult: reason || 'Sync conflict detected.', + reason: reason || 'Sync conflict detected.', + }); + const message = [ + reason || 'Sync conflict detected.', + `Local hash: ${localHash}`, + `Remote hash: ${remoteHash || 'Remote history is newer/different'}`, + 'Choose how to resolve this conflict.', + ].join('\n'); + this.dispatcher({ + type: T.SET_CONFIRM_MODAL, + payload: { + open: true, + message, + actions: [ + { + label: 'Pull remote', + className: 'confirm-btn', + onClick: () => this.forcePullFromServer(), + }, + { + label: 'Force push local', + className: 'confirm-btn', + onClick: () => { + this.setSyncStatus({ + state: 'syncing', + localHash: this.getLocalHash(), + lastResult: 'Force pushing local changes...', + }); + if (this.serverID) { + forceUpdateGraph(this.serverID, this.getGraphML()).then(() => { + this.syncSuccessFromGraphML('Force push successful.', this.getGraphML()); + }).catch((err) => { + this.setSyncError(err); + }); + } else { + postGraph(this.getGraphML()).then((serverID) => { + this.set({ serverID }); + this.syncSuccessFromGraphML('Force push successful.', this.getGraphML()); + }).catch((err) => { + this.setSyncError(err); + }); + } + }, + }, + { + label: 'Open remote in new tab', + className: 'cancel-btn', + onClick: () => this.openRemoteInNewTab(), + }, + { + label: 'Cancel', + className: 'cancel-btn', + onClick: () => this.cancelSyncConflict(), + }, + ], + }, + }); + }; + if (!this.serverID) { + setModal('Unknown'); + return; + } + getGraph(this.serverID).then((graphXML) => { + try { + const doc = new DOMParser().parseFromString(graphXML, 'application/xml'); + const hashes = doc.getElementsByTagName('hash'); + setModal(hashes.length ? (hashes[hashes.length - 1].textContent || '') : ''); + } catch { + setModal('Unavailable'); + } + }).catch(() => { + setModal('Unavailable'); + }); + } + set(config) { const { serverID } = config; super.set(config); if (serverID) { this.setServerID(serverID); this.dispatcher({ type: T.IS_WORKFLOW_ON_SERVER, payload: Boolean(this.serverID) }); + this.setSyncStatus({ + state: 'dirty', + localHash: this.getLocalHash(), + lastResult: 'Connected to server.', + }); } } // Not being immplemented in version 1 @@ -69,18 +245,28 @@ class GraphServer extends GraphLoadSave { // } pushToServer() { + this.setSyncStatus({ + state: 'syncing', + localHash: this.getLocalHash(), + lastResult: 'Pushing local changes...', + }); if (this.serverID) { updateGraph(this.serverID, this.getGraphML()).then(() => { - + this.syncSuccessFromGraphML('Push successful.', this.getGraphML()); }).catch((err) => { - toast.error(err.response?.data?.message || err.message); + if (GraphServer.isSyncConflictError(err)) { + this.showSyncConflictModal('Cannot push: local and remote histories diverged.'); + return; + } + this.setSyncError(err); }); } else { postGraph(this.getGraphML()).then((serverID) => { this.set({ serverID }); this.cy.emit('graph-modified'); + this.syncSuccessFromGraphML('Push successful.', this.getGraphML()); }).catch((err) => { - toast.error(err.response?.data?.message || err.message); + this.setSyncError(err); }); } } @@ -92,17 +278,23 @@ class GraphServer extends GraphLoadSave { open: true, message: 'Forced push may result in workflow overwite and loss of changes pushed by others. Confirm?', onConfirm: () => { + this.setSyncStatus({ + state: 'syncing', + localHash: this.getLocalHash(), + lastResult: 'Force pushing local changes...', + }); if (this.serverID) { forceUpdateGraph(this.serverID, this.getGraphML()).then(() => { - + this.syncSuccessFromGraphML('Force push successful.', this.getGraphML()); }).catch((err) => { - toast.error(err.response?.data?.message || err.message); + this.setSyncError(err); }); } else { postGraph(this.getGraphML()).then((serverID) => { this.set({ serverID }); + this.syncSuccessFromGraphML('Force push successful.', this.getGraphML()); }).catch((err) => { - toast.error(err.response?.data?.message || err.message); + this.setSyncError(err); }); } }, @@ -112,10 +304,16 @@ class GraphServer extends GraphLoadSave { forcePullFromServer() { if (this.serverID) { + this.setSyncStatus({ + state: 'syncing', + localHash: this.getLocalHash(), + lastResult: 'Pulling remote workflow...', + }); getGraph(this.serverID).then((graphXML) => { this.setGraphML(graphXML); + this.syncSuccessFromGraphML('Pull successful.', graphXML); }).catch((err) => { - toast.error(err.response?.data?.message || err.message); + this.setSyncError(err); }); } else { toast.success('Not on server'); @@ -125,10 +323,20 @@ class GraphServer extends GraphLoadSave { pullFromServer() { if (this.actionArr.length === 0) { this.forcePullFromServer(); return; } if (this.serverID) { + this.setSyncStatus({ + state: 'syncing', + localHash: this.getLocalHash(), + lastResult: 'Checking remote changes...', + }); getGraphWithHashCheck(this.serverID, this.actionArr.at(-1).hash).then((graphXML) => { this.setGraphML(graphXML); - }).catch(() => { - + this.syncSuccessFromGraphML('Pull successful.', graphXML); + }).catch((err) => { + if (GraphServer.isSyncConflictError(err)) { + this.showSyncConflictModal('Cannot pull: local and remote histories diverged.'); + return; + } + this.setSyncError(err); }); } else { toast.success('Not on server'); @@ -248,6 +456,12 @@ class GraphServer extends GraphLoadSave { setCurStatus() { super.setCurStatus(); this.dispatcher({ type: T.IS_WORKFLOW_ON_SERVER, payload: Boolean(this.serverID) }); + const currentGraph = this.superState.graphs.find((g) => g.graphID === this.id); + if (!currentGraph || !currentGraph.syncStatus || currentGraph.syncStatus.state !== 'conflict') { + this.setSyncStateFromSavedFlag(); + } else { + this.setSyncStatus({ localHash: this.getLocalHash() }); + } } } diff --git a/src/graph-builder/local-storage-manager.js b/src/graph-builder/local-storage-manager.js index 666865f..2bd00b4 100644 --- a/src/graph-builder/local-storage-manager.js +++ b/src/graph-builder/local-storage-manager.js @@ -23,6 +23,47 @@ const parseStoredJson = (raw) => { } }; +const isValidGraphSnapshot = (graph) => !!( + graph + && typeof graph === 'object' + && Array.isArray(graph.nodes) + && Array.isArray(graph.edges) +); + +const requestAsPromise = (request) => new Promise((resolve, reject) => { + request.onsuccess = () => resolve(request.result); + request.onerror = () => reject(request.error); +}); + +const sanitizeSession = (session) => { + if (!session || typeof session !== 'object') return null; + const openGraphIDs = Array.isArray(session.openGraphIDs) + ? session.openGraphIDs.filter((id) => typeof id === 'string' && id) + : []; + const activeGraphID = typeof session.activeGraphID === 'string' ? session.activeGraphID : null; + const fileState = Array.isArray(session.fileState) + ? session.fileState + .filter((file) => file && typeof file === 'object' && typeof file.key === 'string') + .map((file) => { + let fileName = null; + if (typeof file.fileName === 'string') fileName = file.fileName; + else if (file.fileObj && file.fileObj.name) fileName = file.fileObj.name; + return { + key: file.key, + modified: Number.isFinite(file.modified) ? file.modified : 0, + size: Number.isFinite(file.size) ? file.size : 0, + fileName, + }; + }) + : []; + return { + openGraphIDs, + activeGraphID, + fileState, + uploadedDirName: typeof session.uploadedDirName === 'string' ? session.uploadedDirName : null, + }; +}; + const localStorageGet = (key) => { try { return window.localStorage.getItem(key); @@ -53,64 +94,348 @@ const localStorageRemove = (key) => { const localStorageManager = { ALL_GRAPHS: window.btoa('ALL_GRAPHS'), AUTHOR_NAME: window.btoa('AUTHOR_NAME'), + SESSION_STATE: window.btoa('SESSION_STATE'), - get(id) { + DB_NAME: 'concore-editor-storage', + DB_VERSION: 1, + GRAPH_STORE: 'graphs', + META_STORE: 'meta', + META_GRAPH_ORDER: 'graph_order', + META_SESSION: 'session', + META_AUTHOR: 'author_name', + META_MIGRATION_V1: 'migrated_local_storage_v1', + + db: null, + initialized: false, + initPromise: null, + useFallback: false, + graphCache: new Map(), + graphOrder: [], + sessionCache: null, + authorNameCache: '', + + isIndexedDBAvailable() { + return typeof window !== 'undefined' && !!window.indexedDB; + }, + + openDB() { + return new Promise((resolve, reject) => { + const request = window.indexedDB.open(this.DB_NAME, this.DB_VERSION); + request.onupgradeneeded = (event) => { + const db = event.target.result; + if (!db.objectStoreNames.contains(this.GRAPH_STORE)) { + db.createObjectStore(this.GRAPH_STORE, { keyPath: 'id' }); + } + if (!db.objectStoreNames.contains(this.META_STORE)) { + db.createObjectStore(this.META_STORE, { keyPath: 'key' }); + } + }; + request.onsuccess = () => resolve(request.result); + request.onerror = () => reject(request.error); + }); + }, + + getLegacyGraph(id) { const raw = localStorageGet(id); if (raw === null) return null; const parsed = parseStoredJson(raw); - if (parsed !== null) return parsed; - // fallback for legacy plain JSON data saved before base64 encoding was introduced + if (isValidGraphSnapshot(parsed)) return parsed; try { - return JSON.parse(raw); + const plainJson = JSON.parse(raw); + return isValidGraphSnapshot(plainJson) ? plainJson : null; } catch { return null; } }, + + getLegacyGraphOrder() { + const raw = localStorageGet(this.ALL_GRAPHS); + if (!raw) return []; + const parsed = parseStoredJson(raw); + if (!Array.isArray(parsed)) return []; + return parsed.filter((id) => typeof id === 'string' && id); + }, + + getLegacySession() { + const raw = localStorageGet(this.SESSION_STATE); + if (!raw) return null; + const parsed = parseStoredJson(raw); + return sanitizeSession(parsed); + }, + + setFallbackMode() { + this.useFallback = true; + this.db = null; + this.graphOrder = this.getLegacyGraphOrder(); + this.graphCache = new Map(); + this.graphOrder.forEach((id) => { + const content = this.getLegacyGraph(id); + if (content !== null) this.graphCache.set(id, content); + }); + this.sessionCache = this.getLegacySession(); + this.authorNameCache = localStorageGet(this.AUTHOR_NAME) || ''; + }, + + async getMetaValue(key) { + if (!this.db) return null; + const tx = this.db.transaction(this.META_STORE, 'readonly'); + const store = tx.objectStore(this.META_STORE); + const record = await requestAsPromise(store.get(key)); + return record ? record.value : null; + }, + + async putMetaValue(key, value) { + if (!this.db) return; + const tx = this.db.transaction(this.META_STORE, 'readwrite'); + const store = tx.objectStore(this.META_STORE); + await requestAsPromise(store.put({ key, value })); + }, + + async deleteGraphRecord(id) { + if (!this.db) return; + const tx = this.db.transaction(this.GRAPH_STORE, 'readwrite'); + const store = tx.objectStore(this.GRAPH_STORE); + await requestAsPromise(store.delete(id)); + }, + + async putGraphRecord(id, data) { + if (!this.db) return; + const tx = this.db.transaction(this.GRAPH_STORE, 'readwrite'); + const store = tx.objectStore(this.GRAPH_STORE); + await requestAsPromise(store.put({ id, data, updatedAt: Date.now() })); + }, + + async persistGraphOrder() { + if (this.useFallback) { + localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify(this.graphOrder))); + return; + } + await this.putMetaValue(this.META_GRAPH_ORDER, this.graphOrder); + }, + + async migrateLegacyLocalStorage() { + const migrated = await this.getMetaValue(this.META_MIGRATION_V1); + if (migrated) return; + + const legacyOrder = this.getLegacyGraphOrder(); + legacyOrder.forEach((id) => { + if (this.graphCache.has(id)) return; + const graph = this.getLegacyGraph(id); + if (!graph) return; + this.graphCache.set(id, graph); + }); + + if (!this.graphOrder.length && legacyOrder.length) { + this.graphOrder = legacyOrder; + } + + const legacySession = this.getLegacySession(); + if (!this.sessionCache && legacySession) { + this.sessionCache = legacySession; + } + + if (!this.authorNameCache) { + this.authorNameCache = localStorageGet(this.AUTHOR_NAME) || ''; + } + + await Promise.all( + Array.from(this.graphCache.entries()).map(([id, data]) => this.putGraphRecord(id, data)), + ); + await this.persistGraphOrder(); + if (this.sessionCache) await this.putMetaValue(this.META_SESSION, this.sessionCache); + if (this.authorNameCache) await this.putMetaValue(this.META_AUTHOR, this.authorNameCache); + await this.putMetaValue(this.META_MIGRATION_V1, true); + }, + + async initialize() { + if (this.initPromise) return this.initPromise; + this.initPromise = (async () => { + if (!this.isIndexedDBAvailable()) { + this.setFallbackMode(); + this.initialized = true; + return; + } + try { + this.db = await this.openDB(); + + const tx = this.db.transaction(this.GRAPH_STORE, 'readonly'); + const graphStore = tx.objectStore(this.GRAPH_STORE); + const graphRecords = await requestAsPromise(graphStore.getAll()); + this.graphCache = new Map(); + graphRecords.forEach((record) => { + if (!record || typeof record.id !== 'string') return; + if (!isValidGraphSnapshot(record.data)) return; + this.graphCache.set(record.id, record.data); + }); + + const orderFromMeta = await this.getMetaValue(this.META_GRAPH_ORDER); + if (Array.isArray(orderFromMeta)) { + this.graphOrder = orderFromMeta.filter((id) => typeof id === 'string' && this.graphCache.has(id)); + this.graphCache.forEach((value, id) => { + if (!this.graphOrder.includes(id)) this.graphOrder.push(id); + }); + } else { + this.graphOrder = Array.from(this.graphCache.keys()); + } + + this.sessionCache = sanitizeSession(await this.getMetaValue(this.META_SESSION)); + this.authorNameCache = await this.getMetaValue(this.META_AUTHOR) || ''; + + await this.migrateLegacyLocalStorage(); + this.initialized = true; + } catch (e) { + this.setFallbackMode(); + this.initialized = true; + } + })(); + return this.initPromise; + }, + + ensureInitialized() { + if (!this.initPromise && !this.initialized) this.initialize(); + }, + + get(id) { + this.ensureInitialized(); + if (typeof id !== 'string' || !id) return null; + if (this.graphCache.has(id)) { + const graph = this.graphCache.get(id); + return isValidGraphSnapshot(graph) ? graph : null; + } + if (this.useFallback) return this.getLegacyGraph(id); + return null; + }, save(id, graphContent) { + this.ensureInitialized(); + if (typeof id !== 'string' || !id || !graphContent) return; this.addGraph(id); - if (!localStorageSet(id, encodeBase64(JSON.stringify(graphContent)))) { - const stripped = { ...graphContent, actionHistory: [] }; - localStorageSet(id, encodeBase64(JSON.stringify(stripped))); + this.graphCache.set(id, graphContent); + + if (this.useFallback) { + localStorageSet(id, encodeBase64(JSON.stringify(graphContent))); + return; } + + this.initialize().then(async () => { + if (this.useFallback) { + localStorageSet(id, encodeBase64(JSON.stringify(graphContent))); + return; + } + await this.putGraphRecord(id, graphContent); + }).catch(() => { + localStorageSet(id, encodeBase64(JSON.stringify(graphContent))); + }); }, remove(id) { - const list = this.getAllGraphs().filter((g) => g !== id); - localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify(list))); - localStorageRemove(id); + this.ensureInitialized(); + if (typeof id !== 'string' || !id) return; + this.graphOrder = this.getAllGraphs().filter((g) => g !== id); + this.graphCache.delete(id); + if (this.useFallback) { + localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify(this.graphOrder))); + localStorageRemove(id); + return; + } + this.initialize().then(async () => { + await this.persistGraphOrder(); + await this.deleteGraphRecord(id); + }).catch(() => { + localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify(this.graphOrder))); + localStorageRemove(id); + }); }, addGraph(id) { + this.ensureInitialized(); + if (typeof id !== 'string' || !id) return; const list = this.getAllGraphs(); if (list.includes(id)) return; - list.push(id); - localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify(list))); + this.graphOrder = [...list, id]; + if (this.useFallback) { + localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify(this.graphOrder))); + return; + } + this.initialize().then(() => this.persistGraphOrder()).catch(() => { + localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify(this.graphOrder))); + }); }, getAllGraphs() { - const raw = localStorageGet(this.ALL_GRAPHS); - if (!raw) return []; - const parsed = parseStoredJson(raw); - if (!Array.isArray(parsed)) { - localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify([]))); - return []; + this.ensureInitialized(); + if (Array.isArray(this.graphOrder) && this.graphOrder.length) return this.graphOrder; + if (this.useFallback) { + const parsed = this.getLegacyGraphOrder(); + this.graphOrder = parsed; + return parsed; } - return parsed; + return this.graphOrder; }, addToFront(id) { + this.ensureInitialized(); + if (typeof id !== 'string' || !id) return; const list = this.getAllGraphs(); if (list.includes(id)) return; - list.unshift(id); - localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify(list))); + this.graphOrder = [id, ...list]; + if (this.useFallback) { + localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify(this.graphOrder))); + return; + } + this.initialize().then(() => this.persistGraphOrder()).catch(() => { + localStorageSet(this.ALL_GRAPHS, encodeBase64(JSON.stringify(this.graphOrder))); + }); }, getAuthorName() { - return localStorageGet(this.AUTHOR_NAME) || ''; + this.ensureInitialized(); + if (this.authorNameCache) return this.authorNameCache; + if (this.useFallback) { + this.authorNameCache = localStorageGet(this.AUTHOR_NAME) || ''; + } + return this.authorNameCache || ''; }, setAuthorName(authorName) { - localStorageSet(this.AUTHOR_NAME, authorName); + this.ensureInitialized(); + this.authorNameCache = authorName; + if (this.useFallback) { + localStorageSet(this.AUTHOR_NAME, authorName); + return; + } + this.initialize().then(() => this.putMetaValue(this.META_AUTHOR, authorName)).catch(() => { + localStorageSet(this.AUTHOR_NAME, authorName); + }); }, clearGraph(id) { - localStorageRemove(id); + this.ensureInitialized(); + if (typeof id !== 'string' || !id) return; + this.graphCache.delete(id); + if (this.useFallback) { + localStorageRemove(id); + return; + } + this.initialize().then(() => this.deleteGraphRecord(id)).catch(() => { + localStorageRemove(id); + }); }, getFileList() { return localStorageGet('fileList') || ''; }, + saveSession(sessionState) { + this.ensureInitialized(); + const safeSession = sanitizeSession(sessionState); + if (!safeSession) return; + this.sessionCache = safeSession; + if (this.useFallback) { + localStorageSet(this.SESSION_STATE, encodeBase64(JSON.stringify(safeSession))); + return; + } + this.initialize().then(() => this.putMetaValue(this.META_SESSION, safeSession)).catch(() => { + localStorageSet(this.SESSION_STATE, encodeBase64(JSON.stringify(safeSession))); + }); + }, + getSession() { + this.ensureInitialized(); + if (this.sessionCache) return this.sessionCache; + if (this.useFallback) { + this.sessionCache = this.getLegacySession(); + } + return this.sessionCache; + }, }; export default localStorageManager; diff --git a/src/graph-builder/local-storage-manager.test.js b/src/graph-builder/local-storage-manager.test.js new file mode 100644 index 0000000..77a0798 --- /dev/null +++ b/src/graph-builder/local-storage-manager.test.js @@ -0,0 +1,119 @@ +import { toast } from 'react-toastify'; +import { TextEncoder, TextDecoder } from 'util'; + +global.TextEncoder = TextEncoder; +global.TextDecoder = TextDecoder; + +jest.mock('react-toastify', () => ({ + toast: { + error: jest.fn(), + }, +})); + +const loadManager = async () => { + jest.resetModules(); + // eslint-disable-next-line global-require + const manager = require('./local-storage-manager').default; + await manager.initialize(); + return manager; +}; + +describe('localStorageManager fallback/session behavior', () => { + let originalIndexedDB; + + beforeEach(() => { + localStorage.clear(); + jest.clearAllMocks(); + originalIndexedDB = window.indexedDB; + Object.defineProperty(window, 'indexedDB', { + configurable: true, + writable: true, + value: undefined, + }); + }); + + afterEach(() => { + Object.defineProperty(window, 'indexedDB', { + configurable: true, + writable: true, + value: originalIndexedDB, + }); + }); + + test('restores legacy graphs from localStorage when indexedDB is unavailable', async () => { + const allGraphsKey = window.btoa('ALL_GRAPHS'); + const graphID = 'graph-1'; + const graphPayload = { + id: graphID, + projectName: 'Workflow 1', + nodes: [], + edges: [], + actionHistory: [{ actionName: 'ADD_NODE', parameters: '{}' }], + }; + + localStorage.setItem(allGraphsKey, window.btoa(JSON.stringify([graphID]))); + localStorage.setItem(graphID, window.btoa(JSON.stringify(graphPayload))); + + const manager = await loadManager(); + + expect(manager.getAllGraphs()).toEqual([graphID]); + expect(manager.get(graphID)).toEqual(graphPayload); + }); + + test('persists and restores session metadata in fallback mode', async () => { + const manager = await loadManager(); + const session = { + openGraphIDs: ['g1', 'g2'], + activeGraphID: 'g2', + fileState: [{ key: 'demo/main.py', modified: 1, size: 12, fileName: 'main.py' }], + uploadedDirName: 'demo', + }; + + manager.saveSession(session); + + expect(manager.getSession()).toEqual(session); + }); + + test('keeps full actionHistory when saving graph content', async () => { + const manager = await loadManager(); + const graphID = 'graph-history'; + const graphPayload = { + id: graphID, + projectName: 'Workflow history', + nodes: [], + edges: [], + actionHistory: [ + { actionName: 'ADD_NODE', parameters: '{}' }, + { actionName: 'ADD_EDGE', parameters: '{}' }, + ], + }; + + manager.save(graphID, graphPayload); + + const stored = JSON.parse(window.atob(localStorage.getItem(graphID))); + expect(stored.actionHistory).toHaveLength(2); + expect(toast.error).not.toHaveBeenCalled(); + }); + + test('skips corrupted graph records and keeps valid records accessible', async () => { + const allGraphsKey = window.btoa('ALL_GRAPHS'); + const validGraphID = 'graph-valid'; + const corruptedGraphID = 'graph-corrupted'; + const validPayload = { + id: validGraphID, + projectName: 'Healthy workflow', + nodes: [], + edges: [], + actionHistory: [], + }; + + localStorage.setItem(allGraphsKey, window.btoa(JSON.stringify([validGraphID, corruptedGraphID]))); + localStorage.setItem(validGraphID, window.btoa(JSON.stringify(validPayload))); + localStorage.setItem(corruptedGraphID, window.btoa(JSON.stringify({ broken: true }))); + + const manager = await loadManager(); + + expect(manager.get(validGraphID)).toEqual(validPayload); + expect(manager.get(corruptedGraphID)).toBeNull(); + }); +}); diff --git a/src/reducer/actionType.js b/src/reducer/actionType.js index 5fdf0da..297434f 100644 --- a/src/reducer/actionType.js +++ b/src/reducer/actionType.js @@ -52,6 +52,7 @@ const actionType = { SET_SEARCH_QUERY: 'SET_SEARCH_QUERY', SET_SEARCH_RESULTS: 'SET_SEARCH_RESULTS', SET_SEARCH_INDEX: 'SET_SEARCH_INDEX', + SET_GRAPH_SYNC_STATE: 'SET_GRAPH_SYNC_STATE', }; export default zealit(actionType); diff --git a/src/reducer/initialState.js b/src/reducer/initialState.js index bb53c35..ede9764 100644 --- a/src/reducer/initialState.js +++ b/src/reducer/initialState.js @@ -66,6 +66,13 @@ const initialGraphState = { destroyed: false, cleared: false, stopped: false, + syncStatus: { + state: 'dirty', + localHash: '', + remoteHash: '', + lastResult: 'Not synced yet', + reason: '', + }, }; export { initialState, initialGraphState }; diff --git a/src/reducer/reducer.js b/src/reducer/reducer.js index ebadbe3..51d987c 100644 --- a/src/reducer/reducer.js +++ b/src/reducer/reducer.js @@ -110,8 +110,19 @@ const reducer = (state, action) => { }; } case T.ADD_GRAPH_BULK: { - const newGraphs = action.payload.map((g) => ({ ...initialGraphState, ...g })); - return { ...state, graphs: [...state.graphs, ...newGraphs], curGraphIndex: 0 }; + const payload = Array.isArray(action.payload) + ? { graphs: action.payload, activeGraphID: null } + : action.payload; + const newGraphs = payload.graphs.map((g) => ({ ...initialGraphState, ...g })); + const graphs = [...state.graphs, ...newGraphs]; + const activeGraphIndex = payload.activeGraphID + ? graphs.findIndex((g) => g.graphID === payload.activeGraphID) + : -1; + return { + ...state, + graphs, + curGraphIndex: activeGraphIndex >= 0 ? activeGraphIndex : 0, + }; } case T.SET_CUR_INSTANCE: { return { ...state, curGraphInstance: action.payload }; @@ -259,6 +270,22 @@ const reducer = (state, action) => { return { ...newState }; } + case T.SET_GRAPH_SYNC_STATE: { + const newState = { ...state }; + newState.graphs = newState.graphs.map((g) => ( + g.graphID === action.payload.graphID + ? { + ...g, + syncStatus: { + ...(g.syncStatus || initialGraphState.syncStatus), + ...action.payload.syncStatus, + }, + } + : g + )); + return { ...newState }; + } + case T.TOGGLE_DARK_MODE: { return { ...state, darkMode: !state.darkMode }; } diff --git a/src/reducer/reducer.sync.test.js b/src/reducer/reducer.sync.test.js new file mode 100644 index 0000000..dab2815 --- /dev/null +++ b/src/reducer/reducer.sync.test.js @@ -0,0 +1,49 @@ +import T from './actionType'; +import reducer from './reducer'; +import { initialState } from './initialState'; + +describe('reducer sync state', () => { + it('updates sync state only for target graph', () => { + const state = { + ...initialState, + graphs: [ + { + graphID: 'g1', + syncStatus: { + state: 'dirty', + localHash: 'l1', + remoteHash: '', + lastResult: '', + reason: '', + }, + }, + { + graphID: 'g2', + syncStatus: { + state: 'synced', + localHash: 'l2', + remoteHash: 'r2', + lastResult: 'ok', + reason: '', + }, + }, + ], + }; + + const next = reducer(state, { + type: T.SET_GRAPH_SYNC_STATE, + payload: { + graphID: 'g1', + syncStatus: { + state: 'conflict', + remoteHash: 'remote-x', + }, + }, + }); + + expect(next.graphs[0].syncStatus.state).toBe('conflict'); + expect(next.graphs[0].syncStatus.localHash).toBe('l1'); + expect(next.graphs[0].syncStatus.remoteHash).toBe('remote-x'); + expect(next.graphs[1].syncStatus).toEqual(state.graphs[1].syncStatus); + }); +}); diff --git a/src/serverCon/crud_http.js b/src/serverCon/crud_http.js index 00df3a7..5ea2b5c 100644 --- a/src/serverCon/crud_http.js +++ b/src/serverCon/crud_http.js @@ -3,7 +3,22 @@ import ec from './config'; function readTextOrThrow(x) { return x.text().then((text) => { if (x.ok) return text; - throw new Error(text || `Request failed with status ${x.status}`); + let data = null; + try { + data = text ? JSON.parse(text) : null; + } catch { + data = null; + } + const err = new Error( + (data && data.message) + || text + || `Request failed with status ${x.status}`, + ); + err.status = x.status; + err.body = text; + err.data = data; + err.code = data && data.code ? data.code : null; + throw err; }); } diff --git a/src/setupTests.js b/src/setupTests.js new file mode 100644 index 0000000..140fb2b --- /dev/null +++ b/src/setupTests.js @@ -0,0 +1,5 @@ +window.matchMedia = window.matchMedia || (() => ({ + matches: false, + addListener: () => {}, + removeListener: () => {}, +}));