capns 0.66.12801 → 0.69.12840

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/capns.js CHANGED
@@ -1826,17 +1826,8 @@ class Cap {
1826
1826
  * @returns {Object} JSON representation
1827
1827
  */
1828
1828
  toJSON() {
1829
- // Build complete tags map including in and out
1830
- const allTags = {
1831
- ...this.urn.tags,
1832
- 'in': this.urn.inSpec,
1833
- 'out': this.urn.outSpec
1834
- };
1835
-
1836
1829
  const result = {
1837
- urn: {
1838
- tags: allTags
1839
- },
1830
+ urn: this.urn.toString(),
1840
1831
  title: this.title,
1841
1832
  command: this.command,
1842
1833
  cap_description: this.cap_description,
@@ -1859,16 +1850,11 @@ class Cap {
1859
1850
  * @returns {Cap} The capability instance
1860
1851
  */
1861
1852
  static fromJSON(json) {
1862
- // Handle both string and object URN formats
1863
- let urn;
1864
- if (typeof json.urn === 'string') {
1865
- urn = CapUrn.fromString(json.urn);
1866
- } else if (json.urn && json.urn.tags) {
1867
- // Use fromTags to extract in/out from the tags object
1868
- urn = CapUrn.fromTags(json.urn.tags);
1869
- } else {
1870
- throw new Error('Invalid URN format in JSON');
1853
+ // URN must be a string in canonical format
1854
+ if (typeof json.urn !== 'string') {
1855
+ throw new Error("URN must be a string in canonical format (e.g., 'cap:in=\"media:...\";op=...;out=\"media:...\"')");
1871
1856
  }
1857
+ const urn = CapUrn.fromString(json.urn);
1872
1858
 
1873
1859
  const cap = new Cap(urn, json.title, json.command, json.cap_description, json.metadata, json.metadata_json);
1874
1860
  cap.mediaSpecs = json.media_specs || json.mediaSpecs || [];
package/capns.test.js CHANGED
@@ -939,9 +939,10 @@ function testCapJSONSerialization() {
939
939
  assert(Array.isArray(json.media_specs), 'media_specs should be an array');
940
940
  assertEqual(json.media_specs.length, 1, 'Should have one media spec');
941
941
  assertEqual(json.media_specs[0].urn, 'media:custom', 'Should serialize mediaSpec urn');
942
- // URN tags should include in and out
943
- assertEqual(json.urn.tags['in'], 'media:void', 'Should serialize inSpec in tags');
944
- assertEqual(json.urn.tags['out'], 'media:form=map', 'Should serialize outSpec in tags');
942
+ // URN should be a string in canonical format
943
+ assertEqual(typeof json.urn, 'string', 'URN should be serialized as string');
944
+ assert(json.urn.includes('in="media:void"'), 'Should contain inSpec in URN string');
945
+ assert(json.urn.includes('out="media:form=map"'), 'Should contain outSpec in URN string');
945
946
 
946
947
  // Deserialize from JSON
947
948
  const restored = Cap.fromJSON(json);
package/package.json CHANGED
@@ -32,5 +32,5 @@
32
32
  "scripts": {
33
33
  "test": "node capns.test.js"
34
34
  },
35
- "version": "0.66.12801"
35
+ "version": "0.69.12840"
36
36
  }