space-data-module-sdk 0.6.0 → 0.7.0

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.
Files changed (70) hide show
  1. package/README.md +15 -2
  2. package/package.json +6 -2
  3. package/schemas/orbpro/BaseTypes.fbs +7 -0
  4. package/schemas/orbpro/CatalogQueryBase.fbs +8 -0
  5. package/schemas/orbpro/CatalogQueryRequest.fbs +14 -0
  6. package/schemas/orbpro/CatalogQueryResult.fbs +17 -0
  7. package/schemas/orbpro/EntityMetadata.fbs +53 -0
  8. package/schemas/orbpro/EntityStandardsLink.fbs +18 -0
  9. package/schemas/orbpro/Plugin.fbs +8 -0
  10. package/schemas/orbpro/Propagator.fbs +89 -0
  11. package/schemas/orbpro/StandardsRecordIndex.fbs +15 -0
  12. package/src/browser.js +1 -0
  13. package/src/generated/orbpro/entity/entity-kind.js +15 -0
  14. package/src/generated/orbpro/entity/entity-kind.ts +15 -0
  15. package/src/generated/orbpro/entity/entity-metadata.js +322 -0
  16. package/src/generated/orbpro/entity/entity-metadata.ts +426 -0
  17. package/src/generated/orbpro/entity/entity-standards-link.js +143 -0
  18. package/src/generated/orbpro/entity/entity-standards-link.ts +183 -0
  19. package/src/generated/orbpro/entity/standards-record-index.js +115 -0
  20. package/src/generated/orbpro/entity/standards-record-index.ts +147 -0
  21. package/src/generated/orbpro/entity.js +10 -0
  22. package/src/generated/orbpro/entity.ts +5 -0
  23. package/src/generated/orbpro/plugin/raw-data-payload.js +79 -0
  24. package/src/generated/orbpro/plugin/raw-data-payload.ts +92 -0
  25. package/src/generated/orbpro/plugin.js +4 -0
  26. package/src/generated/orbpro/plugin.ts +5 -0
  27. package/src/generated/orbpro/propagator/propagator-describe-sources-batch-request.js +79 -0
  28. package/src/generated/orbpro/propagator/propagator-describe-sources-batch-request.ts +95 -0
  29. package/src/generated/orbpro/propagator/propagator-describe-sources-batch-result.js +70 -0
  30. package/src/generated/orbpro/propagator/propagator-describe-sources-batch-result.ts +78 -0
  31. package/src/generated/orbpro/propagator/propagator-sample-trajectory-states-request.js +97 -0
  32. package/src/generated/orbpro/propagator/propagator-sample-trajectory-states-request.ts +117 -0
  33. package/src/generated/orbpro/propagator/propagator-sample-trajectory-states-result.js +140 -0
  34. package/src/generated/orbpro/propagator/propagator-sample-trajectory-states-result.ts +175 -0
  35. package/src/generated/orbpro/propagator/propagator-source-description.js +208 -0
  36. package/src/generated/orbpro/propagator/propagator-source-description.ts +257 -0
  37. package/src/generated/orbpro/propagator/propagator-source-kind.js +8 -0
  38. package/src/generated/orbpro/propagator/propagator-source-kind.ts +8 -0
  39. package/src/generated/orbpro/propagator/reference-frame.js +12 -0
  40. package/src/generated/orbpro/propagator/reference-frame.ts +12 -0
  41. package/src/generated/orbpro/propagator/state-flags.js +13 -0
  42. package/src/generated/orbpro/propagator/state-flags.ts +13 -0
  43. package/src/generated/orbpro/propagator/state-vector.js +55 -0
  44. package/src/generated/orbpro/propagator/state-vector.ts +61 -0
  45. package/src/generated/orbpro/propagator.js +20 -0
  46. package/src/generated/orbpro/propagator.ts +13 -0
  47. package/src/generated/orbpro/query/catalog-query-kind.js +10 -0
  48. package/src/generated/orbpro/query/catalog-query-kind.ts +10 -0
  49. package/src/generated/orbpro/query/catalog-query-request.js +89 -0
  50. package/src/generated/orbpro/query/catalog-query-request.ts +105 -0
  51. package/src/generated/orbpro/query/catalog-query-result.js +145 -0
  52. package/src/generated/orbpro/query/catalog-query-result.ts +179 -0
  53. package/src/generated/orbpro/query.js +8 -0
  54. package/src/generated/orbpro/query.ts +4 -0
  55. package/src/generated/orbpro/vec3.js +39 -0
  56. package/src/generated/orbpro/vec3.ts +40 -0
  57. package/src/host/abi.js +158 -0
  58. package/src/host/browserEdgeShims.js +17 -4
  59. package/src/host/browserHost.js +260 -48
  60. package/src/host/isomorphicLoader.js +3 -2
  61. package/src/host/nodeHost.js +168 -71
  62. package/src/index.d.ts +287 -3
  63. package/src/index.js +1 -0
  64. package/src/licensing/index.d.ts +20 -0
  65. package/src/licensing/index.js +11 -0
  66. package/src/licensing/records.js +858 -0
  67. package/src/runtime-host/index.js +34 -0
  68. package/src/testing/browserModuleHarness.js +16 -3
  69. package/src/testing/index.d.ts +1 -0
  70. package/src/testing/index.js +5 -4
@@ -63,6 +63,7 @@ export const NodeHostSupportedCapabilities = Object.freeze([
63
63
  "crypto_decrypt",
64
64
  "crypto_key_agreement",
65
65
  "crypto_kdf",
66
+ "wallet_sign",
66
67
  "process_exec",
67
68
  ]);
68
69
 
@@ -93,9 +94,13 @@ export const NodeHostSupportedOperations = Object.freeze([
93
94
  "udp.request",
94
95
  "tls.request",
95
96
  "ipfs.invoke",
97
+ "ipfs.add",
98
+ "ipfs.cat",
96
99
  "protocol_handle.register",
97
100
  "protocol_handle.unregister",
98
101
  "protocol_dial.dial",
102
+ "protocol.request",
103
+ "keyslot.get",
99
104
  "exec.execFile",
100
105
  "context.get",
101
106
  "context.set",
@@ -160,6 +165,34 @@ function normalizeGrantedCapabilities(options) {
160
165
  return normalized;
161
166
  }
162
167
 
168
+ function resolveCapabilityAdapters(options = {}) {
169
+ const adapters =
170
+ options.capabilityAdapters && typeof options.capabilityAdapters === "object"
171
+ ? options.capabilityAdapters
172
+ : {};
173
+ return {
174
+ filesystem: options.filesystem ?? adapters.filesystem ?? null,
175
+ network: options.network ?? adapters.network ?? null,
176
+ ipfs: options.ipfs ?? adapters.ipfs ?? null,
177
+ walletSign:
178
+ options.walletSign ??
179
+ adapters.walletSign ??
180
+ adapters.wallet_sign ??
181
+ adapters.keyslot ??
182
+ null,
183
+ protocolHandle:
184
+ options.protocolHandle ??
185
+ adapters.protocolHandle ??
186
+ adapters.protocol_handle ??
187
+ null,
188
+ protocolDial:
189
+ options.protocolDial ??
190
+ adapters.protocolDial ??
191
+ adapters.protocol_dial ??
192
+ null,
193
+ };
194
+ }
195
+
163
196
  function normalizeAllowedOrigins(origins) {
164
197
  if (origins === undefined || origins === null) {
165
198
  return null;
@@ -1445,10 +1478,13 @@ export class NodeHost {
1445
1478
  );
1446
1479
  this.fetch = options.fetch ?? globalThis.fetch;
1447
1480
  this.WebSocket = options.WebSocket ?? globalThis.WebSocket;
1448
- this._networkAdapter = options.network ?? null;
1449
- this._ipfsAdapter = options.ipfs ?? null;
1450
- this._protocolHandleAdapter = options.protocolHandle ?? null;
1451
- this._protocolDialAdapter = options.protocolDial ?? null;
1481
+ const capabilityAdapters = resolveCapabilityAdapters(options);
1482
+ this._filesystemAdapter = capabilityAdapters.filesystem;
1483
+ this._networkAdapter = capabilityAdapters.network;
1484
+ this._ipfsAdapter = capabilityAdapters.ipfs;
1485
+ this._walletSignAdapter = capabilityAdapters.walletSign;
1486
+ this._protocolHandleAdapter = capabilityAdapters.protocolHandle;
1487
+ this._protocolDialAdapter = capabilityAdapters.protocolDial;
1452
1488
  if (typeof this.fetch !== "function") {
1453
1489
  throw new TypeError(
1454
1490
  "A fetch implementation is required to create a Node host.",
@@ -1607,6 +1643,12 @@ export class NodeHost {
1607
1643
  this.#withCapability("network", "network.request", async () => {
1608
1644
  const transport = normalizeNetworkTransport(params);
1609
1645
  const request = params.request ?? params;
1646
+ if (this._networkAdapter) {
1647
+ return invokeAdapterMethod(this._networkAdapter, "request", {
1648
+ ...request,
1649
+ transport,
1650
+ }, "network");
1651
+ }
1610
1652
  switch (transport) {
1611
1653
  case "http":
1612
1654
  return this.http.request(request);
@@ -1623,12 +1665,6 @@ export class NodeHost {
1623
1665
  case "tls":
1624
1666
  return this.tls.request(request);
1625
1667
  default:
1626
- if (this._networkAdapter) {
1627
- return invokeAdapterMethod(this._networkAdapter, "request", {
1628
- ...request,
1629
- transport,
1630
- }, "network");
1631
- }
1632
1668
  throw new Error(
1633
1669
  `Node host does not support network transport "${transport}".`,
1634
1670
  );
@@ -1636,6 +1672,87 @@ export class NodeHost {
1636
1672
  }),
1637
1673
  });
1638
1674
 
1675
+ const builtinFilesystem = {
1676
+ resolvePath: (targetPath) => this.#resolveFilesystemPath(targetPath),
1677
+ readFile: async (targetPath, options = {}) => {
1678
+ const resolvedPath = this.#resolveFilesystemPath(targetPath);
1679
+ const file = await readFile(resolvedPath);
1680
+ if (options.encoding) {
1681
+ return file.toString(options.encoding);
1682
+ }
1683
+ return new Uint8Array(file);
1684
+ },
1685
+ writeFile: async (targetPath, value, options = {}) => {
1686
+ const resolvedPath = this.#resolveFilesystemPath(targetPath);
1687
+ await mkdir(path.dirname(resolvedPath), { recursive: true });
1688
+ await writeFile(
1689
+ resolvedPath,
1690
+ typeof value === "string" ? value : Buffer.from(toUint8Array(value)),
1691
+ options.encoding && typeof value === "string" ? options.encoding : undefined,
1692
+ );
1693
+ return { path: resolvedPath };
1694
+ },
1695
+ appendFile: async (targetPath, value, options = {}) => {
1696
+ const resolvedPath = this.#resolveFilesystemPath(targetPath);
1697
+ await mkdir(path.dirname(resolvedPath), { recursive: true });
1698
+ const existing = await readFile(resolvedPath).catch((error) => {
1699
+ if (error?.code === "ENOENT") {
1700
+ return Buffer.alloc(0);
1701
+ }
1702
+ throw error;
1703
+ });
1704
+ const nextChunk =
1705
+ typeof value === "string"
1706
+ ? Buffer.from(value, options.encoding ?? "utf8")
1707
+ : Buffer.from(toUint8Array(value));
1708
+ await writeFile(resolvedPath, Buffer.concat([existing, nextChunk]));
1709
+ return { path: resolvedPath };
1710
+ },
1711
+ deleteFile: async (targetPath) => {
1712
+ const resolvedPath = this.#resolveFilesystemPath(targetPath);
1713
+ await rm(resolvedPath, { force: true });
1714
+ return { path: resolvedPath };
1715
+ },
1716
+ mkdir: async (targetPath, options = {}) => {
1717
+ const resolvedPath = this.#resolveFilesystemPath(targetPath);
1718
+ await mkdir(resolvedPath, {
1719
+ recursive: options.recursive ?? true,
1720
+ });
1721
+ return { path: resolvedPath };
1722
+ },
1723
+ readdir: async (targetPath = ".") => {
1724
+ const resolvedPath = this.#resolveFilesystemPath(targetPath);
1725
+ const entries = await readdir(resolvedPath, { withFileTypes: true });
1726
+ return entries
1727
+ .map((entry) => ({
1728
+ name: entry.name,
1729
+ isFile: entry.isFile(),
1730
+ isDirectory: entry.isDirectory(),
1731
+ }))
1732
+ .sort((left, right) => left.name.localeCompare(right.name));
1733
+ },
1734
+ stat: async (targetPath) => {
1735
+ const resolvedPath = this.#resolveFilesystemPath(targetPath);
1736
+ const metadata = await stat(resolvedPath);
1737
+ return {
1738
+ path: resolvedPath,
1739
+ size: metadata.size,
1740
+ isFile: metadata.isFile(),
1741
+ isDirectory: metadata.isDirectory(),
1742
+ ctimeMs: metadata.ctimeMs,
1743
+ mtimeMs: metadata.mtimeMs,
1744
+ };
1745
+ },
1746
+ rename: async (fromPath, toPath) => {
1747
+ const resolvedFrom = this.#resolveFilesystemPath(fromPath);
1748
+ const resolvedTo = this.#resolveFilesystemPath(toPath);
1749
+ await mkdir(path.dirname(resolvedTo), { recursive: true });
1750
+ await rename(resolvedFrom, resolvedTo);
1751
+ return { from: resolvedFrom, to: resolvedTo };
1752
+ },
1753
+ };
1754
+ const filesystem = this._filesystemAdapter ?? builtinFilesystem;
1755
+
1639
1756
  this.mqtt = Object.freeze({
1640
1757
  publish: async (mqttOptions = {}) =>
1641
1758
  this.#withCapability("mqtt", "mqtt.publish", async () => {
@@ -1687,91 +1804,39 @@ export class NodeHost {
1687
1804
  this.filesystem = Object.freeze({
1688
1805
  resolvePath: (targetPath) =>
1689
1806
  this.#withCapability("filesystem", "filesystem.resolvePath", () =>
1690
- this.#resolveFilesystemPath(targetPath),
1807
+ filesystem.resolvePath(targetPath),
1691
1808
  ),
1692
1809
  readFile: async (targetPath, options = {}) =>
1693
1810
  this.#withCapability("filesystem", "filesystem.readFile", async () => {
1694
- const resolvedPath = this.#resolveFilesystemPath(targetPath);
1695
- const file = await readFile(resolvedPath);
1696
- if (options.encoding) {
1697
- return file.toString(options.encoding);
1698
- }
1699
- return new Uint8Array(file);
1811
+ return filesystem.readFile(targetPath, options);
1700
1812
  }),
1701
1813
  writeFile: async (targetPath, value, options = {}) =>
1702
1814
  this.#withCapability("filesystem", "filesystem.writeFile", async () => {
1703
- const resolvedPath = this.#resolveFilesystemPath(targetPath);
1704
- await mkdir(path.dirname(resolvedPath), { recursive: true });
1705
- await writeFile(
1706
- resolvedPath,
1707
- typeof value === "string" ? value : Buffer.from(toUint8Array(value)),
1708
- options.encoding && typeof value === "string" ? options.encoding : undefined,
1709
- );
1710
- return { path: resolvedPath };
1815
+ return filesystem.writeFile(targetPath, value, options);
1711
1816
  }),
1712
1817
  appendFile: async (targetPath, value, options = {}) =>
1713
1818
  this.#withCapability("filesystem", "filesystem.appendFile", async () => {
1714
- const resolvedPath = this.#resolveFilesystemPath(targetPath);
1715
- await mkdir(path.dirname(resolvedPath), { recursive: true });
1716
- const existing = await readFile(resolvedPath).catch((error) => {
1717
- if (error?.code === "ENOENT") {
1718
- return Buffer.alloc(0);
1719
- }
1720
- throw error;
1721
- });
1722
- const nextChunk =
1723
- typeof value === "string"
1724
- ? Buffer.from(value, options.encoding ?? "utf8")
1725
- : Buffer.from(toUint8Array(value));
1726
- await writeFile(resolvedPath, Buffer.concat([existing, nextChunk]));
1727
- return { path: resolvedPath };
1819
+ return filesystem.appendFile(targetPath, value, options);
1728
1820
  }),
1729
1821
  deleteFile: async (targetPath) =>
1730
1822
  this.#withCapability("filesystem", "filesystem.deleteFile", async () => {
1731
- const resolvedPath = this.#resolveFilesystemPath(targetPath);
1732
- await rm(resolvedPath, { force: true });
1733
- return { path: resolvedPath };
1823
+ return filesystem.deleteFile(targetPath);
1734
1824
  }),
1735
1825
  mkdir: async (targetPath, options = {}) =>
1736
1826
  this.#withCapability("filesystem", "filesystem.mkdir", async () => {
1737
- const resolvedPath = this.#resolveFilesystemPath(targetPath);
1738
- await mkdir(resolvedPath, {
1739
- recursive: options.recursive ?? true,
1740
- });
1741
- return { path: resolvedPath };
1827
+ return filesystem.mkdir(targetPath, options);
1742
1828
  }),
1743
1829
  readdir: async (targetPath = ".") =>
1744
1830
  this.#withCapability("filesystem", "filesystem.readdir", async () => {
1745
- const resolvedPath = this.#resolveFilesystemPath(targetPath);
1746
- const entries = await readdir(resolvedPath, { withFileTypes: true });
1747
- return entries
1748
- .map((entry) => ({
1749
- name: entry.name,
1750
- isFile: entry.isFile(),
1751
- isDirectory: entry.isDirectory(),
1752
- }))
1753
- .sort((left, right) => left.name.localeCompare(right.name));
1831
+ return filesystem.readdir(targetPath);
1754
1832
  }),
1755
1833
  stat: async (targetPath) =>
1756
1834
  this.#withCapability("filesystem", "filesystem.stat", async () => {
1757
- const resolvedPath = this.#resolveFilesystemPath(targetPath);
1758
- const metadata = await stat(resolvedPath);
1759
- return {
1760
- path: resolvedPath,
1761
- size: metadata.size,
1762
- isFile: metadata.isFile(),
1763
- isDirectory: metadata.isDirectory(),
1764
- ctimeMs: metadata.ctimeMs,
1765
- mtimeMs: metadata.mtimeMs,
1766
- };
1835
+ return filesystem.stat(targetPath);
1767
1836
  }),
1768
1837
  rename: async (fromPath, toPath) =>
1769
1838
  this.#withCapability("filesystem", "filesystem.rename", async () => {
1770
- const resolvedFrom = this.#resolveFilesystemPath(fromPath);
1771
- const resolvedTo = this.#resolveFilesystemPath(toPath);
1772
- await mkdir(path.dirname(resolvedTo), { recursive: true });
1773
- await rename(resolvedFrom, resolvedTo);
1774
- return { from: resolvedFrom, to: resolvedTo };
1839
+ return filesystem.rename(fromPath, toPath);
1775
1840
  }),
1776
1841
  });
1777
1842
 
@@ -1921,6 +1986,14 @@ export class NodeHost {
1921
1986
  }
1922
1987
  return invokeAdapterMethod(this._ipfsAdapter, operation, params, "ipfs");
1923
1988
  }),
1989
+ add: async (params = {}) =>
1990
+ this.#withCapability("ipfs", "ipfs.add", async () =>
1991
+ invokeAdapterMethod(this._ipfsAdapter, "add", params, "ipfs"),
1992
+ ),
1993
+ cat: async (params = {}) =>
1994
+ this.#withCapability("ipfs", "ipfs.cat", async () =>
1995
+ invokeAdapterMethod(this._ipfsAdapter, "cat", params, "ipfs"),
1996
+ ),
1924
1997
  });
1925
1998
 
1926
1999
  this.protocolHandle = Object.freeze({
@@ -1960,6 +2033,22 @@ export class NodeHost {
1960
2033
  "protocol_dial",
1961
2034
  ),
1962
2035
  ),
2036
+ request: async (params = {}) =>
2037
+ this.#withCapability("protocol_dial", "protocol.request", async () =>
2038
+ invokeAdapterMethod(
2039
+ this._protocolDialAdapter,
2040
+ "request",
2041
+ params,
2042
+ "protocol_dial",
2043
+ ),
2044
+ ),
2045
+ });
2046
+
2047
+ this.keyslot = Object.freeze({
2048
+ get: async (params = {}) =>
2049
+ this.#withCapability("wallet_sign", "keyslot.get", async () =>
2050
+ invokeAdapterMethod(this._walletSignAdapter, "get", params, "wallet_sign"),
2051
+ ),
1963
2052
  });
1964
2053
  }
1965
2054
 
@@ -2100,12 +2189,20 @@ export class NodeHost {
2100
2189
  return this.tls.request(params);
2101
2190
  case "ipfs.invoke":
2102
2191
  return this.ipfs.invoke(params);
2192
+ case "ipfs.add":
2193
+ return this.ipfs.add(params);
2194
+ case "ipfs.cat":
2195
+ return this.ipfs.cat(params);
2103
2196
  case "protocol_handle.register":
2104
2197
  return this.protocolHandle.register(params);
2105
2198
  case "protocol_handle.unregister":
2106
2199
  return this.protocolHandle.unregister(params);
2107
2200
  case "protocol_dial.dial":
2108
2201
  return this.protocolDial.dial(params);
2202
+ case "protocol.request":
2203
+ return this.protocolDial.request(params);
2204
+ case "keyslot.get":
2205
+ return this.keyslot.get(params);
2109
2206
  case "exec.execFile":
2110
2207
  return this.exec.execFile(params);
2111
2208
  case "context.get":