@stack-spot/portal-network 0.58.4 → 0.58.6

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 (37) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/api/cloudPlatform.d.ts +53 -2
  3. package/dist/api/cloudPlatform.d.ts.map +1 -1
  4. package/dist/api/cloudPlatform.js +28 -2
  5. package/dist/api/cloudPlatform.js.map +1 -1
  6. package/dist/api/cloudRuntimes.d.ts +34 -21
  7. package/dist/api/cloudRuntimes.d.ts.map +1 -1
  8. package/dist/api/cloudRuntimes.js +12 -0
  9. package/dist/api/cloudRuntimes.js.map +1 -1
  10. package/dist/client/cloud-platform.d.ts +1 -1
  11. package/dist/client/cloud-runtimes.d.ts +6 -0
  12. package/dist/client/cloud-runtimes.d.ts.map +1 -1
  13. package/dist/client/cloud-runtimes.js +10 -1
  14. package/dist/client/cloud-runtimes.js.map +1 -1
  15. package/dist/client/content.d.ts +24 -23
  16. package/dist/client/content.d.ts.map +1 -1
  17. package/dist/client/content.js +9 -1
  18. package/dist/client/content.js.map +1 -1
  19. package/dist/network/AutoInfiniteQuery.d.ts.map +1 -1
  20. package/dist/network/AutoInfiniteQuery.js +2 -1
  21. package/dist/network/AutoInfiniteQuery.js.map +1 -1
  22. package/dist/network/ManualInfiniteQuery.d.ts.map +1 -1
  23. package/dist/network/ManualInfiniteQuery.js +2 -1
  24. package/dist/network/ManualInfiniteQuery.js.map +1 -1
  25. package/dist/network/ReactQueryNetworkClient.d.ts +8 -0
  26. package/dist/network/ReactQueryNetworkClient.d.ts.map +1 -1
  27. package/dist/network/ReactQueryNetworkClient.js.map +1 -1
  28. package/dist/network/types.d.ts +1 -1
  29. package/package.json +1 -1
  30. package/src/api/cloudPlatform.ts +87 -4
  31. package/src/api/cloudRuntimes.ts +98 -21
  32. package/src/client/cloud-runtimes.ts +5 -0
  33. package/src/client/content.ts +10 -1
  34. package/src/network/AutoInfiniteQuery.ts +3 -2
  35. package/src/network/ManualInfiniteQuery.ts +3 -3
  36. package/src/network/ReactQueryNetworkClient.ts +16 -0
  37. package/src/network/types.ts +1 -1
@@ -41,6 +41,33 @@ export type CreateDeploymentRequestV2 = {
41
41
  applicationURL?: string;
42
42
  };
43
43
  export type StatusType = number;
44
+ export type SetAutoscalingRequest = {
45
+ deploymentId: string;
46
+ cpu: string;
47
+ mem: string;
48
+ replicaNum: ReplicaNum;
49
+ applicationName: string;
50
+ };
51
+ export type CreateDeploymentResponseV2 = {
52
+ id?: string;
53
+ runtimeId: string;
54
+ applicationId?: string;
55
+ applicationName?: string;
56
+ action: string;
57
+ containerPort?: number;
58
+ healthCheckPath?: string;
59
+ imageUrl: string;
60
+ tag: string;
61
+ mem?: number;
62
+ envVars?: EnvVar[];
63
+ cpu?: number;
64
+ replicaNum?: ReplicaNum;
65
+ awsAccount: string;
66
+ idAwsAccount: string;
67
+ health?: string;
68
+ applicationURL?: string;
69
+ status?: string;
70
+ };
44
71
  export type ApplicationDtov2 = {
45
72
  id?: string;
46
73
  name: string;
@@ -173,28 +200,8 @@ export type PaginatedResponseApplicationDto = {
173
200
  numberOfElements?: number;
174
201
  empty?: boolean;
175
202
  };
176
- export type CreateDeploymentResponseV2 = {
177
- id?: string;
178
- runtimeId: string;
179
- applicationId?: string;
180
- applicationName?: string;
181
- action: string;
182
- containerPort?: number;
183
- healthCheckPath?: string;
184
- imageUrl: string;
185
- tag: string;
186
- mem?: number;
187
- envVars?: EnvVar[];
188
- cpu?: number;
189
- replicaNum?: ReplicaNum;
190
- awsAccount: string;
191
- idAwsAccount: string;
192
- health?: string;
193
- applicationURL?: string;
194
- status?: string;
195
- };
196
203
  export type StatusResponse = {
197
- status: "UP" | "DEPLOYING" | "STOPPED";
204
+ status: "UP" | "DEPLOYING" | "STOPPED" | "UNKNOWN";
198
205
  };
199
206
  export type GetDeploymentLogsResponse = {
200
207
  logs: string;
@@ -341,6 +348,42 @@ export function createDeployment({ createDeploymentRequestV2 }: {
341
348
  body: createDeploymentRequestV2
342
349
  })));
343
350
  }
351
+ export function setAutoscallihng({ setAutoscalingRequest }: {
352
+ setAutoscalingRequest: SetAutoscalingRequest;
353
+ }, opts?: Oazapfts.RequestOpts) {
354
+ return oazapfts.ok(oazapfts.fetchJson<{
355
+ status: 200;
356
+ data: CreateDeploymentResponseV2;
357
+ } | {
358
+ status: 422;
359
+ data: {
360
+ instance?: string;
361
+ "type"?: string;
362
+ parameters?: {
363
+ [key: string]: object;
364
+ };
365
+ title?: string;
366
+ status?: StatusType;
367
+ detail?: string;
368
+ };
369
+ } | {
370
+ status: 500;
371
+ data: {
372
+ instance?: string;
373
+ "type"?: string;
374
+ parameters?: {
375
+ [key: string]: object;
376
+ };
377
+ title?: string;
378
+ status?: StatusType;
379
+ detail?: string;
380
+ };
381
+ }>("/v2/deployments/autoscalling", oazapfts.json({
382
+ ...opts,
383
+ method: "POST",
384
+ body: setAutoscalingRequest
385
+ })));
386
+ }
344
387
  export function createApplication({ applicationDtov2 }: {
345
388
  applicationDtov2: ApplicationDtov2;
346
389
  }, opts?: Oazapfts.RequestOpts) {
@@ -1049,6 +1092,40 @@ export function listDeployments({ applicationId }: {
1049
1092
  ...opts
1050
1093
  }));
1051
1094
  }
1095
+ export function getLastDeploymentByRuntime({ applicationId }: {
1096
+ applicationId: string;
1097
+ }, opts?: Oazapfts.RequestOpts) {
1098
+ return oazapfts.ok(oazapfts.fetchJson<{
1099
+ status: 200;
1100
+ data: BasicDeploymentResponse[];
1101
+ } | {
1102
+ status: 422;
1103
+ data: {
1104
+ instance?: string;
1105
+ "type"?: string;
1106
+ parameters?: {
1107
+ [key: string]: object;
1108
+ };
1109
+ title?: string;
1110
+ status?: StatusType;
1111
+ detail?: string;
1112
+ };
1113
+ } | {
1114
+ status: 500;
1115
+ data: {
1116
+ instance?: string;
1117
+ "type"?: string;
1118
+ parameters?: {
1119
+ [key: string]: object;
1120
+ };
1121
+ title?: string;
1122
+ status?: StatusType;
1123
+ detail?: string;
1124
+ };
1125
+ }>(`/v2/applications/${encodeURIComponent(applicationId)}/deployments/last/runtime`, {
1126
+ ...opts
1127
+ }));
1128
+ }
1052
1129
  export function listApplications1({ projectId, limit, offset }: {
1053
1130
  projectId: string;
1054
1131
  limit?: number;
@@ -10,6 +10,7 @@ import
10
10
  getDeploymentHealth,
11
11
  getDeploymentLogs,
12
12
  getDeploymentStatus,
13
+ getLastDeploymentByRuntime,
13
14
  getRepositoryImages,
14
15
  listApplications,
15
16
  listDeployments,
@@ -49,6 +50,10 @@ class CloudRuntimesClient extends ReactQueryNetworkClient {
49
50
  * Get list of application deployments
50
51
  */
51
52
  listApplicationDeployments = this.query(removeAuthorizationParam(listDeployments))
53
+ /**
54
+ * Get list of last deployments by runtime
55
+ */
56
+ listLastApplicationDeploymentsByRuntime = this.query(removeAuthorizationParam(getLastDeploymentByRuntime))
52
57
  /**
53
58
  * Get an application deployment by id
54
59
  */
@@ -68,6 +68,7 @@ import {
68
68
  listWorkflows,
69
69
  listWorkflowVersion,
70
70
  listWorkspaces,
71
+ Pageable,
71
72
  patchStarterV2,
72
73
  removeActionFromPlugin,
73
74
  removeStackWorkflow,
@@ -173,7 +174,15 @@ class ContentClient extends ReactQueryNetworkClient {
173
174
  /**
174
175
  * Gets workflows from a given studio
175
176
  */
176
- workflowsFromStudio = this.infiniteQuery(getWorkflowByStudioSlug, { accumulator: 'content' })
177
+ workflowsFromStudio = this.infiniteQuery(getWorkflowByStudioSlug, { accumulator: 'content',
178
+ pageParamName: 'pageable.page',
179
+ initialPageParam: { page: 0 },
180
+ getNextPageParam: ({ variables, lastPage, lastPageParam }) => {
181
+ const size = variables.pageable.size ?? 1
182
+ const parsedLastPageParam = (lastPageParam as Pageable)?.page ?? 0
183
+ return lastPage.content && lastPage.content.length < size ? undefined : { page: parsedLastPageParam + 1 }
184
+ },
185
+ })
177
186
  /**
178
187
  * Gets workflows from a given studio
179
188
  */
@@ -6,6 +6,7 @@ import {
6
6
  useInfiniteQuery,
7
7
  useSuspenseInfiniteQuery,
8
8
  } from '@tanstack/react-query'
9
+ import { get, set } from 'lodash'
9
10
  import { StackspotAPIError } from '../error/StackspotAPIError'
10
11
  import { AutoQuery } from './AutoQuery'
11
12
  import { queryClient } from './react-query-client'
@@ -35,8 +36,8 @@ export class AutoInfiniteQuery<Variables, Result, PageParamName extends keyof Va
35
36
  return ({ pageParam, signal }) => {
36
37
  const paginatedVariables = {
37
38
  ...variables,
38
- [this.options.pageParamName]: pageParam ?? variables?.[this.options.pageParamName],
39
- } as Variables
39
+ }
40
+ set(paginatedVariables, this.options.pageParamName, pageParam ?? get(variables, this.options.pageParamName))
40
41
  return this.callFn(paginatedVariables, signal)
41
42
  }
42
43
  }
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react-hooks/rules-of-hooks */
2
-
3
2
  import { InfiniteData, QueryFunctionContext, QueryKey, UseInfiniteQueryResult, useInfiniteQuery, useSuspenseInfiniteQuery } from '@tanstack/react-query'
3
+ import { get, set } from 'lodash'
4
4
  import { StackspotAPIError } from '../error/StackspotAPIError'
5
5
  import { ManualQuery } from './ManualQuery'
6
6
  import { queryClient } from './react-query-client'
@@ -29,8 +29,8 @@ export class ManualInfiniteQuery<
29
29
  return ({ pageParam, signal }) => {
30
30
  const paginatedVariables = {
31
31
  ...variables,
32
- [this.getConfig().pageParamName]: pageParam ?? variables?.[this.getConfig().pageParamName],
33
- } as Variables
32
+ }
33
+ set(paginatedVariables, this.getConfig().pageParamName, pageParam ?? get(variables, this.getConfig().pageParamName))
34
34
  return this.makeRequest(paginatedVariables, signal)
35
35
  }
36
36
  }
@@ -218,6 +218,22 @@ export abstract class ReactQueryNetworkClient extends NetworkClient {
218
218
  fn: (variables: Variables, opts?: RequestOpts) => Promise<Result>,
219
219
  options?: Partial<InfiniteQueryOptions<Variables, Result, PageParamName, Accumulator>>,
220
220
  ): InfiniteQueryObject<Variables, Result, Accumulator>
221
+ /**
222
+ * Builds a query automatically by using a function generated by oazapfts in which the variables `pageParamName` is a string
223
+ * which can be used for dynamic indexing.
224
+ * @param fn the oazapfts function that returns an array.
225
+ * @param options optional configuration for the infinite query. By default, it will use the variables page and size of the function
226
+ * passed in the first parameter.
227
+ */
228
+ protected infiniteQuery<
229
+ Variables extends Record<string, any>,
230
+ Result,
231
+ PageParamName extends string,
232
+ Accumulator extends keyof Result,
233
+ >(
234
+ fn: (variables: Variables, opts?: RequestOpts) => Promise<Result>,
235
+ options: Partial<InfiniteQueryOptions<Variables, Result, PageParamName, Accumulator>>,
236
+ ): InfiniteQueryObject<Variables, Result, Accumulator>
221
237
  protected infiniteQuery(
222
238
  fnOrConfig: any, options?: Partial<InfiniteQueryOptions<any, any, any, any>>,
223
239
  ): InfiniteQueryObject<any, any, any> {
@@ -57,7 +57,7 @@ export interface InfiniteQueryOptions<Variables, Result, PageParamName extends k
57
57
  defaultVariables?: Partial<Variables>,
58
58
  /**
59
59
  * A function that determines the value of the page variable in order to get the next page.
60
- * @parar context the current context with the variables and page details.
60
+ * @param context the current context with the variables and page details.
61
61
  * @returns undefined or null if there are no more pages. The next value for the page variable otherwise.
62
62
  */
63
63
  getNextPageParam: (context: {