doover-js 0.5.0-alpha.0 → 0.5.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 (68) hide show
  1. package/README.md +0 -31
  2. package/dist/apis/agents-api.d.ts +7 -4
  3. package/dist/apis/agents-api.js +1 -139
  4. package/dist/apis/aggregates-api.d.ts +3 -23
  5. package/dist/apis/aggregates-api.js +4 -33
  6. package/dist/apis/alarms-api.d.ts +0 -30
  7. package/dist/apis/alarms-api.js +6 -51
  8. package/dist/apis/channels-api.d.ts +3 -40
  9. package/dist/apis/channels-api.js +5 -50
  10. package/dist/apis/connections-api.d.ts +5 -21
  11. package/dist/apis/connections-api.js +10 -26
  12. package/dist/apis/messages-api.d.ts +9 -54
  13. package/dist/apis/messages-api.js +12 -94
  14. package/dist/apis/notifications-api.d.ts +0 -52
  15. package/dist/apis/notifications-api.js +13 -99
  16. package/dist/apis/permissions-api.d.ts +0 -8
  17. package/dist/apis/permissions-api.js +2 -11
  18. package/dist/apis/processors-api.d.ts +0 -35
  19. package/dist/apis/processors-api.js +8 -64
  20. package/dist/client/doover-client.d.ts +8 -4
  21. package/dist/client/doover-client.js +28 -16
  22. package/dist/client/stats.d.ts +0 -24
  23. package/dist/client/stats.js +0 -62
  24. package/dist/gateway/gateway-client.d.ts +1 -13
  25. package/dist/gateway/gateway-client.js +0 -54
  26. package/dist/index.d.ts +1 -6
  27. package/dist/index.js +7 -13
  28. package/dist/react/index.d.ts +2 -0
  29. package/dist/react/index.js +3 -1
  30. package/dist/react/useChannelAggregate.js +1 -8
  31. package/dist/react/useChannelMessages.d.ts +3 -1
  32. package/dist/react/useChannelMessages.js +26 -9
  33. package/dist/react/useChannelSubscription.js +18 -8
  34. package/dist/react/useDeviceMap.d.ts +109 -0
  35. package/dist/react/useDeviceMap.js +62 -0
  36. package/dist/react/useMultiAgentAggregates.d.ts +11 -1
  37. package/dist/react/useMultiAgentAggregates.js +25 -12
  38. package/dist/react/useMultiAgentChannelMessages.js +13 -8
  39. package/dist/react/useSendMessage.js +1 -6
  40. package/dist/react/useSendRpc.js +1 -4
  41. package/dist/react/useUpdateAggregate.js +3 -9
  42. package/dist/test/utils.test.js +2 -2
  43. package/dist/types/connection.d.ts +72 -0
  44. package/dist/types/connection.js +8 -0
  45. package/dist/utils/snowflake.js +1 -1
  46. package/dist/viewer/doover-data-provider.d.ts +34 -30
  47. package/dist/viewer/doover-data-provider.js +316 -82
  48. package/package.json +1 -1
  49. package/dist/apis/_args.d.ts +0 -16
  50. package/dist/apis/_args.js +0 -26
  51. package/dist/apis/users-api.d.ts +0 -8
  52. package/dist/apis/users-api.js +0 -13
  53. package/dist/rpc/errors.d.ts +0 -10
  54. package/dist/rpc/errors.js +0 -23
  55. package/dist/rpc/rpc-dispatcher.d.ts +0 -28
  56. package/dist/rpc/rpc-dispatcher.js +0 -129
  57. package/dist/test/api-args.test.d.ts +0 -1
  58. package/dist/test/api-args.test.js +0 -48
  59. package/dist/test/api-overloads.test.d.ts +0 -9
  60. package/dist/test/api-overloads.test.js +0 -276
  61. package/dist/test/gateway-subscriptions.test.d.ts +0 -1
  62. package/dist/test/gateway-subscriptions.test.js +0 -95
  63. package/dist/test/rpc-dispatcher.test.d.ts +0 -1
  64. package/dist/test/rpc-dispatcher.test.js +0 -190
  65. package/dist/test/stats-rpc.test.d.ts +0 -1
  66. package/dist/test/stats-rpc.test.js +0 -69
  67. package/dist/test/users-api.test.d.ts +0 -1
  68. package/dist/test/users-api.test.js +0 -19
package/README.md CHANGED
@@ -127,34 +127,3 @@ Reconnections automatically use the latest (potentially refreshed) token.
127
127
  `DooverClient` builds one shared `DooverAuth` instance and injects it into `RestClient`, `DooverDataProvider`, and `GatewayClient`. Token refreshes propagate everywhere automatically.
128
128
 
129
129
  `DooverDataProvider` preserves the older viewer-oriented interface. `DooverClient` exposes the broader API surface through subclients.
130
-
131
- ## Migrating to 0.6.0
132
-
133
- `DooverDataProvider` (`client.viewer`) is deprecated in 0.5.0 and removed in 0.6.0. The replacements are subclients on `DooverClient`:
134
-
135
- | Viewer method | Replacement |
136
- |---|---|
137
- | `client.viewer.getMe()` | `client.users.getMe()` |
138
- | `client.viewer.getAgents(opts)` | `client.agents.listAgents(opts)` |
139
- | `client.viewer.getChannels(id, opts)` | `client.channels.listChannels(id, opts)` |
140
- | `client.viewer.getChannel(id)` | `client.channels.getChannel(id)` |
141
- | `client.viewer.createChannel(id, name, opts)` | `client.channels.putChannel(id, name, body)` |
142
- | `client.viewer.archiveChannel(id)` | `client.channels.archiveChannel(id)` |
143
- | `client.viewer.unarchiveChannel(id)` | `client.channels.unarchiveChannel(id)` |
144
- | `client.viewer.subscribeToChannel(id, msg, agg, upd?)` | `client.gateway.subscribeToChannel(channel, { onMessage, onAggregate, onMessageUpdate })` — returns an unsubscribe fn |
145
- | `client.viewer.unsubscribeFromChannel(id, cb)` | call the unsubscribe fn returned by `subscribeToChannel` |
146
- | `client.viewer.getAggregate(id)` | `const ch = await client.channels.getChannel(id); ch.aggregate ?? client.aggregates.getAggregate(id)` |
147
- | `client.viewer.updateAggregate(id, data, params)` | `client.aggregates.patchAggregate(id, data, params)` |
148
- | `client.viewer.putAggregate(id, data, params)` | `client.aggregates.putAggregate(id, data, params)` |
149
- | `client.viewer.getMessages(id, opts)` | `client.messages.listMessages(id, { ...opts, order: "asc" })` (omit `order` for raw newest-first server order) |
150
- | `client.viewer.deleteMessage(id, msgId)` | `client.messages.deleteMessage(id, msgId)` |
151
- | `client.viewer.sendMessage(id, data)` | `client.messages.postMessage(id, { data })` |
152
- | `client.viewer.sendRPC(id, req, opts)` | `client.rpc.send(id, req, opts)` |
153
- | `client.viewer.getChannelSubscriptions(id)` | `client.connections.getChannelSubscriptions(id)` |
154
- | `client.viewer.getAgentConnections(id)` | `client.connections.getAgentConnections(id)` |
155
- | `client.viewer.getIdentifierFromPath(p, s)` | `getIdentifierFromPath(p, s)` (free function — already exported) |
156
- | `client.viewer.getAgentInfo(id)` | **dropped, no replacement** — was a synthesized stub with no network call |
157
-
158
- `*Api` resource methods accept either positional arguments or a `ChannelIdentifier` / `{ agentId }` object on every call form.
159
-
160
- `client.rpc.send` adds optional `signal: AbortSignal` and `timeoutMs: number` and rejects with `DooverRpcError` (with `.status` and `.request`) instead of the bare status string.
@@ -1,5 +1,4 @@
1
1
  import type { AgentAggregate, BatchMessagesResponse } from "../types/openapi";
2
- import type { AgentsResponse, GetAgentsOptions } from "../types/viewer";
3
2
  import type { RestClient } from "../http/rest-client";
4
3
  export interface MultiAgentMessagesParams {
5
4
  agent_id: string[];
@@ -11,12 +10,16 @@ export interface MultiAgentMessagesParams {
11
10
  }
12
11
  export interface MultiAgentAggregatesParams {
13
12
  agent_id: string[];
13
+ /**
14
+ * Project the response to only the named top-level keys of each aggregate's
15
+ * `data`. Useful for large aggregates (e.g. `tag_values`) when the caller
16
+ * only needs a subset of the tag tree.
17
+ */
18
+ field_name?: string[];
14
19
  }
15
20
  export declare class AgentsApi {
16
21
  private readonly rest;
17
- private readonly controlApiUrl?;
18
- constructor(rest: RestClient, controlApiUrl?: string | undefined);
19
- listAgents(options?: GetAgentsOptions): Promise<AgentsResponse>;
22
+ constructor(rest: RestClient);
20
23
  getMultiAgentMessages(channelName: string, params: MultiAgentMessagesParams): Promise<BatchMessagesResponse>;
21
24
  getMultiAgentAggregates(channelName: string, params: MultiAgentAggregatesParams): Promise<{
22
25
  results: AgentAggregate[];
@@ -2,147 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgentsApi = void 0;
4
4
  const snowflake_1 = require("../utils/snowflake");
5
- function isPlainObject(value) {
6
- return typeof value === "object" && value !== null && !Array.isArray(value);
7
- }
8
- function buildUserDisplayName(rawUser) {
9
- const source = isPlainObject(rawUser)
10
- ? rawUser
11
- : {};
12
- const firstName = typeof source.first_name === "string" ? source.first_name.trim() : "";
13
- const lastName = typeof source.last_name === "string" ? source.last_name.trim() : "";
14
- const fullName = `${firstName} ${lastName}`.trim();
15
- if (fullName !== "") {
16
- return fullName;
17
- }
18
- if (typeof source.username === "string" && source.username !== "") {
19
- return source.username;
20
- }
21
- if (typeof source.email === "string" && source.email !== "") {
22
- return source.email;
23
- }
24
- if (typeof source.id === "string" && source.id !== "") {
25
- return source.id;
26
- }
27
- return String(source.id ?? "");
28
- }
29
- function coerceExtraConfig(value) {
30
- return isPlainObject(value) ? value : {};
31
- }
32
- function normalizeAgentEntry(rawAgent) {
33
- const source = isPlainObject(rawAgent)
34
- ? rawAgent
35
- : {};
36
- const fixedLocation = source.fixed_location;
37
- const normalizedFixedLocation = isPlainObject(fixedLocation) &&
38
- typeof fixedLocation.latitude === "number" &&
39
- typeof fixedLocation.longitude === "number"
40
- ? {
41
- latitude: fixedLocation.latitude,
42
- longitude: fixedLocation.longitude,
43
- }
44
- : { latitude: 0, longitude: 0 };
45
- const faIcon = typeof source.fa_icon === "string" && source.fa_icon.length > 0
46
- ? source.fa_icon
47
- : "fa-solid fa-robot";
48
- return {
49
- ...source,
50
- id: typeof source.id === "string" ? source.id : String(source.id ?? ""),
51
- organisation: typeof source.organisation === "string" ? source.organisation : "",
52
- name: typeof source.name === "string" ? source.name : "",
53
- display_name: typeof source.display_name === "string" ? source.display_name : "",
54
- archived: typeof source.archived === "boolean" ? source.archived : false,
55
- group: typeof source.group === "string" ? source.group : "",
56
- fa_icon: faIcon,
57
- type: source.type === "device" ||
58
- source.type === "dashboard" ||
59
- source.type === "organisation" ||
60
- source.type === "user"
61
- ? source.type
62
- : "device",
63
- fixed_location: normalizedFixedLocation,
64
- extra_config: coerceExtraConfig(source.extra_config),
65
- };
66
- }
67
- function normalizeOrganisationEntry(rawOrganisation) {
68
- const source = isPlainObject(rawOrganisation)
69
- ? rawOrganisation
70
- : {};
71
- const name = typeof source.name === "string" ? source.name : "";
72
- const rootGroup = isPlainObject(source.root_group) ? source.root_group : null;
73
- const groupName = rootGroup && typeof rootGroup.name === "string" ? rootGroup.name : "";
74
- return {
75
- id: typeof source.id === "string" ? source.id : String(source.id ?? ""),
76
- organisation: name,
77
- name,
78
- display_name: name,
79
- archived: typeof source.archived === "boolean" ? source.archived : false,
80
- group: groupName,
81
- fa_icon: "fa-solid fa-building",
82
- type: "organisation",
83
- fixed_location: { latitude: 0, longitude: 0 },
84
- extra_config: coerceExtraConfig(source.extra_config),
85
- };
86
- }
87
- function normalizeUserEntry(rawUser) {
88
- const source = isPlainObject(rawUser)
89
- ? rawUser
90
- : {};
91
- const id = typeof source.id === "string" ? source.id : String(source.id ?? "");
92
- const username = typeof source.username === "string" ? source.username : "";
93
- const email = typeof source.email === "string" ? source.email : "";
94
- const name = username !== "" ? username : email !== "" ? email : id;
95
- return {
96
- id,
97
- organisation: "",
98
- name,
99
- display_name: buildUserDisplayName(source),
100
- archived: false,
101
- group: "",
102
- fa_icon: "fa-solid fa-user",
103
- type: "user",
104
- fixed_location: { latitude: 0, longitude: 0 },
105
- extra_config: coerceExtraConfig(source.custom_data),
106
- };
107
- }
108
5
  class AgentsApi {
109
- constructor(rest, controlApiUrl) {
6
+ constructor(rest) {
110
7
  this.rest = rest;
111
- this.controlApiUrl = controlApiUrl;
112
- }
113
- async listAgents(options) {
114
- const query = {};
115
- if (options?.includeArchived)
116
- query["include-archived"] = true;
117
- if (options?.includeOrganisations)
118
- query["include-organisations"] = true;
119
- if (options?.includeUsers)
120
- query["include-users"] = true;
121
- const raw = await this.rest.request({
122
- path: "/agents/",
123
- baseUrl: this.controlApiUrl,
124
- omitSharingHeader: true,
125
- query: Object.keys(query).length > 0 ? query : undefined,
126
- });
127
- const rawAgents = Array.isArray(raw.agents) ? raw.agents : [];
128
- const normalizedAgents = rawAgents.map(normalizeAgentEntry);
129
- if (!options?.mergeIncludedAsAgents) {
130
- return { ...raw, agents: normalizedAgents };
131
- }
132
- const merged = [...normalizedAgents];
133
- if (options.includeOrganisations) {
134
- const rawOrgs = Array.isArray(raw.organisations)
135
- ? raw.organisations
136
- : [];
137
- for (const org of rawOrgs)
138
- merged.push(normalizeOrganisationEntry(org));
139
- }
140
- if (options.includeUsers) {
141
- const rawUsers = Array.isArray(raw.users) ? raw.users : [];
142
- for (const user of rawUsers)
143
- merged.push(normalizeUserEntry(user));
144
- }
145
- return { ...raw, agents: merged, results: merged, count: merged.length };
146
8
  }
147
9
  async getMultiAgentMessages(channelName, params) {
148
10
  const response = await this.rest.get(`/agents/channels/${channelName}/messages`, params);
@@ -8,28 +8,8 @@ export interface AggregateMutationParams {
8
8
  export declare class AggregatesApi {
9
9
  private readonly rest;
10
10
  constructor(rest: RestClient);
11
- getAggregate(agentId: string, channelName: string): Promise<Aggregate>;
12
- getAggregate(identifier: {
13
- agentId: string;
14
- channelName: string;
15
- }): Promise<Aggregate>;
16
- private _getAggregate;
17
- putAggregate(agentId: string, channelName: string, body: Record<string, unknown> | FormData, params?: AggregateMutationParams): Promise<Aggregate>;
18
- putAggregate(identifier: {
19
- agentId: string;
20
- channelName: string;
21
- }, body: Record<string, unknown> | FormData, params?: AggregateMutationParams): Promise<Aggregate>;
22
- private _putAggregate;
23
- patchAggregate(agentId: string, channelName: string, body: Record<string, unknown> | FormData, params?: AggregateMutationParams): Promise<Aggregate>;
24
- patchAggregate(identifier: {
25
- agentId: string;
26
- channelName: string;
27
- }, body: Record<string, unknown> | FormData, params?: AggregateMutationParams): Promise<Aggregate>;
28
- private _patchAggregate;
11
+ getAggregate(agentId: string, channelName: string): Promise<Aggregate<Record<string, import("..").JSONValue>>>;
12
+ putAggregate(agentId: string, channelName: string, body: Record<string, unknown> | FormData, params?: AggregateMutationParams): Promise<Aggregate<Record<string, import("..").JSONValue>>>;
13
+ patchAggregate(agentId: string, channelName: string, body: Record<string, unknown> | FormData, params?: AggregateMutationParams): Promise<Aggregate<Record<string, import("..").JSONValue>>>;
29
14
  getAggregateAttachment(agentId: string, channelName: string, attachmentId: string): Promise<Blob>;
30
- getAggregateAttachment(identifier: {
31
- agentId: string;
32
- channelName: string;
33
- }, attachmentId: string): Promise<Blob>;
34
- private _getAggregateAttachment;
35
15
  }
@@ -1,49 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AggregatesApi = void 0;
4
- const _args_1 = require("./_args");
5
4
  class AggregatesApi {
6
5
  constructor(rest) {
7
6
  this.rest = rest;
8
7
  }
9
- getAggregate(...args) {
10
- const { agentId, channelName } = (0, _args_1.resolveChannelArgs)(args);
11
- return this._getAggregate(agentId, channelName);
12
- }
13
- _getAggregate(agentId, channelName) {
8
+ getAggregate(agentId, channelName) {
14
9
  return this.rest.get(`/agents/${agentId}/channels/${channelName}/aggregate`);
15
10
  }
16
- putAggregate(...args) {
17
- if (typeof args[0] === "string") {
18
- const [agentId, channelName, body, params] = args;
19
- return this._putAggregate(agentId, channelName, body, params);
20
- }
21
- const id = args[0];
22
- return this._putAggregate(id.agentId, id.channelName, args[1], args[2]);
23
- }
24
- _putAggregate(agentId, channelName, body, params) {
11
+ putAggregate(agentId, channelName, body, params) {
25
12
  return this.rest.put(`/agents/${agentId}/channels/${channelName}/aggregate`, body, params);
26
13
  }
27
- patchAggregate(...args) {
28
- if (typeof args[0] === "string") {
29
- const [agentId, channelName, body, params] = args;
30
- return this._patchAggregate(agentId, channelName, body, params);
31
- }
32
- const id = args[0];
33
- return this._patchAggregate(id.agentId, id.channelName, args[1], args[2]);
34
- }
35
- _patchAggregate(agentId, channelName, body, params) {
14
+ patchAggregate(agentId, channelName, body, params) {
36
15
  return this.rest.patch(`/agents/${agentId}/channels/${channelName}/aggregate`, body, params);
37
16
  }
38
- getAggregateAttachment(...args) {
39
- if (typeof args[0] === "string") {
40
- const [agentId, channelName, attachmentId] = args;
41
- return this._getAggregateAttachment(agentId, channelName, attachmentId);
42
- }
43
- const id = args[0];
44
- return this._getAggregateAttachment(id.agentId, id.channelName, args[1]);
45
- }
46
- _getAggregateAttachment(agentId, channelName, attachmentId) {
17
+ getAggregateAttachment(agentId, channelName, attachmentId) {
47
18
  return this.rest.get(`/agents/${agentId}/channels/${channelName}/aggregate/attachments/${attachmentId}`);
48
19
  }
49
20
  }
@@ -4,39 +4,9 @@ export declare class AlarmsApi {
4
4
  private readonly rest;
5
5
  constructor(rest: RestClient);
6
6
  listAlarms(agentId: string, channelName: string): Promise<Alarm[]>;
7
- listAlarms(identifier: {
8
- agentId: string;
9
- channelName: string;
10
- }): Promise<Alarm[]>;
11
- private _listAlarms;
12
7
  createAlarm(agentId: string, channelName: string, body: CreateAlarmRequest): Promise<Alarm>;
13
- createAlarm(identifier: {
14
- agentId: string;
15
- channelName: string;
16
- }, body: CreateAlarmRequest): Promise<Alarm>;
17
- private _createAlarm;
18
8
  getAlarm(agentId: string, channelName: string, alarmId: string): Promise<Alarm>;
19
- getAlarm(identifier: {
20
- agentId: string;
21
- channelName: string;
22
- }, alarmId: string): Promise<Alarm>;
23
- private _getAlarm;
24
9
  putAlarm(agentId: string, channelName: string, alarmId: string, body: CreateAlarmRequest): Promise<Alarm>;
25
- putAlarm(identifier: {
26
- agentId: string;
27
- channelName: string;
28
- }, alarmId: string, body: CreateAlarmRequest): Promise<Alarm>;
29
- private _putAlarm;
30
10
  patchAlarm(agentId: string, channelName: string, alarmId: string, body: PatchAlarmRequest): Promise<Alarm>;
31
- patchAlarm(identifier: {
32
- agentId: string;
33
- channelName: string;
34
- }, alarmId: string, body: PatchAlarmRequest): Promise<Alarm>;
35
- private _patchAlarm;
36
11
  deleteAlarm(agentId: string, channelName: string, alarmId: string): Promise<unknown>;
37
- deleteAlarm(identifier: {
38
- agentId: string;
39
- channelName: string;
40
- }, alarmId: string): Promise<unknown>;
41
- private _deleteAlarm;
42
12
  }
@@ -1,71 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AlarmsApi = void 0;
4
- const _args_1 = require("./_args");
5
4
  class AlarmsApi {
6
5
  constructor(rest) {
7
6
  this.rest = rest;
8
7
  }
9
- listAlarms(...args) {
10
- const { agentId, channelName } = (0, _args_1.resolveChannelArgs)(args);
11
- return this._listAlarms(agentId, channelName);
12
- }
13
- _listAlarms(agentId, channelName) {
8
+ listAlarms(agentId, channelName) {
14
9
  return this.rest.get(`/agents/${agentId}/channels/${channelName}/alarms`);
15
10
  }
16
- createAlarm(...args) {
17
- if (typeof args[0] === "string") {
18
- const [agentId, channelName, body] = args;
19
- return this._createAlarm(agentId, channelName, body);
20
- }
21
- const id = args[0];
22
- return this._createAlarm(id.agentId, id.channelName, args[1]);
23
- }
24
- _createAlarm(agentId, channelName, body) {
11
+ createAlarm(agentId, channelName, body) {
25
12
  return this.rest.post(`/agents/${agentId}/channels/${channelName}/alarms`, body);
26
13
  }
27
- getAlarm(...args) {
28
- if (typeof args[0] === "string") {
29
- const [agentId, channelName, alarmId] = args;
30
- return this._getAlarm(agentId, channelName, alarmId);
31
- }
32
- const id = args[0];
33
- return this._getAlarm(id.agentId, id.channelName, args[1]);
34
- }
35
- _getAlarm(agentId, channelName, alarmId) {
14
+ getAlarm(agentId, channelName, alarmId) {
36
15
  return this.rest.get(`/agents/${agentId}/channels/${channelName}/alarms/${alarmId}`);
37
16
  }
38
- putAlarm(...args) {
39
- if (typeof args[0] === "string") {
40
- const [agentId, channelName, alarmId, body] = args;
41
- return this._putAlarm(agentId, channelName, alarmId, body);
42
- }
43
- const id = args[0];
44
- return this._putAlarm(id.agentId, id.channelName, args[1], args[2]);
45
- }
46
- _putAlarm(agentId, channelName, alarmId, body) {
17
+ putAlarm(agentId, channelName, alarmId, body) {
47
18
  return this.rest.put(`/agents/${agentId}/channels/${channelName}/alarms/${alarmId}`, body);
48
19
  }
49
- patchAlarm(...args) {
50
- if (typeof args[0] === "string") {
51
- const [agentId, channelName, alarmId, body] = args;
52
- return this._patchAlarm(agentId, channelName, alarmId, body);
53
- }
54
- const id = args[0];
55
- return this._patchAlarm(id.agentId, id.channelName, args[1], args[2]);
56
- }
57
- _patchAlarm(agentId, channelName, alarmId, body) {
20
+ patchAlarm(agentId, channelName, alarmId, body) {
58
21
  return this.rest.patch(`/agents/${agentId}/channels/${channelName}/alarms/${alarmId}`, body);
59
22
  }
60
- deleteAlarm(...args) {
61
- if (typeof args[0] === "string") {
62
- const [agentId, channelName, alarmId] = args;
63
- return this._deleteAlarm(agentId, channelName, alarmId);
64
- }
65
- const id = args[0];
66
- return this._deleteAlarm(id.agentId, id.channelName, args[1]);
67
- }
68
- _deleteAlarm(agentId, channelName, alarmId) {
23
+ deleteAlarm(agentId, channelName, alarmId) {
69
24
  return this.rest.delete(`/agents/${agentId}/channels/${channelName}/alarms/${alarmId}`);
70
25
  }
71
26
  }
@@ -17,48 +17,11 @@ export interface DataSeriesParams {
17
17
  export declare class ChannelsApi {
18
18
  private readonly rest;
19
19
  constructor(rest: RestClient);
20
- listChannels(agentId: string, options?: ListChannelsOptions): Promise<Channel[]>;
21
- listChannels(identifier: {
22
- agentId: string;
23
- }, options?: ListChannelsOptions): Promise<Channel[]>;
24
- private _listChannels;
25
- getChannel(agentId: string, channelName: string, options?: GetChannelOptions): Promise<Channel>;
26
- getChannel(identifier: {
27
- agentId: string;
28
- channelName: string;
29
- }, options?: GetChannelOptions): Promise<Channel>;
30
- private _getChannel;
20
+ listChannels(agentId: string, options?: ListChannelsOptions): Promise<Channel<Record<string, import("..").JSONValue>>[]>;
21
+ getChannel(agentId: string, channelName: string, options?: GetChannelOptions): Promise<Channel<Record<string, import("..").JSONValue>>>;
31
22
  createChannel(agentId: string, channelName: string, body: CreateChannelRequest): Promise<{
32
23
  id: string;
33
24
  }>;
34
- createChannel(identifier: {
35
- agentId: string;
36
- channelName: string;
37
- }, body: CreateChannelRequest): Promise<{
38
- id: string;
39
- }>;
40
- private _createChannel;
41
- putChannel(agentId: string, channelName: string, body: PutChannelRequest): Promise<Channel>;
42
- putChannel(identifier: {
43
- agentId: string;
44
- channelName: string;
45
- }, body: PutChannelRequest): Promise<Channel>;
46
- private _putChannel;
47
- archiveChannel(agentId: string, channelName: string): Promise<unknown>;
48
- archiveChannel(identifier: {
49
- agentId: string;
50
- channelName: string;
51
- }): Promise<unknown>;
52
- private _archiveChannel;
53
- unarchiveChannel(agentId: string, channelName: string): Promise<unknown>;
54
- unarchiveChannel(identifier: {
55
- agentId: string;
56
- channelName: string;
57
- }): Promise<unknown>;
58
- private _unarchiveChannel;
25
+ putChannel(agentId: string, channelName: string, body: PutChannelRequest): Promise<Channel<Record<string, import("..").JSONValue>>>;
59
26
  listDataSeries(agentId: string, params: DataSeriesParams): Promise<DataSeries>;
60
- listDataSeries(identifier: {
61
- agentId: string;
62
- }, params: DataSeriesParams): Promise<DataSeries>;
63
- private _listDataSeries;
64
27
  }
@@ -1,68 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ChannelsApi = void 0;
4
- const _args_1 = require("./_args");
5
4
  class ChannelsApi {
6
5
  constructor(rest) {
7
6
  this.rest = rest;
8
7
  }
9
- listChannels(...args) {
10
- const { agentId, options } = (0, _args_1.resolveAgentArgs)(args);
11
- return this._listChannels(agentId, options);
12
- }
13
- _listChannels(agentId, options) {
8
+ listChannels(agentId, options) {
14
9
  return this.rest.get(`/agents/${agentId}/channels`, options);
15
10
  }
16
- getChannel(...args) {
17
- const { agentId, channelName, options } = (0, _args_1.resolveChannelArgs)(args);
18
- return this._getChannel(agentId, channelName, options);
19
- }
20
- _getChannel(agentId, channelName, options) {
11
+ getChannel(agentId, channelName, options) {
21
12
  return this.rest.get(`/agents/${agentId}/channels/${channelName}`, options);
22
13
  }
23
- createChannel(...args) {
24
- if (typeof args[0] === "string") {
25
- const [agentId, channelName, body] = args;
26
- return this._createChannel(agentId, channelName, body);
27
- }
28
- const id = args[0];
29
- const body = args[1];
30
- return this._createChannel(id.agentId, id.channelName, body);
31
- }
32
- _createChannel(agentId, channelName, body) {
14
+ createChannel(agentId, channelName, body) {
33
15
  return this.rest.post(`/agents/${agentId}/channels/${channelName}`, body);
34
16
  }
35
- putChannel(...args) {
36
- if (typeof args[0] === "string") {
37
- const [agentId, channelName, body] = args;
38
- return this._putChannel(agentId, channelName, body);
39
- }
40
- const id = args[0];
41
- const body = args[1];
42
- return this._putChannel(id.agentId, id.channelName, body);
43
- }
44
- _putChannel(agentId, channelName, body) {
17
+ putChannel(agentId, channelName, body) {
45
18
  return this.rest.put(`/agents/${agentId}/channels/${channelName}`, body);
46
19
  }
47
- archiveChannel(...args) {
48
- const { agentId, channelName } = (0, _args_1.resolveChannelArgs)(args);
49
- return this._archiveChannel(agentId, channelName);
50
- }
51
- _archiveChannel(agentId, channelName) {
52
- return this.rest.post(`/agents/${agentId}/channels/${channelName}/archive`, {});
53
- }
54
- unarchiveChannel(...args) {
55
- const { agentId, channelName } = (0, _args_1.resolveChannelArgs)(args);
56
- return this._unarchiveChannel(agentId, channelName);
57
- }
58
- _unarchiveChannel(agentId, channelName) {
59
- return this.rest.post(`/agents/${agentId}/channels/${channelName}/unarchive`, {});
60
- }
61
- listDataSeries(...args) {
62
- const { agentId, options } = (0, _args_1.resolveAgentArgs)(args);
63
- return this._listDataSeries(agentId, options);
64
- }
65
- _listDataSeries(agentId, params) {
20
+ listDataSeries(agentId, params) {
66
21
  return this.rest.get(`/agents/${agentId}/data_series`, params);
67
22
  }
68
23
  }
@@ -16,30 +16,14 @@ export declare class ConnectionsApi {
16
16
  private readonly rest;
17
17
  constructor(rest: RestClient);
18
18
  getAgentConnections(agentId: string): Promise<ConnectionDetails[]>;
19
- getAgentConnections(identifier: {
20
- agentId: string;
21
- }): Promise<ConnectionDetails[]>;
22
- private _getAgentConnections;
23
19
  getAgentConnectionHistory(agentId: string, params: ConnectionHistoryParams): Promise<ConnectionDetails[]>;
24
- getAgentConnectionHistory(identifier: {
25
- agentId: string;
26
- }, params: ConnectionHistoryParams): Promise<ConnectionDetails[]>;
27
- private _getAgentConnectionHistory;
28
20
  getAgentSubscriptionHistory(agentId: string, params: SubscriptionHistoryParams): Promise<ConnectionSubscriptionLog[]>;
29
- getAgentSubscriptionHistory(identifier: {
30
- agentId: string;
31
- }, params: SubscriptionHistoryParams): Promise<ConnectionSubscriptionLog[]>;
32
- private _getAgentSubscriptionHistory;
33
21
  getConnection(connectionId: string): Promise<ConnectionDetails>;
34
22
  getChannelSubscriptions(agentId: string, channelName: string): Promise<ConnectionSubscription[]>;
35
- getChannelSubscriptions(identifier: {
36
- agentId: string;
37
- channelName: string;
38
- }): Promise<ConnectionSubscription[]>;
39
- private _getChannelSubscriptions;
23
+ /**
24
+ * Ask the server to push the latest state of all channels this agent
25
+ * owns to every active WSS connection. Used to recover from missed updates
26
+ * after a gap in connectivity.
27
+ */
40
28
  syncConnection(agentId: string): Promise<unknown>;
41
- syncConnection(identifier: {
42
- agentId: string;
43
- }): Promise<unknown>;
44
- private _syncConnection;
45
29
  }
@@ -1,47 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConnectionsApi = void 0;
4
- const _args_1 = require("./_args");
5
4
  class ConnectionsApi {
6
5
  constructor(rest) {
7
6
  this.rest = rest;
8
7
  }
9
- getAgentConnections(...args) {
10
- const { agentId } = (0, _args_1.resolveAgentArgs)(args);
11
- return this._getAgentConnections(agentId);
12
- }
13
- _getAgentConnections(agentId) {
8
+ getAgentConnections(agentId) {
14
9
  return this.rest.get(`/agents/${agentId}/wss_connections`);
15
10
  }
16
- getAgentConnectionHistory(...args) {
17
- const { agentId, options } = (0, _args_1.resolveAgentArgs)(args);
18
- return this._getAgentConnectionHistory(agentId, options);
19
- }
20
- _getAgentConnectionHistory(agentId, params) {
11
+ getAgentConnectionHistory(agentId, params) {
21
12
  return this.rest.get(`/agents/${agentId}/wss_connections/history`, params);
22
13
  }
23
- getAgentSubscriptionHistory(...args) {
24
- const { agentId, options } = (0, _args_1.resolveAgentArgs)(args);
25
- return this._getAgentSubscriptionHistory(agentId, options);
26
- }
27
- _getAgentSubscriptionHistory(agentId, params) {
14
+ getAgentSubscriptionHistory(agentId, params) {
28
15
  return this.rest.get(`/agents/${agentId}/wss_connections/subscriptions/history`, params);
29
16
  }
30
17
  getConnection(connectionId) {
31
18
  return this.rest.get(`/connections/${connectionId}`);
32
19
  }
33
- getChannelSubscriptions(...args) {
34
- const { agentId, channelName } = (0, _args_1.resolveChannelArgs)(args);
35
- return this._getChannelSubscriptions(agentId, channelName);
36
- }
37
- _getChannelSubscriptions(agentId, channelName) {
20
+ getChannelSubscriptions(agentId, channelName) {
38
21
  return this.rest.get(`/agents/${agentId}/channels/${channelName}/subscriptions`);
39
22
  }
40
- syncConnection(...args) {
41
- const { agentId } = (0, _args_1.resolveAgentArgs)(args);
42
- return this._syncConnection(agentId);
43
- }
44
- _syncConnection(agentId) {
23
+ /**
24
+ * Ask the server to push the latest state of all channels this agent
25
+ * owns to every active WSS connection. Used to recover from missed updates
26
+ * after a gap in connectivity.
27
+ */
28
+ syncConnection(agentId) {
45
29
  return this.rest.post(`/agents/${agentId}/connection_sync`, {});
46
30
  }
47
31
  }