@iotopen/react-lynx 1.0.0 → 1.0.2-rc.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.
Files changed (106) hide show
  1. package/README.md +1 -1
  2. package/dist/{cjs/Contexts → Contexts}/LynxClientProvider.d.ts +5 -4
  3. package/dist/Contexts/LynxProvider.d.ts +9 -0
  4. package/dist/{esm/Contexts → Contexts}/UserProvider.d.ts +2 -2
  5. package/dist/{esm/Contexts → Contexts}/index.d.ts +2 -2
  6. package/dist/{cjs/Hooks → Hooks}/index.d.ts +42 -26
  7. package/dist/Hooks/useCheckPermissions.d.ts +4 -0
  8. package/dist/{cjs/Hooks → Hooks}/useDevice.d.ts +4 -4
  9. package/dist/Hooks/useDevices.d.ts +9 -0
  10. package/dist/{esm/Hooks → Hooks}/useEdgeApp.d.ts +1 -1
  11. package/dist/{esm/Hooks → Hooks}/useFunction.d.ts +1 -1
  12. package/dist/Hooks/useFunctions.d.ts +9 -0
  13. package/dist/{cjs/Hooks → Hooks}/useInstallation.d.ts +1 -1
  14. package/dist/Hooks/useLiveInstallation.d.ts +10 -0
  15. package/dist/Hooks/useMQTT.d.ts +1 -0
  16. package/dist/Hooks/useMultiLiveInstallation.d.ts +11 -0
  17. package/dist/{esm/Hooks → Hooks}/useNewDevice.d.ts +4 -4
  18. package/dist/{esm/Hooks → Hooks}/useNewFunction.d.ts +4 -4
  19. package/dist/{esm/Hooks → Hooks}/useNewInstallation.d.ts +4 -4
  20. package/dist/{esm/Hooks → Hooks}/useNewNotificationMessage.d.ts +4 -4
  21. package/dist/{cjs/Hooks → Hooks}/useNewNotificationOutput.d.ts +4 -4
  22. package/dist/{esm/Hooks → Hooks}/useNewOAuth2Client.d.ts +4 -4
  23. package/dist/{esm/Hooks → Hooks}/useNewOrganization.d.ts +4 -4
  24. package/dist/{cjs/Hooks → Hooks}/useNewUser.d.ts +7 -8
  25. package/dist/{cjs/Hooks → Hooks}/useNotificationMessage.d.ts +1 -1
  26. package/dist/{esm/Hooks → Hooks}/useNotificationOutput.d.ts +1 -1
  27. package/dist/{cjs/Hooks → Hooks}/useNotificationOutputExecutor.d.ts +1 -1
  28. package/dist/{cjs/Hooks → Hooks}/useOAuth2Client.d.ts +2 -2
  29. package/dist/Hooks/useOAuth2Consent.d.ts +5 -0
  30. package/dist/{cjs/Hooks → Hooks}/useOrganization.d.ts +2 -2
  31. package/dist/{cjs/Hooks → Hooks}/useOrganizations.d.ts +3 -3
  32. package/dist/{esm/Hooks → Hooks}/usePahoMQTTClient.d.ts +2 -2
  33. package/dist/Hooks/useSimpleMQTT.d.ts +18 -0
  34. package/dist/{cjs/Hooks → Hooks}/useTokens.d.ts +1 -1
  35. package/dist/{esm/Hooks → Hooks}/useUser.d.ts +2 -2
  36. package/dist/{esm/Hooks → Hooks}/useUsers.d.ts +1 -1
  37. package/dist/cjs/index.js +1 -16
  38. package/dist/cjs/index.js.map +1 -1
  39. package/dist/esm/index.js +1427 -16
  40. package/dist/esm/index.js.map +1 -1
  41. package/dist/index.d.ts +2 -439
  42. package/package.json +91 -48
  43. package/dist/cjs/Contexts/LynxProvider.d.ts +0 -8
  44. package/dist/cjs/Contexts/UserProvider.d.ts +0 -19
  45. package/dist/cjs/Contexts/index.d.ts +0 -3
  46. package/dist/cjs/Hooks/useDevices.d.ts +0 -10
  47. package/dist/cjs/Hooks/useEdgeApp.d.ts +0 -8
  48. package/dist/cjs/Hooks/useFunction.d.ts +0 -15
  49. package/dist/cjs/Hooks/useFunctions.d.ts +0 -10
  50. package/dist/cjs/Hooks/useNewDevice.d.ts +0 -12
  51. package/dist/cjs/Hooks/useNewFunction.d.ts +0 -12
  52. package/dist/cjs/Hooks/useNewInstallation.d.ts +0 -12
  53. package/dist/cjs/Hooks/useNewNotificationMessage.d.ts +0 -11
  54. package/dist/cjs/Hooks/useNewOAuth2Client.d.ts +0 -22
  55. package/dist/cjs/Hooks/useNewOrganization.d.ts +0 -18
  56. package/dist/cjs/Hooks/useNotificationOutput.d.ts +0 -10
  57. package/dist/cjs/Hooks/useOAuth2Consent.d.ts +0 -5
  58. package/dist/cjs/Hooks/usePahoMQTTClient.d.ts +0 -16
  59. package/dist/cjs/Hooks/useSimpleMQTT.d.ts +0 -12
  60. package/dist/cjs/Hooks/useUser.d.ts +0 -10
  61. package/dist/cjs/Hooks/useUsers.d.ts +0 -8
  62. package/dist/cjs/index.d.ts +0 -2
  63. package/dist/esm/Contexts/LynxClientProvider.d.ts +0 -14
  64. package/dist/esm/Contexts/LynxProvider.d.ts +0 -8
  65. package/dist/esm/Hooks/index.d.ts +0 -38
  66. package/dist/esm/Hooks/useConfiguredEdgeApps.d.ts +0 -7
  67. package/dist/esm/Hooks/useDevice.d.ts +0 -15
  68. package/dist/esm/Hooks/useDevices.d.ts +0 -10
  69. package/dist/esm/Hooks/useEdgeAppVersions.d.ts +0 -8
  70. package/dist/esm/Hooks/useEdgeApps.d.ts +0 -7
  71. package/dist/esm/Hooks/useFunctions.d.ts +0 -10
  72. package/dist/esm/Hooks/useIDTokenAlgorithms.d.ts +0 -7
  73. package/dist/esm/Hooks/useInstallation.d.ts +0 -9
  74. package/dist/esm/Hooks/useInstallationInfo.d.ts +0 -7
  75. package/dist/esm/Hooks/useInstallations.d.ts +0 -7
  76. package/dist/esm/Hooks/useMeta.d.ts +0 -15
  77. package/dist/esm/Hooks/useNewNotificationOutput.d.ts +0 -15
  78. package/dist/esm/Hooks/useNewUser.d.ts +0 -27
  79. package/dist/esm/Hooks/useNotificationMessage.d.ts +0 -10
  80. package/dist/esm/Hooks/useNotificationMessages.d.ts +0 -7
  81. package/dist/esm/Hooks/useNotificationOutputExecutor.d.ts +0 -8
  82. package/dist/esm/Hooks/useNotificationOutputExecutors.d.ts +0 -7
  83. package/dist/esm/Hooks/useNotificationOutputs.d.ts +0 -7
  84. package/dist/esm/Hooks/useOAuth2Client.d.ts +0 -10
  85. package/dist/esm/Hooks/useOAuth2Clients.d.ts +0 -7
  86. package/dist/esm/Hooks/useOAuth2Consent.d.ts +0 -5
  87. package/dist/esm/Hooks/useOrganization.d.ts +0 -10
  88. package/dist/esm/Hooks/useOrganizations.d.ts +0 -9
  89. package/dist/esm/Hooks/useRoles.d.ts +0 -7
  90. package/dist/esm/Hooks/useSimpleMQTT.d.ts +0 -12
  91. package/dist/esm/Hooks/useTokens.d.ts +0 -9
  92. package/dist/esm/index.d.ts +0 -2
  93. package/dist/esm/types.d.ts +0 -1
  94. /package/dist/{cjs/Hooks → Hooks}/useConfiguredEdgeApps.d.ts +0 -0
  95. /package/dist/{cjs/Hooks → Hooks}/useEdgeAppVersions.d.ts +0 -0
  96. /package/dist/{cjs/Hooks → Hooks}/useEdgeApps.d.ts +0 -0
  97. /package/dist/{cjs/Hooks → Hooks}/useIDTokenAlgorithms.d.ts +0 -0
  98. /package/dist/{cjs/Hooks → Hooks}/useInstallationInfo.d.ts +0 -0
  99. /package/dist/{cjs/Hooks → Hooks}/useInstallations.d.ts +0 -0
  100. /package/dist/{cjs/Hooks → Hooks}/useMeta.d.ts +0 -0
  101. /package/dist/{cjs/Hooks → Hooks}/useNotificationMessages.d.ts +0 -0
  102. /package/dist/{cjs/Hooks → Hooks}/useNotificationOutputExecutors.d.ts +0 -0
  103. /package/dist/{cjs/Hooks → Hooks}/useNotificationOutputs.d.ts +0 -0
  104. /package/dist/{cjs/Hooks → Hooks}/useOAuth2Clients.d.ts +0 -0
  105. /package/dist/{cjs/Hooks → Hooks}/useRoles.d.ts +0 -0
  106. /package/dist/{cjs/types.d.ts → types.d.ts} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,439 +1,2 @@
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 };
1
+ export * from './Contexts';
2
+ export * from './Hooks';
package/package.json CHANGED
@@ -1,52 +1,95 @@
1
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"
2
+ "name": "@iotopen/react-lynx",
3
+ "version": "1.0.2-rc.1",
4
+ "main": "dist/cjs/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "source": "src/index.ts",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "pnpm": {
10
+ "onlyBuiltDependencies": [
11
+ "esbuild",
12
+ "unrs-resolver"
44
13
  ],
45
- "types": "dist/index.d.ts",
46
- "eslintConfig": {
47
- "extends": [
48
- "react-app",
49
- "react-app/jest"
50
- ]
14
+ "overrides": {
15
+ "@microsoft/api-extractor": "7.52.8"
51
16
  }
17
+ },
18
+ "scripts": {
19
+ "lint": "pnpm type-check && eslint src --max-warnings 0",
20
+ "lint:fix": "eslint src --fix",
21
+ "type-check": "tsc --noEmit",
22
+ "test": "pnpm run type-check",
23
+ "prepare": "node scripts/prepare.cjs",
24
+ "prepack": "node scripts/prepare.cjs && node scripts/verify-dist.cjs",
25
+ "build": "vite build --config ./vite.config.ts",
26
+ "prepublishOnly": "pnpm run build && node scripts/verify-dist.cjs",
27
+ "dev": "vite",
28
+ "clean": "rimraf dist",
29
+ "publish:prerelease": "pnpm version prerelease --preid=rc && pnpm run build && npm publish --tag rc"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/IoTOpen/react-lynx.git"
37
+ },
38
+ "devDependencies": {
39
+ "@eslint/js": "^9.39.2",
40
+ "@iotopen/node-lynx": "2.6.0-rc.1",
41
+ "@types/node": "^22.19.11",
42
+ "@types/react": "^19.2.14",
43
+ "@types/react-dom": "^19.2.3",
44
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
45
+ "@typescript-eslint/parser": "^8.56.0",
46
+ "@vitejs/plugin-react": "^5.1.4",
47
+ "eslint": "^9.39.2",
48
+ "eslint-import-resolver-typescript": "^4.4.4",
49
+ "eslint-plugin-import-x": "^4.16.1",
50
+ "eslint-plugin-react": "^7.37.5",
51
+ "eslint-plugin-react-hooks": "^7.0.1",
52
+ "eslint-plugin-simple-import-sort": "^12.1.1",
53
+ "globals": "^16.5.0",
54
+ "rimraf": "^5.0.10",
55
+ "typescript": "^5.9.3",
56
+ "typescript-eslint": "^8.56.0",
57
+ "vite": "^7.3.1",
58
+ "vite-plugin-dts": "^4.5.4"
59
+ },
60
+ "peerDependencies": {
61
+ "@iotopen/node-lynx": "2.6.0-rc.1",
62
+ "paho-mqtt": "^1.1.0",
63
+ "react": "^18 || ^19",
64
+ "react-dom": "^18 || ^19"
65
+ },
66
+ "files": [
67
+ "dist"
68
+ ],
69
+ "sideEffects": false,
70
+ "engines": {
71
+ "node": ">=18.15.0"
72
+ },
73
+ "exports": {
74
+ ".": {
75
+ "types": "./dist/index.d.ts",
76
+ "import": "./dist/esm/index.js",
77
+ "require": "./dist/cjs/index.js"
78
+ }
79
+ },
80
+ "browserslist": {
81
+ "production": [
82
+ ">0.2%",
83
+ "not dead",
84
+ "not op_mini all"
85
+ ],
86
+ "development": [
87
+ "last 1 chrome version",
88
+ "last 1 firefox version",
89
+ "last 1 safari version"
90
+ ]
91
+ },
92
+ "dependencies": {
93
+ "tslib": "^2.8.1"
94
+ }
52
95
  }
@@ -1,8 +0,0 @@
1
- import { ReactNode } from 'react';
2
- type LynxProviderProps = {
3
- apiURL?: string;
4
- apiKey?: string;
5
- children?: ReactNode;
6
- };
7
- export declare const LynxProvider: ({ children, apiURL, apiKey }: LynxProviderProps) => import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,19 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { ErrorResponse, User } from '@iotopen/node-lynx';
3
- interface userContext {
4
- user: User | null;
5
- permissions: {
6
- [key: string]: boolean;
7
- } | null;
8
- error: ErrorResponse | undefined;
9
- loading: boolean;
10
- }
11
- interface UserProviderProps {
12
- children: ReactNode;
13
- }
14
- export declare const UserProvider: ({ children }: UserProviderProps) => import("react/jsx-runtime").JSX.Element;
15
- export declare const useGlobalUser: () => userContext;
16
- export declare const useGlobalPermissions: () => ({
17
- [key: string]: boolean;
18
- } | null)[];
19
- export {};
@@ -1,3 +0,0 @@
1
- export * from './LynxProvider';
2
- export { useGlobalUser, useGlobalPermissions } from './UserProvider';
3
- export { useGlobalLynxClient } from './LynxClientProvider';
@@ -1,10 +0,0 @@
1
- import { Devicex, EmptyDevicex, ErrorResponse, Metadata, OKResponse } from '@iotopen/node-lynx';
2
- import { ObjectOrArray } from '../types';
3
- export declare const useDevices: (installationId: number | string, filter?: Metadata) => {
4
- loading: boolean;
5
- error: ErrorResponse | undefined;
6
- create: <T extends EmptyDevicex | EmptyDevicex[]>(devs: T) => ObjectOrArray<Devicex, EmptyDevicex, T>;
7
- remove: <T_1 extends Devicex | Devicex[]>(devs: T_1) => ObjectOrArray<OKResponse, Devicex, T_1>;
8
- devices: Devicex[];
9
- refresh: () => void;
10
- };
@@ -1,8 +0,0 @@
1
- import { EdgeApp, ErrorResponse } from '@iotopen/node-lynx';
2
- export declare const useEdgeApp: (appId: number | string) => {
3
- loading: boolean;
4
- error: ErrorResponse | undefined;
5
- app: EdgeApp;
6
- setApp: import("react").Dispatch<import("react").SetStateAction<EdgeApp>>;
7
- refresh: () => void;
8
- };
@@ -1,15 +0,0 @@
1
- import { ErrorResponse, Functionx, MetaObject, OKResponse } from '@iotopen/node-lynx';
2
- export declare const useFunction: (installationId: number | string, functionId: number | string) => {
3
- loading: boolean;
4
- error: ErrorResponse | undefined;
5
- Function: Functionx;
6
- setFunction: import("react").Dispatch<import("react").SetStateAction<Functionx>>;
7
- update: () => Promise<Functionx>;
8
- remove: () => Promise<OKResponse>;
9
- setType: (t: string) => void;
10
- };
11
- export declare const useFunctionMeta: (installationId: number | string, functionId?: number | string) => {
12
- createMeta: (key: string, meta: MetaObject, funId?: number, silent?: boolean) => Promise<MetaObject>;
13
- updateMeta: (key: string, meta: MetaObject, createMissing?: boolean, funId?: number, silent?: boolean) => Promise<MetaObject>;
14
- removeMeta: (key: string, funId?: number, silent?: boolean) => Promise<MetaObject>;
15
- };
@@ -1,10 +0,0 @@
1
- import { EmptyFunctionx, ErrorResponse, Functionx, Metadata, OKResponse } from '@iotopen/node-lynx';
2
- import { ObjectOrArray } from '../types';
3
- export declare const useFunctions: (installationId: number | string, filter?: Metadata) => {
4
- loading: boolean;
5
- error: ErrorResponse | undefined;
6
- create: <T extends EmptyFunctionx | EmptyFunctionx[]>(fns: T) => ObjectOrArray<Functionx, EmptyFunctionx, T>;
7
- remove: <T_1 extends Functionx | Functionx[]>(fns: T_1) => ObjectOrArray<OKResponse, Functionx, T_1>;
8
- functions: Functionx[];
9
- refresh: () => void;
10
- };
@@ -1,12 +0,0 @@
1
- import { EmptyDevicex, Metadata } from '@iotopen/node-lynx';
2
- export type DeviceTemplate = {
3
- type?: string;
4
- meta?: Metadata;
5
- protected_meta?: Metadata;
6
- };
7
- export declare const useNewDevice: (installationId: number | string, template?: DeviceTemplate) => {
8
- newDevice: EmptyDevicex;
9
- setNewDevice: import("react").Dispatch<import("react").SetStateAction<EmptyDevicex>>;
10
- create: () => Promise<import("@iotopen/node-lynx").Devicex>;
11
- setType: (t: string) => void;
12
- };