@sparkstudio/realtime-ui 1.0.2 → 1.0.5

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.js ADDED
@@ -0,0 +1,474 @@
1
+ // src/api/Controllers/Home.ts
2
+ var Home = class {
3
+ baseUrl;
4
+ constructor(baseUrl) {
5
+ this.baseUrl = baseUrl;
6
+ }
7
+ };
8
+
9
+ // src/api/Controllers/RoomInstance.ts
10
+ var RoomInstance = class {
11
+ baseUrl;
12
+ constructor(baseUrl) {
13
+ this.baseUrl = baseUrl;
14
+ }
15
+ async ReadByUserId(userId) {
16
+ const url = `${this.baseUrl}/api/RoomInstance/ReadByUserId/` + userId;
17
+ const token = localStorage.getItem("auth_token");
18
+ const requestOptions = {
19
+ method: "GET",
20
+ headers: {
21
+ "Content-Type": "application/json",
22
+ ...token && { Authorization: `Bearer ${token}` }
23
+ }
24
+ };
25
+ const response = await fetch(url, requestOptions);
26
+ if (!response.ok) throw new Error(await response.text());
27
+ return await response.json();
28
+ }
29
+ async ReadViewPageByUniqueId(uniqueId, pageNumber, pageSize) {
30
+ const url = `${this.baseUrl}/api/RoomInstance/ReadViewPageByUniqueId/` + uniqueId + `/` + pageNumber + `/` + pageSize;
31
+ const token = localStorage.getItem("auth_token");
32
+ const requestOptions = {
33
+ method: "GET",
34
+ headers: {
35
+ "Content-Type": "application/json",
36
+ ...token && { Authorization: `Bearer ${token}` }
37
+ }
38
+ };
39
+ const response = await fetch(url, requestOptions);
40
+ if (!response.ok) throw new Error(await response.text());
41
+ return await response.json();
42
+ }
43
+ async ReadUserCountByUniqueId(uniqueId) {
44
+ const url = `${this.baseUrl}/api/RoomInstance/ReadUserCountByUniqueId/` + uniqueId;
45
+ const token = localStorage.getItem("auth_token");
46
+ const requestOptions = {
47
+ method: "GET",
48
+ headers: {
49
+ "Content-Type": "application/json",
50
+ ...token && { Authorization: `Bearer ${token}` }
51
+ }
52
+ };
53
+ const response = await fetch(url, requestOptions);
54
+ if (!response.ok) throw new Error(await response.text());
55
+ return await response.json();
56
+ }
57
+ async Read(roomInstanceId) {
58
+ const url = `${this.baseUrl}/api/RoomInstance/Read/` + roomInstanceId;
59
+ const token = localStorage.getItem("auth_token");
60
+ const requestOptions = {
61
+ method: "GET",
62
+ headers: {
63
+ "Content-Type": "application/json",
64
+ ...token && { Authorization: `Bearer ${token}` }
65
+ }
66
+ };
67
+ const response = await fetch(url, requestOptions);
68
+ if (!response.ok) throw new Error(await response.text());
69
+ return await response.json();
70
+ }
71
+ async ReadConnectionsById(roomInstanceId) {
72
+ const url = `${this.baseUrl}/api/RoomInstance/ReadConnectionsById/` + roomInstanceId;
73
+ const token = localStorage.getItem("auth_token");
74
+ const requestOptions = {
75
+ method: "GET",
76
+ headers: {
77
+ "Content-Type": "application/json",
78
+ ...token && { Authorization: `Bearer ${token}` }
79
+ }
80
+ };
81
+ const response = await fetch(url, requestOptions);
82
+ if (!response.ok) throw new Error(await response.text());
83
+ return await response.json();
84
+ }
85
+ async ReadByConnectionId(connectionId) {
86
+ const url = `${this.baseUrl}/api/RoomInstance/ReadByConnectionId/` + connectionId;
87
+ const token = localStorage.getItem("auth_token");
88
+ const requestOptions = {
89
+ method: "GET",
90
+ headers: {
91
+ "Content-Type": "application/json",
92
+ ...token && { Authorization: `Bearer ${token}` }
93
+ }
94
+ };
95
+ const response = await fetch(url, requestOptions);
96
+ if (!response.ok) throw new Error(await response.text());
97
+ return await response.json();
98
+ }
99
+ async Join(roomInstanceId, connectionId) {
100
+ const url = `${this.baseUrl}/api/RoomInstance/Join/` + roomInstanceId + `/` + connectionId;
101
+ const token = localStorage.getItem("auth_token");
102
+ const requestOptions = {
103
+ method: "GET",
104
+ headers: {
105
+ "Content-Type": "application/json",
106
+ ...token && { Authorization: `Bearer ${token}` }
107
+ }
108
+ };
109
+ const response = await fetch(url, requestOptions);
110
+ if (!response.ok) throw new Error(await response.text());
111
+ return await response.json();
112
+ }
113
+ async Leave(roomInstanceId) {
114
+ const url = `${this.baseUrl}/api/RoomInstance/Leave/` + roomInstanceId;
115
+ const token = localStorage.getItem("auth_token");
116
+ const requestOptions = {
117
+ method: "GET",
118
+ headers: {
119
+ "Content-Type": "application/json",
120
+ ...token && { Authorization: `Bearer ${token}` }
121
+ }
122
+ };
123
+ const response = await fetch(url, requestOptions);
124
+ if (!response.ok) throw new Error(await response.text());
125
+ return await response.json();
126
+ }
127
+ async Create(uniqueId, maxUsers) {
128
+ const url = `${this.baseUrl}/api/RoomInstance/Create/` + uniqueId + `/` + maxUsers;
129
+ const token = localStorage.getItem("auth_token");
130
+ const requestOptions = {
131
+ method: "GET",
132
+ headers: {
133
+ "Content-Type": "application/json",
134
+ ...token && { Authorization: `Bearer ${token}` }
135
+ }
136
+ };
137
+ const response = await fetch(url, requestOptions);
138
+ if (!response.ok) throw new Error(await response.text());
139
+ return await response.json();
140
+ }
141
+ async Remove(roomInstanceId) {
142
+ const url = `${this.baseUrl}/api/RoomInstance/Remove/` + roomInstanceId;
143
+ const token = localStorage.getItem("auth_token");
144
+ const requestOptions = {
145
+ method: "GET",
146
+ headers: {
147
+ "Content-Type": "application/json",
148
+ ...token && { Authorization: `Bearer ${token}` }
149
+ }
150
+ };
151
+ const response = await fetch(url, requestOptions);
152
+ if (!response.ok) throw new Error(await response.text());
153
+ return await response.json();
154
+ }
155
+ };
156
+
157
+ // src/api/Controllers/UserSetting.ts
158
+ var UserSetting = class {
159
+ baseUrl;
160
+ constructor(baseUrl) {
161
+ this.baseUrl = baseUrl;
162
+ }
163
+ async GetOrCreate(userId) {
164
+ const url = `${this.baseUrl}/api/UserSetting/GetOrCreate/` + userId;
165
+ const token = localStorage.getItem("auth_token");
166
+ const requestOptions = {
167
+ method: "GET",
168
+ headers: {
169
+ "Content-Type": "application/json",
170
+ ...token && { Authorization: `Bearer ${token}` }
171
+ }
172
+ };
173
+ const response = await fetch(url, requestOptions);
174
+ if (!response.ok) throw new Error(await response.text());
175
+ return await response.json();
176
+ }
177
+ async Set(userSettingDTO) {
178
+ const url = `${this.baseUrl}/api/UserSetting/Set`;
179
+ const token = localStorage.getItem("auth_token");
180
+ const requestOptions = {
181
+ method: "POST",
182
+ headers: {
183
+ "Content-Type": "application/json",
184
+ ...token && { Authorization: `Bearer ${token}` }
185
+ },
186
+ body: JSON.stringify(userSettingDTO)
187
+ };
188
+ const response = await fetch(url, requestOptions);
189
+ if (!response.ok) throw new Error(await response.text());
190
+ return await response.json();
191
+ }
192
+ };
193
+
194
+ // src/api/Controllers/WebSocketConnection.ts
195
+ var WebSocketConnection = class {
196
+ baseUrl;
197
+ constructor(baseUrl) {
198
+ this.baseUrl = baseUrl;
199
+ }
200
+ async Create(webSocketConnectionDTO) {
201
+ const url = `${this.baseUrl}/api/WebSocketConnection/Create`;
202
+ const token = localStorage.getItem("auth_token");
203
+ const requestOptions = {
204
+ method: "POST",
205
+ headers: {
206
+ "Content-Type": "application/json",
207
+ ...token && { Authorization: `Bearer ${token}` }
208
+ },
209
+ body: JSON.stringify(webSocketConnectionDTO)
210
+ };
211
+ const response = await fetch(url, requestOptions);
212
+ if (!response.ok) throw new Error(await response.text());
213
+ return await response.json();
214
+ }
215
+ async Remove(connectionId) {
216
+ const url = `${this.baseUrl}/api/WebSocketConnection/Remove/` + connectionId;
217
+ const token = localStorage.getItem("auth_token");
218
+ const requestOptions = {
219
+ method: "GET",
220
+ headers: {
221
+ "Content-Type": "application/json",
222
+ ...token && { Authorization: `Bearer ${token}` }
223
+ }
224
+ };
225
+ const response = await fetch(url, requestOptions);
226
+ if (!response.ok) throw new Error(await response.text());
227
+ return await response.json();
228
+ }
229
+ async ReadConnections(userId) {
230
+ const url = `${this.baseUrl}/api/WebSocketConnection/ReadConnections/` + userId;
231
+ const token = localStorage.getItem("auth_token");
232
+ const requestOptions = {
233
+ method: "GET",
234
+ headers: {
235
+ "Content-Type": "application/json",
236
+ ...token && { Authorization: `Bearer ${token}` }
237
+ }
238
+ };
239
+ const response = await fetch(url, requestOptions);
240
+ if (!response.ok) throw new Error(await response.text());
241
+ return await response.json();
242
+ }
243
+ async ReadUserIdByConnectionId(connectionId) {
244
+ const url = `${this.baseUrl}/api/WebSocketConnection/ReadUserIdByConnectionId/` + connectionId;
245
+ const token = localStorage.getItem("auth_token");
246
+ const requestOptions = {
247
+ method: "GET",
248
+ headers: {
249
+ "Content-Type": "application/json",
250
+ ...token && { Authorization: `Bearer ${token}` }
251
+ }
252
+ };
253
+ const response = await fetch(url, requestOptions);
254
+ if (!response.ok) throw new Error(await response.text());
255
+ return await response.json();
256
+ }
257
+ async Clear() {
258
+ const url = `${this.baseUrl}/api/WebSocketConnection/Clear`;
259
+ const token = localStorage.getItem("auth_token");
260
+ const requestOptions = {
261
+ method: "GET",
262
+ headers: {
263
+ "Content-Type": "application/json",
264
+ ...token && { Authorization: `Bearer ${token}` }
265
+ }
266
+ };
267
+ const response = await fetch(url, requestOptions);
268
+ if (!response.ok) throw new Error(await response.text());
269
+ return await response.json();
270
+ }
271
+ async SendMessage(webSocketClientRequestDTO) {
272
+ const url = `${this.baseUrl}/api/WebSocketConnection/SendMessage`;
273
+ const token = localStorage.getItem("auth_token");
274
+ const requestOptions = {
275
+ method: "POST",
276
+ headers: {
277
+ "Content-Type": "application/json",
278
+ ...token && { Authorization: `Bearer ${token}` }
279
+ },
280
+ body: JSON.stringify(webSocketClientRequestDTO)
281
+ };
282
+ const response = await fetch(url, requestOptions);
283
+ if (!response.ok) throw new Error(await response.text());
284
+ return await response.json();
285
+ }
286
+ };
287
+
288
+ // src/api/SparkStudioRealtimeSDK.ts
289
+ var SparkStudioRealtimeSDK = class {
290
+ home;
291
+ roomInstance;
292
+ userSetting;
293
+ webSocketConnection;
294
+ constructor(baseUrl) {
295
+ this.home = new Home(baseUrl);
296
+ this.roomInstance = new RoomInstance(baseUrl);
297
+ this.userSetting = new UserSetting(baseUrl);
298
+ this.webSocketConnection = new WebSocketConnection(baseUrl);
299
+ }
300
+ };
301
+
302
+ // src/api/DTOs/Guid.ts
303
+ var GuidUtil = class {
304
+ static Empty = "00000000-0000-0000-0000-000000000000";
305
+ static guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
306
+ static create() {
307
+ return crypto.randomUUID();
308
+ }
309
+ static parse(value) {
310
+ if (value === this.Empty) return this.Empty;
311
+ if (!this.isValid(value)) {
312
+ throw new Error(`Invalid GUID: ${value}`);
313
+ }
314
+ return value;
315
+ }
316
+ static isValid(value) {
317
+ return value === this.Empty || this.guidRegex.test(value);
318
+ }
319
+ static isEmpty(value) {
320
+ return value === this.Empty;
321
+ }
322
+ };
323
+
324
+ // src/api/DTOs/GuidResultDTO.ts
325
+ var GuidResultDTO = class {
326
+ Result;
327
+ constructor(init) {
328
+ this.Result = init.Result;
329
+ }
330
+ };
331
+
332
+ // src/api/DTOs/RoomInstanceDTO.ts
333
+ var RoomInstanceDTO = class {
334
+ Id;
335
+ HostUserId;
336
+ UniqueId;
337
+ Data;
338
+ MaxUsers;
339
+ constructor(init) {
340
+ this.Id = init.Id;
341
+ this.HostUserId = init.HostUserId;
342
+ this.UniqueId = init.UniqueId;
343
+ this.Data = init.Data;
344
+ this.MaxUsers = init.MaxUsers;
345
+ }
346
+ };
347
+
348
+ // src/api/DTOs/RoomInstanceViewDTO.ts
349
+ var RoomInstanceViewDTO = class {
350
+ Id;
351
+ RoomInstance;
352
+ UsersInRoom;
353
+ constructor(init) {
354
+ this.Id = init.Id;
355
+ this.RoomInstance = init.RoomInstance;
356
+ this.UsersInRoom = init.UsersInRoom;
357
+ }
358
+ };
359
+
360
+ // src/api/DTOs/StringResultDTO.ts
361
+ var StringResultDTO = class {
362
+ Result;
363
+ constructor(init) {
364
+ this.Result = init.Result;
365
+ }
366
+ };
367
+
368
+ // src/api/DTOs/UniqueViewDTO.ts
369
+ var UniqueViewDTO = class {
370
+ Id;
371
+ UserCount;
372
+ constructor(init) {
373
+ this.Id = init.Id;
374
+ this.UserCount = init.UserCount;
375
+ }
376
+ };
377
+
378
+ // src/api/DTOs/UserSettingDTO.ts
379
+ var UserSettingDTO = class {
380
+ Id;
381
+ UserId;
382
+ Status;
383
+ StatusDescription;
384
+ TimeZone;
385
+ constructor(init) {
386
+ this.Id = init.Id;
387
+ this.UserId = init.UserId;
388
+ this.Status = init.Status;
389
+ this.StatusDescription = init.StatusDescription;
390
+ this.TimeZone = init.TimeZone;
391
+ }
392
+ };
393
+
394
+ // src/api/DTOs/WebSocketClientRequestDTO.ts
395
+ var WebSocketClientRequestDTO = class {
396
+ AccessToken;
397
+ Data;
398
+ Type;
399
+ ControllerName;
400
+ MethodName;
401
+ constructor(init) {
402
+ this.AccessToken = init.AccessToken;
403
+ this.Data = init.Data;
404
+ this.Type = init.Type;
405
+ this.ControllerName = init.ControllerName;
406
+ this.MethodName = init.MethodName;
407
+ }
408
+ };
409
+
410
+ // src/api/DTOs/WebSocketConnectionDTO.ts
411
+ var WebSocketConnectionDTO = class {
412
+ Id;
413
+ UserId;
414
+ ConnectionId;
415
+ constructor(init) {
416
+ this.Id = init.Id;
417
+ this.UserId = init.UserId;
418
+ this.ConnectionId = init.ConnectionId;
419
+ }
420
+ };
421
+
422
+ // src/api/Enums/UserStatusType.ts
423
+ var UserStatusType = /* @__PURE__ */ ((UserStatusType2) => {
424
+ UserStatusType2[UserStatusType2["Offline"] = 0] = "Offline";
425
+ UserStatusType2[UserStatusType2["Online"] = 1] = "Online";
426
+ UserStatusType2[UserStatusType2["Away"] = 2] = "Away";
427
+ UserStatusType2[UserStatusType2["DoNotDisturb"] = 3] = "DoNotDisturb";
428
+ return UserStatusType2;
429
+ })(UserStatusType || {});
430
+
431
+ // src/views/HomeView.tsx
432
+ import {
433
+ AppSettings,
434
+ AuthenticatorProvider,
435
+ UserInfoCard,
436
+ useUser
437
+ } from "@sparkstudio/authentication-ui";
438
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
439
+ function HomeView() {
440
+ return /* @__PURE__ */ jsx(
441
+ AuthenticatorProvider,
442
+ {
443
+ googleClientId: AppSettings.GoogleClientId,
444
+ authenticationUrl: AppSettings.AuthenticationUrl,
445
+ accountsUrl: AppSettings.AccountsUrl,
446
+ children: /* @__PURE__ */ jsx(HomeContent, {})
447
+ }
448
+ );
449
+ }
450
+ function HomeContent() {
451
+ const { user } = useUser();
452
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
453
+ /* @__PURE__ */ jsx(UserInfoCard, {}),
454
+ user && /* @__PURE__ */ jsx(Fragment, { children: "Hello World" })
455
+ ] });
456
+ }
457
+ export {
458
+ GuidResultDTO,
459
+ GuidUtil,
460
+ Home,
461
+ HomeView,
462
+ RoomInstance,
463
+ RoomInstanceDTO,
464
+ RoomInstanceViewDTO,
465
+ SparkStudioRealtimeSDK,
466
+ StringResultDTO,
467
+ UniqueViewDTO,
468
+ UserSetting,
469
+ UserSettingDTO,
470
+ UserStatusType,
471
+ WebSocketClientRequestDTO,
472
+ WebSocketConnection,
473
+ WebSocketConnectionDTO
474
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkstudio/realtime-ui",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",