@stack-spot/portal-network 0.184.0 → 0.185.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.
- package/CHANGELOG.md +2419 -2412
- package/dist/api/account.js +1 -1
- package/dist/api/agent-tools.js +1 -1
- package/dist/api/agent.js +1 -1
- package/dist/api/ai.js +1 -1
- package/dist/api/apiManagement.js +1 -1
- package/dist/api/apiRuntime.js +1 -1
- package/dist/api/cloudAccount.js +1 -1
- package/dist/api/cloudPlatform.js +1 -1
- package/dist/api/cloudPlatformHorizon.js +1 -1
- package/dist/api/cloudRuntimes.js +1 -1
- package/dist/api/cloudServices.js +1 -1
- package/dist/api/codeShift.d.ts +63 -4
- package/dist/api/codeShift.d.ts.map +1 -1
- package/dist/api/codeShift.js +14 -1
- package/dist/api/codeShift.js.map +1 -1
- package/dist/api/content.js +1 -1
- package/dist/api/dataIntegration.js +1 -1
- package/dist/api/discover.js +1 -1
- package/dist/api/genAiInference.js +1 -1
- package/dist/api/insights.js +1 -1
- package/dist/api/notification.js +1 -1
- package/dist/api/secrets.js +1 -1
- package/dist/api/serviceCatalog.js +1 -1
- package/dist/api/workspace-ai.js +1 -1
- package/dist/api/workspace.js +1 -1
- package/dist/api/workspaceManager.js +1 -1
- package/dist/api/workspaceSearchEngine.js +1 -1
- package/dist/client/code-shift.d.ts +22 -0
- package/dist/client/code-shift.d.ts.map +1 -1
- package/dist/client/code-shift.js +28 -1
- package/dist/client/code-shift.js.map +1 -1
- package/package.json +6 -6
- package/scripts/generate-apis.ts +134 -134
- package/src/api/account.ts +8367 -8367
- package/src/api/agent-tools.ts +2169 -2169
- package/src/api/agent.ts +1083 -1083
- package/src/api/ai.ts +3388 -3388
- package/src/api/apiManagement.ts +570 -570
- package/src/api/apiRuntime.ts +2103 -2103
- package/src/api/cloudAccount.ts +1239 -1239
- package/src/api/cloudPlatform.ts +927 -927
- package/src/api/cloudPlatformHorizon.ts +2655 -2655
- package/src/api/cloudRuntimes.ts +2043 -2043
- package/src/api/cloudServices.ts +1445 -1445
- package/src/api/codeShift.ts +3567 -3481
- package/src/api/content.ts +9785 -9785
- package/src/api/dataIntegration.ts +1657 -1657
- package/src/api/discover.ts +435 -435
- package/src/api/eventBus.ts +171 -171
- package/src/api/genAiInference.ts +603 -603
- package/src/api/insights.ts +310 -310
- package/src/api/notification.ts +334 -334
- package/src/api/secrets.ts +342 -342
- package/src/api/serviceCatalog.ts +2908 -2908
- package/src/api/workflows.ts +1669 -1669
- package/src/api/workspace-ai.ts +677 -677
- package/src/api/workspace.ts +5889 -5889
- package/src/api/workspaceManager.ts +2951 -2951
- package/src/api/workspaceSearchEngine.ts +153 -153
- package/src/api-addresses.ts +120 -120
- package/src/apis-itau.json +225 -225
- package/src/apis.json +225 -225
- package/src/client/account.ts +902 -902
- package/src/client/agent-tools.ts +210 -210
- package/src/client/agent.ts +81 -81
- package/src/client/ai.ts +395 -395
- package/src/client/api-management.ts +40 -40
- package/src/client/cloud-account.ts +70 -70
- package/src/client/cloud-platform-horizon.ts +113 -113
- package/src/client/cloud-platform.ts +163 -163
- package/src/client/cloud-runtimes.ts +129 -129
- package/src/client/cloud-services.ts +94 -94
- package/src/client/code-shift.ts +364 -349
- package/src/client/content.ts +538 -538
- package/src/client/data-integration.ts +191 -191
- package/src/client/discover.ts +89 -89
- package/src/client/event-bus.ts +84 -84
- package/src/client/gen-ai-inference.ts +65 -65
- package/src/client/insights.ts +28 -28
- package/src/client/notification.ts +32 -32
- package/src/client/runtime-manager.ts +76 -76
- package/src/client/secrets.ts +60 -60
- package/src/client/types.ts +377 -377
- package/src/client/workflow.ts +83 -83
- package/src/client/workspace-ai.ts +191 -191
- package/src/client/workspace-manager.ts +564 -564
- package/src/client/workspace-search.ts +39 -39
- package/src/client/workspace.ts +480 -480
- package/src/error/DefaultAPIError.ts +151 -151
- package/src/error/FileUploadError.ts +18 -18
- package/src/error/IgnoredErrorCodes.ts +3 -3
- package/src/error/StackspotAPIError.ts +101 -101
- package/src/error/StreamCanceledError.ts +10 -10
- package/src/error/StreamError.ts +7 -7
- package/src/error/StreamJsonError.ts +10 -10
- package/src/error/dictionary/account.ts +58 -58
- package/src/error/dictionary/action-details.ts +20 -20
- package/src/error/dictionary/action.ts +211 -211
- package/src/error/dictionary/agent-tools.ts +75 -75
- package/src/error/dictionary/ai-inference.ts +28 -28
- package/src/error/dictionary/base.ts +22 -22
- package/src/error/dictionary/cloud-platform.ts +82 -82
- package/src/error/dictionary/cnt-fields.ts +14 -14
- package/src/error/dictionary/cnt.ts +103 -103
- package/src/error/dictionary/code-shift.ts +12 -12
- package/src/error/dictionary/rte.ts +24 -24
- package/src/error/dictionary/rtm.ts +10 -10
- package/src/error/dictionary/secrets.ts +14 -14
- package/src/error/dictionary/workspace-ai.ts +10 -10
- package/src/error/dictionary/workspace-details.ts +15 -15
- package/src/error/dictionary/workspace-fields.ts +10 -10
- package/src/error/dictionary/workspace.ts +209 -209
- package/src/error/types.ts +21 -21
- package/src/index.ts +43 -43
- package/src/network/AutoInfiniteQuery.ts +115 -115
- package/src/network/AutoMutation.ts +27 -27
- package/src/network/AutoOperation.ts +73 -73
- package/src/network/AutoQuery.ts +75 -75
- package/src/network/ManualInfiniteQuery.ts +95 -95
- package/src/network/ManualMutation.ts +40 -40
- package/src/network/ManualOperation.ts +52 -52
- package/src/network/ManualQuery.ts +82 -82
- package/src/network/NetworkClient.ts +167 -167
- package/src/network/ReactQueryNetworkClient.ts +312 -312
- package/src/network/react-query-client.ts +14 -14
- package/src/network/types.ts +294 -294
- package/src/types.ts +1 -1
- package/src/utils/StreamedArray.tsx +146 -146
- package/src/utils/StreamedJson.tsx +166 -166
- package/src/utils/remove-authorization-param.ts +6 -6
- package/src/utils/string.ts +19 -19
- package/src/utils/use-extended-list.ts +80 -80
- package/src/utils/use-streamed-array.ts +17 -17
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +10 -10
package/scripts/generate-apis.ts
CHANGED
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
import { exec } from 'child_process'
|
|
4
|
-
import { readFile, unlink, writeFile } from 'fs/promises'
|
|
5
|
-
import checkbox from '@inquirer/checkbox'
|
|
6
|
-
import { Presets, SingleBar } from 'cli-progress'
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
import list from 'inquirer-interactive-list-prompt'
|
|
9
|
-
import apis from '../src/apis.json'
|
|
10
|
-
|
|
11
|
-
const MAX_ATTEMPTS = 5
|
|
12
|
-
const DELAY_MS = 2000
|
|
13
|
-
const TARGET_DIR = 'src/api'
|
|
14
|
-
const LOG_FILE = '.generate-api.failed.json'
|
|
15
|
-
const envs = [
|
|
16
|
-
{ name: 'Production', value: 'prd', key: 'p' },
|
|
17
|
-
{ name: 'Staging', value: 'stg', key: 's' },
|
|
18
|
-
{ name: 'Development', value: 'dev', key: 'd' },
|
|
19
|
-
] as const
|
|
20
|
-
|
|
21
|
-
function delay() {
|
|
22
|
-
return new Promise<void>(resolve => {
|
|
23
|
-
setTimeout(resolve, DELAY_MS)
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function generateAPICode(name: string, docsUrl: any) {
|
|
28
|
-
return new Promise<string>((resolve, reject) => {
|
|
29
|
-
let output = ''
|
|
30
|
-
const child = exec(
|
|
31
|
-
`pnpm oazapfts ${docsUrl} ${TARGET_DIR}/${name}.ts --optimistic --argumentStyle object`,
|
|
32
|
-
(_, out, err) => output += out || err,
|
|
33
|
-
)
|
|
34
|
-
child.on('error', err => reject(err.message))
|
|
35
|
-
child.on('close', code => code === 0 ? resolve(output) : reject(output))
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function generateCodeForAPIs(apiNames: (keyof typeof apis)[], env: 'dev' | 'stg' | 'prd') {
|
|
40
|
-
let progress = 0
|
|
41
|
-
const progressBar = new SingleBar({ clearOnComplete: true, stopOnComplete: true }, Presets.shades_classic)
|
|
42
|
-
progressBar.start(apiNames.length, 0)
|
|
43
|
-
const succeeded: string[] = []
|
|
44
|
-
const failed: string[] = []
|
|
45
|
-
const errors: string[] = []
|
|
46
|
-
await Promise.all(apiNames.map(async (name) => {
|
|
47
|
-
let retries = MAX_ATTEMPTS
|
|
48
|
-
while (retries > 0) {
|
|
49
|
-
try {
|
|
50
|
-
const api = apis[name]
|
|
51
|
-
if ('docs' in api) {
|
|
52
|
-
const docsUrl = `${api.url[env]}${api.docs}`
|
|
53
|
-
await generateAPICode(name, docsUrl)
|
|
54
|
-
}
|
|
55
|
-
retries = 0
|
|
56
|
-
succeeded.push(name)
|
|
57
|
-
progressBar.update(++progress)
|
|
58
|
-
} catch (error: any) {
|
|
59
|
-
retries--
|
|
60
|
-
await delay()
|
|
61
|
-
if (retries === 0) {
|
|
62
|
-
errors.push(error.message || `${error}`)
|
|
63
|
-
failed.push(name)
|
|
64
|
-
progressBar.update(++progress)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}))
|
|
69
|
-
const succeededStr = succeeded.length ? ` Code generated successfully for ${succeeded.length} APIs.` : ''
|
|
70
|
-
const failedStr = failed.length ? ` Failed to generate code for ${failed.length} APIs. Check the logs below.` : ''
|
|
71
|
-
console.log(`\nFinished!${succeededStr}${failedStr}`)
|
|
72
|
-
if (succeeded.length) {
|
|
73
|
-
console.log('\n> Generated code for:')
|
|
74
|
-
succeeded.forEach(api => console.log(` - ${api}`))
|
|
75
|
-
await removeLastFailed()
|
|
76
|
-
}
|
|
77
|
-
if (failed.length) {
|
|
78
|
-
console.log('\n> Failed to generate code for:')
|
|
79
|
-
failed.forEach(api => console.log(` - ${api}`))
|
|
80
|
-
await saveFailed(failed)
|
|
81
|
-
}
|
|
82
|
-
if (errors.length) throw new Error(errors.join('\n\n'))
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async function getLastFailed(): Promise<(keyof typeof apis)[]> {
|
|
86
|
-
try {
|
|
87
|
-
const raw = await readFile(LOG_FILE, { encoding: 'utf-8' })
|
|
88
|
-
return JSON.parse(raw)
|
|
89
|
-
} catch {
|
|
90
|
-
return []
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function removeLastFailed() {
|
|
95
|
-
try {
|
|
96
|
-
await unlink(LOG_FILE)
|
|
97
|
-
// eslint-disable-next-line no-empty
|
|
98
|
-
} catch {}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async function saveFailed(failed: string[]) {
|
|
102
|
-
try {
|
|
103
|
-
await writeFile(LOG_FILE, JSON.stringify(failed), { encoding: 'utf-8' })
|
|
104
|
-
// eslint-disable-next-line no-empty
|
|
105
|
-
} catch {}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async function start() {
|
|
109
|
-
try {
|
|
110
|
-
const cmdEnvArg = process.argv[2]
|
|
111
|
-
const allAPINames = Object.keys(apis) as (keyof typeof apis)[]
|
|
112
|
-
if ((envs.map(e => e.value) as string[]).includes(cmdEnvArg?.trim() ?? '')) {
|
|
113
|
-
await generateCodeForAPIs(allAPINames, cmdEnvArg as 'prd' | 'stg' | 'dev')
|
|
114
|
-
} else {
|
|
115
|
-
const lastFailed = await getLastFailed()
|
|
116
|
-
const selectedAPIs = await checkbox({
|
|
117
|
-
message: 'Select the APIs you wish to update',
|
|
118
|
-
choices: allAPINames.map(api => ({ name: api, value: api, checked: !lastFailed.length || lastFailed.includes(api) })),
|
|
119
|
-
})
|
|
120
|
-
const env: 'prd' | 'stg' | 'dev' = await list({
|
|
121
|
-
message: 'Select an environment',
|
|
122
|
-
choices: envs,
|
|
123
|
-
default: envs[0].value,
|
|
124
|
-
})
|
|
125
|
-
await generateCodeForAPIs(selectedAPIs, env)
|
|
126
|
-
}
|
|
127
|
-
process.exit(0)
|
|
128
|
-
} catch (error: any) {
|
|
129
|
-
console.error(error.message || `${error}`)
|
|
130
|
-
process.exit(1)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
start()
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
|
|
3
|
+
import { exec } from 'child_process'
|
|
4
|
+
import { readFile, unlink, writeFile } from 'fs/promises'
|
|
5
|
+
import checkbox from '@inquirer/checkbox'
|
|
6
|
+
import { Presets, SingleBar } from 'cli-progress'
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import list from 'inquirer-interactive-list-prompt'
|
|
9
|
+
import apis from '../src/apis.json'
|
|
10
|
+
|
|
11
|
+
const MAX_ATTEMPTS = 5
|
|
12
|
+
const DELAY_MS = 2000
|
|
13
|
+
const TARGET_DIR = 'src/api'
|
|
14
|
+
const LOG_FILE = '.generate-api.failed.json'
|
|
15
|
+
const envs = [
|
|
16
|
+
{ name: 'Production', value: 'prd', key: 'p' },
|
|
17
|
+
{ name: 'Staging', value: 'stg', key: 's' },
|
|
18
|
+
{ name: 'Development', value: 'dev', key: 'd' },
|
|
19
|
+
] as const
|
|
20
|
+
|
|
21
|
+
function delay() {
|
|
22
|
+
return new Promise<void>(resolve => {
|
|
23
|
+
setTimeout(resolve, DELAY_MS)
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function generateAPICode(name: string, docsUrl: any) {
|
|
28
|
+
return new Promise<string>((resolve, reject) => {
|
|
29
|
+
let output = ''
|
|
30
|
+
const child = exec(
|
|
31
|
+
`pnpm oazapfts ${docsUrl} ${TARGET_DIR}/${name}.ts --optimistic --argumentStyle object`,
|
|
32
|
+
(_, out, err) => output += out || err,
|
|
33
|
+
)
|
|
34
|
+
child.on('error', err => reject(err.message))
|
|
35
|
+
child.on('close', code => code === 0 ? resolve(output) : reject(output))
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function generateCodeForAPIs(apiNames: (keyof typeof apis)[], env: 'dev' | 'stg' | 'prd') {
|
|
40
|
+
let progress = 0
|
|
41
|
+
const progressBar = new SingleBar({ clearOnComplete: true, stopOnComplete: true }, Presets.shades_classic)
|
|
42
|
+
progressBar.start(apiNames.length, 0)
|
|
43
|
+
const succeeded: string[] = []
|
|
44
|
+
const failed: string[] = []
|
|
45
|
+
const errors: string[] = []
|
|
46
|
+
await Promise.all(apiNames.map(async (name) => {
|
|
47
|
+
let retries = MAX_ATTEMPTS
|
|
48
|
+
while (retries > 0) {
|
|
49
|
+
try {
|
|
50
|
+
const api = apis[name]
|
|
51
|
+
if ('docs' in api) {
|
|
52
|
+
const docsUrl = `${api.url[env]}${api.docs}`
|
|
53
|
+
await generateAPICode(name, docsUrl)
|
|
54
|
+
}
|
|
55
|
+
retries = 0
|
|
56
|
+
succeeded.push(name)
|
|
57
|
+
progressBar.update(++progress)
|
|
58
|
+
} catch (error: any) {
|
|
59
|
+
retries--
|
|
60
|
+
await delay()
|
|
61
|
+
if (retries === 0) {
|
|
62
|
+
errors.push(error.message || `${error}`)
|
|
63
|
+
failed.push(name)
|
|
64
|
+
progressBar.update(++progress)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}))
|
|
69
|
+
const succeededStr = succeeded.length ? ` Code generated successfully for ${succeeded.length} APIs.` : ''
|
|
70
|
+
const failedStr = failed.length ? ` Failed to generate code for ${failed.length} APIs. Check the logs below.` : ''
|
|
71
|
+
console.log(`\nFinished!${succeededStr}${failedStr}`)
|
|
72
|
+
if (succeeded.length) {
|
|
73
|
+
console.log('\n> Generated code for:')
|
|
74
|
+
succeeded.forEach(api => console.log(` - ${api}`))
|
|
75
|
+
await removeLastFailed()
|
|
76
|
+
}
|
|
77
|
+
if (failed.length) {
|
|
78
|
+
console.log('\n> Failed to generate code for:')
|
|
79
|
+
failed.forEach(api => console.log(` - ${api}`))
|
|
80
|
+
await saveFailed(failed)
|
|
81
|
+
}
|
|
82
|
+
if (errors.length) throw new Error(errors.join('\n\n'))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function getLastFailed(): Promise<(keyof typeof apis)[]> {
|
|
86
|
+
try {
|
|
87
|
+
const raw = await readFile(LOG_FILE, { encoding: 'utf-8' })
|
|
88
|
+
return JSON.parse(raw)
|
|
89
|
+
} catch {
|
|
90
|
+
return []
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function removeLastFailed() {
|
|
95
|
+
try {
|
|
96
|
+
await unlink(LOG_FILE)
|
|
97
|
+
// eslint-disable-next-line no-empty
|
|
98
|
+
} catch {}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function saveFailed(failed: string[]) {
|
|
102
|
+
try {
|
|
103
|
+
await writeFile(LOG_FILE, JSON.stringify(failed), { encoding: 'utf-8' })
|
|
104
|
+
// eslint-disable-next-line no-empty
|
|
105
|
+
} catch {}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function start() {
|
|
109
|
+
try {
|
|
110
|
+
const cmdEnvArg = process.argv[2]
|
|
111
|
+
const allAPINames = Object.keys(apis) as (keyof typeof apis)[]
|
|
112
|
+
if ((envs.map(e => e.value) as string[]).includes(cmdEnvArg?.trim() ?? '')) {
|
|
113
|
+
await generateCodeForAPIs(allAPINames, cmdEnvArg as 'prd' | 'stg' | 'dev')
|
|
114
|
+
} else {
|
|
115
|
+
const lastFailed = await getLastFailed()
|
|
116
|
+
const selectedAPIs = await checkbox({
|
|
117
|
+
message: 'Select the APIs you wish to update',
|
|
118
|
+
choices: allAPINames.map(api => ({ name: api, value: api, checked: !lastFailed.length || lastFailed.includes(api) })),
|
|
119
|
+
})
|
|
120
|
+
const env: 'prd' | 'stg' | 'dev' = await list({
|
|
121
|
+
message: 'Select an environment',
|
|
122
|
+
choices: envs,
|
|
123
|
+
default: envs[0].value,
|
|
124
|
+
})
|
|
125
|
+
await generateCodeForAPIs(selectedAPIs, env)
|
|
126
|
+
}
|
|
127
|
+
process.exit(0)
|
|
128
|
+
} catch (error: any) {
|
|
129
|
+
console.error(error.message || `${error}`)
|
|
130
|
+
process.exit(1)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
start()
|