@peers-app/peers-sdk 0.20.5 → 0.20.6

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.
@@ -1,41 +1,77 @@
1
- import type { GroupMemberRole, IChangeRecord } from "../data";
1
+ import type { GroupMemberRole, IChangeRecord, IDeviceInfo } from "../data";
2
2
  import type { DataFilter, IDataQueryParams } from "../data/orm";
3
+ import type { ISignedObject } from "../keys";
4
+ /** A remotely addressable Peers device that can exchange data and mesh messages. */
3
5
  export interface IPeerDevice {
6
+ /** Stable identifier for this device installation. */
4
7
  deviceId: string;
8
+ /** User identity that owns this device. */
5
9
  userId: string;
10
+ /** Role used when this device participates in a shared group. */
6
11
  role: GroupMemberRole;
12
+ /** Lists change records available from this device. */
7
13
  listChanges(filter?: DataFilter<IChangeRecord>, opts?: IDataQueryParams<IChangeRecord>): Promise<IChangeRecord[]>;
14
+ /** Returns current connectivity and resource information for this device. */
8
15
  getNetworkInfo(): Promise<INetworkInfo>;
16
+ /** Reports the latest change timestamp applied from another device. */
9
17
  notifyOfChanges(deviceId: string, timestampLastApplied: number): Promise<void>;
18
+ /** Sends a routed message to another device. */
10
19
  sendDeviceMessage(message: IDeviceMessage): Promise<any>;
11
20
  }
21
+ /** A signed, routable message exchanged through the Peers device mesh. */
12
22
  export interface IDeviceMessage<T = any> {
23
+ /** Unique identifier used for deduplication and retention. */
13
24
  deviceMessageId: string;
25
+ /** Device that originated the message. */
14
26
  fromDeviceId: string;
27
+ /** Signed source identity used to bootstrap fresh same-user devices. */
28
+ fromDeviceInfo?: ISignedObject<IDeviceInfo>;
29
+ /** Intended destination device. */
15
30
  toDeviceId: string;
31
+ /** Personal or group data context in which the message is valid. */
16
32
  dataContextId: string;
33
+ /** Remaining forwarding hops. */
17
34
  ttl: number;
35
+ /** Signed or boxed application payload while in transit. */
18
36
  payload: T;
37
+ /** Device IDs through which the message has already passed. */
19
38
  hops: string[];
39
+ /** Optional preferred route supplied by routing intelligence. */
20
40
  suggestedPath?: string[];
21
41
  }
42
+ /** Connectivity, synchronization, and resource snapshot reported by a device. */
22
43
  export interface INetworkInfo {
44
+ /** Device that produced this snapshot. */
23
45
  deviceId: string;
46
+ /** Latest change timestamp applied by the reporting device. */
24
47
  timestampLastApplied: number;
48
+ /** Current direct device connections. */
25
49
  connections: IDeviceConnection[];
50
+ /** Device IDs this device prefers to connect to. */
26
51
  preferredDeviceIds: string[];
52
+ /** Current CPU utilization percentage. */
27
53
  cpuPercent: number;
54
+ /** Current memory utilization percentage. */
28
55
  memPercent: number;
56
+ /** Number of additional direct connections available. */
29
57
  connectionSlotsAvailable: number;
30
58
  }
59
+ /** Health and synchronization metadata for one direct device connection. */
31
60
  export interface IDeviceConnection {
61
+ /** Connected remote device. */
32
62
  deviceId: string;
63
+ /** Observed round-trip latency in milliseconds. */
33
64
  latencyMs: number;
65
+ /** Observed request error rate. */
34
66
  errorRate: number;
67
+ /** Latest change timestamp applied by the remote device. */
35
68
  timestampLastApplied: number;
69
+ /** Optional cleanup callback for closing the connection. */
36
70
  onClose?(): Promise<void>;
71
+ /** Whether the connection has already closed. */
37
72
  closed?: boolean;
38
73
  }
74
+ /** Shared tuning constants for device synchronization and routing. */
39
75
  export declare const PeerDeviceConsts: Readonly<{
40
76
  readonly MAX_CONNECTIONS: 30;
41
77
  readonly RESYNC_INTERVAL: 300000;
@@ -46,6 +82,7 @@ export declare const PeerDeviceConsts: Readonly<{
46
82
  readonly TIMEOUT_MAX: 30000;
47
83
  readonly NETWORK_INFO_CACHE_TIME: 1000;
48
84
  }>;
85
+ /** Availability and queue information for a requested file chunk. */
49
86
  export type IFileChunkInfo = {
50
87
  hasChunk: false;
51
88
  } | {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PeerDeviceConsts = void 0;
4
+ /** Shared tuning constants for device synchronization and routing. */
4
5
  exports.PeerDeviceConsts = Object.freeze({
5
6
  // TODO set this based on device type (desktops and servers should be able to handle 100 connections)
6
7
  MAX_CONNECTIONS: 30,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-sdk",
3
- "version": "0.20.5",
3
+ "version": "0.20.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-sdk.git"