@sogni-ai/sogni-client 4.0.0-alpha.11 → 4.0.0-alpha.13

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 (44) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/Account/index.d.ts +1 -0
  3. package/dist/Account/index.js +11 -2
  4. package/dist/Account/index.js.map +1 -1
  5. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/BrowserWebSocketClient.d.ts +34 -0
  6. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/BrowserWebSocketClient.js +195 -0
  7. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/BrowserWebSocketClient.js.map +1 -0
  8. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/WSCoordinator.d.ts +101 -0
  9. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/WSCoordinator.js +359 -0
  10. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/WSCoordinator.js.map +1 -0
  11. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/types.d.ts +101 -0
  12. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/types.js +3 -0
  13. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/types.js.map +1 -0
  14. package/dist/ApiClient/WebSocketClient/events.d.ts +1 -0
  15. package/dist/ApiClient/WebSocketClient/index.d.ts +2 -2
  16. package/dist/ApiClient/WebSocketClient/types.d.ts +13 -0
  17. package/dist/ApiClient/index.d.ts +2 -3
  18. package/dist/ApiClient/index.js +20 -2
  19. package/dist/ApiClient/index.js.map +1 -1
  20. package/dist/Projects/Job.d.ts +1 -1
  21. package/dist/Projects/index.d.ts +3 -9
  22. package/dist/Projects/index.js +3 -1
  23. package/dist/Projects/index.js.map +1 -1
  24. package/dist/Projects/types/EstimationResponse.d.ts +2 -0
  25. package/dist/Projects/types/index.d.ts +13 -0
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +6 -2
  28. package/dist/index.js.map +1 -1
  29. package/dist/lib/DataEntity.js +4 -2
  30. package/dist/lib/DataEntity.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/Account/index.ts +11 -2
  33. package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/BrowserWebSocketClient.ts +206 -0
  34. package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/WSCoordinator.ts +425 -0
  35. package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/types.ts +107 -0
  36. package/src/ApiClient/WebSocketClient/events.ts +2 -0
  37. package/src/ApiClient/WebSocketClient/index.ts +2 -2
  38. package/src/ApiClient/WebSocketClient/types.ts +16 -0
  39. package/src/ApiClient/index.ts +25 -6
  40. package/src/Projects/index.ts +5 -2
  41. package/src/Projects/types/EstimationResponse.ts +2 -0
  42. package/src/Projects/types/index.ts +14 -0
  43. package/src/index.ts +7 -3
  44. package/src/lib/DataEntity.ts +4 -2
@@ -208,4 +208,18 @@ export interface EstimateRequest {
208
208
  contextImages?: number;
209
209
  }
210
210
 
211
+ /**
212
+ * Represents estimation of project cost in different currency formats
213
+ */
214
+ export interface CostEstimation {
215
+ /** Cost in selected token type */
216
+ token: string;
217
+ /** Cost in USD */
218
+ usd: string;
219
+ /** Cost in Spark Points */
220
+ spark: string;
221
+ /** Cost in Sogni tokens */
222
+ sogni: string;
223
+ }
224
+
211
225
  export type EnhancementStrength = 'light' | 'medium' | 'heavy';
package/src/index.ts CHANGED
@@ -63,7 +63,7 @@ export interface SogniClientConfig {
63
63
  socketEndpoint?: string;
64
64
  /**
65
65
  * Disable WebSocket connection. Useful for testing or when WebSocket is not needed.
66
- * Note that many may not work without WebSocket connection.
66
+ * Note that many APIs may not work without WebSocket connection.
67
67
  * @experimental
68
68
  * @internal
69
69
  */
@@ -141,9 +141,13 @@ export class SogniClient {
141
141
  throw Error('This method should only be called when using cookie auth');
142
142
  }
143
143
  try {
144
- await this.apiClient.rest.get<ApiResponse<MeData>>('/v1/account/me');
144
+ const res = await this.apiClient.rest.get<ApiResponse<MeData>>('/v1/account/me');
145
145
  await auth.authenticate();
146
- await this.account.me();
146
+ this.currentAccount._update({
147
+ username: res.data.username,
148
+ email: res.data.currentEmail,
149
+ walletAddress: res.data.walletAddress
150
+ });
147
151
  return true;
148
152
  } catch (e) {
149
153
  this.apiClient.logger.info('Client is not authenticated');
@@ -25,9 +25,11 @@ abstract class DataEntity<D, E extends EntityEvents = EntityEvents> extends Type
25
25
  _update(delta: Partial<D>) {
26
26
  //@ts-ignore
27
27
  const changedKeys = Object.keys(delta).filter((key) => this.data[key] !== delta[key]);
28
- this.data = { ...this.data, ...delta };
29
28
  this.lastUpdated = new Date();
30
- this.emit('updated', changedKeys);
29
+ if (changedKeys.length > 0) {
30
+ this.data = { ...this.data, ...delta };
31
+ this.emit('updated', changedKeys);
32
+ }
31
33
  }
32
34
 
33
35
  /**