ironflock 1.0.2 → 1.2.1

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
@@ -1,2 +1,169 @@
1
- import { IronFlock } from "./ironflock";
2
- export = IronFlock;
1
+ import { default as default_2 } from 'autobahn';
2
+ import { default as default_3 } from 'typia';
3
+ import { EventEmitter } from 'eventemitter3';
4
+ import { IRegistration } from 'autobahn';
5
+ import { StandardSchemaV1 } from '@standard-schema/spec';
6
+ import { Subscription } from 'autobahn';
7
+ import { tags } from 'typia';
8
+
9
+ export declare type AuthPayload = {
10
+ success: boolean;
11
+ role: string;
12
+ realm: string;
13
+ authid: string;
14
+ extra: {
15
+ username: string;
16
+ };
17
+ };
18
+
19
+ export declare interface CallParams {
20
+ deviceKey: string & tags.MinLength<1>;
21
+ topic: string & tags.MinLength<1>;
22
+ args?: unknown[];
23
+ kwargs?: Record<string, unknown>;
24
+ }
25
+
26
+ export declare class CrossbarConnection extends EventEmitter {
27
+ session?: default_2.Session;
28
+ connection?: default_2.Connection;
29
+ serial_number?: string;
30
+ socketURI?: string;
31
+ realm?: string;
32
+ private subscriptions;
33
+ private registrations;
34
+ private firstConnection?;
35
+ private firstResolver;
36
+ private firstRejecter;
37
+ constructor();
38
+ static getWebSocketURI(reswarmUrl?: string): string;
39
+ configure(swarmKey: number, appKey: number, stage: Stage, serialNumber: string, cburl?: string): void;
40
+ start(): Promise<void>;
41
+ private onOpen;
42
+ private onClose;
43
+ private sessionWait;
44
+ waitForConnection(): Promise<void | undefined>;
45
+ getSession(): default_2.Session | undefined;
46
+ get is_open(): boolean;
47
+ isConnected(): boolean;
48
+ stop(): void;
49
+ subscribe(topic: string, handler: default_2.SubscribeHandler): Promise<default_2.Subscription | undefined>;
50
+ unsubscribe(sub: default_2.Subscription): Promise<void>;
51
+ unsubscribeTopic(topic: string): Promise<void>;
52
+ private resubscribeAll;
53
+ register(topic: string, endpoint: default_2.RegisterEndpoint): Promise<default_2.IRegistration | undefined>;
54
+ unregister(registration: default_2.Registration): Promise<void>;
55
+ call<T>(procedure: string, args?: any[], kwargs?: object, options?: any): Promise<T | undefined>;
56
+ publish(topic: string, args?: any[], kwargs?: object, options?: any): Promise<default_2.IPublication | undefined>;
57
+ }
58
+
59
+ export declare type Details = {
60
+ caller_authid: string;
61
+ caller_authrole: string;
62
+ };
63
+
64
+ export declare class IronFlock {
65
+ private _connection;
66
+ private _serialNumber;
67
+ private _deviceName?;
68
+ private _deviceKey?;
69
+ private _appName?;
70
+ private _swarmKey;
71
+ private _appKey;
72
+ private _env?;
73
+ private _isConfigured;
74
+ private _reswarmUrl?;
75
+ private _cburl?;
76
+ constructor(options?: IronFlockOptions);
77
+ get connection(): CrossbarConnection;
78
+ get isConnected(): boolean;
79
+ private configureConnection;
80
+ start(cburl?: string): Promise<void>;
81
+ stop(): Promise<void>;
82
+ publish(topic: string, args?: unknown[], kwargs?: Record<string, unknown>): Promise<unknown>;
83
+ publishToTable(tablename: string, args?: unknown[], kwargs?: Record<string, unknown>): Promise<unknown>;
84
+ subscribe(topic: string, handler: (...args: any[]) => void, options?: object): Promise<Subscription<any[], any, string> | undefined>;
85
+ subscribeToTable(tablename: string, handler: (...args: any[]) => void, options?: object): Promise<Subscription<any[], any, string> | undefined>;
86
+ call(deviceKey: string, topic: string, args?: unknown[], kwargs?: Record<string, unknown>, options?: object): Promise<unknown>;
87
+ registerFunction(topic: string, endpoint: (...args: any[]) => any, options?: object): Promise<IRegistration<any, any[], any, string> | undefined>;
88
+ register(topic: string, endpoint: (...args: any[]) => any, options?: object): Promise<IRegistration<any, any[], any, string> | undefined>;
89
+ getHistory(tablename: string, queryParams?: TableQueryParams): Promise<unknown>;
90
+ setDeviceLocation(long: number, lat: number): Promise<unknown>;
91
+ getRemoteAccessUrlForPort(port: number): string | null;
92
+ /**
93
+ * Create an IronFlock instance by fetching configuration from a server endpoint.
94
+ * The endpoint should return JSON matching `IronFlockOptions`.
95
+ *
96
+ * Useful in browser environments where config is provided by a backend:
97
+ * ```ts
98
+ * const flock = await IronFlock.fromServer("/api/ironflock-config");
99
+ * await flock.start();
100
+ * ```
101
+ */
102
+ static fromServer(url: string): Promise<IronFlock>;
103
+ }
104
+
105
+ export declare interface IronFlockOptions {
106
+ serialNumber?: string;
107
+ deviceName?: string;
108
+ deviceKey?: string;
109
+ appName?: string;
110
+ swarmKey?: number;
111
+ appKey?: number;
112
+ env?: string;
113
+ /** URL of the IronFlock studio instance (e.g. "https://studio.ironflock.com") used to resolve the WebSocket URI. */
114
+ reswarmUrl?: string;
115
+ /** Direct WebSocket URI override (e.g. "wss://cbw.ironflock.com/ws-ua-usr"). Takes precedence over reswarmUrl. */
116
+ cburl?: string;
117
+ }
118
+
119
+ export declare interface ISOTimeRange {
120
+ start: string & tags.Format<"date-time">;
121
+ end: string & tags.Format<"date-time">;
122
+ }
123
+
124
+ export declare interface LocationParams {
125
+ longitude: number & tags.Minimum<-180> & tags.Maximum<180>;
126
+ latitude: number & tags.Minimum<-90> & tags.Maximum<90>;
127
+ }
128
+
129
+ export declare interface PublishParams {
130
+ topic: string & tags.MinLength<1>;
131
+ args?: unknown[];
132
+ kwargs?: Record<string, unknown>;
133
+ }
134
+
135
+ export declare interface SQLFilterAnd {
136
+ column: string & tags.MinLength<1>;
137
+ operator: string & tags.MinLength<1>;
138
+ value: string | number | boolean | Array<string | number>;
139
+ }
140
+
141
+ export declare enum Stage {
142
+ DEVELOPMENT = "dev",
143
+ PRODUCTION = "prod"
144
+ }
145
+
146
+ export declare interface TableParams {
147
+ tablename: string & tags.MinLength<1>;
148
+ args?: unknown[];
149
+ kwargs?: Record<string, unknown>;
150
+ }
151
+
152
+ export declare interface TableQueryParams {
153
+ limit: number & tags.Type<"uint32"> & tags.Minimum<1> & tags.Maximum<10000>;
154
+ offset?: number & tags.Type<"uint32"> & tags.Minimum<0>;
155
+ timeRange?: ISOTimeRange;
156
+ filterAnd?: SQLFilterAnd[];
157
+ }
158
+
159
+ export declare const validateCallParams: ((input: unknown) => default_3.IValidation<CallParams>) & StandardSchemaV1<CallParams, CallParams>;
160
+
161
+ export declare const validateLocationParams: ((input: unknown) => default_3.IValidation<LocationParams>) & StandardSchemaV1<LocationParams, LocationParams>;
162
+
163
+ export declare const validatePublishParams: ((input: unknown) => default_3.IValidation<PublishParams>) & StandardSchemaV1<PublishParams, PublishParams>;
164
+
165
+ export declare const validateTableParams: ((input: unknown) => default_3.IValidation<TableParams>) & StandardSchemaV1<TableParams, TableParams>;
166
+
167
+ export declare const validateTableQueryParams: ((input: unknown) => default_3.IValidation<TableQueryParams>) & StandardSchemaV1<TableQueryParams, TableQueryParams>;
168
+
169
+ export { }