@stack-spot/portal-network 0.42.2 → 0.44.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 +20 -0
- package/dist/api/cloudPlatform.js +2 -2
- package/dist/api/content.d.ts +38 -33
- package/dist/api/content.d.ts.map +1 -1
- package/dist/api/content.js +19 -10
- package/dist/api/content.js.map +1 -1
- package/dist/api/notification.d.ts +32 -8
- package/dist/api/notification.d.ts.map +1 -1
- package/dist/api/notification.js +17 -1
- package/dist/api/notification.js.map +1 -1
- package/dist/apis.json +1 -1
- package/dist/client/content.d.ts +14 -0
- package/dist/client/content.d.ts.map +1 -1
- package/dist/client/content.js +10 -1
- package/dist/client/content.js.map +1 -1
- package/dist/error/DefaultAPIError.d.ts.map +1 -1
- package/dist/error/DefaultAPIError.js +15 -6
- package/dist/error/DefaultAPIError.js.map +1 -1
- package/dist/error/StackspotAPIError.d.ts +21 -2
- package/dist/error/StackspotAPIError.d.ts.map +1 -1
- package/dist/error/StackspotAPIError.js +18 -3
- package/dist/error/StackspotAPIError.js.map +1 -1
- package/dist/error/dictionary/action-details.d.ts +2 -0
- package/dist/error/dictionary/action-details.d.ts.map +1 -0
- package/dist/error/dictionary/action-details.js +19 -0
- package/dist/error/dictionary/action-details.js.map +1 -0
- package/dist/error/dictionary/workspace-details.d.ts +2 -0
- package/dist/error/dictionary/workspace-details.d.ts.map +1 -0
- package/dist/error/dictionary/workspace-details.js +15 -0
- package/dist/error/dictionary/workspace-details.js.map +1 -0
- package/package.json +1 -1
- package/src/api/cloudPlatform.ts +2 -2
- package/src/api/content.ts +52 -38
- package/src/api/notification.ts +53 -8
- package/src/apis.json +1 -1
- package/src/client/content.ts +19 -13
- package/src/error/DefaultAPIError.ts +20 -7
- package/src/error/StackspotAPIError.ts +44 -6
- package/src/error/dictionary/action-details.ts +20 -0
- package/src/error/dictionary/workspace-details.ts +15 -0
package/src/apis.json
CHANGED
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"url": {
|
|
155
155
|
"dev": "https://cloud-cloud-platform-api.dev.stackspot.com",
|
|
156
156
|
"stg": "https://cloud-cloud-platform-api.stg.stackspot.com",
|
|
157
|
-
"prd": "https://cloud-cloud-platform-api.stackspot.com"
|
|
157
|
+
"prd": "https://cloud-cloud-platform-api.prd.stackspot.com"
|
|
158
158
|
},
|
|
159
159
|
"docs": "/v3/api-docs"
|
|
160
160
|
}
|
package/src/client/content.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
addAction, addLink, addWorkspace, associateActionToPlugin, changeVisibility, createStudio, defaults,
|
|
3
4
|
deleteAction, deleteActionVersion, deleteLink, deletePluginVersion, deleteStudio, deleteV1StacksVersionsByStackVersionId,
|
|
4
|
-
delWorkspace, deprecateActionVersion, deprecatePluginVersion, deprecateStackVersionBy, downloadAction, getActionBySlug,
|
|
5
|
-
getActionsVersions, getActionVersionById, getAllActionVersions, getApplicationDetailsView, getApplicationsUsesPlugin,
|
|
6
|
-
getAvailableActionVersionsByActionSlug, getDependentPluginsVersions,
|
|
7
|
-
getGetPluginView, getInfrastructureEnvironmentsUsesPlugin,
|
|
8
|
-
getListOfInputs, getPluginInfrastructureView, getPluginModalView, getPluginVersions, getPluginVersionsNotInUse,
|
|
5
|
+
delWorkspace, deprecateActionVersion, deprecatePluginVersion, deprecateStackVersionBy, downloadAction, getActionBySlug,
|
|
6
|
+
getActionsVersions, getActionVersionById, getAllActionVersions, getApplicationDetailsView, getApplicationsUsesPlugin,
|
|
7
|
+
getAvailableActionVersionsByActionSlug, getDependentPluginsVersions,
|
|
8
|
+
getGetPluginView, getInfrastructureEnvironmentsUsesPlugin,
|
|
9
|
+
getListOfInputs, getPluginInfrastructureView, getPluginModalView, getPluginVersions, getPluginVersionsNotInUse,
|
|
9
10
|
getPluginVersionUsageSummary, getStackUsesPlugin, getStackVersionById, getStackVersionListByIds, getStackWorkspaceDetailView,
|
|
10
|
-
getStackWorkspaces, getStarterStackVersionsAndPluginsVersions, getStarterUsesPlugin, getStudioByIdOrSlug, getStudios1,
|
|
11
|
-
getStudiosToCreateButton, getStudioTabs, getUnusedStackVersions, getWorkflow, getWorkflowByStudioSlug, getWorkflowDoc,
|
|
12
|
-
listActions, listActions1,
|
|
11
|
+
getStackWorkspaces, getStarterStackVersionsAndPluginsVersions, getStarterUsesPlugin, getStudioByIdOrSlug, getStudios, getStudios1,
|
|
12
|
+
getStudiosToCreateButton, getStudioTabs, getUnusedStackVersions, getWorkflow, getWorkflowByStudioSlug, getWorkflowDoc,
|
|
13
|
+
listActions, listActions1,
|
|
13
14
|
listActionsByFilters1, listConnectionInterfaceTypes, listLinksByStackVersion, listPlugins, listPluginVersionByIdsController,
|
|
14
|
-
listReasons, listStacksByFilters, listStarters, listWorkflowVersion,
|
|
15
|
+
listReasons, listStacksByFilters, listStarters, listWorkflowVersion,
|
|
15
16
|
listWorkspaces, patchStarterV2, removeActionFromPlugin, stackModalViewSummary,
|
|
16
|
-
stackVersionUsageSummary, updateStudio, updateStudioTabs
|
|
17
|
+
stackVersionUsageSummary, updateStudio, updateStudioTabs,
|
|
18
|
+
} from '../api/content'
|
|
17
19
|
import apis from '../apis.json'
|
|
18
20
|
import { DefaultAPIError } from '../error/DefaultAPIError'
|
|
19
21
|
import { cntDictionary } from '../error/dictionary/cnt'
|
|
@@ -50,6 +52,10 @@ class ContentClient extends ReactQueryNetworkClient {
|
|
|
50
52
|
* Gets all studios
|
|
51
53
|
*/
|
|
52
54
|
studios = this.query(removeAuthorizationParam(getStudios1))
|
|
55
|
+
/**
|
|
56
|
+
* Gets all studios
|
|
57
|
+
*/
|
|
58
|
+
studiosWithPagination = this.query(removeAuthorizationParam(getStudios))
|
|
53
59
|
/**
|
|
54
60
|
* Gets all studios
|
|
55
61
|
*/
|
|
@@ -102,7 +108,7 @@ class ContentClient extends ReactQueryNetworkClient {
|
|
|
102
108
|
* Gets stacks from a given studio
|
|
103
109
|
*/
|
|
104
110
|
stacksFromStudios = this.query(listStacksByFilters)
|
|
105
|
-
|
|
111
|
+
|
|
106
112
|
//Workflow
|
|
107
113
|
/**
|
|
108
114
|
* Gets workflows from a given studio
|
|
@@ -283,7 +289,7 @@ class ContentClient extends ReactQueryNetworkClient {
|
|
|
283
289
|
/**
|
|
284
290
|
* Gets the inputs of a specific Action. This fn is only used for permission purposes.
|
|
285
291
|
*/
|
|
286
|
-
actionInputs = this.query(getListOfInputs) as
|
|
292
|
+
actionInputs = this.query(getListOfInputs) as
|
|
287
293
|
OperationObject<Parameters<typeof getListOfInputs>[0]>
|
|
288
294
|
/**
|
|
289
295
|
* Gets action versions by ids
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Dictionary, Language } from '@stack-spot/portal-translate'
|
|
2
2
|
import { every, isString } from 'lodash'
|
|
3
3
|
import { ErrorResponse, ValidationDetails } from '../api/account'
|
|
4
|
-
import { StackspotAPIError } from './StackspotAPIError'
|
|
4
|
+
import { ErrorDetailsProperties, StackspotAPIError } from './StackspotAPIError'
|
|
5
5
|
import { baseDictionary } from './dictionary/base'
|
|
6
6
|
import { cntFields } from './dictionary/cnt-fields'
|
|
7
7
|
import { workspaceFields } from './dictionary/workspace-fields'
|
|
8
|
+
import { workspaceDetails } from './dictionary/workspace-details'
|
|
9
|
+
import { actionDetails } from './dictionary/action-details'
|
|
8
10
|
|
|
9
11
|
// these details don't say anything the status already doesn't and we'd better use local translations for them.
|
|
10
12
|
const ignoredDescriptions = [
|
|
@@ -16,6 +18,11 @@ const fieldDictionary = {
|
|
|
16
18
|
wks: workspaceFields,
|
|
17
19
|
}
|
|
18
20
|
|
|
21
|
+
const detailsDictionary = {
|
|
22
|
+
wks: workspaceDetails,
|
|
23
|
+
actionapi: actionDetails,
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
function getTitle(status: number, raw: ErrorResponse, dictionary: Dictionary, language: Language) {
|
|
20
27
|
if (dictionary[language][raw.code]) return dictionary[language][raw.code]
|
|
21
28
|
if (raw.details && !ignoredDescriptions.includes(raw.details)) return raw.details
|
|
@@ -26,16 +33,22 @@ function getValues(detail: ValidationDetails) {
|
|
|
26
33
|
return detail.values && every(detail.values, isString) ? `\n${detail.values.join('\n')}` : ''
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
function createMessage(status: number, raw: ErrorResponse, dictionary: Dictionary, language
|
|
30
|
-
const title = getTitle(status, raw, dictionary, language)
|
|
31
|
-
if (!raw.validationDetails?.length) return title
|
|
36
|
+
function createMessage(status: number, raw: ErrorResponse, dictionary: Dictionary, language?: Language): ErrorDetailsProperties {
|
|
37
|
+
const title = getTitle(status, raw, dictionary, language || 'en')
|
|
32
38
|
const api = raw.code?.split(/[-_]/)[0]
|
|
39
|
+
const dictDetails = (detailsDictionary[api?.toLowerCase() as keyof typeof detailsDictionary] ?? {})[language || 'en']
|
|
40
|
+
const dictionaryDetails = raw.code && dictDetails ? dictDetails[raw.code] : {}
|
|
41
|
+
|
|
42
|
+
if (!raw.validationDetails?.length) return { description : title, ...dictionaryDetails }
|
|
43
|
+
|
|
33
44
|
const details = raw.validationDetails?.map((detail) => {
|
|
34
|
-
const dict: Record<string, string> = (fieldDictionary[api?.toLowerCase() as keyof typeof fieldDictionary] ?? {})[language] ?? {}
|
|
35
|
-
const name = dict[detail.code] || detail.field ||
|
|
45
|
+
const dict: Record<string, string> = (fieldDictionary[api?.toLowerCase() as keyof typeof fieldDictionary] ?? {})[language || 'en'] ?? {}
|
|
46
|
+
const name = dict[detail.code] || detail.field ||
|
|
47
|
+
(raw.code !== detail.code && dictionary[language || 'en'][detail.code]) || detail.details || ''
|
|
36
48
|
return `${name}${getValues(detail)}`
|
|
37
49
|
})?.filter(d => !!d)
|
|
38
|
-
|
|
50
|
+
|
|
51
|
+
return { description: details ? `${title}\n${details?.join('\n')}` : title, ...dictionaryDetails }
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
/**
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { Language, getLanguage } from '@stack-spot/portal-translate'
|
|
2
2
|
|
|
3
|
-
export type InternationalizedMessage = (language: Language) => string
|
|
3
|
+
export type InternationalizedMessage = (language: Language) => string | ErrorDetailsProperties
|
|
4
|
+
|
|
5
|
+
export interface ErrorDetailsProperties {
|
|
6
|
+
/**
|
|
7
|
+
* The error title
|
|
8
|
+
*/
|
|
9
|
+
title?: string,
|
|
10
|
+
/**
|
|
11
|
+
* The error description
|
|
12
|
+
*/
|
|
13
|
+
description?: string,
|
|
14
|
+
/**
|
|
15
|
+
* Label for link
|
|
16
|
+
*/
|
|
17
|
+
linkLabel?: string,
|
|
18
|
+
/**
|
|
19
|
+
* Text for href of link
|
|
20
|
+
*/
|
|
21
|
+
linkHref?: string,
|
|
22
|
+
}
|
|
4
23
|
|
|
5
24
|
interface ErrorProperties {
|
|
6
25
|
/**
|
|
@@ -20,11 +39,17 @@ interface ErrorProperties {
|
|
|
20
39
|
*
|
|
21
40
|
* If not provided, will attempt to use the error code or 'unknown'.
|
|
22
41
|
*/
|
|
23
|
-
message?: InternationalizedMessage | string,
|
|
42
|
+
message?: InternationalizedMessage | string | ErrorDetailsProperties,
|
|
24
43
|
/**
|
|
25
44
|
* The error's stack trace, if any.
|
|
26
45
|
*/
|
|
27
46
|
stack?: string,
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getMessage(error: ErrorProperties['message']) {
|
|
51
|
+
const message = typeof error === 'function' ? error('en') : error
|
|
52
|
+
return typeof message === 'string' ? message : message?.description
|
|
28
53
|
}
|
|
29
54
|
|
|
30
55
|
export class StackspotAPIError extends Error {
|
|
@@ -43,12 +68,12 @@ export class StackspotAPIError extends Error {
|
|
|
43
68
|
private intl?: InternationalizedMessage
|
|
44
69
|
|
|
45
70
|
constructor({ status, code, headers, message, stack }: ErrorProperties) {
|
|
46
|
-
super(`Stackspot API error (network ${status}): ${
|
|
71
|
+
super(`Stackspot API error (network ${status}): ${getMessage(message)}`)
|
|
47
72
|
this.status = status
|
|
48
73
|
this.code = code
|
|
49
74
|
this.headers = headers
|
|
50
75
|
this.stack = stack
|
|
51
|
-
this.intl = typeof message === 'string' ?
|
|
76
|
+
this.intl = typeof message === 'string' || typeof message === 'object' ? () => message : message
|
|
52
77
|
}
|
|
53
78
|
|
|
54
79
|
/**
|
|
@@ -56,8 +81,21 @@ export class StackspotAPIError extends Error {
|
|
|
56
81
|
* @param language
|
|
57
82
|
* @returns an error message
|
|
58
83
|
*/
|
|
59
|
-
translate(language: Language = getLanguage()) {
|
|
84
|
+
translate(language: Language = getLanguage()): string {
|
|
85
|
+
const unknown = language === 'en' ? 'unknown error' : 'erro desconhecido'
|
|
86
|
+
|
|
87
|
+
const error = this.intl?.(language)
|
|
88
|
+
const message = typeof error === 'string' ? error : error?.description
|
|
89
|
+
return message ?? this.message ?? this.code ?? (this.status === 0 ? unknown : `${this.status}`)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
translateDetails(language: Language = getLanguage()): ErrorDetailsProperties {
|
|
60
93
|
const unknown = language === 'en' ? 'unknown error' : 'erro desconhecido'
|
|
61
|
-
|
|
94
|
+
const errorMessage = this.intl?.(language)
|
|
95
|
+
if (typeof errorMessage === 'string')
|
|
96
|
+
return { description: errorMessage }
|
|
97
|
+
if (typeof errorMessage === 'object')
|
|
98
|
+
return errorMessage
|
|
99
|
+
return { description: this.message ?? this.code ?? (this.status === 0 ? unknown : `${this.status}`) }
|
|
62
100
|
}
|
|
63
101
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
export const actionDetails: Record<string, Record<string, object>> = {
|
|
3
|
+
en: {
|
|
4
|
+
ACTIONAPI_5004_GITHUB_SAML_ERROR :
|
|
5
|
+
{
|
|
6
|
+
title: 'SSO Authorization pending',
|
|
7
|
+
description: 'Authorize SSO on GitHub to continue',
|
|
8
|
+
linkLabel: 'Check documentation',
|
|
9
|
+
linkHref: 'https://docs.stackspot.com/en/home/account/guides/scm-integration/scm-github#integrate-github-with-stackspot',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
pt: {
|
|
13
|
+
ACTIONAPI_5004_GITHUB_SAML_ERROR :{
|
|
14
|
+
title: 'Autorização SSO pendente',
|
|
15
|
+
description: 'Autorize o SSO no GitHub para continuar',
|
|
16
|
+
linkLabel: 'Ver Documentação',
|
|
17
|
+
linkHref: 'https://docs.stackspot.com/home/account/guides/scm-integration/scm-github#integrar-o-github-com-a-stackspot',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
export const workspaceDetails: Record<string, Record<string, object>> = {
|
|
3
|
+
en: {
|
|
4
|
+
WKS_API_WORKFLOW_UNAUTHORIZED: {
|
|
5
|
+
title: 'Invalid token',
|
|
6
|
+
description: 'Check your authorizations on GitHub and the token on StackSpot',
|
|
7
|
+
},
|
|
8
|
+
},
|
|
9
|
+
pt: {
|
|
10
|
+
WKS_API_WORKFLOW_UNAUTHORIZED: {
|
|
11
|
+
title: 'Token inválido',
|
|
12
|
+
description: 'Confira suas autorizações no Github e o token na StackSpot',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
}
|