@iotopen/react-lynx 1.0.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/LICENSE +202 -0
- package/README.md +51 -0
- package/dist/cjs/Contexts/LynxClientProvider.d.ts +14 -0
- package/dist/cjs/Contexts/LynxProvider.d.ts +8 -0
- package/dist/cjs/Contexts/UserProvider.d.ts +19 -0
- package/dist/cjs/Contexts/index.d.ts +3 -0
- package/dist/cjs/Hooks/index.d.ts +38 -0
- package/dist/cjs/Hooks/useConfiguredEdgeApps.d.ts +7 -0
- package/dist/cjs/Hooks/useDevice.d.ts +15 -0
- package/dist/cjs/Hooks/useDevices.d.ts +10 -0
- package/dist/cjs/Hooks/useEdgeApp.d.ts +8 -0
- package/dist/cjs/Hooks/useEdgeAppVersions.d.ts +8 -0
- package/dist/cjs/Hooks/useEdgeApps.d.ts +7 -0
- package/dist/cjs/Hooks/useFunction.d.ts +15 -0
- package/dist/cjs/Hooks/useFunctions.d.ts +10 -0
- package/dist/cjs/Hooks/useIDTokenAlgorithms.d.ts +7 -0
- package/dist/cjs/Hooks/useInstallation.d.ts +9 -0
- package/dist/cjs/Hooks/useInstallationInfo.d.ts +7 -0
- package/dist/cjs/Hooks/useInstallations.d.ts +7 -0
- package/dist/cjs/Hooks/useMeta.d.ts +15 -0
- package/dist/cjs/Hooks/useNewDevice.d.ts +12 -0
- package/dist/cjs/Hooks/useNewFunction.d.ts +12 -0
- package/dist/cjs/Hooks/useNewInstallation.d.ts +12 -0
- package/dist/cjs/Hooks/useNewNotificationMessage.d.ts +11 -0
- package/dist/cjs/Hooks/useNewNotificationOutput.d.ts +15 -0
- package/dist/cjs/Hooks/useNewOAuth2Client.d.ts +22 -0
- package/dist/cjs/Hooks/useNewOrganization.d.ts +18 -0
- package/dist/cjs/Hooks/useNewUser.d.ts +27 -0
- package/dist/cjs/Hooks/useNotificationMessage.d.ts +10 -0
- package/dist/cjs/Hooks/useNotificationMessages.d.ts +7 -0
- package/dist/cjs/Hooks/useNotificationOutput.d.ts +10 -0
- package/dist/cjs/Hooks/useNotificationOutputExecutor.d.ts +8 -0
- package/dist/cjs/Hooks/useNotificationOutputExecutors.d.ts +7 -0
- package/dist/cjs/Hooks/useNotificationOutputs.d.ts +7 -0
- package/dist/cjs/Hooks/useOAuth2Client.d.ts +10 -0
- package/dist/cjs/Hooks/useOAuth2Clients.d.ts +7 -0
- package/dist/cjs/Hooks/useOAuth2Consent.d.ts +5 -0
- package/dist/cjs/Hooks/useOrganization.d.ts +10 -0
- package/dist/cjs/Hooks/useOrganizations.d.ts +9 -0
- package/dist/cjs/Hooks/usePahoMQTTClient.d.ts +16 -0
- package/dist/cjs/Hooks/useRoles.d.ts +7 -0
- package/dist/cjs/Hooks/useSimpleMQTT.d.ts +12 -0
- package/dist/cjs/Hooks/useTokens.d.ts +9 -0
- package/dist/cjs/Hooks/useUser.d.ts +10 -0
- package/dist/cjs/Hooks/useUsers.d.ts +8 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +17 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.d.ts +1 -0
- package/dist/esm/Contexts/LynxClientProvider.d.ts +14 -0
- package/dist/esm/Contexts/LynxProvider.d.ts +8 -0
- package/dist/esm/Contexts/UserProvider.d.ts +19 -0
- package/dist/esm/Contexts/index.d.ts +3 -0
- package/dist/esm/Hooks/index.d.ts +38 -0
- package/dist/esm/Hooks/useConfiguredEdgeApps.d.ts +7 -0
- package/dist/esm/Hooks/useDevice.d.ts +15 -0
- package/dist/esm/Hooks/useDevices.d.ts +10 -0
- package/dist/esm/Hooks/useEdgeApp.d.ts +8 -0
- package/dist/esm/Hooks/useEdgeAppVersions.d.ts +8 -0
- package/dist/esm/Hooks/useEdgeApps.d.ts +7 -0
- package/dist/esm/Hooks/useFunction.d.ts +15 -0
- package/dist/esm/Hooks/useFunctions.d.ts +10 -0
- package/dist/esm/Hooks/useIDTokenAlgorithms.d.ts +7 -0
- package/dist/esm/Hooks/useInstallation.d.ts +9 -0
- package/dist/esm/Hooks/useInstallationInfo.d.ts +7 -0
- package/dist/esm/Hooks/useInstallations.d.ts +7 -0
- package/dist/esm/Hooks/useMeta.d.ts +15 -0
- package/dist/esm/Hooks/useNewDevice.d.ts +12 -0
- package/dist/esm/Hooks/useNewFunction.d.ts +12 -0
- package/dist/esm/Hooks/useNewInstallation.d.ts +12 -0
- package/dist/esm/Hooks/useNewNotificationMessage.d.ts +11 -0
- package/dist/esm/Hooks/useNewNotificationOutput.d.ts +15 -0
- package/dist/esm/Hooks/useNewOAuth2Client.d.ts +22 -0
- package/dist/esm/Hooks/useNewOrganization.d.ts +18 -0
- package/dist/esm/Hooks/useNewUser.d.ts +27 -0
- package/dist/esm/Hooks/useNotificationMessage.d.ts +10 -0
- package/dist/esm/Hooks/useNotificationMessages.d.ts +7 -0
- package/dist/esm/Hooks/useNotificationOutput.d.ts +10 -0
- package/dist/esm/Hooks/useNotificationOutputExecutor.d.ts +8 -0
- package/dist/esm/Hooks/useNotificationOutputExecutors.d.ts +7 -0
- package/dist/esm/Hooks/useNotificationOutputs.d.ts +7 -0
- package/dist/esm/Hooks/useOAuth2Client.d.ts +10 -0
- package/dist/esm/Hooks/useOAuth2Clients.d.ts +7 -0
- package/dist/esm/Hooks/useOAuth2Consent.d.ts +5 -0
- package/dist/esm/Hooks/useOrganization.d.ts +10 -0
- package/dist/esm/Hooks/useOrganizations.d.ts +9 -0
- package/dist/esm/Hooks/usePahoMQTTClient.d.ts +16 -0
- package/dist/esm/Hooks/useRoles.d.ts +7 -0
- package/dist/esm/Hooks/useSimpleMQTT.d.ts +12 -0
- package/dist/esm/Hooks/useTokens.d.ts +9 -0
- package/dist/esm/Hooks/useUser.d.ts +10 -0
- package/dist/esm/Hooks/useUsers.d.ts +8 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.d.ts +1 -0
- package/dist/index.d.ts +439 -0
- package/package.json +52 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { DependencyList, ReactNode } from 'react';
|
|
3
|
+
import * as _iotopen_node_lynx from '@iotopen/node-lynx';
|
|
4
|
+
import { MetaObject, WithMeta, InstallationInfo, ErrorResponse, Token, EmptyToken, Metadata, EmptyFunctionx, Functionx, OKResponse, Installation, EmptyInstallation, EmptyDevicex, Devicex, EdgeAppInstance, EdgeApp, EdgeAppVersion, EmptyOAuth2Client, OAuth2Client, Organization, MinimalOrg, Address, OrganizationChild, EmptyOrganization, EmptyUser, User, Role, EmptyNotificationMessage, NotificationMessage, EmptyNotificationOutput, NotificationOutput, NotificationOutputExecutor, LynxClient } from '@iotopen/node-lynx';
|
|
5
|
+
import Paho, { Qos, TypedArray } from 'paho-mqtt';
|
|
6
|
+
import { Address as Address$1 } from '@iotopen/node-lynx/src/types';
|
|
7
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
type MetaElement = MetaObject & {
|
|
10
|
+
key: string;
|
|
11
|
+
};
|
|
12
|
+
declare const useMeta: (obj?: WithMeta, deps?: DependencyList) => {
|
|
13
|
+
metaList: MetaElement[];
|
|
14
|
+
compile: () => WithMeta;
|
|
15
|
+
addMeta: (e?: MetaElement) => void;
|
|
16
|
+
removeMeta: (idx: number) => void;
|
|
17
|
+
setMeta: (idx: number, e: MetaElement) => void;
|
|
18
|
+
setMetaKey: (idx: number, key: string) => void;
|
|
19
|
+
setMetaValue: (idx: number, value: string) => void;
|
|
20
|
+
setMetaProtected: (idx: number, value: boolean) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
declare const useInstallationInfo: (assignedOnly?: boolean) => {
|
|
24
|
+
installations: InstallationInfo[];
|
|
25
|
+
refresh: () => void;
|
|
26
|
+
loading: boolean;
|
|
27
|
+
error: ErrorResponse | undefined;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
interface MQTTHandlers {
|
|
31
|
+
onMessage?: Paho.OnMessageHandler;
|
|
32
|
+
onDelivery?: Paho.OnMessageHandler;
|
|
33
|
+
onConnected?: Paho.OnConnectHandler;
|
|
34
|
+
onDisconnect?: Paho.OnConnectionLostHandler;
|
|
35
|
+
}
|
|
36
|
+
declare const usePahoMQTTClient: (uri: string, handlers?: MQTTHandlers, connectionOptions?: Paho.ConnectionOptions, clientId?: string) => {
|
|
37
|
+
client: react.MutableRefObject<Paho.Client>;
|
|
38
|
+
connected: boolean;
|
|
39
|
+
error: Paho.MQTTError | undefined;
|
|
40
|
+
sub: (topic: string, qos?: Qos) => Promise<Paho.Qos>;
|
|
41
|
+
pub: (topic: string, payload: string | TypedArray, qos?: Qos, retained?: boolean) => void;
|
|
42
|
+
unsub: (topic: string) => Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type Binding = (topic: string, payload: string, qos: Qos, retained: boolean) => void;
|
|
46
|
+
declare const useSimpleMQTT: (uri?: string, username?: string, password?: string) => {
|
|
47
|
+
setSubs: (s: string[]) => void;
|
|
48
|
+
error: Paho.MQTTError | undefined;
|
|
49
|
+
connected: boolean;
|
|
50
|
+
bind: (topic: RegExp | string, binder: Binding) => void;
|
|
51
|
+
unbind: (binder: Binding) => void;
|
|
52
|
+
bindExact: (topic: string, binder: Binding) => void;
|
|
53
|
+
unbindExact: (topic: string, binder: Binding) => void;
|
|
54
|
+
pub: (topic: string, payload: string | Paho.TypedArray, qos?: Paho.Qos | undefined, retained?: boolean | undefined) => void;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
declare const useTokens: () => {
|
|
58
|
+
tokens: Token[];
|
|
59
|
+
remove: (token: Token) => Promise<_iotopen_node_lynx.OKResponse>;
|
|
60
|
+
create: (token: EmptyToken) => Promise<Token>;
|
|
61
|
+
refresh: () => void;
|
|
62
|
+
loading: boolean;
|
|
63
|
+
error: ErrorResponse | undefined;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type FunctionTemplate = {
|
|
67
|
+
type?: string;
|
|
68
|
+
meta?: Metadata;
|
|
69
|
+
protected_meta?: Metadata;
|
|
70
|
+
};
|
|
71
|
+
declare const useNewFunction: (installationId: number | string, template?: FunctionTemplate) => {
|
|
72
|
+
newFunction: EmptyFunctionx;
|
|
73
|
+
setNewFunction: react.Dispatch<react.SetStateAction<EmptyFunctionx>>;
|
|
74
|
+
create: () => Promise<_iotopen_node_lynx.Functionx>;
|
|
75
|
+
setType: (t: string) => void;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
type ObjectOrArray<X, Y, T extends Y | Y[]> = T extends Y ? Promise<X> : Promise<PromiseSettledResult<X>[]>;
|
|
79
|
+
|
|
80
|
+
declare const useFunctions: (installationId: number | string, filter?: Metadata) => {
|
|
81
|
+
loading: boolean;
|
|
82
|
+
error: ErrorResponse | undefined;
|
|
83
|
+
create: <T extends EmptyFunctionx | EmptyFunctionx[]>(fns: T) => ObjectOrArray<Functionx, EmptyFunctionx, T>;
|
|
84
|
+
remove: <T_1 extends Functionx | Functionx[]>(fns: T_1) => ObjectOrArray<OKResponse, Functionx, T_1>;
|
|
85
|
+
functions: Functionx[];
|
|
86
|
+
refresh: () => void;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
declare const useFunction: (installationId: number | string, functionId: number | string) => {
|
|
90
|
+
loading: boolean;
|
|
91
|
+
error: ErrorResponse | undefined;
|
|
92
|
+
Function: Functionx;
|
|
93
|
+
setFunction: react.Dispatch<react.SetStateAction<Functionx>>;
|
|
94
|
+
update: () => Promise<Functionx>;
|
|
95
|
+
remove: () => Promise<OKResponse>;
|
|
96
|
+
setType: (t: string) => void;
|
|
97
|
+
};
|
|
98
|
+
declare const useFunctionMeta: (installationId: number | string, functionId?: number | string) => {
|
|
99
|
+
createMeta: (key: string, meta: MetaObject, funId?: number, silent?: boolean) => Promise<MetaObject>;
|
|
100
|
+
updateMeta: (key: string, meta: MetaObject, createMissing?: boolean, funId?: number, silent?: boolean) => Promise<MetaObject>;
|
|
101
|
+
removeMeta: (key: string, funId?: number, silent?: boolean) => Promise<MetaObject>;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
declare const useInstallation: (installationId: number | string) => {
|
|
105
|
+
installation: Installation;
|
|
106
|
+
setInstallation: react.Dispatch<react.SetStateAction<Installation>>;
|
|
107
|
+
update: () => Promise<Installation>;
|
|
108
|
+
remove: () => Promise<Installation>;
|
|
109
|
+
error: Error | undefined;
|
|
110
|
+
loading: boolean;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
declare const useInstallations: (filter?: Metadata) => {
|
|
114
|
+
loading: boolean;
|
|
115
|
+
error: ErrorResponse | undefined;
|
|
116
|
+
installations: Installation[];
|
|
117
|
+
refresh: () => void;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
type InstallationTemplate = {
|
|
121
|
+
name?: string;
|
|
122
|
+
notes?: string;
|
|
123
|
+
meta?: Metadata;
|
|
124
|
+
protected_meta?: Metadata;
|
|
125
|
+
};
|
|
126
|
+
declare const useNewInstallation: (organizationId: number | string, template?: InstallationTemplate) => {
|
|
127
|
+
newInstallation: EmptyInstallation;
|
|
128
|
+
setNewInstallation: react.Dispatch<react.SetStateAction<EmptyInstallation>>;
|
|
129
|
+
create: () => Promise<_iotopen_node_lynx.Installation>;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type DeviceTemplate = {
|
|
133
|
+
type?: string;
|
|
134
|
+
meta?: Metadata;
|
|
135
|
+
protected_meta?: Metadata;
|
|
136
|
+
};
|
|
137
|
+
declare const useNewDevice: (installationId: number | string, template?: DeviceTemplate) => {
|
|
138
|
+
newDevice: EmptyDevicex;
|
|
139
|
+
setNewDevice: react.Dispatch<react.SetStateAction<EmptyDevicex>>;
|
|
140
|
+
create: () => Promise<_iotopen_node_lynx.Devicex>;
|
|
141
|
+
setType: (t: string) => void;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
declare const useDevices: (installationId: number | string, filter?: Metadata) => {
|
|
145
|
+
loading: boolean;
|
|
146
|
+
error: ErrorResponse | undefined;
|
|
147
|
+
create: <T extends EmptyDevicex | EmptyDevicex[]>(devs: T) => ObjectOrArray<Devicex, EmptyDevicex, T>;
|
|
148
|
+
remove: <T_1 extends Devicex | Devicex[]>(devs: T_1) => ObjectOrArray<OKResponse, Devicex, T_1>;
|
|
149
|
+
devices: Devicex[];
|
|
150
|
+
refresh: () => void;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
declare const useDevice: (installationId: number | string, deviceId: number | string) => {
|
|
154
|
+
loading: boolean;
|
|
155
|
+
error: ErrorResponse | undefined;
|
|
156
|
+
Device: Devicex;
|
|
157
|
+
setDevice: react.Dispatch<react.SetStateAction<Devicex>>;
|
|
158
|
+
update: () => Promise<Devicex>;
|
|
159
|
+
remove: () => Promise<OKResponse>;
|
|
160
|
+
setType: (t: string) => void;
|
|
161
|
+
};
|
|
162
|
+
declare const useDeviceMeta: (installationId: number | string, deviceId?: number | string) => {
|
|
163
|
+
createMeta: (key: string, meta: MetaObject, devId?: number, silent?: boolean) => Promise<MetaObject>;
|
|
164
|
+
updateMeta: (key: string, meta: MetaObject, createMissing?: boolean, devId?: number, silent?: boolean) => Promise<MetaObject>;
|
|
165
|
+
removeMeta: (key: string, devId?: number, silent?: boolean) => Promise<MetaObject>;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
declare const useConfiguredEdgeApps: (installationId: number | string) => {
|
|
169
|
+
refresh: () => void;
|
|
170
|
+
loading: boolean;
|
|
171
|
+
error: ErrorResponse | undefined;
|
|
172
|
+
apps: EdgeAppInstance[];
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
declare const useEdgeApps: () => {
|
|
176
|
+
apps: EdgeApp[];
|
|
177
|
+
error: ErrorResponse | undefined;
|
|
178
|
+
loading: boolean;
|
|
179
|
+
refresh: () => void;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
declare const useEdgeApp: (appId: number | string) => {
|
|
183
|
+
loading: boolean;
|
|
184
|
+
error: ErrorResponse | undefined;
|
|
185
|
+
app: EdgeApp;
|
|
186
|
+
setApp: react.Dispatch<react.SetStateAction<EdgeApp>>;
|
|
187
|
+
refresh: () => void;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
declare const useEdgeAppVersions: (appId: number | string, untagged?: boolean) => {
|
|
191
|
+
loading: boolean;
|
|
192
|
+
error: ErrorResponse | undefined;
|
|
193
|
+
versions: EdgeAppVersion[];
|
|
194
|
+
nameVersion: (name: string, hash: string) => Promise<EdgeAppVersion>;
|
|
195
|
+
refresh: () => void;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
type OAuth2ClientTemplate = {
|
|
199
|
+
name?: string;
|
|
200
|
+
trusted?: boolean;
|
|
201
|
+
allowed_scopes?: string[];
|
|
202
|
+
icon_uri?: string;
|
|
203
|
+
tos_uri?: string;
|
|
204
|
+
policy_uri?: string;
|
|
205
|
+
redirect_uris?: string[];
|
|
206
|
+
id_token_alg?: string;
|
|
207
|
+
};
|
|
208
|
+
declare const useNewOAuth2Client: (template?: OAuth2ClientTemplate) => {
|
|
209
|
+
newClient: EmptyOAuth2Client;
|
|
210
|
+
create: () => Promise<_iotopen_node_lynx.OAuth2Client>;
|
|
211
|
+
setName: (name: string) => void;
|
|
212
|
+
setScope: (scopes: string[]) => void;
|
|
213
|
+
setIconURI: (uri: string) => void;
|
|
214
|
+
setTosURI: (uri: string) => void;
|
|
215
|
+
setPolicyURI: (uri: string) => void;
|
|
216
|
+
setRedirectURIs: (uris: string[]) => void;
|
|
217
|
+
setClient: react.Dispatch<react.SetStateAction<EmptyOAuth2Client>>;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
declare const useOAuth2Client: (id: string) => {
|
|
221
|
+
refresh: () => void;
|
|
222
|
+
client: OAuth2Client;
|
|
223
|
+
setClient: react.Dispatch<react.SetStateAction<OAuth2Client>>;
|
|
224
|
+
error: ErrorResponse | undefined;
|
|
225
|
+
loading: boolean;
|
|
226
|
+
remove: () => Promise<_iotopen_node_lynx.OKResponse>;
|
|
227
|
+
update: () => Promise<OAuth2Client>;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
declare const useOAuth2Clients: () => {
|
|
231
|
+
refresh: () => void;
|
|
232
|
+
clients: OAuth2Client[];
|
|
233
|
+
error: ErrorResponse | undefined;
|
|
234
|
+
loading: boolean;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
declare const useOAuth2Consent: () => {
|
|
238
|
+
consent: (scope: string[]) => Promise<_iotopen_node_lynx.ConsentAcceptResponse>;
|
|
239
|
+
client: _iotopen_node_lynx.OAuth2Client;
|
|
240
|
+
requestedScopes: string[];
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
declare const useIDTokenAlgorithms: () => {
|
|
244
|
+
loading: boolean;
|
|
245
|
+
refresh: () => void;
|
|
246
|
+
algs: string[];
|
|
247
|
+
error: ErrorResponse | undefined;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
declare const useOrganization: (organizationId: number | string) => {
|
|
251
|
+
loading: boolean;
|
|
252
|
+
organization: Organization;
|
|
253
|
+
setOrganization: react.Dispatch<react.SetStateAction<Organization>>;
|
|
254
|
+
error: Error | undefined;
|
|
255
|
+
update: () => Promise<Organization>;
|
|
256
|
+
remove: () => Promise<_iotopen_node_lynx.OKResponse>;
|
|
257
|
+
refresh: () => void;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
declare const useOrganizations: <T extends boolean = false>(minimal?: T | undefined) => {
|
|
261
|
+
loading: boolean;
|
|
262
|
+
organizations: MinimalOrg<T>[];
|
|
263
|
+
setOrganizations: react.Dispatch<react.SetStateAction<MinimalOrg<T>[]>>;
|
|
264
|
+
error: ErrorResponse | undefined;
|
|
265
|
+
create: (org: Organization) => Promise<Organization>;
|
|
266
|
+
remove: (org: Organization) => Promise<_iotopen_node_lynx.OKResponse>;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
type OrganizationTemplate = {
|
|
270
|
+
address?: Address;
|
|
271
|
+
children?: OrganizationChild[];
|
|
272
|
+
email?: string;
|
|
273
|
+
force_sms_login?: boolean;
|
|
274
|
+
phone?: string;
|
|
275
|
+
name?: string;
|
|
276
|
+
notes?: string;
|
|
277
|
+
password_valid_days?: number;
|
|
278
|
+
meta?: Metadata;
|
|
279
|
+
protected_meta?: Metadata;
|
|
280
|
+
};
|
|
281
|
+
declare const useNewOrganization: (parentId: number | string, template?: OrganizationTemplate) => {
|
|
282
|
+
newOrganization: EmptyOrganization;
|
|
283
|
+
setNewOrganization: react.Dispatch<react.SetStateAction<EmptyOrganization>>;
|
|
284
|
+
create: () => Promise<_iotopen_node_lynx.Organization>;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
type UserTemplate = {
|
|
288
|
+
email?: string;
|
|
289
|
+
password?: string;
|
|
290
|
+
first_name?: string;
|
|
291
|
+
last_name?: string;
|
|
292
|
+
role?: number;
|
|
293
|
+
sms_login?: boolean;
|
|
294
|
+
mobile?: string;
|
|
295
|
+
note?: string;
|
|
296
|
+
organisations?: number[];
|
|
297
|
+
assigned_installations?: number[];
|
|
298
|
+
address?: Address$1;
|
|
299
|
+
expire_at?: number;
|
|
300
|
+
meta?: {
|
|
301
|
+
[key: string]: any;
|
|
302
|
+
};
|
|
303
|
+
protected_meta?: {
|
|
304
|
+
[key: string]: any;
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
declare const useNewUser: (template?: UserTemplate) => {
|
|
308
|
+
newUser: EmptyUser;
|
|
309
|
+
setNewUser: react.Dispatch<react.SetStateAction<EmptyUser>>;
|
|
310
|
+
create: () => Promise<_iotopen_node_lynx.User>;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
declare const useUsers: (filter?: Metadata) => {
|
|
314
|
+
users: User[];
|
|
315
|
+
setUsers: react.Dispatch<react.SetStateAction<User[]>>;
|
|
316
|
+
refresh: () => void;
|
|
317
|
+
loading: boolean;
|
|
318
|
+
error: Error | undefined;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
declare const useUser: (userId: number | string) => {
|
|
322
|
+
loading: boolean;
|
|
323
|
+
error: Error | undefined;
|
|
324
|
+
user: User;
|
|
325
|
+
setUser: react.Dispatch<react.SetStateAction<User>>;
|
|
326
|
+
update: () => Promise<User>;
|
|
327
|
+
refresh: () => void;
|
|
328
|
+
remove: () => Promise<_iotopen_node_lynx.OKResponse>;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
declare const useRoles: () => {
|
|
332
|
+
loading: boolean;
|
|
333
|
+
error: Error | undefined;
|
|
334
|
+
roles: Role[];
|
|
335
|
+
refresh: () => void;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
type NotificationMessageTemplate = {
|
|
339
|
+
installation_id?: number;
|
|
340
|
+
name?: string;
|
|
341
|
+
text?: string;
|
|
342
|
+
};
|
|
343
|
+
declare const useNewNotificationMessage: (installationId: number | string, template?: NotificationMessageTemplate) => {
|
|
344
|
+
newNotificationMessage: EmptyNotificationMessage;
|
|
345
|
+
setNewNotificationMessage: react.Dispatch<react.SetStateAction<EmptyNotificationMessage>>;
|
|
346
|
+
create: () => Promise<_iotopen_node_lynx.NotificationMessage>;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
declare const useNotificationMessage: (installationId: number | string, notificationId: number | string) => {
|
|
350
|
+
refresh: () => void;
|
|
351
|
+
message: NotificationMessage;
|
|
352
|
+
setMessage: react.Dispatch<react.SetStateAction<NotificationMessage>>;
|
|
353
|
+
error: ErrorResponse | undefined;
|
|
354
|
+
loading: boolean;
|
|
355
|
+
remove: () => void;
|
|
356
|
+
update: () => void;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
declare const useNotificationMessages: (installationId: number | string) => {
|
|
360
|
+
refresh: () => void;
|
|
361
|
+
notificationMessages: NotificationMessage[];
|
|
362
|
+
error: ErrorResponse | undefined;
|
|
363
|
+
loading: boolean;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
type NotificationOutputTemplate = {
|
|
367
|
+
installation_id?: number;
|
|
368
|
+
name?: string;
|
|
369
|
+
notification_message_id?: number;
|
|
370
|
+
notification_output_executor_id?: number;
|
|
371
|
+
config?: {
|
|
372
|
+
[key: string]: string;
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
declare const useNewNotificationOutput: (installationId: number | string, template?: NotificationOutputTemplate) => {
|
|
376
|
+
newNotificationOutput: EmptyNotificationOutput;
|
|
377
|
+
setNewNotificationOutput: react.Dispatch<react.SetStateAction<EmptyNotificationOutput>>;
|
|
378
|
+
create: () => Promise<_iotopen_node_lynx.NotificationOutput>;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
declare const useNotificationOutput: (installationId: number | string, notificationId: number | string) => {
|
|
382
|
+
refresh: () => void;
|
|
383
|
+
output: NotificationOutput;
|
|
384
|
+
setOutput: react.Dispatch<react.SetStateAction<NotificationOutput>>;
|
|
385
|
+
error: ErrorResponse | undefined;
|
|
386
|
+
loading: boolean;
|
|
387
|
+
remove: () => void;
|
|
388
|
+
update: () => void;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
declare const useNotificationOutputs: (installationId: number | string) => {
|
|
392
|
+
refresh: () => void;
|
|
393
|
+
notificationOutputs: NotificationOutput[];
|
|
394
|
+
error: ErrorResponse | undefined;
|
|
395
|
+
loading: boolean;
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
declare const useNotificationOutputExecutor: (installationId: number | string, executorId: number | string) => {
|
|
399
|
+
refresh: () => void;
|
|
400
|
+
outputExecutor: NotificationOutputExecutor;
|
|
401
|
+
setOutputExecutor: react.Dispatch<react.SetStateAction<NotificationOutputExecutor>>;
|
|
402
|
+
error: ErrorResponse | undefined;
|
|
403
|
+
loading: boolean;
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
declare const useNotificationOutputExecutors: (installationId: number | string) => {
|
|
407
|
+
refresh: () => void;
|
|
408
|
+
notificationExecutors: NotificationOutputExecutor[];
|
|
409
|
+
error: ErrorResponse | undefined;
|
|
410
|
+
loading: boolean;
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
type LynxProviderProps = {
|
|
414
|
+
apiURL?: string;
|
|
415
|
+
apiKey?: string;
|
|
416
|
+
children?: ReactNode;
|
|
417
|
+
};
|
|
418
|
+
declare const LynxProvider: ({ children, apiURL, apiKey }: LynxProviderProps) => react_jsx_runtime.JSX.Element;
|
|
419
|
+
|
|
420
|
+
interface userContext {
|
|
421
|
+
user: User | null;
|
|
422
|
+
permissions: {
|
|
423
|
+
[key: string]: boolean;
|
|
424
|
+
} | null;
|
|
425
|
+
error: ErrorResponse | undefined;
|
|
426
|
+
loading: boolean;
|
|
427
|
+
}
|
|
428
|
+
declare const useGlobalUser: () => userContext;
|
|
429
|
+
declare const useGlobalPermissions: () => ({
|
|
430
|
+
[key: string]: boolean;
|
|
431
|
+
} | null)[];
|
|
432
|
+
|
|
433
|
+
interface lynxClientContext {
|
|
434
|
+
lynxClient: LynxClient;
|
|
435
|
+
newLynxClient: (url: string, apiKey?: string) => void;
|
|
436
|
+
}
|
|
437
|
+
declare const useGlobalLynxClient: () => lynxClientContext;
|
|
438
|
+
|
|
439
|
+
export { Binding, DeviceTemplate, FunctionTemplate, InstallationTemplate, LynxProvider, MetaElement, NotificationMessageTemplate, NotificationOutputTemplate, OAuth2ClientTemplate, OrganizationTemplate, UserTemplate, useConfiguredEdgeApps, useDevice, useDeviceMeta, useDevices, useEdgeApp, useEdgeAppVersions, useEdgeApps, useFunction, useFunctionMeta, useFunctions, useGlobalLynxClient, useGlobalPermissions, useGlobalUser, useIDTokenAlgorithms, useInstallation, useInstallationInfo, useInstallations, useMeta, useNewDevice, useNewFunction, useNewInstallation, useNewNotificationMessage, useNewNotificationOutput, useNewOAuth2Client, useNewOrganization, useNewUser, useNotificationMessage, useNotificationMessages, useNotificationOutput, useNotificationOutputExecutor, useNotificationOutputExecutors, useNotificationOutputs, useOAuth2Client, useOAuth2Clients, useOAuth2Consent, useOrganization, useOrganizations, usePahoMQTTClient, useRoles, useSimpleMQTT, useTokens, useUser, useUsers };
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iotopen/react-lynx",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/cjs/index.js",
|
|
5
|
+
"module": "dist/esm/index.js",
|
|
6
|
+
"source": "src/index.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"lint": "eslint --ext js,ts,tsx --max-warnings 0 src",
|
|
9
|
+
"clean": "rimraf dist",
|
|
10
|
+
"prepare": "npm run clean && npm run build:ts",
|
|
11
|
+
"dev": "npm run dev:ts",
|
|
12
|
+
"build": "npm run build:ts",
|
|
13
|
+
"build:ts": "rollup -c",
|
|
14
|
+
"dev:ts": "rollup -c -w"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@iotopen/node-lynx": "^2.3.0",
|
|
18
|
+
"paho-mqtt": "^1.1.0",
|
|
19
|
+
"react": "^18.2.0",
|
|
20
|
+
"react-dom": "^18.2.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@rollup/plugin-commonjs": "^22.0.2",
|
|
24
|
+
"@rollup/plugin-node-resolve": "^14.0.1",
|
|
25
|
+
"@rollup/plugin-typescript": "^8.5.0",
|
|
26
|
+
"@types/jest": "^29.0.0",
|
|
27
|
+
"@types/node": "^18.7.16",
|
|
28
|
+
"@types/react": "^18.0.18",
|
|
29
|
+
"@types/react-dom": "^18.0.6",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
|
31
|
+
"@typescript-eslint/parser": "^5.36.2",
|
|
32
|
+
"cross-env": "^7.0.3",
|
|
33
|
+
"eslint": "^7.32.0",
|
|
34
|
+
"eslint-plugin-react": "^7.30.1",
|
|
35
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
36
|
+
"rollup": "^2.79.0",
|
|
37
|
+
"rollup-plugin-dts": "^4.2.2",
|
|
38
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
39
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
40
|
+
"typescript": "^4.8.2"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
],
|
|
45
|
+
"types": "dist/index.d.ts",
|
|
46
|
+
"eslintConfig": {
|
|
47
|
+
"extends": [
|
|
48
|
+
"react-app",
|
|
49
|
+
"react-app/jest"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|