@stack-spot/portal-network 0.6.0 → 0.8.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 +14 -0
- package/dist/api/secrets.d.ts +100 -0
- package/dist/api/secrets.d.ts.map +1 -0
- package/dist/api/secrets.js +101 -0
- package/dist/api/secrets.js.map +1 -0
- package/dist/apis.json +8 -0
- package/dist/client/account.d.ts +64 -0
- package/dist/client/account.d.ts.map +1 -1
- package/dist/client/account.js +168 -1
- package/dist/client/account.js.map +1 -1
- package/dist/client/secrets.d.ts +50 -0
- package/dist/client/secrets.d.ts.map +1 -0
- package/dist/client/secrets.js +78 -0
- package/dist/client/secrets.js.map +1 -0
- package/dist/client/types.d.ts +38 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +2 -0
- package/dist/client/types.js.map +1 -0
- package/dist/error/dictionary/secrets.d.ts +13 -0
- package/dist/error/dictionary/secrets.d.ts.map +1 -0
- package/dist/error/dictionary/secrets.js +13 -0
- package/dist/error/dictionary/secrets.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/src/api/secrets.ts +279 -0
- package/src/apis.json +8 -0
- package/src/client/account.ts +108 -3
- package/src/client/secrets.ts +56 -0
- package/src/client/types.ts +44 -0
- package/src/error/dictionary/secrets.ts +14 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
+
|
|
3
|
+
import { createKey, defaults, deleteKey, deleteSecretValue, editKey, getAll1, getAvailability, updateSecretValue } from '../api/secrets'
|
|
4
|
+
import apis from '../apis.json'
|
|
5
|
+
import { DefaultAPIError } from '../error/DefaultAPIError'
|
|
6
|
+
import { secretsDictionary } from '../error/dictionary/secrets'
|
|
7
|
+
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
8
|
+
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
9
|
+
|
|
10
|
+
class SecretClient extends ReactQueryNetworkClient {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(apis.secrets.url, defaults)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected buildStackSpotError(error: HttpError): StackspotAPIError {
|
|
16
|
+
return new DefaultAPIError(error.data, error.status, secretsDictionary, error.headers)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a key
|
|
21
|
+
*/
|
|
22
|
+
createKey = this.mutation(createKey)
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get all keys
|
|
26
|
+
*/
|
|
27
|
+
getAllKeys = this.query(getAll1)
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Delete a key
|
|
31
|
+
*/
|
|
32
|
+
deleteKey = this.mutation(deleteKey)
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Update a key's description
|
|
36
|
+
*/
|
|
37
|
+
updateKey = this.mutation(editKey)
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get which secrets are defined or undefined for a user
|
|
41
|
+
*/
|
|
42
|
+
getAvailability = this.query(getAvailability)
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Update a secret's value
|
|
46
|
+
*/
|
|
47
|
+
updateSecretValue = this.mutation(updateSecretValue)
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Delete a secret's value
|
|
51
|
+
*/
|
|
52
|
+
deleteSecretValue = this.mutation(deleteSecretValue)
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const secretsClient = new SecretClient()
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AccountScmInfoSaveRequest, AccountScmInfoUpdateRequest, AccountScmStatusResponse } from '../api/account'
|
|
2
|
+
|
|
3
|
+
interface BaseSMCStatus {
|
|
4
|
+
/**
|
|
5
|
+
* Indicates the current status of the SCM credential.
|
|
6
|
+
* - 'valid': the SCM credential is valid.
|
|
7
|
+
* - 'missing-account': the SCM credential is not configured at the account level.
|
|
8
|
+
* - 'missing-user': the SCM credential is configured at the account level, but the SCM access is not configured for the user.
|
|
9
|
+
*/
|
|
10
|
+
status: 'missing-account' | 'missing-user' | 'valid',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface ValidSCMStatus extends BaseSMCStatus, AccountScmStatusResponse {
|
|
14
|
+
status: 'valid',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface InvalidSCMStatus extends BaseSMCStatus {
|
|
18
|
+
status: 'missing-account' | 'missing-user',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type SCMStatus = InvalidSCMStatus | ValidSCMStatus
|
|
22
|
+
|
|
23
|
+
interface SCMAuthPATValue {
|
|
24
|
+
user: string,
|
|
25
|
+
pass: string,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface SCMAuthGitValue {
|
|
29
|
+
appId: string,
|
|
30
|
+
installationId: string,
|
|
31
|
+
privateKey: string,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface CreateSCMRequest {
|
|
35
|
+
accountScmInfoSaveRequest: AccountScmInfoSaveRequest & {
|
|
36
|
+
value: SCMAuthGitValue | SCMAuthPATValue,
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface UpdateSCMRequest {
|
|
41
|
+
accountScmInfoUpdateRequest: AccountScmInfoUpdateRequest & {
|
|
42
|
+
value?: SCMAuthGitValue | SCMAuthPATValue,
|
|
43
|
+
},
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Dictionary } from '@stack-spot/portal-translate'
|
|
2
|
+
|
|
3
|
+
export const secretsDictionary = {
|
|
4
|
+
en: {
|
|
5
|
+
WSA_SECRET_KEY_ALREADY_EXISTS: 'Secret Key already exists.',
|
|
6
|
+
WSA_SECRET_KEY_NOT_FOUND: 'Secret Key not found.',
|
|
7
|
+
WSA_SECRET_VALUE_NOT_FOUND: 'Secret Value not found.',
|
|
8
|
+
},
|
|
9
|
+
pt: {
|
|
10
|
+
WSA_SECRET_KEY_ALREADY_EXISTS: 'Secret Key já existe.',
|
|
11
|
+
WSA_SECRET_KEY_NOT_FOUND: 'Secret Key não encontrada.',
|
|
12
|
+
WSA_SECRET_VALUE_NOT_FOUND: 'Valor da Secret não encontrado.',
|
|
13
|
+
},
|
|
14
|
+
} satisfies Dictionary
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { accountClient } from './client/account'
|
|
2
|
+
export { secretsClient } from './client/secrets'
|
|
3
|
+
export * from './client/types'
|
|
2
4
|
export { workspaceClient } from './client/workspace'
|
|
3
5
|
export { DefaultAPIError } from './error/DefaultAPIError'
|
|
4
6
|
export { StackspotAPIError } from './error/StackspotAPIError'
|