@stack-spot/portal-network 0.40.0 → 0.41.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.
@@ -8,11 +8,11 @@ import * as Oazapfts from "@oazapfts/runtime";
8
8
  import * as QS from "@oazapfts/runtime/query";
9
9
  export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = {
10
10
  headers: {},
11
- baseUrl: "https://cloud-cloud-platform-api.dev.stackspot.com",
11
+ baseUrl: "https://cloud-cloud-platform-api.stg.stackspot.com",
12
12
  };
13
13
  const oazapfts = Oazapfts.runtime(defaults);
14
14
  export const servers = {
15
- generatedServerUrl: "https://cloud-cloud-platform-api.dev.stackspot.com"
15
+ generatedServerUrl: "https://cloud-cloud-platform-api.stg.stackspot.com"
16
16
  };
17
17
  export type ReplicasConfigRequest = {
18
18
  /** Minimum number of replicas */
@@ -30,6 +30,7 @@ export type CreateDeploymentRequest = {
30
30
  [key: string]: string;
31
31
  }[];
32
32
  imageUrl?: string;
33
+ tag?: string;
33
34
  runtimeId?: string;
34
35
  runtimeTags?: string[];
35
36
  runtimeEnv?: string;
@@ -39,7 +40,7 @@ export type CreateDeploymentRequest = {
39
40
  };
40
41
  export type CreateDeploymentResponse = {
41
42
  deploymentId?: string;
42
- applicationUrl?: string;
43
+ applicationURL?: string;
43
44
  action: "DEPLOY" | "STOP" | "START" | "RESTART" | "REDEPLOY";
44
45
  containerPort?: string;
45
46
  healthCheckPath?: string;
@@ -170,8 +171,9 @@ export type ListRepositoryResponse = {
170
171
  limit: number;
171
172
  offset: number;
172
173
  };
173
- export type GetRepositoryImagesResponse = {
174
- imageUri: string[];
174
+ export type ImageResponse = {
175
+ imageUri: string;
176
+ tags: string[];
175
177
  };
176
178
  export type DeploymentStatusResponse = {
177
179
  status: "UP" | "STOPPED" | "DEPLOYING";
@@ -184,9 +186,6 @@ export type DeploymentHealthResponse = {
184
186
  };
185
187
  export type BasicDeploymentResponse = {
186
188
  deploymentId: string;
187
- runtimeName?: string;
188
- deploymentStatus?: "UP" | "STOPPED" | "DEPLOYING";
189
- runtimeEnv: string;
190
189
  };
191
190
  export type DeploymentResponse = {
192
191
  deploymentId?: string;
@@ -416,7 +415,7 @@ export function getRepositoryImages({ authorization, repositoryId }: {
416
415
  }, opts?: Oazapfts.RequestOpts) {
417
416
  return oazapfts.ok(oazapfts.fetchJson<{
418
417
  status: 200;
419
- data: GetRepositoryImagesResponse;
418
+ data: ImageResponse[];
420
419
  } | {
421
420
  status: 500;
422
421
  data: ErrorResponse;
@@ -490,7 +489,8 @@ export function getDeploymentHealth({ authorization, deploymentId }: {
490
489
  })
491
490
  }));
492
491
  }
493
- export function listDeployments({ applicationId }: {
492
+ export function listDeployments({ authorization, applicationId }: {
493
+ authorization: string;
494
494
  applicationId: string;
495
495
  }, opts?: Oazapfts.RequestOpts) {
496
496
  return oazapfts.ok(oazapfts.fetchJson<{
@@ -503,7 +503,10 @@ export function listDeployments({ applicationId }: {
503
503
  status: 503;
504
504
  data: ErrorResponse;
505
505
  }>(`/v1/deployments/${encodeURIComponent(applicationId)}`, {
506
- ...opts
506
+ ...opts,
507
+ headers: oazapfts.mergeHeaders(opts?.headers, {
508
+ Authorization: authorization
509
+ })
507
510
  }));
508
511
  }
509
512
  export function getDeployment({ authorization, deploymentId }: {
@@ -526,9 +529,9 @@ export function getDeployment({ authorization, deploymentId }: {
526
529
  })
527
530
  }));
528
531
  }
529
- export function getApplicationHistory({ authorization, applicationId, limit, offset }: {
532
+ export function getApplicationHistory({ authorization, projectId, limit, offset }: {
530
533
  authorization: string;
531
- applicationId: string;
534
+ projectId: string;
532
535
  limit?: number;
533
536
  offset?: number;
534
537
  }, opts?: Oazapfts.RequestOpts) {
@@ -541,7 +544,7 @@ export function getApplicationHistory({ authorization, applicationId, limit, off
541
544
  } | {
542
545
  status: 503;
543
546
  data: ErrorResponse;
544
- }>(`/v1/applications/${encodeURIComponent(applicationId)}/history${QS.query(QS.explode({
547
+ }>(`/v1/applications/${encodeURIComponent(projectId)}/history${QS.query(QS.explode({
545
548
  limit,
546
549
  offset
547
550
  }))}`, {
package/src/apis.json CHANGED
@@ -7,6 +7,14 @@
7
7
  },
8
8
  "docs": "/openapi.json"
9
9
  },
10
+ "agent": {
11
+ "url": {
12
+ "dev": "https://genai-ai-agent-mgmt-api.dev.stackspot.com",
13
+ "stg": "https://genai-ai-agent-mgmt-api.stg.stackspot.com",
14
+ "prd": "https://genai-ai-agent-mgmt-api.stackspot.com"
15
+ },
16
+ "docs": "/q/openapi"
17
+ },
10
18
  "workspace": {
11
19
  "url": {
12
20
  "dev": "https://workspace-workspace-api.dev.stackspot.com",
@@ -0,0 +1,35 @@
1
+ import { HttpError } from '@oazapfts/runtime'
2
+ import { defaults, getV1Agents, getV1PublicAgents } from '../api/agent'
3
+ import apis from '../apis.json'
4
+ import { StackspotAPIError } from '../error/StackspotAPIError'
5
+ import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
6
+
7
+ interface AgentError {
8
+ code?: string,
9
+ details?: string,
10
+ additionalInformation?: Record<string, any>,
11
+ }
12
+
13
+ class AgentClient extends ReactQueryNetworkClient {
14
+ constructor() {
15
+ super(apis.agent.url, defaults)
16
+ }
17
+
18
+ protected buildStackSpotError(error: HttpError): StackspotAPIError {
19
+ const errorData = error.data as AgentError | undefined
20
+ const message = [errorData?.details]
21
+ Object.keys(errorData?.additionalInformation ?? {}).forEach(k => message.push(` - ${k}: ${errorData?.additionalInformation?.[k]}`))
22
+ return new StackspotAPIError({
23
+ status: error.status,
24
+ headers: error.headers,
25
+ stack: error.stack,
26
+ code: error.data?.code,
27
+ message: message.join('\n'),
28
+ })
29
+ }
30
+
31
+ agents = this.query(getV1Agents)
32
+ publicAgents = this.query(getV1PublicAgents)
33
+ }
34
+
35
+ export const agentClient = new AgentClient()
package/src/client/ai.ts CHANGED
@@ -44,7 +44,7 @@ class AIClient extends ReactQueryNetworkClient {
44
44
  quickCommands = this.query(removeAuthorizationParam(listAllV1QuickCommandsAllGet))
45
45
  quickCommand = this.query(removeAuthorizationParam(getQuickCommandV1QuickCommandsSlugGet))
46
46
  knowledgeSources = this.query(removeAuthorizationParam(listKnowledgeSourcesV1KnowledgeSourcesGet))
47
- knowledgeSource = this.query(removeAuthorizationParam(findKnowledgeObjectByCustomIdV1KnowledgeSourcesSlugObjectsCustomIdGet))
47
+ knowledgeSourceDocument = this.query(removeAuthorizationParam(findKnowledgeObjectByCustomIdV1KnowledgeSourcesSlugObjectsCustomIdGet))
48
48
  chats = this.infiniteQuery(removeAuthorizationParam(listConversationsV1ConversationsGet))
49
49
  chat = this.query(removeAuthorizationParam(conversationHistoryV1ConversationsConversationIdGet))
50
50
  deleteChat = this.mutation(removeAuthorizationParam(deleteConversationV1ConversationsConversationIdDelete))
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { accountClient } from './client/account'
2
+ export { agentClient } from './client/agent'
2
3
  export { aiClient } from './client/ai'
3
4
  export { cloudAccountClient } from './client/cloud-account'
4
5
  export { cloudPlatformClient } from './client/cloud-platform'
@@ -23,4 +24,3 @@ export { queryClient } from './network/react-query-client'
23
24
  export { OperationResult, OperationVariables, UseQueryObjectOptions } from './network/types'
24
25
  export { StreamedJson } from './utils/StreamedJson'
25
26
  export { useExtendedList } from './utils/use-extended-list'
26
-