ironflock 1.5.2 → 1.6.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.
package/dist/index.d.ts CHANGED
@@ -5,6 +5,14 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
5
5
  import { Subscription } from 'autobahn';
6
6
  import { tags } from 'typia';
7
7
 
8
+ /**
9
+ * Rejects a `latest` marker (or a legacy latest_flag predicate) in series
10
+ * query filters before the request reaches the backend: the series SQL path
11
+ * has no latest-per-entity mode and would generate invalid SQL. Read current
12
+ * values with getHistory and `filterAnd: [{ latest: true }]` instead.
13
+ */
14
+ export declare function assertNoLatestMarker(params: SeriesQueryParams | null | undefined): void;
15
+
8
16
  export declare type AuthPayload = {
9
17
  success: boolean;
10
18
  role: string;
@@ -87,9 +95,20 @@ export declare class ConsumedApp {
87
95
  * so caller code always sees the single-row shape.
88
96
  */
89
97
  subscribeToTable(tablename: string, handler: (...args: any[]) => void, options?: object): Promise<Subscription<any[], any, string> | undefined>;
90
- /** Queries history rows of a shared table or transform. */
98
+ /**
99
+ * Queries history rows of a shared table or transform. To read the CURRENT
100
+ * value(s), add the `latest` marker to the filters:
101
+ * `{ filterAnd: [{ latest: true }], limit: 100 }` — the provider's data
102
+ * backend derives the latest row per entity in SQL (the physical
103
+ * `latest_flag` column no longer exists).
104
+ */
91
105
  getHistory(tablename: string, queryParams?: TableQueryParams): Promise<unknown>;
92
- /** Queries down-sampled series history of a shared table (tables only — no series RPC exists for transforms). */
106
+ /**
107
+ * Queries down-sampled series history of a shared table (tables only — no
108
+ * series RPC exists for transforms). Series queries do not support the
109
+ * `latest` marker; use {@link getHistory} with
110
+ * `filterAnd: [{ latest: true }]` to read current values.
111
+ */
93
112
  getSeriesHistory(tablename: string, params: SeriesQueryParams): Promise<unknown>;
94
113
  /** Closes the underlying connection to the provider's realm. */
95
114
  close(): Promise<void>;
@@ -150,6 +169,10 @@ export declare class CrossbarConnection extends EventEmitter {
150
169
  private onOpen;
151
170
  private onClose;
152
171
  private handleManualReconnect;
172
+ /**
173
+ * Waits for an open session; `context` names the pending operation so the
174
+ * timeout error explains what could not be performed and why.
175
+ */
153
176
  private sessionWait;
154
177
  waitForConnection(): Promise<void | undefined>;
155
178
  getSession(): default_2.Session | undefined;
@@ -163,8 +186,8 @@ export declare class CrossbarConnection extends EventEmitter {
163
186
  private reregisterAll;
164
187
  register(topic: string, endpoint: default_2.RegisterEndpoint, options?: default_2.IRegisterOptions): Promise<default_2.IRegistration | undefined>;
165
188
  unregister(registration: default_2.Registration): Promise<void>;
166
- call<T>(procedure: string, args?: any[], kwargs?: object, options?: any): Promise<T | undefined>;
167
- publish(topic: string, args?: any[], kwargs?: object, options?: any): Promise<default_2.IPublication | undefined>;
189
+ call<T>(procedure: string, args?: any[], kwargs?: object, options?: any): Promise<T>;
190
+ publish(topic: string, args?: any[], kwargs?: object, options?: any): Promise<default_2.IPublication>;
168
191
  }
169
192
 
170
193
  export declare type Details = {
@@ -297,15 +320,70 @@ export declare class IronFlock {
297
320
  /** @deprecated Use registerDeviceFunction() instead. */
298
321
  registerFunction(topic: string, endpoint: (...args: any[]) => any, options?: default_2.IRegisterOptions): Promise<default_2.IRegistration<any, any[], any, string> | undefined>;
299
322
  register(topic: string, endpoint: (...args: any[]) => any, options?: default_2.IRegisterOptions): Promise<default_2.IRegistration<any, any[], any, string> | undefined>;
323
+ /**
324
+ * Queries history rows of an own table or transform via
325
+ * `history.transformed.{tablename}`.
326
+ *
327
+ * To read the CURRENT value(s) instead of raw history, add the `latest`
328
+ * marker to `filterAnd`: `{ filterAnd: [{ latest: true }], limit: 100 }`.
329
+ * The data backend then derives the latest row per entity in SQL (the
330
+ * entity key is the table's `maintainLatestFlagFor` columns; without one,
331
+ * the single most recent row is returned). The former physical
332
+ * `latest_flag` column no longer exists.
333
+ *
334
+ * @throws {Error} on invalid parameters, when the history procedure is not
335
+ * registered (table missing / data backend down), or when the call fails.
336
+ */
300
337
  getHistory(tablename: string, queryParams?: TableQueryParams): Promise<unknown>;
301
338
  /**
302
339
  * Queries down-sampled series history of an own table by calling
303
340
  * `history.transformed.series.{tablename}` (tables only — no series RPC
304
- * exists for transforms).
341
+ * exists for transforms). Series queries do not support the `latest`
342
+ * marker; use {@link getHistory} with `filterAnd: [{ latest: true }]` to
343
+ * read current values.
344
+ *
345
+ * @throws {Error} on invalid parameters, when the series procedure is not
346
+ * registered (table missing / data backend down), or when the call fails.
305
347
  */
306
348
  getSeriesHistory(tablename: string, params: SeriesQueryParams): Promise<unknown>;
349
+ /**
350
+ * Updates the device's location in the platform master data.
351
+ *
352
+ * @throws {Error} on invalid coordinates or when the location service call
353
+ * fails (e.g. not connected).
354
+ */
307
355
  setDeviceLocation(long: number, lat: number): Promise<unknown>;
308
- getRemoteAccessUrlForPort(port: number): string | null;
356
+ /**
357
+ * Public URL under which a declared port (port-template.yml) is reachable
358
+ * from the internet once its tunnel is active.
359
+ *
360
+ * For `http`/`https` ports, composes the platform's tunnel label
361
+ * `{device_key}-{app_name}-{port}` (`https` ports carry the platform's
362
+ * `secure-` prefix) on the tunnel domain the device agent injects
363
+ * (`TUNNEL_DOMAIN`; the cloud edge, or the operator's appliance domain).
364
+ * On devices that belong to an instance (appliance), the agent injects
365
+ * `INSTANCE_KEY` and the cloud-forwarded route
366
+ * `https://i{instance_key}-{label}.{cloud edge}` is returned instead —
367
+ * reachable while the instance forwards its tunnels to the cloud.
368
+ *
369
+ * For `tcp`/`udp` ports, the URL uses the tunnel-assigned public port,
370
+ * which the platform injects under the port-template's
371
+ * `remote_port_environment` name — pass that name here. On instance
372
+ * devices the internet-facing port arrives as `{name}_CLOUD`; when it is
373
+ * not (yet) present, the instance-local URL built from `{name}` is
374
+ * returned as a fallback.
375
+ *
376
+ * Port values are read live from the agent-maintained files under
377
+ * `/data/env` (falling back to the process environment), so this method
378
+ * returns the CURRENT url: the instance cloud port is allocated shortly
379
+ * after the tunnel first connects and appears here within seconds — call
380
+ * the method again rather than caching its result.
381
+ *
382
+ * Returns null when the identity or required env vars are unavailable,
383
+ * the protocol is unknown, or the label is not a valid DNS label (longer
384
+ * than 63 characters, or a dot in the app name).
385
+ */
386
+ getRemoteAccessUrlForPort(port: number, protocol?: string, remotePortEnvironment?: string): string | null;
309
387
  /**
310
388
  * Create an IronFlock instance by fetching configuration from a server endpoint.
311
389
  * The endpoint should return JSON matching `IronFlockOptions`.
@@ -340,6 +418,20 @@ export declare interface ISOTimeRange {
340
418
  end: string & tags.Format<"date-time">;
341
419
  }
342
420
 
421
+ /**
422
+ * Mode marker for `filterAnd`: requests "latest row per entity" instead of
423
+ * adding a WHERE predicate. fleetdb derives the latest rows in SQL
424
+ * (DISTINCT ON over the entity key the table declares via
425
+ * `maintainLatestFlagFor` in its data-template; a table without an entity key
426
+ * yields the single most recent row). Replaces the removed physical
427
+ * `latest_flag` column — a legacy `{column: "latest_flag", operator: "=",
428
+ * value: true}` predicate is still accepted by the server and treated as this
429
+ * marker.
430
+ */
431
+ export declare interface LatestMarker {
432
+ latest: true;
433
+ }
434
+
343
435
  export declare interface LocationParams {
344
436
  longitude: number & tags.Minimum<-180> & tags.Maximum<180>;
345
437
  latitude: number & tags.Minimum<-90> & tags.Maximum<90>;
@@ -380,6 +472,7 @@ export declare interface SeriesQueryParams {
380
472
  /** Required — the series RPC rejects queries without a time range. */
381
473
  timeRange: SeriesTimeRange;
382
474
  groupBy?: string[] | null;
475
+ /** WHERE predicates only — the `latest` marker is not supported in series queries. */
383
476
  filterAnd?: SQLFilterAnd[] | null;
384
477
  }
385
478
 
@@ -400,6 +493,9 @@ export declare enum Stage {
400
493
  PRODUCTION = "prod"
401
494
  }
402
495
 
496
+ /** One entry of `filterAnd`: a WHERE predicate or the `latest` mode marker. */
497
+ export declare type TableFilter = SQLFilterAnd | LatestMarker;
498
+
403
499
  export declare interface TableParams {
404
500
  tablename: string & tags.MinLength<1>;
405
501
  args?: unknown[];
@@ -410,7 +506,12 @@ export declare interface TableQueryParams {
410
506
  limit: number & tags.Type<"uint32"> & tags.Minimum<1> & tags.Maximum<10000>;
411
507
  offset?: number & tags.Type<"uint32"> & tags.Minimum<0>;
412
508
  timeRange?: ISOTimeRange;
413
- filterAnd?: SQLFilterAnd[];
509
+ filterAnd?: TableFilter[];
510
+ /**
511
+ * Columns to return (the system columns tsp, device_key and authid are
512
+ * always included). Omit for all columns.
513
+ */
514
+ columns?: string[];
414
515
  }
415
516
 
416
517
  export declare const validateBulkTableParams: ((input: unknown) => default_3.IValidation<BulkTableParams>) & StandardSchemaV1<BulkTableParams, BulkTableParams>;
@@ -427,4 +528,19 @@ export declare const validateTableParams: ((input: unknown) => default_3.IValida
427
528
 
428
529
  export declare const validateTableQueryParams: ((input: unknown) => default_3.IValidation<TableQueryParams>) & StandardSchemaV1<TableQueryParams, TableQueryParams>;
429
530
 
531
+ /**
532
+ * Error thrown when a WAMP operation (call/publish/subscribe/register) is
533
+ * rejected by the router or the remote handler. autobahn rejects with a plain
534
+ * `{error: <uri>, args, kwargs}` object that is not a native Error and prints
535
+ * as "[object Object]" — this preserves the WAMP error URI and payload while
536
+ * giving callers a readable message and a stack trace.
537
+ */
538
+ export declare class WampError extends Error {
539
+ /** WAMP error URI, e.g. "wamp.error.no_such_procedure". */
540
+ readonly error: string;
541
+ readonly args: unknown[];
542
+ readonly kwargs: Record<string, unknown>;
543
+ constructor(message: string, uri: string, args?: unknown[], kwargs?: Record<string, unknown>);
544
+ }
545
+
430
546
  export { }