o2g-node-sdk 2.5.3 → 2.5.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.
Files changed (88) hide show
  1. package/README.md +315 -21
  2. package/dist/o2g-node-sdk.js +3008 -2262
  3. package/dist/o2g-node-sdk.js.map +1 -1
  4. package/dist/types/events/chunk-eventing.d.ts.map +1 -0
  5. package/dist/types/events/event-dispatcher.d.ts.map +1 -0
  6. package/dist/types/events/event-packages.d.ts.map +1 -0
  7. package/dist/types/internal/o2g-application.d.ts +7 -1
  8. package/dist/types/internal/o2g-application.d.ts.map +1 -1
  9. package/dist/types/internal/rest/ccStatistics-rest.d.ts +1 -1
  10. package/dist/types/internal/rest/ccStatistics-rest.d.ts.map +1 -1
  11. package/dist/types/internal/util/logger.d.ts +3 -7
  12. package/dist/types/internal/util/logger.d.ts.map +1 -1
  13. package/dist/types/log-level.d.ts +17 -0
  14. package/dist/types/log-level.d.ts.map +1 -0
  15. package/dist/types/o2g-node-sdk.d.ts +126 -59
  16. package/dist/types/o2g-node-sdk.d.ts.map +1 -1
  17. package/dist/types/o2g-servers.d.ts +111 -0
  18. package/dist/types/o2g-servers.d.ts.map +1 -0
  19. package/dist/types/services/o2g-analytics.d.ts +70 -0
  20. package/dist/types/services/o2g-analytics.d.ts.map +1 -0
  21. package/dist/types/{o2g-cc-agent.d.ts → services/o2g-cc-agent.d.ts} +15 -11
  22. package/dist/types/services/o2g-cc-agent.d.ts.map +1 -0
  23. package/dist/types/{o2g-cc-mngt.d.ts → services/o2g-cc-mngt.d.ts} +68 -47
  24. package/dist/types/services/o2g-cc-mngt.d.ts.map +1 -0
  25. package/dist/types/{o2g-cc-pilot.d.ts → services/o2g-cc-pilot.d.ts} +7 -5
  26. package/dist/types/services/o2g-cc-pilot.d.ts.map +1 -0
  27. package/dist/types/{o2g-cc-rt.d.ts → services/o2g-cc-rt.d.ts} +7 -6
  28. package/dist/types/services/o2g-cc-rt.d.ts.map +1 -0
  29. package/dist/types/{o2g-cc-stat.d.ts → services/o2g-cc-stat.d.ts} +172 -175
  30. package/dist/types/services/o2g-cc-stat.d.ts.map +1 -0
  31. package/dist/types/{o2g-comlog.d.ts → services/o2g-comlog.d.ts} +72 -71
  32. package/dist/types/services/o2g-comlog.d.ts.map +1 -0
  33. package/dist/types/{o2g-directory.d.ts → services/o2g-directory.d.ts} +37 -42
  34. package/dist/types/services/o2g-directory.d.ts.map +1 -0
  35. package/dist/types/{o2g-eventSummary.d.ts → services/o2g-eventSummary.d.ts} +8 -9
  36. package/dist/types/services/o2g-eventSummary.d.ts.map +1 -0
  37. package/dist/types/{o2g-maint.d.ts → services/o2g-maint.d.ts} +11 -11
  38. package/dist/types/services/o2g-maint.d.ts.map +1 -0
  39. package/dist/types/{o2g-messaging.d.ts → services/o2g-messaging.d.ts} +6 -5
  40. package/dist/types/services/o2g-messaging.d.ts.map +1 -0
  41. package/dist/types/{o2g-pbx-mngt.d.ts → services/o2g-pbx-mngt.d.ts} +5 -5
  42. package/dist/types/services/o2g-pbx-mngt.d.ts.map +1 -0
  43. package/dist/types/{o2g-phone-set-prog.d.ts → services/o2g-phone-set-prog.d.ts} +5 -5
  44. package/dist/types/services/o2g-phone-set-prog.d.ts.map +1 -0
  45. package/dist/types/{o2g-routing.d.ts → services/o2g-routing.d.ts} +44 -26
  46. package/dist/types/services/o2g-routing.d.ts.map +1 -0
  47. package/dist/types/services/o2g-rsi.d.ts +164 -0
  48. package/dist/types/services/o2g-rsi.d.ts.map +1 -0
  49. package/dist/types/{o2g-telephony.d.ts → services/o2g-telephony.d.ts} +269 -238
  50. package/dist/types/services/o2g-telephony.d.ts.map +1 -0
  51. package/dist/types/{o2g-users-mngt.d.ts → services/o2g-users-mngt.d.ts} +22 -14
  52. package/dist/types/services/o2g-users-mngt.d.ts.map +1 -0
  53. package/dist/types/{o2g-users.d.ts → services/o2g-users.d.ts} +11 -8
  54. package/dist/types/services/o2g-users.d.ts.map +1 -0
  55. package/dist/types/session-monitoring-policy.d.ts +152 -0
  56. package/dist/types/session-monitoring-policy.d.ts.map +1 -0
  57. package/dist/types/subscription.d.ts +1 -1
  58. package/dist/types/subscription.d.ts.map +1 -1
  59. package/dist/types/types/telephony/call/ccd/call-profile.d.ts.map +1 -1
  60. package/package.json +2 -2
  61. package/dist/types/host.d.ts +0 -18
  62. package/dist/types/host.d.ts.map +0 -1
  63. package/dist/types/internal/events/chunk-eventing.d.ts.map +0 -1
  64. package/dist/types/internal/events/event-dispatcher.d.ts.map +0 -1
  65. package/dist/types/internal/events/event-packages.d.ts.map +0 -1
  66. package/dist/types/o2g-analytics.d.ts +0 -61
  67. package/dist/types/o2g-analytics.d.ts.map +0 -1
  68. package/dist/types/o2g-cc-agent.d.ts.map +0 -1
  69. package/dist/types/o2g-cc-mngt.d.ts.map +0 -1
  70. package/dist/types/o2g-cc-pilot.d.ts.map +0 -1
  71. package/dist/types/o2g-cc-rt.d.ts.map +0 -1
  72. package/dist/types/o2g-cc-stat.d.ts.map +0 -1
  73. package/dist/types/o2g-comlog.d.ts.map +0 -1
  74. package/dist/types/o2g-directory.d.ts.map +0 -1
  75. package/dist/types/o2g-eventSummary.d.ts.map +0 -1
  76. package/dist/types/o2g-maint.d.ts.map +0 -1
  77. package/dist/types/o2g-messaging.d.ts.map +0 -1
  78. package/dist/types/o2g-pbx-mngt.d.ts.map +0 -1
  79. package/dist/types/o2g-phone-set-prog.d.ts.map +0 -1
  80. package/dist/types/o2g-routing.d.ts.map +0 -1
  81. package/dist/types/o2g-rsi.d.ts +0 -156
  82. package/dist/types/o2g-rsi.d.ts.map +0 -1
  83. package/dist/types/o2g-telephony.d.ts.map +0 -1
  84. package/dist/types/o2g-users-mngt.d.ts.map +0 -1
  85. package/dist/types/o2g-users.d.ts.map +0 -1
  86. /package/dist/types/{internal/events → events}/chunk-eventing.d.ts +0 -0
  87. /package/dist/types/{internal/events → events}/event-dispatcher.d.ts +0 -0
  88. /package/dist/types/{internal/events → events}/event-packages.d.ts +0 -0
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # o2g-node-sdk
2
2
 
3
- A Node.js SDK for the ALE International O2G (OmniPCX OpenTouch Gateway) platform, providing a comprehensive TypeScript API for telephony, call control, and contact center services.
3
+ A Node.js SDK for the ALE International O2G (OmniPCX OpenTouch Gateway) platform,
4
+ providing a comprehensive TypeScript API for telephony, call control, management
5
+ and contact center services.
4
6
 
5
7
  ## Requirements
6
8
 
@@ -17,12 +19,14 @@ npm install o2g-node-sdk
17
19
  ## Quick Start
18
20
 
19
21
  ```typescript
20
- import { O2G, Subscription, Telephony } from 'o2g-node-sdk';
22
+ import { O2G, O2GServers, Host, Subscription, Telephony } from 'o2g-node-sdk';
21
23
 
22
- // 1. Initialize the SDK, configure the O2G IP address or FQDN
23
- O2G.initialize("MyApp", { privateAddress: "192.168.1.1" });
24
+ // 1. Initialize the SDK with the O2G server configuration
25
+ O2G.initialize("MyApp", O2GServers.Builder
26
+ .primaryHost(new Host("192.168.1.1"))
27
+ .build());
24
28
 
25
- // 2. Login
29
+ // 2. Login — retries automatically if the server is not yet reachable
26
30
  const success = await O2G.login("jdoe", "password");
27
31
  if (!success) {
28
32
  console.error("Login failed");
@@ -50,11 +54,226 @@ await O2G.telephony.makeCall("1234", "5678");
50
54
  await O2G.shutdown();
51
55
  ```
52
56
 
57
+ ## What's New in 2.5.6
58
+
59
+ - Fixed a syntax error in the `UserManagement` service that prevented compiling `createUsers`
60
+ - Improved JSDoc documentation across all services for consistency and completeness
61
+
62
+ ## What's New in 2.5.5
63
+
64
+ ### Automatic session recovery
65
+
66
+ The SDK now handles O2G server failures transparently. When the server crashes
67
+ or becomes unreachable, the SDK automatically detects the failure, retries the
68
+ connection with exponential backoff, re-subscribes to events, and notifies the
69
+ application when service is restored. No application-level reconnection logic
70
+ is required.
71
+
72
+ ### `SessionMonitoringPolicy` — full control over recovery behaviour
73
+
74
+ A new `SessionMonitoringPolicy` class allows applications to customise how the
75
+ SDK reacts to each failure scenario:
76
+
77
+ | Callback | When called | Returns |
78
+ |---|---|---|
79
+ | `onConnectError(err)` | Initial connection or recovery attempt fails | `Behavior` — retry or abort |
80
+ | `onChunkError(err, consecutiveErrors)` | Chunk stream network error | `Behavior` — retry or abort |
81
+ | `onKeepAliveError(err)` | Keep-alive network error | `Behavior` — retry or abort |
82
+ | `onChunkEstablished()` | Chunk channel confirmed working | — |
83
+ | `onChunkFatalError(httpStatus)` | Chunk HTTP error (e.g. 401, 403) | — |
84
+ | `onKeepAliveDone()` | Keep-alive acknowledged by server | — |
85
+ | `onKeepAliveFatalError()` | Keep-alive rejected by server | — |
86
+ | `onEventError(err)` | Exception in an application event listener | — |
87
+
88
+ ### Session lifecycle events
89
+
90
+ Three new events on the `O2G` facade:
91
+
92
+ - `O2G.O2G_SESSION_LOST` — fired when the session is lost; recovery starts automatically
93
+ - `O2G.O2G_RECONNECTED` — fired when the session has been successfully recovered
94
+ - `O2G.O2G_SERVER_SWITCHED` — fired when the SDK switches to the secondary server (geographic HA only)
95
+
96
+ ### `O2GServers` — server topology configuration
97
+
98
+ A new `O2GServers` class with a fluent builder replaces the plain
99
+ `{ privateAddress }` object. It supports three deployment topologies:
100
+ standalone, local HA (virtual IP), and geographic HA (two distinct hosts).
101
+
102
+ ```typescript
103
+ // Standalone
104
+ O2GServers.Builder.primaryHost(new Host("10.0.0.1")).build()
105
+
106
+ // Geographic HA — automatic permanent failover to secondary
107
+ O2GServers.Builder
108
+ .primaryHost(new Host("10.0.0.1"))
109
+ .secondaryHost(new Host("10.0.0.2"))
110
+ .build()
111
+ ```
112
+
113
+ ### Geographic HA — automatic permanent failover
114
+
115
+ When a secondary host is configured and the primary becomes unreachable, the
116
+ SDK switches to the secondary immediately and stays there permanently — no
117
+ manual intervention required. The `O2G.O2G_SERVER_SWITCHED` event is emitted
118
+ when the switch occurs.
119
+
120
+ ### `O2G.setLogLevel()` — SDK verbosity control
121
+
122
+ A new static method to control internal SDK logging at runtime:
123
+
124
+ ```typescript
125
+ O2G.setLogLevel(LogLevel.DEBUG); // show all internal traces
126
+ O2G.setLogLevel(LogLevel.NONE); // silent
127
+ ```
128
+
129
+ ### `O2G.currentHost` — active server visibility
130
+
131
+ A new getter exposes which server the SDK is currently connected to:
132
+
133
+ ```typescript
134
+ console.log(`Connected to: ${O2G.currentHost}`);
135
+ ```
136
+
137
+ ---
138
+
53
139
  ## Getting Started
54
140
 
55
141
  New to TypeScript or Node.js? Follow the [Getting Started guide](GETTING_STARTED.md)
56
142
  for a complete step-by-step walkthrough from installing the tools to your first login.
57
143
 
144
+ ## Server Configuration
145
+
146
+ Use `O2GServers` to configure the O2G server topology. Three deployment
147
+ configurations are supported:
148
+
149
+ ### Standalone server
150
+
151
+ ```typescript
152
+ O2G.initialize("MyApp", O2GServers.Builder
153
+ .primaryHost(new Host("10.0.0.1"))
154
+ .build());
155
+ ```
156
+
157
+ ### Local HA (virtual IP)
158
+
159
+ Two O2G server instances sharing the same virtual IP address or URL.
160
+ Configure it exactly like a standalone server — the virtual IP routes
161
+ transparently to whichever node is active:
162
+
163
+ ```typescript
164
+ O2G.initialize("MyApp", O2GServers.Builder
165
+ .primaryHost(new Host("vip.example.com"))
166
+ .build());
167
+ ```
168
+
169
+ ### Geographic HA (two distinct hosts)
170
+
171
+ Two O2G server instances at different locations with distinct IP addresses.
172
+ On primary failure, the SDK switches immediately to the secondary and stays
173
+ there permanently. The {@link O2G.O2G_SERVER_SWITCHED} event is emitted when
174
+ the switch occurs:
175
+
176
+ ```typescript
177
+ O2G.initialize("MyApp", O2GServers.Builder
178
+ .primaryHost(new Host("10.0.0.1"))
179
+ .secondaryHost(new Host("10.0.0.2"))
180
+ .build());
181
+ ```
182
+
183
+ A `Host` can also be configured with both a private and a public address:
184
+
185
+ ```typescript
186
+ new Host("10.0.0.1", "93.12.1.1")
187
+ ```
188
+
189
+ The SDK tries the private address first, then falls back to the public address.
190
+
191
+ ## Session Monitoring and Recovery
192
+
193
+ The SDK automatically handles session failures and recovery. When the O2G server
194
+ crashes or becomes unreachable, the SDK:
195
+
196
+ 1. Detects the failure via the chunk stream or keep-alive
197
+ 2. Notifies the application via the `O2G.O2G_SESSION_LOST` event
198
+ 3. Retries the connection with exponential backoff
199
+ 4. Switches to the secondary server permanently if geographic HA is configured
200
+ 5. Re-subscribes to events after recovery
201
+ 6. Notifies the application via the `O2G.O2G_RECONNECTED` event
202
+
203
+ ### Custom monitoring policy
204
+
205
+ Extend `SessionMonitoringPolicy` to control SDK behaviour and receive
206
+ notifications:
207
+
208
+ ```typescript
209
+ import { O2G, SessionMonitoringPolicy, Behavior, LogLevel } from 'o2g-node-sdk';
210
+
211
+ class MyMonitoringPolicy extends SessionMonitoringPolicy {
212
+
213
+ onConnectError(err: Error): Behavior {
214
+ console.warn(`Connection failed: ${err.message} — retrying in 5s`);
215
+ return Behavior.retryAfter(5_000);
216
+ }
217
+
218
+ onChunkError(err: Error, consecutiveErrors: number): Behavior {
219
+ console.warn(`Chunk error #${consecutiveErrors}: ${err.message}`);
220
+ return Behavior.abort(); // trigger session recovery
221
+ }
222
+
223
+ onSessionLost(reason: string): void {
224
+ console.warn(`Session lost (${reason}) — SDK is recovering...`);
225
+ }
226
+
227
+ onSessionRecovered(): void {
228
+ console.log("Session recovered — back online.");
229
+ }
230
+ }
231
+
232
+ O2G.setMonitoringPolicy(new MyMonitoringPolicy());
233
+ ```
234
+
235
+ Set the policy before calling `O2G.login()`. If not set, the
236
+ `DefaultSessionMonitoringPolicy` is used.
237
+
238
+ ### Session lifecycle events
239
+
240
+ ```typescript
241
+ O2G.on(O2G.O2G_SESSION_LOST, ({ reason }) => {
242
+ console.warn(`Session lost: ${reason} — reconnecting...`);
243
+ });
244
+
245
+ O2G.on(O2G.O2G_RECONNECTED, () => {
246
+ console.log("Session recovered — resuming activity.");
247
+ });
248
+
249
+ O2G.on(O2G.O2G_SERVER_SWITCHED, ({ from, to }) => {
250
+ console.warn(`Switched from ${from} to ${to} permanently.`);
251
+ });
252
+ ```
253
+
254
+ ### Default behaviours
255
+
256
+ | Situation | Default behaviour |
257
+ |---|---|
258
+ | Initial connection fails | Retry after 5 seconds |
259
+ | Chunk network error | Abort → trigger session recovery |
260
+ | Keep-alive network error | Abort → trigger session recovery |
261
+ | Keep-alive rejected by server | Trigger session recovery |
262
+ | Server switched to secondary | Permanent — never switches back |
263
+
264
+ ### Logging
265
+
266
+ Control SDK verbosity using `O2G.setLogLevel()`:
267
+
268
+ ```typescript
269
+ import { O2G, LogLevel } from 'o2g-node-sdk';
270
+
271
+ O2G.setLogLevel(LogLevel.DEBUG); // show all internal SDK traces
272
+ O2G.setLogLevel(LogLevel.INFO); // default
273
+ O2G.setLogLevel(LogLevel.ERROR); // errors only
274
+ O2G.setLogLevel(LogLevel.NONE); // silent
275
+ ```
276
+
58
277
  ## Sessions
59
278
 
60
279
  Three types of sessions are supported:
@@ -62,11 +281,14 @@ Three types of sessions are supported:
62
281
  ### User Session
63
282
 
64
283
  Opened with user credentials. Allows the user to access all user-oriented services.
65
- Most service methods that accept a `loginName` parameter will ignore it in a user session —
66
- the session user is used automatically.
284
+ Most service methods that accept a `loginName` parameter will ignore it in a user
285
+ session — the session user is used automatically.
67
286
 
68
287
  ```typescript
69
- O2G.initialize("MyApp", { privateAddress: "192.168.1.1" });
288
+ O2G.initialize("MyApp", O2GServers.Builder
289
+ .primaryHost(new Host("192.168.1.1"))
290
+ .build());
291
+
70
292
  await O2G.login("jdoe", "password");
71
293
 
72
294
  // loginName is ignored — operates on the session user
@@ -77,10 +299,10 @@ await O2G.routing.activateDnd();
77
299
  ### Administrator Session
78
300
 
79
301
  Opened with administrator credentials. Allows access to all services for any user.
80
- Methods that accept a `loginName` parameter require it to be specified in an administrator session.
302
+ Methods that accept a `loginName` parameter require it to be specified in an
303
+ administrator session.
81
304
 
82
305
  ```typescript
83
- O2G.initialize("MyApp", { privateAddress: "192.168.1.1" });
84
306
  await O2G.login("admin", "password");
85
307
 
86
308
  // loginName is mandatory in an administrator session
@@ -93,12 +315,13 @@ await O2G.callCenterAgent.getState("agent01");
93
315
 
94
316
  Opened with administrator credentials combined with a supervised user identity.
95
317
  Behaves exactly like a user session for the supervised user — `loginName` is ignored.
96
- This allows an application to use user-oriented services on behalf of a specific user.
97
318
 
98
319
  ```typescript
99
- import { O2G, SupervisedAccount } from 'o2g-node-sdk';
320
+ import { O2G, O2GServers, Host, SupervisedAccount } from 'o2g-node-sdk';
100
321
 
101
- O2G.initialize("MyApp", { privateAddress: "192.168.1.1" });
322
+ O2G.initialize("MyApp", O2GServers.Builder
323
+ .primaryHost(new Host("192.168.1.1"))
324
+ .build());
102
325
 
103
326
  // Open a supervised session on behalf of jdoe
104
327
  await O2G.login("admin", "password", new SupervisedAccount("jdoe"));
@@ -108,6 +331,50 @@ await O2G.telephony.getCalls();
108
331
  await O2G.routing.activateDnd();
109
332
  ```
110
333
 
334
+ ## Event Subscription
335
+
336
+ ### Chunk eventing (default)
337
+
338
+ The SDK opens an outgoing HTTPS connection to the O2G server and receives events
339
+ as a stream. No server-side endpoint is required from the application.
340
+
341
+ ```typescript
342
+ const subscription = Subscription.Builder
343
+ .addTelephonyEvents([])
344
+ .addRoutingEvents([])
345
+ .setTimeout(10)
346
+ .build();
347
+
348
+ await O2G.subscribe(subscription);
349
+ ```
350
+
351
+ ### Webhook eventing
352
+
353
+ The O2G server sends events via HTTP POST to a URL provided by the application.
354
+ The application must expose an HTTPS endpoint and implement the `WebHook` interface:
355
+
356
+ ```typescript
357
+ import { O2G, Subscription, WebHook, EventDispatcher } from 'o2g-node-sdk';
358
+
359
+ const myWebHook: WebHook = {
360
+ url: "https://myapp.example.com/o2g/events",
361
+ connectDispatcher: (dispatcher: EventDispatcher) => {
362
+ myDispatcher = dispatcher;
363
+ }
364
+ };
365
+
366
+ const subscription = Subscription.Builder
367
+ .addMaintenanceEvents()
368
+ .setWebHook(myWebHook)
369
+ .build();
370
+
371
+ await O2G.subscribe(subscription);
372
+ ```
373
+
374
+ The SDK provides no built-in HTTP server — the application is responsible for
375
+ exposing the endpoint. See the [webhook examples](examples/webhook) for complete
376
+ working examples with common frameworks.
377
+
111
378
  ## Services
112
379
 
113
380
  | Service | Description | License Required |
@@ -123,7 +390,7 @@ await O2G.routing.activateDnd();
123
390
  | `O2G.callCenterPilot` | CCD pilot monitoring | `CONTACTCENTER_SVCS` |
124
391
  | `O2G.callCenterRealtime` | Real-time ACD statistics | `CONTACTCENTER_SVCS` |
125
392
  | `O2G.callCenterStatistics` | Historical ACD statistics | `CONTACTCENTER_SVCS` |
126
- | `O2G.callCenterManagement` | CCD pilot and calendar management | `CONTACTCENTER_SRV` |
393
+ | `O2G.callCenterManagement` | CCD pilot and calendar management | `CONTACTCENTER_SVCS` |
127
394
  | `O2G.maintenance` | System status and PBX health | — |
128
395
  | `O2G.pbxManagement` | PBX object model management | `MANAGEMENT` |
129
396
  | `O2G.phoneSetProgramming` | Phone device keys and settings | — |
@@ -135,7 +402,8 @@ await O2G.routing.activateDnd();
135
402
  ### Forward calls to voicemail when busy
136
403
 
137
404
  ```typescript
138
- import { O2G, ForwardCondition } from 'o2g-node-sdk';
405
+ import { O2G } from 'o2g-node-sdk';
406
+ import { ForwardCondition } from 'o2g-node-sdk';
139
407
 
140
408
  await O2G.routing.forwardOnVoiceMail(ForwardCondition.BUSY);
141
409
  ```
@@ -173,7 +441,6 @@ await O2G.callCenterPilot.monitorStart("60141");
173
441
  ```typescript
174
442
  import { O2G, Criteria, FilterItem, OperationFilter, SearchResult } from 'o2g-node-sdk';
175
443
 
176
- // Search users whose last name begins with "Smith"
177
444
  const criteria = Criteria.create(FilterItem.LAST_NAME, OperationFilter.BEGINS_WITH, "Smith");
178
445
  await O2G.directory.search(criteria, 10);
179
446
 
@@ -181,15 +448,13 @@ let finished = false;
181
448
  while (!finished) {
182
449
  const result = await O2G.directory.getResults();
183
450
  if (result?.status === SearchResult.Status.NOK) {
184
- // Search still in progress — wait before retrying
185
451
  await new Promise(resolve => setTimeout(resolve, 500));
186
452
  } else if (result?.status === SearchResult.Status.OK) {
187
- // Process available results
188
453
  result.items?.forEach(item => {
189
- item.contacts?.forEach(contact => console.log(contact.firstName, contact.lastName));
454
+ item.contacts?.forEach(contact =>
455
+ console.log(contact.firstName, contact.lastName));
190
456
  });
191
457
  } else {
192
- // FINISH or TIMEOUT — search is complete
193
458
  finished = true;
194
459
  }
195
460
  }
@@ -229,6 +494,35 @@ await O2G.callCenterAgent.logon("acd001", "pg001");
229
494
  await O2G.callCenterAgent.setReady();
230
495
  ```
231
496
 
497
+ ### Configure geographic HA
498
+
499
+ ```typescript
500
+ import { O2G, O2GServers, Host } from 'o2g-node-sdk';
501
+
502
+ O2G.initialize("MyApp", O2GServers.Builder
503
+ .primaryHost(new Host("10.0.0.1"))
504
+ .secondaryHost(new Host("10.0.0.2"))
505
+ .build());
506
+
507
+ O2G.on(O2G.O2G_SERVER_SWITCHED, ({ from, to }) => {
508
+ console.warn(`Switched from ${from} to ${to} permanently.`);
509
+ });
510
+ ```
511
+
512
+ ## Migration from previous versions
513
+
514
+ If you were using the old `{ privateAddress }` syntax, update your code as follows:
515
+
516
+ ```typescript
517
+ // Before
518
+ O2G.initialize("MyApp", { privateAddress: "10.0.0.1" });
519
+
520
+ // After
521
+ O2G.initialize("MyApp", O2GServers.Builder
522
+ .primaryHost(new Host("10.0.0.1"))
523
+ .build());
524
+ ```
525
+
232
526
  ## API Reference
233
527
 
234
528
  - [O2G REST API Reference](https://api.dspp.al-enterprise.com/o2g/)
@@ -241,7 +535,7 @@ This SDK follows the O2G API version it targets:
241
535
  - **Minor**: O2G API patch version (currently 7.5 → 5)
242
536
  - **Patch**: SDK release number
243
537
 
244
- For example, `2.5.0` targets O2G API version 2.7.5.
538
+ For example, `2.5.5` targets O2G API version 2.7.5.
245
539
 
246
540
  ## License
247
541