@alizarin/napi 2.0.0-alpha.98 → 2.0.0-alpha.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -563,3 +563,42 @@ describe('NapiNodeConfigManager', () => {
563
563
  ncm.buildFromGraphJson(JSON.stringify(graphObj));
564
564
  });
565
565
  });
566
+
567
+ // =============================================================================
568
+ // NapiStaticGraph serialization guard
569
+ // Regression: JSON.stringify(NapiStaticGraph) produces {} because NAPI class
570
+ // getters are not enumerable own properties. Any code path that does
571
+ // JSON.stringify(graph) where graph could be a NapiStaticGraph will break.
572
+ // =============================================================================
573
+
574
+ describe('NapiStaticGraph serialization', () => {
575
+ const groupJson = fs.readFileSync(
576
+ path.join(TEST_DATA, 'data', 'models', 'Group.json'),
577
+ 'utf-8'
578
+ );
579
+
580
+ it('JSON.stringify of NapiStaticGraph produces empty object', () => {
581
+ const graph = NapiStaticGraph.fromJsonString(groupJson);
582
+ const stringified = JSON.stringify(graph);
583
+ // This documents the fundamental limitation: NAPI class instances
584
+ // do not serialize via JSON.stringify
585
+ assert.equal(stringified, '{}', 'NapiStaticGraph should stringify to {}');
586
+ });
587
+
588
+ it('NapiResourceModelWrapper.fromGraph accepts NapiStaticGraph directly', () => {
589
+ const graph = NapiStaticGraph.fromJsonString(groupJson);
590
+ // This is the correct NAPI path — no JSON.stringify needed
591
+ const wrapper = NapiResourceModelWrapper.fromGraph(graph, true);
592
+ assert.equal(wrapper.getGraphId(), '07883c9e-b25c-11e9-975a-a4d18cec433a');
593
+ });
594
+
595
+ it('NapiResourceModelWrapper constructor fails with JSON.stringify of NapiStaticGraph', () => {
596
+ const graph = NapiStaticGraph.fromJsonString(groupJson);
597
+ // Demonstrates the bug this regression test guards against
598
+ assert.throws(
599
+ () => new NapiResourceModelWrapper(JSON.stringify(graph), true),
600
+ /Invalid graph JSON/i,
601
+ 'JSON.stringify of NapiStaticGraph should produce invalid input for constructor'
602
+ );
603
+ });
604
+ });
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alizarin/napi",
3
- "version": "2.0.0-alpha.98",
3
+ "version": "2.0.0-alpha.99",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,8 +30,8 @@
30
30
  "@napi-rs/cli": "^2.18.0"
31
31
  },
32
32
  "optionalDependencies": {
33
- "@alizarin/napi-win32-x64-msvc": "2.0.0-alpha.98",
34
- "@alizarin/napi-darwin-x64": "2.0.0-alpha.98",
35
- "@alizarin/napi-linux-x64-gnu": "2.0.0-alpha.98"
33
+ "@alizarin/napi-win32-x64-msvc": "2.0.0-alpha.99",
34
+ "@alizarin/napi-darwin-x64": "2.0.0-alpha.99",
35
+ "@alizarin/napi-linux-x64-gnu": "2.0.0-alpha.99"
36
36
  }
37
37
  }