@datalayer/core 0.0.16 → 0.0.18

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 (133) hide show
  1. package/README.md +9 -13
  2. package/lib/client/auth/AuthenticationManager.d.ts +95 -0
  3. package/lib/client/auth/AuthenticationManager.js +214 -0
  4. package/lib/client/auth/index.d.ts +8 -0
  5. package/lib/client/auth/index.js +17 -0
  6. package/lib/client/auth/storage.d.ts +154 -0
  7. package/lib/client/auth/storage.js +447 -0
  8. package/lib/client/auth/strategies.d.ts +54 -0
  9. package/lib/client/auth/strategies.js +238 -0
  10. package/lib/client/auth/types.d.ts +151 -0
  11. package/lib/{examples/index.js → client/auth/types.js} +4 -2
  12. package/lib/client/base.d.ts +3 -0
  13. package/lib/client/base.js +9 -0
  14. package/lib/client/index.d.ts +1 -0
  15. package/lib/client/index.js +2 -0
  16. package/lib/components/auth/Login.d.ts +40 -0
  17. package/lib/components/auth/Login.js +173 -0
  18. package/lib/components/auth/Login.stories.d.ts +54 -0
  19. package/lib/components/auth/Login.stories.js +104 -0
  20. package/lib/components/auth/LoginToken.d.ts +16 -0
  21. package/lib/components/auth/LoginToken.js +63 -0
  22. package/lib/components/auth/index.d.ts +5 -0
  23. package/lib/components/auth/index.js +16 -0
  24. package/lib/components/avatars/BoringAvatar.d.ts +6 -15
  25. package/lib/components/avatars/BoringAvatar.js +30 -34
  26. package/lib/components/avatars/BoringAvatar.stories.d.ts +7 -16
  27. package/lib/components/avatars/UserProfileAvatar.d.ts +1 -6
  28. package/lib/components/avatars/UserProfileAvatar.js +3 -8
  29. package/lib/components/buttons/DownloadCSVButton.d.ts +2 -7
  30. package/lib/components/buttons/DownloadCSVButton.js +1 -5
  31. package/lib/components/buttons/DownloadJsonButton.d.ts +3 -10
  32. package/lib/components/buttons/DownloadJsonButton.js +1 -7
  33. package/lib/components/buttons/UploadButton.d.ts +1 -4
  34. package/lib/components/buttons/UploadButton.js +3 -7
  35. package/lib/components/chat/ChatComponent.d.ts +4 -0
  36. package/lib/components/chat/ChatComponent.js +143 -0
  37. package/lib/components/chat/MessagePart.d.ts +11 -0
  38. package/lib/components/chat/MessagePart.js +23 -0
  39. package/lib/components/chat/display/DynamicToolPart.d.ts +6 -0
  40. package/lib/components/chat/display/DynamicToolPart.js +5 -0
  41. package/lib/components/chat/display/ReasoningPart.d.ts +6 -0
  42. package/lib/components/chat/display/ReasoningPart.js +58 -0
  43. package/lib/components/chat/display/TextPart.d.ts +9 -0
  44. package/lib/components/chat/display/TextPart.js +93 -0
  45. package/lib/components/chat/display/ToolPart.d.ts +6 -0
  46. package/lib/components/chat/display/ToolPart.js +148 -0
  47. package/lib/components/chat/display/index.d.ts +4 -0
  48. package/lib/components/chat/display/index.js +13 -0
  49. package/lib/components/chat/handler.d.ts +8 -0
  50. package/lib/components/chat/handler.js +43 -0
  51. package/lib/components/chat/index.d.ts +4 -0
  52. package/lib/components/chat/index.js +13 -0
  53. package/lib/components/display/CenteredSpinner.d.ts +1 -4
  54. package/lib/components/display/CenteredSpinner.js +1 -5
  55. package/lib/components/display/HorizontalCenter.d.ts +1 -4
  56. package/lib/components/display/HorizontalCenter.js +1 -5
  57. package/lib/components/flashes/FlashClosable.d.ts +1 -4
  58. package/lib/components/flashes/FlashClosable.js +1 -5
  59. package/lib/components/flashes/FlashDisclaimer.js +1 -1
  60. package/lib/components/index.d.ts +2 -1
  61. package/lib/components/index.js +2 -1
  62. package/lib/components/notebooks/JupyterNotebook.d.ts +1 -6
  63. package/lib/components/notebooks/JupyterNotebook.js +1 -5
  64. package/lib/components/runtimes/RuntimeSimplePicker.d.ts +4 -0
  65. package/lib/components/runtimes/RuntimeSimplePicker.js +3 -3
  66. package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -4
  67. package/lib/components/snapshots/RuntimeSnapshotMenu.js +1 -5
  68. package/lib/config/Configuration.js +1 -1
  69. package/lib/examples/CellExample.js +11 -47
  70. package/lib/examples/lexical-theme.css +436 -0
  71. package/lib/examples/notebooks/Matplotlib.ipynb.json +1 -1
  72. package/lib/examples/notebooks/NotebookExample1.ipynb.json +1 -1
  73. package/lib/hooks/useAIJupyterChat.d.ts +36 -0
  74. package/lib/hooks/useAIJupyterChat.js +53 -0
  75. package/lib/hooks/useBackdrop.d.ts +4 -4
  76. package/lib/hooks/useBackdrop.js +5 -9
  77. package/lib/hooks/useCache.d.ts +5 -1
  78. package/lib/hooks/useCache.js +126 -58
  79. package/lib/hooks/useMobile.d.ts +1 -0
  80. package/lib/hooks/useMobile.js +26 -0
  81. package/lib/hooks/useScreenshot.d.ts +3 -5
  82. package/lib/hooks/useScreenshot.js +1 -8
  83. package/lib/hooks/useUpload.js +29 -21
  84. package/lib/index.d.ts +1 -0
  85. package/lib/index.js +8 -4
  86. package/lib/models/Outbound.d.ts +2 -0
  87. package/lib/models/Outbound.js +3 -1
  88. package/lib/state/substates/CoreState.js +1 -1
  89. package/lib/state/substates/IAMState.js +15 -6
  90. package/lib/stateful/index.d.ts +0 -1
  91. package/lib/stateful/index.js +0 -1
  92. package/lib/stateful/runtimes/actions.d.ts +1 -1
  93. package/lib/stateful/runtimes/actions.js +1 -1
  94. package/lib/theme/DatalayerTheme.d.ts +2 -2
  95. package/lib/theme/DatalayerTheme.js +4 -4
  96. package/lib/theme/DatalayerThemeProvider.js +2 -2
  97. package/lib/tools/adapters/agui/AgUIToolAdapter.d.ts +75 -0
  98. package/lib/tools/adapters/agui/AgUIToolAdapter.js +244 -0
  99. package/lib/tools/adapters/agui/index.d.ts +10 -0
  100. package/lib/tools/adapters/agui/index.js +19 -0
  101. package/lib/tools/adapters/agui/lexicalHooks.d.ts +27 -0
  102. package/lib/tools/adapters/agui/lexicalHooks.js +64 -0
  103. package/lib/tools/adapters/agui/notebookHooks.d.ts +27 -0
  104. package/lib/tools/adapters/agui/notebookHooks.js +61 -0
  105. package/lib/tools/index.d.ts +6 -0
  106. package/lib/tools/index.js +18 -0
  107. package/lib/types.d.ts +5 -0
  108. package/lib/types.js +5 -0
  109. package/lib/utils/cli/index.d.ts +4 -0
  110. package/lib/utils/cli/index.js +13 -0
  111. package/lib/utils/cli/query.d.ts +6 -0
  112. package/lib/utils/cli/query.js +26 -0
  113. package/lib/utils/index.d.ts +1 -0
  114. package/lib/utils/index.js +1 -0
  115. package/package.json +62 -5
  116. package/style/base.css +4 -0
  117. package/lib/examples/DatalayerNotebookExample.d.ts +0 -16
  118. package/lib/examples/DatalayerNotebookExample.js +0 -75
  119. package/lib/examples/NativeNavigationExample.d.ts +0 -8
  120. package/lib/examples/NativeNavigationExample.js +0 -97
  121. package/lib/examples/NotebookMutationsKernel.d.ts +0 -2
  122. package/lib/examples/NotebookMutationsKernel.js +0 -115
  123. package/lib/examples/NotebookMutationsServiceManager.d.ts +0 -2
  124. package/lib/examples/NotebookMutationsServiceManager.js +0 -107
  125. package/lib/examples/ReactRouterExample.d.ts +0 -6
  126. package/lib/examples/ReactRouterExample.js +0 -175
  127. package/lib/examples/example-selector.d.ts +0 -22
  128. package/lib/examples/example-selector.js +0 -45
  129. package/lib/examples/index.d.ts +0 -2
  130. package/lib/examples/main.d.ts +0 -1
  131. package/lib/examples/main.js +0 -153
  132. package/lib/examples/notebooks/OutputIPyWidgetsExample.d.ts +0 -145
  133. package/lib/examples/notebooks/OutputIPyWidgetsExample.js +0 -153
@@ -227,6 +227,7 @@ export const queryKeys = {
227
227
  // Contacts
228
228
  contacts: {
229
229
  all: () => ['contacts'],
230
+ lists: () => [...queryKeys.contacts.all(), 'list'],
230
231
  details: () => [...queryKeys.contacts.all(), 'detail'],
231
232
  detail: (id) => [...queryKeys.contacts.details(), id],
232
233
  byHandle: (handle) => [...queryKeys.contacts.all(), 'handle', handle],
@@ -988,7 +989,6 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
988
989
  method: 'GET',
989
990
  });
990
991
  if (resp.success && resp.organizations) {
991
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
992
992
  const orgs = resp.organizations.map((org) => {
993
993
  const organization = toOrganization(org);
994
994
  // Pre-populate caches
@@ -1517,6 +1517,9 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
1517
1517
  return useQuery({
1518
1518
  queryKey: queryKeys.documents.bySpace(spaceId),
1519
1519
  queryFn: async () => {
1520
+ if (!spaceId) {
1521
+ return [];
1522
+ }
1520
1523
  const resp = await requestDatalayer({
1521
1524
  url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/${spaceId}/items/types/document`,
1522
1525
  method: 'GET',
@@ -1901,7 +1904,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
1901
1904
  const useCreateToken = () => {
1902
1905
  return useMutation({
1903
1906
  mutationFn: async (token) => {
1904
- return requestDatalayer({
1907
+ const resp = await requestDatalayer({
1905
1908
  url: `${configuration.iamRunUrl}/api/iam/v1/tokens`,
1906
1909
  method: 'POST',
1907
1910
  body: {
@@ -1909,13 +1912,15 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
1909
1912
  expirationDate: token.expirationDate.getTime(),
1910
1913
  },
1911
1914
  });
1915
+ // Transform the token in the response
1916
+ if (resp.success && resp.token) {
1917
+ resp.token = toToken(resp.token);
1918
+ }
1919
+ return resp;
1912
1920
  },
1913
1921
  onSuccess: resp => {
1914
1922
  if (resp.success && resp.token) {
1915
- const tok = toToken(resp.token);
1916
- if (tok) {
1917
- queryClient.setQueryData(queryKeys.tokens.detail(tok.id), tok);
1918
- }
1923
+ queryClient.setQueryData(queryKeys.tokens.detail(resp.token.id), resp.token);
1919
1924
  }
1920
1925
  queryClient.invalidateQueries({ queryKey: queryKeys.tokens.all() });
1921
1926
  },
@@ -1927,7 +1932,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
1927
1932
  /**
1928
1933
  * Get contact by ID
1929
1934
  */
1930
- const useContact = (contactId) => {
1935
+ const useContact = (contactId, options) => {
1931
1936
  return useQuery({
1932
1937
  queryKey: queryKeys.contacts.detail(contactId),
1933
1938
  queryFn: async () => {
@@ -1945,7 +1950,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
1945
1950
  throw new Error(resp.message || 'Failed to fetch contact');
1946
1951
  },
1947
1952
  ...DEFAULT_QUERY_OPTIONS,
1948
- enabled: !!contactId,
1953
+ enabled: options?.enabled ?? !!contactId,
1949
1954
  });
1950
1955
  };
1951
1956
  /**
@@ -2023,9 +2028,9 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
2023
2028
  queryClient.invalidateQueries({
2024
2029
  queryKey: queryKeys.contacts.detail(variables.contactId),
2025
2030
  });
2026
- // Invalidate all contact queries
2031
+ // Invalidate contact list queries (avoid re-fetching deleted detail)
2027
2032
  queryClient.invalidateQueries({
2028
- queryKey: queryKeys.contacts.all(),
2033
+ queryKey: queryKeys.contacts.lists(),
2029
2034
  });
2030
2035
  },
2031
2036
  });
@@ -2104,7 +2109,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
2104
2109
  });
2105
2110
  };
2106
2111
  // ============================================================================
2107
- // BATCH 1: Core CRUD Operations - Refresh & Get Methods
2112
+ // Core CRUD Operations - Refresh & Get Methods
2108
2113
  // ============================================================================
2109
2114
  /**
2110
2115
  * Get single datasource by ID
@@ -2390,7 +2395,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
2390
2395
  });
2391
2396
  };
2392
2397
  // ============================================================================
2393
- // BATCH 2: Member Management & User Extensions
2398
+ // Member Management & User Extensions
2394
2399
  // ============================================================================
2395
2400
  /**
2396
2401
  * Refresh user data by ID (re-fetch from API)
@@ -2691,7 +2696,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
2691
2696
  });
2692
2697
  };
2693
2698
  // ============================================================================
2694
- // BATCH 3: Authentication, Roles, Schools, and Refresh Methods
2699
+ // Authentication, Roles, Schools, and Refresh Methods
2695
2700
  // ============================================================================
2696
2701
  /**
2697
2702
  * Change user password
@@ -2901,9 +2906,8 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
2901
2906
  return useMutation({
2902
2907
  mutationFn: async (organizationId) => {
2903
2908
  return requestDatalayer({
2904
- url: `${configuration.iamRunUrl}/api/iam/v1/teams`,
2909
+ url: `${configuration.iamRunUrl}/api/iam/v1/organizations/${organizationId}/teams`,
2905
2910
  method: 'GET',
2906
- body: { organizationId },
2907
2911
  });
2908
2912
  },
2909
2913
  onSuccess: (resp, organizationId) => {
@@ -2955,7 +2959,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
2955
2959
  return useMutation({
2956
2960
  mutationFn: async (organizationId) => {
2957
2961
  return requestDatalayer({
2958
- url: `${configuration.spacerRunUrl}/api/spacer/v1/organizations/${organizationId}/spaces`,
2962
+ url: `${configuration.spacerRunUrl}/api/spacer/v1/spaces/organizations/${organizationId}`,
2959
2963
  method: 'GET',
2960
2964
  });
2961
2965
  },
@@ -3001,7 +3005,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
3001
3005
  });
3002
3006
  };
3003
3007
  // ============================================================================
3004
- // BATCH 4: Courses, Space Items, and Advanced Features
3008
+ // Courses, Space Items, and Advanced Features
3005
3009
  // ============================================================================
3006
3010
  /**
3007
3011
  * Get course by ID
@@ -3220,24 +3224,30 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
3220
3224
  },
3221
3225
  onSuccess: (resp, variables) => {
3222
3226
  if (resp.success) {
3227
+ // Transform raw API data to typed models
3228
+ const transformedUser = resp.user ? toUser(resp.user) : undefined;
3229
+ const transformedOrganization = resp.organization
3230
+ ? toOrganization(resp.organization)
3231
+ : undefined;
3232
+ const transformedSpace = resp.space ? toSpace(resp.space) : undefined;
3223
3233
  // Set data directly into cache instead of just invalidating
3224
- if (resp.user) {
3225
- queryClient.setQueryData(queryKeys.users.byHandle(variables.accountHandle), resp.user);
3234
+ if (transformedUser) {
3235
+ queryClient.setQueryData(queryKeys.users.byHandle(variables.accountHandle), transformedUser);
3226
3236
  queryClient.invalidateQueries({ queryKey: queryKeys.users.all() });
3227
3237
  }
3228
- if (resp.organization) {
3229
- queryClient.setQueryData(queryKeys.organizations.byHandle(variables.accountHandle), resp.organization);
3238
+ if (transformedOrganization) {
3239
+ queryClient.setQueryData(queryKeys.organizations.byHandle(variables.accountHandle), transformedOrganization);
3230
3240
  queryClient.invalidateQueries({
3231
3241
  queryKey: queryKeys.organizations.all(),
3232
3242
  });
3233
3243
  }
3234
- if (resp.space) {
3244
+ if (transformedSpace) {
3235
3245
  // Set both user and org space queries based on which type it is
3236
- if (resp.user && variables.spaceHandle) {
3237
- queryClient.setQueryData(queryKeys.spaces.byHandle(variables.spaceHandle), resp.space);
3246
+ if (transformedUser && variables.spaceHandle) {
3247
+ queryClient.setQueryData(queryKeys.spaces.byHandle(variables.spaceHandle), transformedSpace);
3238
3248
  }
3239
- if (resp.organization && variables.spaceHandle) {
3240
- queryClient.setQueryData(queryKeys.spaces.orgSpaceByHandle(resp.organization.id, variables.spaceHandle), resp.space);
3249
+ if (transformedOrganization && variables.spaceHandle) {
3250
+ queryClient.setQueryData(queryKeys.spaces.orgSpaceByHandle(transformedOrganization.id, variables.spaceHandle), transformedSpace);
3241
3251
  }
3242
3252
  queryClient.invalidateQueries({ queryKey: queryKeys.spaces.all() });
3243
3253
  }
@@ -3259,7 +3269,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
3259
3269
  });
3260
3270
  };
3261
3271
  // ============================================================================
3262
- // BATCH 5: Cells, Datasets, Environments, and Lessons
3272
+ // Cells, Datasets, Environments, and Lessons
3263
3273
  // ============================================================================
3264
3274
  /**
3265
3275
  * Get cell by ID
@@ -3536,7 +3546,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
3536
3546
  });
3537
3547
  };
3538
3548
  // ============================================================================
3539
- // BATCH 6: Exercises, Assignments, Invites, and Contacts
3549
+ // Exercises, Assignments, Invites, and Contacts
3540
3550
  // ============================================================================
3541
3551
  /**
3542
3552
  * Get exercise by ID
@@ -3768,7 +3778,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
3768
3778
  });
3769
3779
  };
3770
3780
  // ============================================================================
3771
- // [BATCH 7] Assignment Student Operations
3781
+ // Assignment Student Operations
3772
3782
  // ============================================================================
3773
3783
  /**
3774
3784
  * Fetch assignment from student perspective with enrollment data
@@ -3851,7 +3861,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
3851
3861
  });
3852
3862
  };
3853
3863
  // ============================================================================
3854
- // [BATCH 7] Exercise Grading
3864
+ // Exercise Grading
3855
3865
  // ============================================================================
3856
3866
  /**
3857
3867
  * Grade an exercise by assigning points to student code
@@ -3877,7 +3887,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
3877
3887
  });
3878
3888
  };
3879
3889
  // ============================================================================
3880
- // [BATCH 7] Course Student & Course Items
3890
+ // Course Student & Course Items
3881
3891
  // ============================================================================
3882
3892
  /**
3883
3893
  * Get a student in a course
@@ -3946,7 +3956,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
3946
3956
  });
3947
3957
  };
3948
3958
  // ============================================================================
3949
- // [BATCH 7] Inbounds & Outbounds
3959
+ // Inbounds & Outbounds
3950
3960
  // ============================================================================
3951
3961
  /**
3952
3962
  * Get all inbound leads
@@ -4020,12 +4030,15 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4020
4030
  });
4021
4031
  },
4022
4032
  onSuccess: () => {
4023
- queryClient.invalidateQueries({ queryKey: ['outbounds'] });
4033
+ queryClient.invalidateQueries({
4034
+ queryKey: ['outbounds'],
4035
+ refetchType: 'inactive',
4036
+ });
4024
4037
  },
4025
4038
  });
4026
4039
  };
4027
4040
  // ============================================================================
4028
- // [BATCH 8] Advanced Outbound Operations
4041
+ // Advanced Outbound Operations
4029
4042
  // ============================================================================
4030
4043
  /**
4031
4044
  * Try bulk emails (test mode) for outbound campaign
@@ -4043,6 +4056,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4043
4056
  onSuccess: (_, outboundId) => {
4044
4057
  queryClient.invalidateQueries({
4045
4058
  queryKey: ['outbounds', outboundId],
4059
+ refetchType: 'inactive',
4046
4060
  });
4047
4061
  },
4048
4062
  });
@@ -4061,10 +4075,13 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4061
4075
  });
4062
4076
  },
4063
4077
  onSuccess: (_, outboundId) => {
4064
- queryClient.invalidateQueries({
4078
+ queryClient.removeQueries({
4065
4079
  queryKey: ['outbounds', outboundId],
4066
4080
  });
4067
- queryClient.invalidateQueries({ queryKey: ['outbounds'] });
4081
+ queryClient.invalidateQueries({
4082
+ queryKey: ['outbounds'],
4083
+ refetchType: 'inactive',
4084
+ });
4068
4085
  },
4069
4086
  });
4070
4087
  };
@@ -4095,15 +4112,18 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4095
4112
  });
4096
4113
  },
4097
4114
  onSuccess: (_, outboundId) => {
4098
- queryClient.invalidateQueries({
4115
+ queryClient.removeQueries({
4099
4116
  queryKey: ['outbounds', outboundId],
4100
4117
  });
4101
- queryClient.invalidateQueries({ queryKey: ['outbounds'] });
4118
+ queryClient.invalidateQueries({
4119
+ queryKey: ['outbounds'],
4120
+ refetchType: 'inactive',
4121
+ });
4102
4122
  },
4103
4123
  });
4104
4124
  };
4105
4125
  // ============================================================================
4106
- // [BATCH 8] Outbound Subscriptions
4126
+ // Outbound Subscriptions
4107
4127
  // ============================================================================
4108
4128
  /**
4109
4129
  * Subscribe a user to outbound communications
@@ -4158,7 +4178,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4158
4178
  });
4159
4179
  };
4160
4180
  // ============================================================================
4161
- // [BATCH 8] MFA (Multi-Factor Authentication)
4181
+ // MFA (Multi-Factor Authentication)
4162
4182
  // ============================================================================
4163
4183
  /**
4164
4184
  * Enable MFA for current user
@@ -4209,7 +4229,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4209
4229
  });
4210
4230
  };
4211
4231
  // ============================================================================
4212
- // [BATCH 8] Checkout & Credits
4232
+ // Checkout & Credits
4213
4233
  // ============================================================================
4214
4234
  /**
4215
4235
  * Get Stripe pricing information
@@ -4264,7 +4284,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4264
4284
  });
4265
4285
  };
4266
4286
  // ============================================================================
4267
- // [BATCH 8] Support & Surveys
4287
+ // Support & Surveys
4268
4288
  // ============================================================================
4269
4289
  /**
4270
4290
  * Request platform support (first form)
@@ -4318,7 +4338,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4318
4338
  });
4319
4339
  };
4320
4340
  // ============================================================================
4321
- // [BATCH 9] Join & Registration
4341
+ // Join & Registration
4322
4342
  // ============================================================================
4323
4343
  /**
4324
4344
  * Request to join platform (standard registration)
@@ -4390,7 +4410,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4390
4410
  });
4391
4411
  };
4392
4412
  // ============================================================================
4393
- // [BATCH 9] Password Recovery
4413
+ // Password Recovery
4394
4414
  // ============================================================================
4395
4415
  /**
4396
4416
  * Create token for password change
@@ -4420,7 +4440,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4420
4440
  });
4421
4441
  };
4422
4442
  // ============================================================================
4423
- // [BATCH 9] OAuth2 Authentication
4443
+ // OAuth2 Authentication
4424
4444
  // ============================================================================
4425
4445
  /**
4426
4446
  * Get OAuth2 authorization URL
@@ -4456,7 +4476,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4456
4476
  });
4457
4477
  };
4458
4478
  // ============================================================================
4459
- // [BATCH 9] Contact Enrichment & Tagging
4479
+ // Contact Enrichment & Tagging
4460
4480
  // ============================================================================
4461
4481
  /**
4462
4482
  * Assign tag to contact
@@ -4571,7 +4591,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4571
4591
  });
4572
4592
  };
4573
4593
  // ============================================================================
4574
- // [BATCH 9] Contact-User Linking
4594
+ // Contact-User Linking
4575
4595
  // ============================================================================
4576
4596
  /**
4577
4597
  * Link user with contact
@@ -4618,7 +4638,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4618
4638
  });
4619
4639
  };
4620
4640
  // ============================================================================
4621
- // [BATCH 9] Credits Quota & Usage
4641
+ // Credits Quota & Usage
4622
4642
  // ============================================================================
4623
4643
  /**
4624
4644
  * Update user credits quota
@@ -4655,7 +4675,23 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4655
4675
  url: `${configuration.iamRunUrl}/api/iam/v1/usage/user`,
4656
4676
  method: 'GET',
4657
4677
  });
4658
- return resp.usages || [];
4678
+ // Transform snake_case API response to camelCase IUsage interface
4679
+ const usages = (resp.usages || []).map((u) => ({
4680
+ id: u.resource_uid,
4681
+ accountId: u.account_uid,
4682
+ type: u.resource_type,
4683
+ burningRate: u.burning_rate,
4684
+ credits: u.credits,
4685
+ creditsLimit: u.credits_limit,
4686
+ startDate: u.start_date ? new Date(u.start_date) : new Date(),
4687
+ updatedAt: u.updated_at ? new Date(u.updated_at) : new Date(),
4688
+ endDate: u.end_date ? new Date(u.end_date) : undefined,
4689
+ givenName: u.given_name || u.resource_given_name || '',
4690
+ resourceState: u.resource_state,
4691
+ resources: u.pod_resources,
4692
+ metadata: new Map(Object.entries(u.metadata || {})),
4693
+ }));
4694
+ return usages;
4659
4695
  },
4660
4696
  ...options,
4661
4697
  });
@@ -4671,7 +4707,23 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4671
4707
  url: `${configuration.iamRunUrl}/api/iam/v1/usage/users/${userId}`,
4672
4708
  method: 'GET',
4673
4709
  });
4674
- return resp.usages || [];
4710
+ // Transform snake_case API response to camelCase IUsage interface
4711
+ const usages = (resp.usages || []).map((u) => ({
4712
+ id: u.resource_uid,
4713
+ accountId: u.account_uid,
4714
+ type: u.resource_type,
4715
+ burningRate: u.burning_rate,
4716
+ credits: u.credits,
4717
+ creditsLimit: u.credits_limit,
4718
+ startDate: u.start_date ? new Date(u.start_date) : new Date(),
4719
+ updatedAt: u.updated_at ? new Date(u.updated_at) : new Date(),
4720
+ endDate: u.end_date ? new Date(u.end_date) : undefined,
4721
+ givenName: u.given_name || u.resource_given_name || '',
4722
+ resourceState: u.resource_state,
4723
+ resources: u.pod_resources,
4724
+ metadata: new Map(Object.entries(u.metadata || {})),
4725
+ }));
4726
+ return usages;
4675
4727
  },
4676
4728
  enabled: !!userId,
4677
4729
  ...options,
@@ -4688,13 +4740,29 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4688
4740
  url: `${configuration.iamRunUrl}/api/iam/v1/usage/platform`,
4689
4741
  method: 'GET',
4690
4742
  });
4691
- return resp.usages || [];
4743
+ // Transform snake_case API response to camelCase IUsage interface
4744
+ const usages = (resp.usages || []).map((u) => ({
4745
+ id: u.resource_uid,
4746
+ accountId: u.account_uid,
4747
+ type: u.resource_type,
4748
+ burningRate: u.burning_rate,
4749
+ credits: u.credits,
4750
+ creditsLimit: u.credits_limit,
4751
+ startDate: u.start_date ? new Date(u.start_date) : new Date(),
4752
+ updatedAt: u.updated_at ? new Date(u.updated_at) : new Date(),
4753
+ endDate: u.end_date ? new Date(u.end_date) : undefined,
4754
+ givenName: u.given_name || u.resource_given_name || '',
4755
+ resourceState: u.resource_state,
4756
+ resources: u.pod_resources,
4757
+ metadata: new Map(Object.entries(u.metadata || {})),
4758
+ }));
4759
+ return usages;
4692
4760
  },
4693
4761
  ...options,
4694
4762
  });
4695
4763
  };
4696
4764
  // ============================================================================
4697
- // [BATCH 10] Search Operations
4765
+ // Search Operations
4698
4766
  // ============================================================================
4699
4767
  /**
4700
4768
  * Search public items (notebooks, documents, etc.)
@@ -4722,7 +4790,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4722
4790
  });
4723
4791
  };
4724
4792
  // ============================================================================
4725
- // [BATCH 10] Social Media Integrations
4793
+ // Social Media Integrations
4726
4794
  // ============================================================================
4727
4795
  /**
4728
4796
  * Get GitHub profile from access token
@@ -4874,7 +4942,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4874
4942
  });
4875
4943
  };
4876
4944
  // ============================================================================
4877
- // [BATCH 10] Proxy Operations
4945
+ // Proxy Operations
4878
4946
  // ============================================================================
4879
4947
  /**
4880
4948
  * Proxy GET request
@@ -4933,7 +5001,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4933
5001
  });
4934
5002
  };
4935
5003
  // ============================================================================
4936
- // [BATCH 10] Waiting List & Growth
5004
+ // Waiting List & Growth
4937
5005
  // ============================================================================
4938
5006
  /**
4939
5007
  * Register to waiting list
@@ -4971,7 +5039,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
4971
5039
  });
4972
5040
  };
4973
5041
  // ============================================================================
4974
- // BATCH 11: Refresh Operations & Additional Methods
5042
+ // Refresh Operations & Additional Methods
4975
5043
  // ============================================================================
4976
5044
  /**
4977
5045
  * Refresh a specific user space
@@ -5411,7 +5479,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
5411
5479
  });
5412
5480
  };
5413
5481
  // ============================================================================
5414
- // BATCH 12: Additional Refresh Operations
5482
+ // Additional Refresh Operations
5415
5483
  // ============================================================================
5416
5484
  /**
5417
5485
  * Refresh a specific environment
@@ -5646,7 +5714,7 @@ export const useCache = ({ loginRoute = '/login' } = {}) => {
5646
5714
  });
5647
5715
  };
5648
5716
  // ============================================================================
5649
- // BATCH 13: Final Methods - Invites, Contacts, Inbounds, Outbounds
5717
+ // Invites, Contacts, Inbounds, Outbounds
5650
5718
  // ============================================================================
5651
5719
  /**
5652
5720
  * Request an invite (mutation)
@@ -0,0 +1 @@
1
+ export declare function useIsMobile(): boolean;
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /*
6
+ * Copyright (c) 2024-2025 Datalayer, Inc.
7
+ *
8
+ * BSD 3-Clause License
9
+ */
10
+ import * as React from 'react';
11
+ const MOBILE_BREAKPOINT = 768;
12
+ export function useIsMobile() {
13
+ const [isMobile, setIsMobile] = React.useState(undefined);
14
+ React.useEffect(() => {
15
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
16
+ const onChange = () => {
17
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
18
+ };
19
+ mql.addEventListener('change', onChange);
20
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
21
+ return () => {
22
+ mql.removeEventListener('change', onChange);
23
+ };
24
+ }, []);
25
+ return !!isMobile;
26
+ }
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  type ScreenshotContextType = {
2
3
  closeScreenshot: () => void;
3
4
  displayScreenshot: (nextScreenshot: any) => void;
@@ -9,13 +10,10 @@ export declare function useScreenshot(): ScreenshotContextType;
9
10
  */
10
11
  export declare const ScreenshotContextProvider: import("react").Provider<ScreenshotContextType>;
11
12
  type IScreenshotProviderProps = {
12
- children?: JSX.Element | JSX.Element[];
13
+ children?: ReactNode;
13
14
  zIndex?: number;
14
15
  disableDarken?: boolean;
15
16
  screenshotSurface?: (qfds: any) => JSX.Element;
16
17
  };
17
- export declare function ScreenshotProvider(props: IScreenshotProviderProps): import("react/jsx-runtime").JSX.Element;
18
- export declare namespace ScreenshotProvider {
19
- var defaultProps: IScreenshotProviderProps;
20
- }
18
+ export declare function ScreenshotProvider({ children, zIndex, disableDarken, screenshotSurface, }: IScreenshotProviderProps): import("react/jsx-runtime").JSX.Element;
21
19
  export {};
@@ -19,8 +19,7 @@ export function useScreenshot() {
19
19
  * The type for the Screenshot context provider.
20
20
  */
21
21
  export const ScreenshotContextProvider = ScreenshotContext.Provider;
22
- export function ScreenshotProvider(props) {
23
- const { children, zIndex, disableDarken, screenshotSurface } = props;
22
+ export function ScreenshotProvider({ children = null, zIndex = 9999, disableDarken = false, screenshotSurface = undefined, }) {
24
23
  const defaultScreenshotSurface = {
25
24
  position: 'fixed',
26
25
  top: 0,
@@ -52,9 +51,3 @@ export function ScreenshotProvider(props) {
52
51
  return (_jsxs(ScreenshotContextProvider, { value: { closeScreenshot, displayScreenshot }, children: [_jsx(LayoutScreenshot, {}), children, screenshot.open &&
53
52
  (screenshotSurface ? (screenshotSurface(screenshot.render(closeScreenshot))) : (_jsx("div", { style: defaultScreenshotSurface, children: screenshot.render(closeScreenshot) })))] }));
54
53
  }
55
- ScreenshotProvider.defaultProps = {
56
- children: undefined,
57
- disableScreenshot: false,
58
- zIndex: 9999,
59
- screenshotSurface: undefined,
60
- };
@@ -20,27 +20,35 @@ export const useUploadForm = (url) => {
20
20
  };
21
21
  const uploadAndSubmit = async (formData) => {
22
22
  setIsLoading(true);
23
- const { data } = await axios.post(url, formData, {
24
- headers: {
25
- 'Content-Type': 'multipart/form-data',
26
- Authorization: `Bearer ${token}`,
27
- },
28
- onUploadProgress: progressEvent => {
29
- const progress = (progressEvent.loaded / progressEvent.total) * 50;
30
- setProgress(progress);
31
- },
32
- onDownloadProgress: progressEvent => {
33
- const progress = 50 + (progressEvent.loaded / progressEvent.total) * 50;
34
- setProgress(progress);
35
- },
36
- });
37
- setProgress(100);
38
- await new Promise(resolve => {
39
- setTimeout(() => resolve('success'), 500);
40
- });
41
- setIsSuccess(true);
42
- setProgress(0);
43
- return data;
23
+ try {
24
+ const { data } = await axios.post(url, formData, {
25
+ headers: {
26
+ 'Content-Type': 'multipart/form-data',
27
+ Authorization: `Bearer ${token}`,
28
+ },
29
+ onUploadProgress: progressEvent => {
30
+ const progress = (progressEvent.loaded / progressEvent.total) * 50;
31
+ setProgress(progress);
32
+ },
33
+ onDownloadProgress: progressEvent => {
34
+ const progress = 50 + (progressEvent.loaded / progressEvent.total) * 50;
35
+ setProgress(progress);
36
+ },
37
+ });
38
+ setProgress(100);
39
+ await new Promise(resolve => {
40
+ setTimeout(() => resolve('success'), 500);
41
+ });
42
+ setIsSuccess(true);
43
+ setIsLoading(false);
44
+ setProgress(0);
45
+ return data;
46
+ }
47
+ catch (error) {
48
+ setIsLoading(false);
49
+ setProgress(0);
50
+ throw error;
51
+ }
44
52
  };
45
53
  return { uploadAndSubmit, isSuccess, isLoading, progress, reset };
46
54
  };
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './components';
1
2
  export * from './utils';
2
3
  export * from './state';
3
4
  export * from './collaboration';