@stack-spot/portal-network 0.158.0 → 0.159.0-beta.2

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 (147) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/dist/api/codeShift.d.ts +110 -196
  3. package/dist/api/codeShift.d.ts.map +1 -1
  4. package/dist/api/codeShift.js +37 -94
  5. package/dist/api/codeShift.js.map +1 -1
  6. package/dist/api-addresses.d.ts +32 -0
  7. package/dist/api-addresses.d.ts.map +1 -1
  8. package/dist/api-addresses.js +53 -0
  9. package/dist/api-addresses.js.map +1 -1
  10. package/dist/client/account.d.ts +7 -0
  11. package/dist/client/account.d.ts.map +1 -1
  12. package/dist/client/account.js +12 -3
  13. package/dist/client/account.js.map +1 -1
  14. package/dist/client/agent-tools.d.ts +89 -3
  15. package/dist/client/agent-tools.d.ts.map +1 -1
  16. package/dist/client/agent-tools.js +135 -4
  17. package/dist/client/agent-tools.js.map +1 -1
  18. package/dist/client/agent.d.ts +5 -49
  19. package/dist/client/agent.d.ts.map +1 -1
  20. package/dist/client/agent.js +2 -65
  21. package/dist/client/agent.js.map +1 -1
  22. package/dist/client/ai.d.ts +7 -0
  23. package/dist/client/ai.d.ts.map +1 -1
  24. package/dist/client/ai.js +12 -3
  25. package/dist/client/ai.js.map +1 -1
  26. package/dist/client/api-management.d.ts.map +1 -1
  27. package/dist/client/api-management.js +2 -2
  28. package/dist/client/api-management.js.map +1 -1
  29. package/dist/client/cloud-account.d.ts.map +1 -1
  30. package/dist/client/cloud-account.js +2 -2
  31. package/dist/client/cloud-account.js.map +1 -1
  32. package/dist/client/cloud-platform-horizon.d.ts.map +1 -1
  33. package/dist/client/cloud-platform-horizon.js +2 -2
  34. package/dist/client/cloud-platform-horizon.js.map +1 -1
  35. package/dist/client/cloud-platform.d.ts.map +1 -1
  36. package/dist/client/cloud-platform.js +2 -2
  37. package/dist/client/cloud-platform.js.map +1 -1
  38. package/dist/client/cloud-runtimes.d.ts.map +1 -1
  39. package/dist/client/cloud-runtimes.js +2 -2
  40. package/dist/client/cloud-runtimes.js.map +1 -1
  41. package/dist/client/cloud-services.d.ts.map +1 -1
  42. package/dist/client/cloud-services.js +2 -2
  43. package/dist/client/cloud-services.js.map +1 -1
  44. package/dist/client/code-shift.d.ts +25 -67
  45. package/dist/client/code-shift.d.ts.map +1 -1
  46. package/dist/client/code-shift.js +32 -75
  47. package/dist/client/code-shift.js.map +1 -1
  48. package/dist/client/content.d.ts.map +1 -1
  49. package/dist/client/content.js +2 -2
  50. package/dist/client/content.js.map +1 -1
  51. package/dist/client/data-integration.d.ts.map +1 -1
  52. package/dist/client/data-integration.js +2 -2
  53. package/dist/client/data-integration.js.map +1 -1
  54. package/dist/client/discovery.d.ts.map +1 -1
  55. package/dist/client/discovery.js +2 -2
  56. package/dist/client/discovery.js.map +1 -1
  57. package/dist/client/event-bus.d.ts.map +1 -1
  58. package/dist/client/event-bus.js +2 -2
  59. package/dist/client/event-bus.js.map +1 -1
  60. package/dist/client/gen-ai-inference.d.ts +9 -0
  61. package/dist/client/gen-ai-inference.d.ts.map +1 -1
  62. package/dist/client/gen-ai-inference.js +12 -3
  63. package/dist/client/gen-ai-inference.js.map +1 -1
  64. package/dist/client/insights.d.ts.map +1 -1
  65. package/dist/client/insights.js +2 -2
  66. package/dist/client/insights.js.map +1 -1
  67. package/dist/client/notification.d.ts.map +1 -1
  68. package/dist/client/notification.js +2 -2
  69. package/dist/client/notification.js.map +1 -1
  70. package/dist/client/runtime-manager.d.ts.map +1 -1
  71. package/dist/client/runtime-manager.js +2 -2
  72. package/dist/client/runtime-manager.js.map +1 -1
  73. package/dist/client/secrets.d.ts.map +1 -1
  74. package/dist/client/secrets.js +2 -2
  75. package/dist/client/secrets.js.map +1 -1
  76. package/dist/client/types.d.ts +5 -4
  77. package/dist/client/types.d.ts.map +1 -1
  78. package/dist/client/workflow.d.ts.map +1 -1
  79. package/dist/client/workflow.js +2 -2
  80. package/dist/client/workflow.js.map +1 -1
  81. package/dist/client/workspace-ai.d.ts +1 -4
  82. package/dist/client/workspace-ai.d.ts.map +1 -1
  83. package/dist/client/workspace-ai.js +2 -2
  84. package/dist/client/workspace-ai.js.map +1 -1
  85. package/dist/client/workspace-manager.d.ts.map +1 -1
  86. package/dist/client/workspace-manager.js +2 -2
  87. package/dist/client/workspace-manager.js.map +1 -1
  88. package/dist/client/workspace-search.d.ts.map +1 -1
  89. package/dist/client/workspace-search.js +2 -2
  90. package/dist/client/workspace-search.js.map +1 -1
  91. package/dist/client/workspace.d.ts.map +1 -1
  92. package/dist/client/workspace.js +2 -2
  93. package/dist/client/workspace.js.map +1 -1
  94. package/dist/error/DefaultAPIError.d.ts +1 -1
  95. package/dist/error/DefaultAPIError.d.ts.map +1 -1
  96. package/dist/error/DefaultAPIError.js +27 -12
  97. package/dist/error/DefaultAPIError.js.map +1 -1
  98. package/dist/error/types.d.ts +19 -0
  99. package/dist/error/types.d.ts.map +1 -0
  100. package/dist/error/types.js +2 -0
  101. package/dist/error/types.js.map +1 -0
  102. package/dist/index.d.ts +1 -1
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +1 -1
  105. package/dist/index.js.map +1 -1
  106. package/dist/network/NetworkClient.d.ts +6 -0
  107. package/dist/network/NetworkClient.d.ts.map +1 -1
  108. package/dist/network/NetworkClient.js +10 -1
  109. package/dist/network/NetworkClient.js.map +1 -1
  110. package/package.json +1 -1
  111. package/readme.md +1 -1
  112. package/src/api/account.ts +1 -0
  113. package/src/api/agent-tools.ts +3 -0
  114. package/src/api/agent.ts +2 -0
  115. package/src/api/codeShift.ts +257 -481
  116. package/src/api/notification.ts +2 -0
  117. package/src/api-addresses.ts +71 -0
  118. package/src/client/account.ts +12 -3
  119. package/src/client/agent-tools.ts +103 -5
  120. package/src/client/agent.ts +2 -68
  121. package/src/client/ai.ts +8 -2
  122. package/src/client/api-management.ts +2 -2
  123. package/src/client/cloud-account.ts +2 -2
  124. package/src/client/cloud-platform-horizon.ts +2 -2
  125. package/src/client/cloud-platform.ts +2 -2
  126. package/src/client/cloud-runtimes.ts +2 -2
  127. package/src/client/cloud-services.ts +2 -2
  128. package/src/client/code-shift.ts +21 -59
  129. package/src/client/content.ts +2 -2
  130. package/src/client/data-integration.ts +2 -2
  131. package/src/client/discovery.ts +2 -2
  132. package/src/client/event-bus.ts +2 -2
  133. package/src/client/gen-ai-inference.ts +8 -3
  134. package/src/client/insights.ts +2 -2
  135. package/src/client/notification.ts +2 -2
  136. package/src/client/runtime-manager.ts +2 -2
  137. package/src/client/secrets.ts +2 -2
  138. package/src/client/types.ts +7 -5
  139. package/src/client/workflow.ts +2 -2
  140. package/src/client/workspace-ai.ts +2 -2
  141. package/src/client/workspace-manager.ts +2 -2
  142. package/src/client/workspace-search.ts +2 -2
  143. package/src/client/workspace.ts +2 -2
  144. package/src/error/DefaultAPIError.ts +35 -12
  145. package/src/error/types.ts +21 -0
  146. package/src/index.ts +1 -1
  147. package/src/network/NetworkClient.ts +11 -1
@@ -332,3 +332,5 @@ export function delete1({ notificationIntentId }: {
332
332
  method: "DELETE"
333
333
  }));
334
334
  }
335
+
336
+
@@ -7,14 +7,26 @@ type ApiConfig = {
7
7
  docs?: string,
8
8
  }
9
9
 
10
+ type PartialApiConfig = {
11
+ url: Partial<Record<Env, string>>,
12
+ docs?: string
13
+ }
14
+
10
15
  interface Apis {
11
16
  [api: string]: ApiConfig,
12
17
  }
13
18
 
19
+ interface PartialApis {
20
+ [api: string]: PartialApiConfig
21
+ }
22
+
14
23
  type ApiAddress = {
15
24
  [api: string]: string,
16
25
  }
17
26
 
27
+ let defaultApis: Apis = apisJson;
28
+ let overrideApis: PartialApis = {};
29
+
18
30
  function transformApisToApiAddress(apis: Apis, env: Env): ApiAddress {
19
31
  const apiAddress: ApiAddress = {}
20
32
 
@@ -25,6 +37,65 @@ function transformApisToApiAddress(apis: Apis, env: Env): ApiAddress {
25
37
  return apiAddress
26
38
  }
27
39
 
40
+ /**
41
+ * Searchs the default APIs configuration for the API object that matches the given baseURL.
42
+ * @param baseUrl the base URL to search.
43
+ * @param candidate the URL of the desired API to find.
44
+ * @returns {boolean} true if the URL is found, otherwise false.
45
+ */
46
+ function matchesBaseUrl(baseUrl: Record<Env, string>, candidate: Record<Env, string>): boolean {
47
+ const envs: Env[] = ['dev', 'stg', 'prd'];
48
+
49
+ return envs.every(e => {
50
+ if (candidate[e]) {
51
+ return baseUrl[e] === candidate[e];
52
+ }
53
+ return true;
54
+ });
55
+ }
56
+
57
+ /**
58
+ * Checks if there is override for the given base URL and target environment.
59
+ * @param baseURL the default API base URL to check for overrides.
60
+ * @param targetEnv the target environment
61
+ * @returns {string} the overriden base URL if found, otherwise the original API baseURL.
62
+ */
63
+ export const getBaseUrlWithOverride = (baseUrl: Record<Env, string>, targetEnv: Env = 'prd'): string => {
64
+ let matchesApiName: string | null = null;
65
+
66
+ for (const [apiName, config] of Object.entries(defaultApis)) {
67
+ if (matchesBaseUrl(baseUrl, config.url)) {
68
+ matchesApiName = apiName;
69
+ break;
70
+ }
71
+ }
72
+
73
+ if (matchesApiName) {
74
+ const overrideUrl = overrideApis[matchesApiName]?.url?.[targetEnv];
75
+
76
+ if (overrideUrl) {
77
+ return overrideUrl;
78
+ }
79
+ }
80
+ return baseUrl[targetEnv];
81
+ }
82
+
83
+ /**
84
+ * Sets the APIs addresses for override.
85
+ * @param customApis a JSON object containing APIs address to override.
86
+ */
87
+ export const setApisOverride = (customApis: PartialApis) => {
88
+ overrideApis = customApis;
89
+ }
90
+
91
+ /**
92
+ * Sets the default APIs addresses for each environments.
93
+ * @returns {Apis} an object containing APIs URLs grouped by api name and enviroments.
94
+ */
95
+ export const getApiAddresses = (): Apis => {
96
+ return defaultApis;
97
+ }
98
+
28
99
  export const apiAddresses = () => {
29
100
  const env = NetworkClient.getEnv()
30
101
  return transformApisToApiAddress(apisJson, env)
@@ -8,7 +8,12 @@ import {
8
8
  bindGroupMembers,
9
9
  bindRoleGroups,
10
10
  bindRoles,
11
- bindToGroups, bindToRoles, create, create1, createAccountRole, createExtension, createExtensionLink, createExtensionVersion, createGroupMapping,
11
+ bindToGroups,
12
+ bindToRoles,
13
+ create,
14
+ create1,
15
+ createAccountRole, createExtension, createExtensionLink,
16
+ createExtensionVersion, createFidoMagicLink, createGroupMapping,
12
17
  createPartner,
13
18
  createPersonalAccessToken,
14
19
  createSecret,
@@ -130,16 +135,16 @@ import {
130
135
  validateNewPartnerData,
131
136
  validatePartnerAssociationLimit,
132
137
  } from '../api/account'
133
- import apis from '../apis.json'
134
138
  import { DefaultAPIError } from '../error/DefaultAPIError'
135
139
  import { accountDictionary } from '../error/dictionary/account'
136
140
  import { StackspotAPIError } from '../error/StackspotAPIError'
137
141
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
138
142
  import { CreateSCMRequest, SCMStatus, UpdateSCMRequest } from './types'
143
+ import { getApiAddresses } from '../api-addresses'
139
144
 
140
145
  class AccountClient extends ReactQueryNetworkClient {
141
146
  constructor() {
142
- super(apis.account.url, defaults)
147
+ super(getApiAddresses().account.url, defaults)
143
148
  }
144
149
 
145
150
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
@@ -872,6 +877,10 @@ class AccountClient extends ReactQueryNetworkClient {
872
877
  * Updates the sales representatives
873
878
  */
874
879
  updateSalesRepresentatives = this.mutation(updateSalesRepresentatives)
880
+ /**
881
+ * Create FIDO magic link
882
+ */
883
+ createFidoMagicLink = this.mutation(createFidoMagicLink)
875
884
  }
876
885
 
877
886
  export const accountClient = new AccountClient()
@@ -1,16 +1,18 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
- import { createToolkitToolsV1ToolkitsToolkitIdToolsPost, createToolkitV1ToolkitsPost, defaults, deleteToolkitToolsV1ToolkitsToolkitIdToolsDelete, deleteToolkitV1ToolkitsToolkitIdDelete, editToolkitToolV1ToolkitsToolkitIdToolsToolIdPut, forkToolkitV1ToolkitsToolkitIdForkPost, getPublicToolKitsV1BuiltinToolkitGet, getToolkitToolV1ToolkitsToolkitIdToolsToolIdGet, getToolkitV1ToolkitsToolkitIdGet, HttpValidationError, listAgentsUsingToolsV1ToolkitsToolkitIdToolsAgentsPost, listToolkitsV1ToolkitsGet, updateToolkitV1ToolkitsToolkitIdPatch } from '../api/agent-tools'
3
- import apis from '../apis.json'
2
+ import { getApiAddresses } from '../api-addresses'
3
+ import { addFavoriteV1AgentsAgentIdFavoritePost, AgentVisibilityLevelEnum, createAgentV1AgentsPost, createToolkitToolsV1ToolkitsToolkitIdToolsPost, createToolkitV1ToolkitsPost, defaults, deleteAgentV1AgentsAgentIdDelete, deleteToolkitToolsV1ToolkitsToolkitIdToolsDelete, deleteToolkitV1ToolkitsToolkitIdDelete, editToolkitToolV1ToolkitsToolkitIdToolsToolIdPut, forkToolkitV1ToolkitsToolkitIdForkPost, getAgentV1AgentsAgentIdGet, getPublicToolKitsV1BuiltinToolkitGet, getToolkitToolV1ToolkitsToolkitIdToolsToolIdGet, getToolkitV1ToolkitsToolkitIdGet, HttpValidationError, listAgentsUsingToolsV1ToolkitsToolkitIdToolsAgentsPost, listAgentsV1AgentsGet, listToolkitsV1ToolkitsGet, publishAgentV1AgentsAgentIdPublishPost, searchAgentsV1AgentsSearchPost, updateAgentV1AgentsAgentIdPut, updateToolkitV1ToolkitsToolkitIdPatch, VisibilityLevelEnum } from '../api/agent-tools'
4
4
  import { StackspotAPIError } from '../error/StackspotAPIError'
5
5
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
6
6
  import { FetchEventStream } from '../network/types'
7
7
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
8
8
  import { StreamedArray } from '../utils/StreamedArray'
9
- import { AgentToolsOpenAPIPreview } from './types'
9
+ import { AgentResponseWithBuiltIn, AgentToolsOpenAPIPreview, AgentVisibilityLevel } from './types'
10
+ import { workspaceAiClient } from './workspace-ai'
11
+ const AGENT_DEFAULT_SLUG = 'stk_code_buddy'
10
12
 
11
13
  class AgentToolsClient extends ReactQueryNetworkClient {
12
14
  constructor() {
13
- super(apis['agent-tools'].url, defaults)
15
+ super(getApiAddresses()['agent-tools'].url, defaults)
14
16
  }
15
17
 
16
18
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
@@ -26,8 +28,104 @@ class AgentToolsClient extends ReactQueryNetworkClient {
26
28
  tools = this.query(removeAuthorizationParam(getPublicToolKitsV1BuiltinToolkitGet))
27
29
 
28
30
  /**
29
- * Get list of Toolkits
31
+ * Create agent
30
32
  */
33
+ createAgent = this.mutation(removeAuthorizationParam(createAgentV1AgentsPost))
34
+
35
+ /**
36
+ * Delete agent
37
+ */
38
+ deleteAgent = this.mutation(deleteAgentV1AgentsAgentIdDelete)
39
+
40
+ /**
41
+ * Updates an agent
42
+ */
43
+ updateAgent = this.mutation(updateAgentV1AgentsAgentIdPut)
44
+
45
+ /**
46
+ * Favorite an agent
47
+ */
48
+ favoriteAgent = this.mutation(addFavoriteV1AgentsAgentIdFavoritePost)
49
+
50
+ /**
51
+ * Publish an agent
52
+ */
53
+ publishAgent = this.mutation(publishAgentV1AgentsAgentIdPublishPost)
54
+
55
+ /**
56
+ * List agents
57
+ */
58
+ agents = this.infiniteQuery(removeAuthorizationParam(listAgentsV1AgentsGet))
59
+
60
+ /**
61
+ * Gets agent by id
62
+ */
63
+ agent = this.query(removeAuthorizationParam(getAgentV1AgentsAgentIdGet))
64
+
65
+ /**
66
+ * Gets agents by ids
67
+ */
68
+ agentsByIds = this.query(removeAuthorizationParam(searchAgentsV1AgentsSearchPost))
69
+
70
+ /**
71
+ * Gets the default agent slug
72
+ */
73
+ agentDefaultSlug = AGENT_DEFAULT_SLUG
74
+
75
+ /**
76
+ * Gets the default agent
77
+ */
78
+ agentDefault = this.query({
79
+ name: 'agentDefault',
80
+ request: async (signal) => {
81
+ const agentDefault = await listAgentsV1AgentsGet(
82
+ { visibility: 'built_in', slug: this.agentDefaultSlug, authorization: '' }, { signal },
83
+ )
84
+
85
+ const agentId = agentDefault.at(0)?.id
86
+ const agent = agentId ? await this.agent.query({ agentId }) : undefined
87
+ return agent
88
+ },
89
+ })
90
+
91
+ /**
92
+ * List agents filtered by visibility.
93
+ */
94
+ allAgents = this.query({
95
+ name: 'allAgents',
96
+ request: async (signal, variables: { visibilities: (AgentVisibilityLevel | 'all')[] }) => {
97
+ const allVisibilities = ['account', 'built_in', 'favorite', 'personal', 'shared', 'workspace'] as const
98
+ const visibilities = variables.visibilities.includes('all')
99
+ ? allVisibilities
100
+ : variables.visibilities as Array<AgentVisibilityLevelEnum | VisibilityLevelEnum>
101
+
102
+ const shouldFetchWorkspaceAgents = visibilities.includes('workspace')
103
+
104
+ const workspaceAgentsPromise = shouldFetchWorkspaceAgents
105
+ ? workspaceAiClient.workspacesContentsByType.query({ contentType: 'agent' })
106
+ : Promise.resolve([])
107
+
108
+ const [workspaceAgents, ...agentsByVisibility] = await Promise.all([
109
+ workspaceAgentsPromise,
110
+ ...visibilities.map((visibility) => listAgentsV1AgentsGet({ visibility, authorization: '' }, { signal })),
111
+ ])
112
+
113
+ const workspaceAgentsWithSpaceName = workspaceAgents.flatMap(({ agents, space_name }) =>
114
+ agents?.map((agent) => ({ ...agent, spaceName: space_name, builtIn: false }))) as AgentResponseWithBuiltIn[]
115
+
116
+ const allAgents: AgentResponseWithBuiltIn[] = workspaceAgentsWithSpaceName ?? []
117
+
118
+ agentsByVisibility.forEach(agents => allAgents.push(...agents.map(agent => ({
119
+ ...agent,
120
+ builtIn: agent?.visibility_level === 'built_in',
121
+ }))))
122
+
123
+ return allAgents
124
+ },
125
+ })
126
+
127
+ /* Get list of Toolkits
128
+ */
31
129
  toolkits = this.query(removeAuthorizationParam(listToolkitsV1ToolkitsGet))
32
130
  /**
33
131
  * Get a toolkit by Id
@@ -1,14 +1,11 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
+ import { getApiAddresses } from '../api-addresses'
2
3
  import {
3
4
  defaults, deleteV1AgentByAgentIdFavorite, getV1AgentByAgentId, getV1Agents, getV1PublicAgentByAgentId, getV1PublicAgents,
4
5
  postV1AgentByAgentIdFavorite, putV1AgentByAgentId,
5
- VisibilityLevel,
6
6
  } from '../api/agent'
7
- import apis from '../apis.json'
8
7
  import { StackspotAPIError } from '../error/StackspotAPIError'
9
8
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
10
- import { AgentResponseWithBuiltIn, AgentVisibilityLevel } from './types'
11
- import { workspaceAiClient } from './workspace-ai'
12
9
 
13
10
  export const isAgentDefault = (agentSlug?: string) => agentSlug === 'stk_code_buddy'
14
11
 
@@ -20,7 +17,7 @@ interface AgentError {
20
17
 
21
18
  class AgentClient extends ReactQueryNetworkClient {
22
19
  constructor() {
23
- super(apis.agent.url, defaults)
20
+ super(getApiAddresses().agent.url, defaults)
24
21
  }
25
22
 
26
23
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
@@ -36,57 +33,6 @@ class AgentClient extends ReactQueryNetworkClient {
36
33
  })
37
34
  }
38
35
 
39
- /**
40
- * List agents filtered by visibility.
41
- */
42
- allAgents = this.query({
43
- name: 'allAgents',
44
- request: async (signal, variables: { visibilities: AgentVisibilityLevel[] }) => {
45
- const visibilities: VisibilityLevel[] = variables.visibilities.includes('ALL')
46
- ? ['PERSONAL', 'SHARED', 'WORKSPACE', 'ACCOUNT', 'FAVORITE']
47
- : variables.visibilities.filter((visibility) => visibility !== 'BUILT-IN' && visibility !== 'ALL') as VisibilityLevel[]
48
-
49
- const shouldIncludeBuiltInAgent = variables.visibilities.includes('ALL') || variables.visibilities.includes('BUILT-IN')
50
- const shouldFetchBuiltInAgent = shouldIncludeBuiltInAgent || variables.visibilities.includes('FAVORITE')
51
- const shouldFetchWorkspaceAgents = variables.visibilities.includes('ALL') || variables.visibilities.includes('WORKSPACE')
52
-
53
- const publicAgentsPromise = shouldFetchBuiltInAgent ? getV1PublicAgents({}, { signal }) : Promise.resolve([])
54
- const workspaceAgentsPromise = shouldFetchWorkspaceAgents
55
- ? workspaceAiClient.workspacesContentsByType.query({ contentType: 'agent' })
56
- : Promise.resolve([])
57
-
58
- const [publicAgents, workspaceAgents, ...agentsByVisibility] = await Promise.all([
59
- publicAgentsPromise,
60
- workspaceAgentsPromise,
61
- ...visibilities.map((visibility) => getV1Agents({ visibility }, { signal })),
62
- ])
63
-
64
- const workspaceAgentsWithSpaceName = workspaceAgents?.flatMap(({ agents, space_name }) =>
65
- agents?.map((agent) => ({
66
- ...agent,
67
- spaceName: space_name,
68
- builtIn: publicAgents?.some(publicAgent => publicAgent.id === agent.id),
69
- }))) as AgentResponseWithBuiltIn[]
70
-
71
- const allAgents: AgentResponseWithBuiltIn[] = workspaceAgentsWithSpaceName || []
72
-
73
- if (shouldIncludeBuiltInAgent) {
74
- const builtInsAgents = publicAgents?.map((agent) => ({ ...agent, builtIn: true, visibility_level: 'BUILT-IN' }))
75
- // @ts-ignore fixme: above, BUILT-IN is not a valid value for the enum VisibilityLevel.
76
- allAgents.push(...builtInsAgents)
77
- }
78
-
79
- agentsByVisibility.forEach(agents => {
80
- allAgents.push(...agents.map(agent => ({
81
- ...agent,
82
- builtIn: publicAgents?.some(publicAgent => publicAgent.id === agent.id),
83
- })))
84
- })
85
-
86
- return allAgents
87
- },
88
- })
89
-
90
36
  /**
91
37
  * Gets an agent by id
92
38
  */
@@ -97,18 +43,6 @@ class AgentClient extends ReactQueryNetworkClient {
97
43
  : getV1AgentByAgentId({ ...variables }, { signal }),
98
44
  })
99
45
 
100
- /**
101
- * Gets the default agent
102
- */
103
- agentDefault = this.query({
104
- name: 'agentDefault',
105
- request: async (signal) => {
106
- const publicAgents = await getV1PublicAgents({}, { signal })
107
- const agentDefault = publicAgents.find((agent) => isAgentDefault(agent.slug))
108
- return agentDefault ? { ...agentDefault, builtIn: true } : undefined
109
- },
110
- })
111
-
112
46
  /**
113
47
  * List commons agents
114
48
  */
package/src/client/ai.ts CHANGED
@@ -34,11 +34,11 @@ import {
34
34
  quickCommandsRunV2V2QuickCommandsSlugStepsStepSlugRunPost,
35
35
  resetKnowledgeObjectsV1KnowledgeSourcesSlugObjectsDelete,
36
36
  runFetchStepV1QuickCommandsSlugStepsStepSlugFetchRunPost,
37
+ searchKnowledgeSourcesV1KnowledgeSourcesSearchPost,
37
38
  updateQuickCommandV1QuickCommandsSlugPatch,
38
39
  updateTitleV1ConversationsConversationIdPatch,
39
40
  vectorizeCustomKnowledgeSourceV1KnowledgeSourcesSlugCustomPost,
40
41
  } from '../api/ai'
41
- import apis from '../apis.json'
42
42
  import { StackspotAPIError } from '../error/StackspotAPIError'
43
43
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
44
44
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
@@ -55,10 +55,11 @@ import {
55
55
  ReplaceResult,
56
56
  StepChatStep,
57
57
  } from './types'
58
+ import { getApiAddresses } from '../api-addresses'
58
59
 
59
60
  class AIClient extends ReactQueryNetworkClient {
60
61
  constructor() {
61
- super(apis.ai.url, defaults)
62
+ super(getApiAddresses().ai.url, defaults)
62
63
  }
63
64
 
64
65
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
@@ -135,6 +136,10 @@ class AIClient extends ReactQueryNetworkClient {
135
136
  * Gets a knowledge source document by the slug of the parent knowledge source and the document id.
136
137
  */
137
138
  knowledgeSourceDocument = this.query(removeAuthorizationParam(findKnowledgeObjectByCustomIdV1KnowledgeSourcesSlugObjectsCustomIdGet))
139
+ /**
140
+ * Lists knowledge sources matching the provided IDs.
141
+ */
142
+ searchKnowledgeSources = this.query(removeAuthorizationParam(searchKnowledgeSourcesV1KnowledgeSourcesSearchPost))
138
143
  /**
139
144
  * Gets the chat history. This is a paginated resource.
140
145
  */
@@ -376,3 +381,4 @@ class AIClient extends ReactQueryNetworkClient {
376
381
  }
377
382
 
378
383
  export const aiClient = new AIClient()
384
+
@@ -1,14 +1,14 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
2
  import { defaults, getEntries, getEntryById, getSubEntries } from '../api/apiManagement'
3
- import apis from '../apis.json'
4
3
  import { DefaultAPIError } from '../error/DefaultAPIError'
5
4
  import { actionDictionary } from '../error/dictionary/action'
6
5
  import { StackspotAPIError } from '../error/StackspotAPIError'
7
6
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
7
+ import { getApiAddresses } from '../api-addresses'
8
8
 
9
9
  class ApiManagementClient extends ReactQueryNetworkClient {
10
10
  constructor() {
11
- super(apis.apiManagement.url, defaults)
11
+ super(getApiAddresses().apiManagement.url, defaults)
12
12
  }
13
13
 
14
14
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
@@ -1,17 +1,17 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
2
  import { createCloudAccount, defaults, deleteCloudAccountFromEnvironment, deleteManagedAccountsFromWorkspace, getCloudAccountByWorkspace, getManagedCloudRegion, getManagedCloudTemplate, getProvisionWorkflowInWorkspace, listCloudAccounts, provisionManagedAccountsForWorkspace } from '../api/cloudAccount'
3
- import apis from '../apis.json'
4
3
  import { DefaultAPIError } from '../error/DefaultAPIError'
5
4
  import { StackspotAPIError } from '../error/StackspotAPIError'
6
5
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
7
6
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
8
7
  import { FixedConnectAccountRequestV2, FixedManagedAccountProvisionRequest, FixVariables } from './types'
8
+ import { getApiAddresses } from '../api-addresses'
9
9
 
10
10
  const listAccounts = removeAuthorizationParam(listCloudAccounts)
11
11
 
12
12
  class CloudAccountClient extends ReactQueryNetworkClient {
13
13
  constructor() {
14
- super(apis.cloudAccount.url, defaults)
14
+ super(getApiAddresses().cloudAccount.url, defaults)
15
15
  }
16
16
 
17
17
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
@@ -1,16 +1,16 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
2
 
3
- import apis from '../apis.json'
4
3
  import { DefaultAPIError } from '../error/DefaultAPIError'
5
4
  import { StackspotAPIError } from '../error/StackspotAPIError'
6
5
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
7
6
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
8
7
  import { createAddon, createDeployTemplate, createOrganization, createRuntime1, createTenant1, defaults, deploy, findApplicationDeploymentById, getApplicationDeploymentHealth, getApplicationDeploymentLogs, getOrganizationById, getOrganizations, getRuntime1, getTenant1, listAddon, listApplicationDeployments, listDeployTemplate, listRuntimes, listRuntimes1, listTenants, listTenants1 } from '../api/cloudPlatformHorizon'
9
8
  import { baseDictionary } from '../error/dictionary/base'
9
+ import { getApiAddresses } from '../api-addresses'
10
10
 
11
11
  class CloudPlatformHorizonClient extends ReactQueryNetworkClient {
12
12
  constructor() {
13
- super(apis.cloudPlatformHorizon.url, defaults)
13
+ super(getApiAddresses().cloudPlatformHorizon.url, defaults)
14
14
  }
15
15
 
16
16
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
@@ -31,16 +31,16 @@ import
31
31
  listVpns,
32
32
  providers,
33
33
  } from '../api/cloudPlatform'
34
- import apis from '../apis.json'
35
34
  import { DefaultAPIError } from '../error/DefaultAPIError'
36
35
  import { StackspotAPIError } from '../error/StackspotAPIError'
37
36
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
38
37
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
39
38
  import { scfDictionary } from '../error/dictionary/cloud-platform'
39
+ import { getApiAddresses } from '../api-addresses'
40
40
 
41
41
  class CloudPlatformClient extends ReactQueryNetworkClient {
42
42
  constructor() {
43
- super(apis.cloudPlatform.url, defaults)
43
+ super(getApiAddresses().cloudPlatform.url, defaults)
44
44
  }
45
45
 
46
46
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
@@ -24,16 +24,16 @@ import
24
24
  startApplication,
25
25
  stopApplication,
26
26
  } from '../api/cloudRuntimes'
27
- import apis from '../apis.json'
28
27
  import { DefaultAPIError } from '../error/DefaultAPIError'
29
28
  import { StackspotAPIError } from '../error/StackspotAPIError'
30
29
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
31
30
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
32
31
  import { baseDictionary } from '../error/dictionary/base'
32
+ import { getApiAddresses } from '../api-addresses'
33
33
 
34
34
  class CloudRuntimesClient extends ReactQueryNetworkClient {
35
35
  constructor() {
36
- super(apis.cloudRuntimes.url, defaults)
36
+ super(getApiAddresses().cloudRuntimes.url, defaults)
37
37
  }
38
38
 
39
39
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
@@ -5,15 +5,15 @@ import {
5
5
  getCostOverview, getGuardrails, getInstanceDetails, listBillingAccounts, listInstances, listServices,
6
6
  processAllocationCostRequest,
7
7
  } from '../api/cloudServices'
8
- import apis from '../apis.json'
9
8
  import { DefaultAPIError } from '../error/DefaultAPIError'
10
9
  import { StackspotAPIError } from '../error/StackspotAPIError'
11
10
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
12
11
  import { CostAllocationResult, CostAllocationVariables, FixedManagedService, FixVariables, OazapftsFunction, ReplaceResult } from './types'
12
+ import { getApiAddresses } from '../api-addresses'
13
13
 
14
14
  class CloudServicesClient extends ReactQueryNetworkClient {
15
15
  constructor() {
16
- super(apis.cloudServices.url, defaults)
16
+ super(getApiAddresses().cloudServices.url, defaults)
17
17
  }
18
18
 
19
19
  protected buildStackSpotError(error: HttpError): StackspotAPIError {