@stack-spot/portal-network 0.45.0 → 0.46.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/api/ai.d.ts +60 -34
  3. package/dist/api/ai.d.ts.map +1 -1
  4. package/dist/api/ai.js +38 -0
  5. package/dist/api/ai.js.map +1 -1
  6. package/dist/client/ai.d.ts +21 -0
  7. package/dist/client/ai.d.ts.map +1 -1
  8. package/dist/client/ai.js +19 -1
  9. package/dist/client/ai.js.map +1 -1
  10. package/dist/client/types.d.ts +1 -1
  11. package/dist/client/types.d.ts.map +1 -1
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/network/AutoInfiniteQuery.d.ts +2 -0
  17. package/dist/network/AutoInfiniteQuery.d.ts.map +1 -1
  18. package/dist/network/AutoInfiniteQuery.js +11 -8
  19. package/dist/network/AutoInfiniteQuery.js.map +1 -1
  20. package/dist/network/AutoMutation.d.ts +4 -2
  21. package/dist/network/AutoMutation.d.ts.map +1 -1
  22. package/dist/network/AutoMutation.js +5 -3
  23. package/dist/network/AutoMutation.js.map +1 -1
  24. package/dist/network/AutoOperation.d.ts +1 -3
  25. package/dist/network/AutoOperation.d.ts.map +1 -1
  26. package/dist/network/AutoOperation.js +4 -31
  27. package/dist/network/AutoOperation.js.map +1 -1
  28. package/dist/network/AutoQuery.d.ts +2 -6
  29. package/dist/network/AutoQuery.d.ts.map +1 -1
  30. package/dist/network/AutoQuery.js +7 -20
  31. package/dist/network/AutoQuery.js.map +1 -1
  32. package/dist/network/ManualInfiniteQuery.d.ts.map +1 -1
  33. package/dist/network/ManualInfiniteQuery.js +2 -6
  34. package/dist/network/ManualInfiniteQuery.js.map +1 -1
  35. package/dist/network/ManualMutation.d.ts +4 -2
  36. package/dist/network/ManualMutation.d.ts.map +1 -1
  37. package/dist/network/ManualMutation.js +6 -11
  38. package/dist/network/ManualMutation.js.map +1 -1
  39. package/dist/network/ManualOperation.d.ts +0 -2
  40. package/dist/network/ManualOperation.d.ts.map +1 -1
  41. package/dist/network/ManualOperation.js +0 -18
  42. package/dist/network/ManualOperation.js.map +1 -1
  43. package/dist/network/ManualQuery.d.ts +3 -7
  44. package/dist/network/ManualQuery.d.ts.map +1 -1
  45. package/dist/network/ManualQuery.js +7 -26
  46. package/dist/network/ManualQuery.js.map +1 -1
  47. package/dist/network/ReactQueryNetworkClient.d.ts.map +1 -1
  48. package/dist/network/ReactQueryNetworkClient.js +2 -0
  49. package/dist/network/ReactQueryNetworkClient.js.map +1 -1
  50. package/dist/network/react-query-client.d.ts.map +1 -1
  51. package/dist/network/react-query-client.js +9 -1
  52. package/dist/network/react-query-client.js.map +1 -1
  53. package/dist/network/types.d.ts +11 -12
  54. package/dist/network/types.d.ts.map +1 -1
  55. package/package.json +2 -2
  56. package/src/api/ai.ts +108 -34
  57. package/src/client/ai.ts +6 -0
  58. package/src/client/types.ts +2 -1
  59. package/src/index.ts +1 -0
  60. package/src/network/AutoInfiniteQuery.ts +13 -7
  61. package/src/network/AutoMutation.ts +6 -4
  62. package/src/network/AutoOperation.ts +4 -25
  63. package/src/network/AutoQuery.ts +8 -16
  64. package/src/network/ManualInfiniteQuery.ts +2 -5
  65. package/src/network/ManualMutation.ts +8 -11
  66. package/src/network/ManualOperation.ts +0 -14
  67. package/src/network/ManualQuery.ts +9 -22
  68. package/src/network/ReactQueryNetworkClient.ts +1 -0
  69. package/src/network/react-query-client.ts +9 -1
  70. package/src/network/types.ts +9 -12
  71. package/dist/error/CanceledError.d.ts +0 -8
  72. package/dist/error/CanceledError.d.ts.map +0 -1
  73. package/dist/error/CanceledError.js +0 -10
  74. package/dist/error/CanceledError.js.map +0 -1
  75. package/src/error/CanceledError.ts +0 -10
@@ -3,4 +3,12 @@ import { QueryClient } from '@tanstack/react-query'
3
3
  /**
4
4
  * The global, unique, Query Client for React Query.
5
5
  */
6
- export const queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false, retry: 3, staleTime: Infinity } } })
6
+ export const queryClient = new QueryClient({
7
+ defaultOptions: {
8
+ queries: {
9
+ refetchOnWindowFocus: false,
10
+ retry: false,
11
+ staleTime: Infinity,
12
+ },
13
+ },
14
+ })
@@ -136,15 +136,6 @@ export interface OperationObject<Variables> {
136
136
  * @returns the query key.
137
137
  */
138
138
  getPermissionKey: (...args: Variables extends void ? [] : [variables?: Partial<Variables>]) => any[],
139
- /**
140
- * Cancels the request if it hasn't finished yet.
141
- *
142
- * A canceled request will fail by throwing a `CanceledError`.
143
- *
144
- * @param variables the variables for the operation. If not provided, this will cancel all requests in progress for this operation.
145
- * @returns true if any request has been canceled, false otherwise.
146
- */
147
- cancel: (variables?: Partial<Variables>) => boolean,
148
139
  }
149
140
 
150
141
  export type UseQueryObjectOptions<Result> = Omit<UseQueryOptions<Result, StackspotAPIError>, 'queryFn' | 'queryKey'>
@@ -200,6 +191,12 @@ export interface QueryObject<Variables, Result> extends OperationObject<Variable
200
191
  * @returns the query key.
201
192
  */
202
193
  getKey: (...args: Variables extends void ? [] : [variables?: Partial<Variables>]) => any[],
194
+ /**
195
+ * Cancels the query if it hasn't finished yet.
196
+ *
197
+ * @param variables the variables for the operation. If not provided, this will cancel all requests in progress for this query.
198
+ */
199
+ cancel: (variables?: Partial<Variables>) => void,
203
200
  }
204
201
 
205
202
  export type UseInfiniteQueryObjectOptions<Result> = Omit<
@@ -263,7 +260,7 @@ export interface MutationObject<Variables, Result> extends OperationObject<Varia
263
260
  * @param args the variables for the mutation.
264
261
  * @returns a promise that resolves to the response's data.
265
262
  */
266
- mutate: (...args: Variables extends void ? [] : [variables: Variables]) => Promise<Result>,
263
+ mutate: (...args: Variables extends void ? [signal?: AbortSignal] : [variables: Variables, signal?: AbortSignal]) => Promise<Result>,
267
264
  /**
268
265
  * A React hook equivalent to React Query's `useMutation`. It creates a mutation function and the mutation states.
269
266
  * @param options the options for `useMutation`
@@ -274,7 +271,7 @@ export interface MutationObject<Variables, Result> extends OperationObject<Varia
274
271
  * - [3]: the original UseMutationResult object, from ReactQuery.
275
272
  *
276
273
  */
277
- useMutation: (options?: Omit<UseMutationOptions<Result, StackspotAPIError, Variables>, 'mutationFn'>) =>
274
+ useMutation: (options?: Omit<UseMutationOptions<Result, StackspotAPIError, Variables>, 'mutationFn'> & { signal?: AbortSignal }) =>
278
275
  Readonly<[
279
276
  (...args: Variables extends void
280
277
  ? [options?: MutateOptions<Result, StackspotAPIError>]
@@ -286,7 +283,7 @@ export interface MutationObject<Variables, Result> extends OperationObject<Varia
286
283
  ]>,
287
284
  }
288
285
 
289
- export type OperationVariables<T extends Pick<OperationObject<any>, 'cancel'>> = T extends Pick<OperationObject<infer R>, 'cancel'>
286
+ export type OperationVariables<T extends Pick<OperationObject<any>, 'isAllowed'>> = T extends Pick<OperationObject<infer R>, 'isAllowed'>
290
287
  ? R
291
288
  : never
292
289
  export type OperationResult<T extends { query: (variables?: any) => Promise<any> } | { mutate: (variables?: any) => Promise<any> }> =
@@ -1,8 +0,0 @@
1
- import { StackspotAPIError } from './StackspotAPIError.js';
2
- /**
3
- * This error is thrown when a request is canceled by the user before it completes.
4
- */
5
- export declare class CanceledError extends StackspotAPIError {
6
- constructor();
7
- }
8
- //# sourceMappingURL=CanceledError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CanceledError.d.ts","sourceRoot":"","sources":["../../src/error/CanceledError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD;;GAEG;AACH,qBAAa,aAAc,SAAQ,iBAAiB;;CAInD"}
@@ -1,10 +0,0 @@
1
- import { StackspotAPIError } from './StackspotAPIError.js';
2
- /**
3
- * This error is thrown when a request is canceled by the user before it completes.
4
- */
5
- export class CanceledError extends StackspotAPIError {
6
- constructor() {
7
- super({ status: 0, message: lang => lang === 'en' ? 'Canceled by the user' : 'Cancelado pelo usuário' });
8
- }
9
- }
10
- //# sourceMappingURL=CanceledError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CanceledError.js","sourceRoot":"","sources":["../../src/error/CanceledError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAClD;QACE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,wBAAwB,EAAE,CAAC,CAAA;IAC1G,CAAC;CACF"}
@@ -1,10 +0,0 @@
1
- import { StackspotAPIError } from './StackspotAPIError'
2
-
3
- /**
4
- * This error is thrown when a request is canceled by the user before it completes.
5
- */
6
- export class CanceledError extends StackspotAPIError {
7
- constructor() {
8
- super({ status: 0, message: lang => lang === 'en' ? 'Canceled by the user' : 'Cancelado pelo usuário' })
9
- }
10
- }