@stack-spot/portal-network 1.0.0-betaadp.3 → 1.0.0-dev.1768423147036
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.
- package/CHANGELOG.md +633 -0
- package/dist/api/account.d.ts +413 -277
- package/dist/api/account.d.ts.map +1 -1
- package/dist/api/account.js +261 -176
- package/dist/api/account.js.map +1 -1
- package/dist/api/accountAssetManager.d.ts +309 -0
- package/dist/api/accountAssetManager.d.ts.map +1 -0
- package/dist/api/accountAssetManager.js +169 -0
- package/dist/api/accountAssetManager.js.map +1 -0
- package/dist/api/agent-tools.d.ts +818 -261
- package/dist/api/agent-tools.d.ts.map +1 -1
- package/dist/api/agent-tools.js +245 -50
- package/dist/api/agent-tools.js.map +1 -1
- package/dist/api/agent.d.ts +55 -55
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/ai.d.ts +488 -98
- package/dist/api/ai.d.ts.map +1 -1
- package/dist/api/ai.js +426 -146
- package/dist/api/ai.js.map +1 -1
- package/dist/api/cloudPlatform.d.ts +374 -221
- package/dist/api/cloudPlatform.d.ts.map +1 -1
- package/dist/api/cloudPlatform.js +299 -93
- package/dist/api/cloudPlatform.js.map +1 -1
- package/dist/api/cloudPlatformHorizon.d.ts +178 -9
- package/dist/api/cloudPlatformHorizon.d.ts.map +1 -1
- package/dist/api/cloudPlatformHorizon.js +69 -1
- package/dist/api/cloudPlatformHorizon.js.map +1 -1
- package/dist/api/codeShift.d.ts +1125 -83
- package/dist/api/codeShift.d.ts.map +1 -1
- package/dist/api/codeShift.js +538 -16
- package/dist/api/codeShift.js.map +1 -1
- package/dist/api/dataIntegration.d.ts +291 -1
- package/dist/api/dataIntegration.d.ts.map +1 -1
- package/dist/api/dataIntegration.js +254 -0
- package/dist/api/dataIntegration.js.map +1 -1
- package/dist/api/discover.d.ts +98 -12
- package/dist/api/discover.d.ts.map +1 -1
- package/dist/api/discover.js +78 -2
- package/dist/api/discover.js.map +1 -1
- package/dist/api/edpBfa.d.ts +215 -0
- package/dist/api/edpBfa.d.ts.map +1 -0
- package/dist/api/edpBfa.js +87 -0
- package/dist/api/edpBfa.js.map +1 -0
- package/dist/api/genAiInference.d.ts +22 -2
- package/dist/api/genAiInference.d.ts.map +1 -1
- package/dist/api/genAiInference.js +22 -3
- package/dist/api/genAiInference.js.map +1 -1
- package/dist/api/workflows.d.ts +68 -5
- package/dist/api/workflows.d.ts.map +1 -1
- package/dist/api/workflows.js +16 -0
- package/dist/api/workflows.js.map +1 -1
- package/dist/api/workspace-ai.d.ts +41 -0
- package/dist/api/workspace-ai.d.ts.map +1 -1
- package/dist/api/workspace-ai.js +34 -0
- package/dist/api/workspace-ai.js.map +1 -1
- package/dist/api/workspaceManager.d.ts +16 -10
- package/dist/api/workspaceManager.d.ts.map +1 -1
- package/dist/api/workspaceManager.js +10 -0
- package/dist/api/workspaceManager.js.map +1 -1
- package/dist/api-addresses.d.ts +20 -18
- package/dist/api-addresses.d.ts.map +1 -1
- package/dist/api-addresses.js +81 -21
- package/dist/api-addresses.js.map +1 -1
- package/dist/apis-itau.json +241 -0
- package/dist/apis.json +17 -1
- package/dist/client/account-asset-manager.d.ts +112 -0
- package/dist/client/account-asset-manager.d.ts.map +1 -0
- package/dist/client/account-asset-manager.js +160 -0
- package/dist/client/account-asset-manager.js.map +1 -0
- package/dist/client/account.d.ts +265 -242
- package/dist/client/account.d.ts.map +1 -1
- package/dist/client/account.js +80 -34
- package/dist/client/account.js.map +1 -1
- package/dist/client/agent-tools.d.ts +295 -121
- package/dist/client/agent-tools.d.ts.map +1 -1
- package/dist/client/agent-tools.js +166 -12
- package/dist/client/agent-tools.js.map +1 -1
- package/dist/client/agent.d.ts +46 -46
- package/dist/client/agent.d.ts.map +1 -1
- package/dist/client/ai.d.ts +265 -79
- package/dist/client/ai.d.ts.map +1 -1
- package/dist/client/ai.js +268 -24
- package/dist/client/ai.js.map +1 -1
- package/dist/client/api-management.d.ts +10 -1
- package/dist/client/api-management.d.ts.map +1 -1
- package/dist/client/api-management.js +11 -2
- package/dist/client/api-management.js.map +1 -1
- package/dist/client/cloud-account.d.ts +13 -13
- package/dist/client/cloud-platform-horizon.d.ts +38 -19
- package/dist/client/cloud-platform-horizon.d.ts.map +1 -1
- package/dist/client/cloud-platform-horizon.js +19 -1
- package/dist/client/cloud-platform-horizon.js.map +1 -1
- package/dist/client/cloud-platform.d.ts +213 -46
- package/dist/client/cloud-platform.d.ts.map +1 -1
- package/dist/client/cloud-platform.js +168 -33
- package/dist/client/cloud-platform.js.map +1 -1
- package/dist/client/cloud-runtimes.d.ts +4 -4
- package/dist/client/cloud-services.d.ts +17 -17
- package/dist/client/cloud-services.d.ts.map +1 -1
- package/dist/client/code-shift.d.ts +535 -162
- package/dist/client/code-shift.d.ts.map +1 -1
- package/dist/client/code-shift.js +296 -7
- package/dist/client/code-shift.js.map +1 -1
- package/dist/client/content.d.ts +127 -132
- package/dist/client/content.d.ts.map +1 -1
- package/dist/client/data-integration.d.ts +92 -53
- package/dist/client/data-integration.d.ts.map +1 -1
- package/dist/client/data-integration.js +38 -2
- package/dist/client/data-integration.js.map +1 -1
- package/dist/client/discover.d.ts +31 -10
- package/dist/client/discover.d.ts.map +1 -1
- package/dist/client/discover.js +239 -3
- package/dist/client/discover.js.map +1 -1
- package/dist/client/edp-bfa.d.ts +16 -0
- package/dist/client/edp-bfa.d.ts.map +1 -0
- package/dist/client/edp-bfa.js +24 -0
- package/dist/client/edp-bfa.js.map +1 -0
- package/dist/client/event-bus.d.ts.map +1 -1
- package/dist/client/gen-ai-inference.d.ts +20 -20
- package/dist/client/insights.d.ts +7 -7
- package/dist/client/notification.d.ts +17 -10
- package/dist/client/notification.d.ts.map +1 -1
- package/dist/client/notification.js +10 -1
- package/dist/client/notification.js.map +1 -1
- package/dist/client/runtime-manager.d.ts +8 -8
- package/dist/client/secrets.d.ts.map +1 -1
- package/dist/client/secrets.js +1 -1
- package/dist/client/secrets.js.map +1 -1
- package/dist/client/types.d.ts +50 -7
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/workflow.d.ts +10 -10
- package/dist/client/workspace-ai.d.ts +65 -55
- package/dist/client/workspace-ai.d.ts.map +1 -1
- package/dist/client/workspace-ai.js +19 -9
- package/dist/client/workspace-ai.js.map +1 -1
- package/dist/client/workspace-manager.d.ts +115 -76
- package/dist/client/workspace-manager.d.ts.map +1 -1
- package/dist/client/workspace-manager.js +47 -2
- package/dist/client/workspace-manager.js.map +1 -1
- package/dist/client/workspace-search.d.ts +2 -2
- package/dist/client/workspace.d.ts +58 -105
- package/dist/client/workspace.d.ts.map +1 -1
- package/dist/error/DefaultAPIError.d.ts.map +1 -1
- package/dist/error/DefaultAPIError.js.map +1 -1
- package/dist/error/StackspotAPIError.d.ts +3 -4
- package/dist/error/StackspotAPIError.d.ts.map +1 -1
- package/dist/error/StackspotAPIError.js +3 -3
- package/dist/error/StackspotAPIError.js.map +1 -1
- package/dist/error/dictionary/accountAssetManager.d.ts +11 -0
- package/dist/error/dictionary/accountAssetManager.d.ts.map +1 -0
- package/dist/error/dictionary/accountAssetManager.js +11 -0
- package/dist/error/dictionary/accountAssetManager.js.map +1 -0
- package/dist/error/dictionary/cloud-platform.d.ts +76 -8
- package/dist/error/dictionary/cloud-platform.d.ts.map +1 -1
- package/dist/error/dictionary/cloud-platform.js +80 -12
- package/dist/error/dictionary/cloud-platform.js.map +1 -1
- package/dist/error/dictionary/workspace-ai.d.ts +9 -0
- package/dist/error/dictionary/workspace-ai.d.ts.map +1 -0
- package/dist/error/dictionary/workspace-ai.js +9 -0
- package/dist/error/dictionary/workspace-ai.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/network/NetworkClient.d.ts +4 -2
- package/dist/network/NetworkClient.d.ts.map +1 -1
- package/dist/network/NetworkClient.js +16 -4
- package/dist/network/NetworkClient.js.map +1 -1
- package/dist/network/types.d.ts +2 -0
- package/dist/network/types.d.ts.map +1 -1
- package/dist/utils/StreamedJson.d.ts +3 -1
- package/dist/utils/StreamedJson.d.ts.map +1 -1
- package/dist/utils/StreamedJson.js +23 -3
- package/dist/utils/StreamedJson.js.map +1 -1
- package/package.dev.json +3 -0
- package/package.json +10 -9
- package/package.stg.json +3 -0
- package/readme.md +40 -1
- package/src/api/account.ts +701 -540
- package/src/api/accountAssetManager.ts +771 -0
- package/src/api/agent-tools.ts +1354 -556
- package/src/api/ai.ts +891 -170
- package/src/api/cloudPlatform.ts +667 -298
- package/src/api/cloudPlatformHorizon.ts +412 -9
- package/src/api/codeShift.ts +2088 -97
- package/src/api/dataIntegration.ts +635 -1
- package/src/api/discover.ts +180 -14
- package/src/api/edpBfa.ts +472 -0
- package/src/api/genAiInference.ts +47 -4
- package/src/api/workflows.ts +100 -5
- package/src/api/workspace-ai.ts +83 -0
- package/src/api/workspaceManager.ts +25 -10
- package/src/api-addresses.ts +113 -38
- package/src/apis-itau.json +241 -0
- package/src/apis.json +17 -1
- package/src/client/account-asset-manager.ts +100 -0
- package/src/client/account.ts +71 -40
- package/src/client/agent-tools.ts +111 -18
- package/src/client/ai.ts +237 -24
- package/src/client/api-management.ts +7 -2
- package/src/client/cloud-platform-horizon.ts +12 -4
- package/src/client/cloud-platform.ts +101 -27
- package/src/client/code-shift.ts +196 -8
- package/src/client/data-integration.ts +28 -1
- package/src/client/discover.ts +238 -5
- package/src/client/edp-bfa.ts +24 -0
- package/src/client/notification.ts +6 -1
- package/src/client/secrets.ts +1 -1
- package/src/client/types.ts +55 -9
- package/src/client/workspace-ai.ts +37 -26
- package/src/client/workspace-manager.ts +31 -2
- package/src/error/DefaultAPIError.ts +5 -5
- package/src/error/StackspotAPIError.ts +4 -4
- package/src/error/dictionary/accountAssetManager.ts +12 -0
- package/src/error/dictionary/cloud-platform.ts +80 -12
- package/src/error/dictionary/workspace-ai.ts +10 -0
- package/src/index.ts +6 -3
- package/src/network/NetworkClient.ts +18 -6
- package/src/network/types.ts +3 -0
- package/src/utils/StreamedJson.tsx +19 -4
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CancelledError } from '@tanstack/react-query'
|
|
2
|
-
export { apiAddresses, getApiAddresses,
|
|
2
|
+
export { apiAddresses, getApiAddresses, getApisBaseUrlConfig, getBaseUrlByTenantWithOverride } from './api-addresses'
|
|
3
3
|
export { accountClient } from './client/account'
|
|
4
|
-
export
|
|
4
|
+
export { accountAssetManagerClient } from './client/account-asset-manager'
|
|
5
5
|
export { agentClient } from './client/agent'
|
|
6
6
|
export { agentToolsClient } from './client/agent-tools'
|
|
7
7
|
export { aiClient } from './client/ai'
|
|
@@ -14,7 +14,9 @@ export { cloudServicesClient } from './client/cloud-services'
|
|
|
14
14
|
export { codeShiftClient } from './client/code-shift'
|
|
15
15
|
export { contentClient } from './client/content'
|
|
16
16
|
export { dataIntegrationClient } from './client/data-integration'
|
|
17
|
+
export * from './client/discover'
|
|
17
18
|
export { discoverClient } from './client/discover'
|
|
19
|
+
export { edpBfaClient } from './client/edp-bfa'
|
|
18
20
|
export { eventBusClient } from './client/event-bus'
|
|
19
21
|
export { genAiInferenceClient } from './client/gen-ai-inference'
|
|
20
22
|
export { insightsClient } from './client/insights'
|
|
@@ -35,9 +37,10 @@ export { StreamError } from './error/StreamError'
|
|
|
35
37
|
export { StreamJsonError } from './error/StreamJsonError'
|
|
36
38
|
export { NetworkClient } from './network/NetworkClient'
|
|
37
39
|
export { queryClient } from './network/react-query-client'
|
|
38
|
-
export { OperationResult, OperationVariables, UseQueryObjectOptions } from './network/types'
|
|
40
|
+
export { Env, OperationResult, OperationVariables, Tenant, UseQueryObjectOptions } from './network/types'
|
|
39
41
|
export { StreamingStatus } from './types'
|
|
40
42
|
export { StreamedArray } from './utils/StreamedArray'
|
|
41
43
|
export { StreamedJson } from './utils/StreamedJson'
|
|
42
44
|
export { useExtendedList } from './utils/use-extended-list'
|
|
43
45
|
export { useStreamedArray } from './utils/use-streamed-array'
|
|
46
|
+
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AuthenticationError, SessionExpiredError } from '@stack-spot/auth'
|
|
2
|
-
import { requestPermission } from '@stack-spot/opa'
|
|
1
|
+
import { AuthenticationError, Session, SessionExpiredError } from '@stack-spot/auth'
|
|
2
|
+
import { requestPermission, setup as setupPermissions } from '@stack-spot/opa'
|
|
3
3
|
import { events } from 'fetch-event-stream'
|
|
4
|
+
import { getApisBaseUrlConfig, getBaseUrlByTenantWithOverride, getPermissionsAPIMap } from '../api-addresses'
|
|
4
5
|
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { queryClient } from './react-query-client'
|
|
7
|
+
import { Env, FetchEventStream, HTTPMethod, SessionManager, Tenant } from './types'
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* A set of methods for performing network requests to an API.
|
|
@@ -21,6 +22,7 @@ export abstract class NetworkClient {
|
|
|
21
22
|
private baseURL: Record<Env, string>
|
|
22
23
|
static readonly sessionManager?: SessionManager
|
|
23
24
|
private static env?: Env
|
|
25
|
+
private static tenant?: Tenant
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* @param baseURL An object with the keys "dev", "stg" and "prd". The values must be the url for each of these environments.
|
|
@@ -33,11 +35,21 @@ export abstract class NetworkClient {
|
|
|
33
35
|
* Sets up all network clients. Must be called before attempting to make any request.
|
|
34
36
|
* @param sessionManager An object with functions capable of checking, retrieving and ending the current session.
|
|
35
37
|
* @param env The environment to send the requests to.
|
|
38
|
+
* @param tenant - {@link Tenant} tenant identifier used to scope requests.
|
|
36
39
|
*/
|
|
37
|
-
static setup(sessionManager: SessionManager, env: Env) {
|
|
40
|
+
static setup(sessionManager: SessionManager, env: Env, tenant?: Tenant) {
|
|
38
41
|
//@ts-ignore This is the only place we would link session manager to be set.
|
|
39
42
|
NetworkClient.sessionManager = sessionManager
|
|
40
43
|
NetworkClient.env = env
|
|
44
|
+
NetworkClient.tenant = tenant
|
|
45
|
+
const url = getApisBaseUrlConfig(env, tenant).permissionValidation
|
|
46
|
+
const apiMap = getPermissionsAPIMap(env, tenant)
|
|
47
|
+
const onChange = (session?: Session) => {
|
|
48
|
+
queryClient.invalidateQueries()
|
|
49
|
+
session && setupPermissions({ url, session, apiMap })
|
|
50
|
+
}
|
|
51
|
+
sessionManager.onChange?.(onChange)
|
|
52
|
+
if (sessionManager.hasSession()) onChange(sessionManager.getSession())
|
|
41
53
|
}
|
|
42
54
|
|
|
43
55
|
/**
|
|
@@ -62,7 +74,7 @@ export abstract class NetworkClient {
|
|
|
62
74
|
* @returns the final baseURL for the current environment, considering overrides if available.
|
|
63
75
|
*/
|
|
64
76
|
protected getBaseURL(): string {
|
|
65
|
-
return
|
|
77
|
+
return getBaseUrlByTenantWithOverride(this.baseURL, NetworkClient.env, NetworkClient.tenant)
|
|
66
78
|
}
|
|
67
79
|
|
|
68
80
|
/**
|
package/src/network/types.ts
CHANGED
|
@@ -8,8 +8,11 @@ export interface SessionManager {
|
|
|
8
8
|
hasSession(): boolean,
|
|
9
9
|
endSession(): void,
|
|
10
10
|
getSession(): Session,
|
|
11
|
+
onChange?: (listener: (session: Session | undefined) => void) => (() => void),
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
export type Tenant = 'stackspot' | 'itau'
|
|
15
|
+
|
|
13
16
|
export type Env = 'dev' | 'stg' | 'prd'
|
|
14
17
|
|
|
15
18
|
export type HTTPMethod = 'post' | 'patch' | 'delete' | 'put' | 'get'
|
|
@@ -31,6 +31,7 @@ interface ConstructorParams<T> {
|
|
|
31
31
|
* of merged.
|
|
32
32
|
*/
|
|
33
33
|
ignoreKeys?: (keyof T)[],
|
|
34
|
+
textFromErrorEvent?: (data: Partial<T>) => string,
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
/**
|
|
@@ -44,16 +45,18 @@ export class StreamedJson<T> {
|
|
|
44
45
|
private abortController: AbortController | undefined
|
|
45
46
|
private transform?: (event: Partial<T>, data: Partial<T>) => void | Promise<void>
|
|
46
47
|
private ignoreKeys?: (keyof T)[]
|
|
48
|
+
private textFromErrorEvent: (data: Partial<T>) => string
|
|
47
49
|
|
|
48
50
|
/**
|
|
49
51
|
* @param response the fetch response.
|
|
50
52
|
* @param minChangeIntervalMS a stream can be too fast. This sets a minimum interval between running the listeners. The default is 50ms.
|
|
51
53
|
*/
|
|
52
|
-
constructor({ eventsPromise, abortController, minChangeIntervalMS = 50, transform, ignoreKeys }: ConstructorParams<T>) {
|
|
54
|
+
constructor({ eventsPromise, abortController, minChangeIntervalMS = 50, transform, ignoreKeys, textFromErrorEvent }: ConstructorParams<T>) {
|
|
53
55
|
this.abortController = abortController
|
|
54
56
|
this.transform = transform
|
|
55
57
|
this.ignoreKeys = ignoreKeys
|
|
56
58
|
this.run(eventsPromise, minChangeIntervalMS)
|
|
59
|
+
this.textFromErrorEvent = textFromErrorEvent ?? ((data) => JSON.stringify(data))
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
private async run(eventsPromise: Promise<FetchEventStream>, minChangeIntervalMS: number) {
|
|
@@ -64,10 +67,17 @@ export class StreamedJson<T> {
|
|
|
64
67
|
for await (const event of events) {
|
|
65
68
|
if (this.error) return
|
|
66
69
|
if (event.data) {
|
|
67
|
-
|
|
70
|
+
let json
|
|
71
|
+
try {
|
|
72
|
+
json = JSON.parse(event.data)
|
|
73
|
+
} catch (e) {
|
|
74
|
+
// eslint-disable-next-line no-console
|
|
75
|
+
console.warn('Mal formed JSON in streaming:', event.data)
|
|
76
|
+
continue
|
|
77
|
+
}
|
|
68
78
|
await this.transform?.(json, this.data)
|
|
69
79
|
this.merge(json, this.data)
|
|
70
|
-
if (new Date().getTime() - lastChangeCall >= minChangeIntervalMS) {
|
|
80
|
+
if (event.event !== 'error' && new Date().getTime() - lastChangeCall >= minChangeIntervalMS) {
|
|
71
81
|
this.onChangeListeners.forEach(l => l(this.data))
|
|
72
82
|
lastChangeCall = new Date().getTime()
|
|
73
83
|
flushed = true
|
|
@@ -75,6 +85,11 @@ export class StreamedJson<T> {
|
|
|
75
85
|
flushed = false
|
|
76
86
|
}
|
|
77
87
|
}
|
|
88
|
+
if (event.event === 'error') {
|
|
89
|
+
const error = new Error(this.textFromErrorEvent(this.data))
|
|
90
|
+
this.data = {}
|
|
91
|
+
throw error
|
|
92
|
+
}
|
|
78
93
|
}
|
|
79
94
|
if (!flushed) this.onChangeListeners.forEach(l => l(this.data))
|
|
80
95
|
} catch (error: any) {
|
|
@@ -138,7 +153,7 @@ export class StreamedJson<T> {
|
|
|
138
153
|
onChange(listener: (value: Partial<T>) => void) {
|
|
139
154
|
if (this.fullPromise.resolved) {
|
|
140
155
|
listener(this.data)
|
|
141
|
-
return () => {}
|
|
156
|
+
return () => { }
|
|
142
157
|
}
|
|
143
158
|
this.onChangeListeners.push(listener)
|
|
144
159
|
return () => {
|