@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,78 @@
|
|
|
1
|
+
import { createKey, defaults, deleteKey, deleteSecretValue, editKey, getAll1, getAvailability, updateSecretValue } from '../api/secrets.js';
|
|
2
|
+
import apis from '../apis.json';
|
|
3
|
+
import { DefaultAPIError } from '../error/DefaultAPIError.js';
|
|
4
|
+
import { secretsDictionary } from '../error/dictionary/secrets.js';
|
|
5
|
+
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient.js';
|
|
6
|
+
class SecretClient extends ReactQueryNetworkClient {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(apis.secrets.url, defaults);
|
|
9
|
+
/**
|
|
10
|
+
* Create a key
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(this, "createKey", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: this.mutation(createKey)
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Get all keys
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(this, "getAllKeys", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: this.query(getAll1)
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Delete a key
|
|
29
|
+
*/
|
|
30
|
+
Object.defineProperty(this, "deleteKey", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: this.mutation(deleteKey)
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Update a key's description
|
|
38
|
+
*/
|
|
39
|
+
Object.defineProperty(this, "updateKey", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: this.mutation(editKey)
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Get which secrets are defined or undefined for a user
|
|
47
|
+
*/
|
|
48
|
+
Object.defineProperty(this, "getAvailability", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true,
|
|
52
|
+
value: this.query(getAvailability)
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Update a secret's value
|
|
56
|
+
*/
|
|
57
|
+
Object.defineProperty(this, "updateSecretValue", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
value: this.mutation(updateSecretValue)
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Delete a secret's value
|
|
65
|
+
*/
|
|
66
|
+
Object.defineProperty(this, "deleteSecretValue", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
value: this.mutation(deleteSecretValue)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
buildStackSpotError(error) {
|
|
74
|
+
return new DefaultAPIError(error.data, error.status, secretsDictionary, error.headers);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export const secretsClient = new SecretClient();
|
|
78
|
+
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/client/secrets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACxI,OAAO,IAAI,MAAM,cAAc,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAE/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAE5E,MAAM,YAAa,SAAQ,uBAAuB;IAChD;QACE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;QAOnC;;WAEG;QACH;;;;mBAAY,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;WAAA;QAEpC;;WAEG;QACH;;;;mBAAa,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;WAAA;QAEhC;;WAEG;QACH;;;;mBAAY,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;WAAA;QAEpC;;WAEG;QACH;;;;mBAAY,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;WAAA;QAElC;;WAEG;QACH;;;;mBAAkB,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC;WAAA;QAE7C;;WAEG;QACH;;;;mBAAoB,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC;WAAA;QAEpD;;WAEG;QACH;;;;mBAAoB,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC;WAAA;IAvCpD,CAAC;IAES,mBAAmB,CAAC,KAAgB;QAC5C,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IACxF,CAAC;CAqCF;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AccountScmInfoSaveRequest, AccountScmInfoUpdateRequest, AccountScmStatusResponse } from '../api/account.js';
|
|
2
|
+
interface BaseSMCStatus {
|
|
3
|
+
/**
|
|
4
|
+
* Indicates the current status of the SCM credential.
|
|
5
|
+
* - 'valid': the SCM credential is valid.
|
|
6
|
+
* - 'missing-account': the SCM credential is not configured at the account level.
|
|
7
|
+
* - 'missing-user': the SCM credential is configured at the account level, but the SCM access is not configured for the user.
|
|
8
|
+
*/
|
|
9
|
+
status: 'missing-account' | 'missing-user' | 'valid';
|
|
10
|
+
}
|
|
11
|
+
interface ValidSCMStatus extends BaseSMCStatus, AccountScmStatusResponse {
|
|
12
|
+
status: 'valid';
|
|
13
|
+
}
|
|
14
|
+
interface InvalidSCMStatus extends BaseSMCStatus {
|
|
15
|
+
status: 'missing-account' | 'missing-user';
|
|
16
|
+
}
|
|
17
|
+
export type SCMStatus = InvalidSCMStatus | ValidSCMStatus;
|
|
18
|
+
interface SCMAuthPATValue {
|
|
19
|
+
user: string;
|
|
20
|
+
pass: string;
|
|
21
|
+
}
|
|
22
|
+
interface SCMAuthGitValue {
|
|
23
|
+
appId: string;
|
|
24
|
+
installationId: string;
|
|
25
|
+
privateKey: string;
|
|
26
|
+
}
|
|
27
|
+
export interface CreateSCMRequest {
|
|
28
|
+
accountScmInfoSaveRequest: AccountScmInfoSaveRequest & {
|
|
29
|
+
value: SCMAuthGitValue | SCMAuthPATValue;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface UpdateSCMRequest {
|
|
33
|
+
accountScmInfoUpdateRequest: AccountScmInfoUpdateRequest & {
|
|
34
|
+
value?: SCMAuthGitValue | SCMAuthPATValue;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAEjH,UAAU,aAAa;IACrB;;;;;OAKG;IACH,MAAM,EAAE,iBAAiB,GAAG,cAAc,GAAG,OAAO,CAAC;CACtD;AAED,UAAU,cAAe,SAAQ,aAAa,EAAE,wBAAwB;IACtE,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,UAAU,gBAAiB,SAAQ,aAAa;IAC9C,MAAM,EAAE,iBAAiB,GAAG,cAAc,CAAC;CAC5C;AAED,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,cAAc,CAAA;AAEzD,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,yBAAyB,EAAE,yBAAyB,GAAG;QACrD,KAAK,EAAE,eAAe,GAAG,eAAe,CAAC;KAC1C,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,2BAA2B,EAAE,2BAA2B,GAAG;QACzD,KAAK,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC;KAC3C,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const secretsDictionary: {
|
|
2
|
+
en: {
|
|
3
|
+
WSA_SECRET_KEY_ALREADY_EXISTS: string;
|
|
4
|
+
WSA_SECRET_KEY_NOT_FOUND: string;
|
|
5
|
+
WSA_SECRET_VALUE_NOT_FOUND: string;
|
|
6
|
+
};
|
|
7
|
+
pt: {
|
|
8
|
+
WSA_SECRET_KEY_ALREADY_EXISTS: string;
|
|
9
|
+
WSA_SECRET_KEY_NOT_FOUND: string;
|
|
10
|
+
WSA_SECRET_VALUE_NOT_FOUND: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../../src/error/dictionary/secrets.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;;;;;;;;;;;CAWR,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const secretsDictionary = {
|
|
2
|
+
en: {
|
|
3
|
+
WSA_SECRET_KEY_ALREADY_EXISTS: 'Secret Key already exists.',
|
|
4
|
+
WSA_SECRET_KEY_NOT_FOUND: 'Secret Key not found.',
|
|
5
|
+
WSA_SECRET_VALUE_NOT_FOUND: 'Secret Value not found.',
|
|
6
|
+
},
|
|
7
|
+
pt: {
|
|
8
|
+
WSA_SECRET_KEY_ALREADY_EXISTS: 'Secret Key já existe.',
|
|
9
|
+
WSA_SECRET_KEY_NOT_FOUND: 'Secret Key não encontrada.',
|
|
10
|
+
WSA_SECRET_VALUE_NOT_FOUND: 'Valor da Secret não encontrado.',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../../src/error/dictionary/secrets.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,EAAE,EAAE;QACF,6BAA6B,EAAE,4BAA4B;QAC3D,wBAAwB,EAAE,uBAAuB;QACjD,0BAA0B,EAAE,yBAAyB;KACtD;IACD,EAAE,EAAE;QACF,6BAA6B,EAAE,uBAAuB;QACtD,wBAAwB,EAAE,4BAA4B;QACtD,0BAA0B,EAAE,iCAAiC;KAC9D;CACmB,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { accountClient } from './client/account.js';
|
|
2
|
+
export { secretsClient } from './client/secrets.js';
|
|
3
|
+
export * from './client/types.js';
|
|
2
4
|
export { workspaceClient } from './client/workspace.js';
|
|
3
5
|
export { DefaultAPIError } from './error/DefaultAPIError.js';
|
|
4
6
|
export { StackspotAPIError } from './error/StackspotAPIError.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { accountClient } from './client/account.js';
|
|
2
|
+
export { secretsClient } from './client/secrets.js';
|
|
3
|
+
export * from './client/types.js';
|
|
2
4
|
export { workspaceClient } from './client/workspace.js';
|
|
3
5
|
export { DefaultAPIError } from './error/DefaultAPIError.js';
|
|
4
6
|
export { StackspotAPIError } from './error/StackspotAPIError.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/portal-network",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"typescript": "^5.2.2"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@oazapfts/runtime": "^1.0.3"
|
|
55
|
-
"lodash": "^4.17.21"
|
|
54
|
+
"@oazapfts/runtime": "^1.0.3"
|
|
56
55
|
}
|
|
57
56
|
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Secrets API
|
|
3
|
+
* v1.0.0
|
|
4
|
+
* DO NOT MODIFY - This file has been generated using oazapfts.
|
|
5
|
+
* See https://www.npmjs.com/package/oazapfts
|
|
6
|
+
*/
|
|
7
|
+
import * as Oazapfts from "@oazapfts/runtime";
|
|
8
|
+
import * as QS from "@oazapfts/runtime/query";
|
|
9
|
+
export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = {
|
|
10
|
+
headers: {},
|
|
11
|
+
baseUrl: "https://workspace-workspace-secrets-api.dev.stackspot.com",
|
|
12
|
+
};
|
|
13
|
+
const oazapfts = Oazapfts.runtime(defaults);
|
|
14
|
+
export const servers = {
|
|
15
|
+
generatedServerUrl: "https://workspace-workspace-secrets-api.dev.stackspot.com"
|
|
16
|
+
};
|
|
17
|
+
export type SecretValueResponse = {
|
|
18
|
+
key: string;
|
|
19
|
+
description: string;
|
|
20
|
+
value: string;
|
|
21
|
+
};
|
|
22
|
+
export type ValidationDetails = {
|
|
23
|
+
code: string;
|
|
24
|
+
field?: string;
|
|
25
|
+
details?: string;
|
|
26
|
+
values?: string[];
|
|
27
|
+
};
|
|
28
|
+
export type ErrorResponse = {
|
|
29
|
+
code: string;
|
|
30
|
+
status: number;
|
|
31
|
+
details: string;
|
|
32
|
+
validationDetails?: ValidationDetails[];
|
|
33
|
+
};
|
|
34
|
+
export type UpdateSecretValueRequest = {
|
|
35
|
+
value: string;
|
|
36
|
+
};
|
|
37
|
+
export type EditKeyRequest = {
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
export type SecretKeyResponse = {
|
|
41
|
+
key: string;
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
export type CreateKeyRequest = {
|
|
45
|
+
key: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
export type SecretAvailabilityResponse = {
|
|
49
|
+
definedKeys: string[];
|
|
50
|
+
undefinedKeys: string[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Get a Secret Key value.
|
|
54
|
+
*/
|
|
55
|
+
export function getSecretValue({ key, executionId }: {
|
|
56
|
+
key: string;
|
|
57
|
+
executionId?: string;
|
|
58
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
59
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
60
|
+
status: 200;
|
|
61
|
+
data: SecretValueResponse;
|
|
62
|
+
} | {
|
|
63
|
+
status: 400;
|
|
64
|
+
data: ErrorResponse;
|
|
65
|
+
} | {
|
|
66
|
+
status: 403;
|
|
67
|
+
data: ErrorResponse;
|
|
68
|
+
} | {
|
|
69
|
+
status: 422;
|
|
70
|
+
data: ErrorResponse;
|
|
71
|
+
} | {
|
|
72
|
+
status: 500;
|
|
73
|
+
data: ErrorResponse;
|
|
74
|
+
}>(`/v1/secrets/values/${encodeURIComponent(key)}${QS.query(QS.explode({
|
|
75
|
+
executionId
|
|
76
|
+
}))}`, {
|
|
77
|
+
...opts
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Edit a Secret Key value.
|
|
82
|
+
*/
|
|
83
|
+
export function updateSecretValue({ key, updateSecretValueRequest }: {
|
|
84
|
+
key: string;
|
|
85
|
+
updateSecretValueRequest: UpdateSecretValueRequest;
|
|
86
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
87
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
88
|
+
status: 204;
|
|
89
|
+
} | {
|
|
90
|
+
status: 400;
|
|
91
|
+
data: ErrorResponse;
|
|
92
|
+
} | {
|
|
93
|
+
status: 403;
|
|
94
|
+
data: ErrorResponse;
|
|
95
|
+
} | {
|
|
96
|
+
status: 422;
|
|
97
|
+
data: ErrorResponse;
|
|
98
|
+
} | {
|
|
99
|
+
status: 500;
|
|
100
|
+
data: ErrorResponse;
|
|
101
|
+
}>(`/v1/secrets/values/${encodeURIComponent(key)}`, oazapfts.json({
|
|
102
|
+
...opts,
|
|
103
|
+
method: "PUT",
|
|
104
|
+
body: updateSecretValueRequest
|
|
105
|
+
})));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Delete a Secret Key value.
|
|
109
|
+
*/
|
|
110
|
+
export function deleteSecretValue({ key }: {
|
|
111
|
+
key: string;
|
|
112
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
113
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
114
|
+
status: 204;
|
|
115
|
+
} | {
|
|
116
|
+
status: 400;
|
|
117
|
+
data: ErrorResponse;
|
|
118
|
+
} | {
|
|
119
|
+
status: 403;
|
|
120
|
+
data: ErrorResponse;
|
|
121
|
+
} | {
|
|
122
|
+
status: 422;
|
|
123
|
+
data: ErrorResponse;
|
|
124
|
+
} | {
|
|
125
|
+
status: 500;
|
|
126
|
+
data: ErrorResponse;
|
|
127
|
+
}>(`/v1/secrets/values/${encodeURIComponent(key)}`, {
|
|
128
|
+
...opts,
|
|
129
|
+
method: "DELETE"
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Edit a Secret Key.
|
|
134
|
+
*/
|
|
135
|
+
export function editKey({ key, editKeyRequest }: {
|
|
136
|
+
key: string;
|
|
137
|
+
editKeyRequest: EditKeyRequest;
|
|
138
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
139
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
140
|
+
status: 200;
|
|
141
|
+
} | {
|
|
142
|
+
status: 400;
|
|
143
|
+
data: ErrorResponse;
|
|
144
|
+
} | {
|
|
145
|
+
status: 403;
|
|
146
|
+
data: ErrorResponse;
|
|
147
|
+
} | {
|
|
148
|
+
status: 422;
|
|
149
|
+
data: ErrorResponse;
|
|
150
|
+
} | {
|
|
151
|
+
status: 500;
|
|
152
|
+
data: ErrorResponse;
|
|
153
|
+
}>(`/v1/secrets/keys/${encodeURIComponent(key)}`, oazapfts.json({
|
|
154
|
+
...opts,
|
|
155
|
+
method: "PUT",
|
|
156
|
+
body: editKeyRequest
|
|
157
|
+
})));
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Delete a Secret Key.
|
|
161
|
+
*/
|
|
162
|
+
export function deleteKey({ key }: {
|
|
163
|
+
key: string;
|
|
164
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
165
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
166
|
+
status: 204;
|
|
167
|
+
} | {
|
|
168
|
+
status: 400;
|
|
169
|
+
data: ErrorResponse;
|
|
170
|
+
} | {
|
|
171
|
+
status: 403;
|
|
172
|
+
data: ErrorResponse;
|
|
173
|
+
} | {
|
|
174
|
+
status: 422;
|
|
175
|
+
data: ErrorResponse;
|
|
176
|
+
} | {
|
|
177
|
+
status: 500;
|
|
178
|
+
data: ErrorResponse;
|
|
179
|
+
}>(`/v1/secrets/keys/${encodeURIComponent(key)}`, {
|
|
180
|
+
...opts,
|
|
181
|
+
method: "DELETE"
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* List all Secret Keys.
|
|
186
|
+
*/
|
|
187
|
+
export function getAll1(opts?: Oazapfts.RequestOpts) {
|
|
188
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
189
|
+
status: 200;
|
|
190
|
+
data: SecretKeyResponse[];
|
|
191
|
+
} | {
|
|
192
|
+
status: 400;
|
|
193
|
+
data: ErrorResponse;
|
|
194
|
+
} | {
|
|
195
|
+
status: 403;
|
|
196
|
+
data: ErrorResponse;
|
|
197
|
+
} | {
|
|
198
|
+
status: 422;
|
|
199
|
+
data: ErrorResponse;
|
|
200
|
+
} | {
|
|
201
|
+
status: 500;
|
|
202
|
+
data: ErrorResponse;
|
|
203
|
+
}>("/v1/secrets/keys", {
|
|
204
|
+
...opts
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Create a new Secret Key.
|
|
209
|
+
*/
|
|
210
|
+
export function createKey({ createKeyRequest }: {
|
|
211
|
+
createKeyRequest: CreateKeyRequest;
|
|
212
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
213
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
214
|
+
status: 201;
|
|
215
|
+
} | {
|
|
216
|
+
status: 400;
|
|
217
|
+
data: ErrorResponse;
|
|
218
|
+
} | {
|
|
219
|
+
status: 403;
|
|
220
|
+
data: ErrorResponse;
|
|
221
|
+
} | {
|
|
222
|
+
status: 422;
|
|
223
|
+
data: ErrorResponse;
|
|
224
|
+
} | {
|
|
225
|
+
status: 500;
|
|
226
|
+
data: ErrorResponse;
|
|
227
|
+
}>("/v1/secrets/keys", oazapfts.json({
|
|
228
|
+
...opts,
|
|
229
|
+
method: "POST",
|
|
230
|
+
body: createKeyRequest
|
|
231
|
+
})));
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* List all configured Secret Keys values.
|
|
235
|
+
*/
|
|
236
|
+
export function getAll({ executionId }: {
|
|
237
|
+
executionId?: string;
|
|
238
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
239
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
240
|
+
status: 200;
|
|
241
|
+
data: SecretValueResponse[];
|
|
242
|
+
} | {
|
|
243
|
+
status: 400;
|
|
244
|
+
data: ErrorResponse;
|
|
245
|
+
} | {
|
|
246
|
+
status: 403;
|
|
247
|
+
data: ErrorResponse;
|
|
248
|
+
} | {
|
|
249
|
+
status: 422;
|
|
250
|
+
data: ErrorResponse;
|
|
251
|
+
} | {
|
|
252
|
+
status: 500;
|
|
253
|
+
data: ErrorResponse;
|
|
254
|
+
}>(`/v1/secrets/values${QS.query(QS.explode({
|
|
255
|
+
executionId
|
|
256
|
+
}))}`, {
|
|
257
|
+
...opts
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* List all defined and not defined secret keys by the user.
|
|
262
|
+
*/
|
|
263
|
+
export function getAvailability(opts?: Oazapfts.RequestOpts) {
|
|
264
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
265
|
+
status: 200;
|
|
266
|
+
data: SecretAvailabilityResponse;
|
|
267
|
+
} | {
|
|
268
|
+
status: 400;
|
|
269
|
+
data: ErrorResponse;
|
|
270
|
+
} | {
|
|
271
|
+
status: 403;
|
|
272
|
+
data: ErrorResponse;
|
|
273
|
+
} | {
|
|
274
|
+
status: 500;
|
|
275
|
+
data: ErrorResponse;
|
|
276
|
+
}>("/v1/secrets/availability", {
|
|
277
|
+
...opts
|
|
278
|
+
}));
|
|
279
|
+
}
|
package/src/apis.json
CHANGED
|
@@ -117,5 +117,13 @@
|
|
|
117
117
|
"prd": "https://api-management-apigw.stackspot.com/api-management"
|
|
118
118
|
},
|
|
119
119
|
"docs": "/v3/api-docs"
|
|
120
|
+
},
|
|
121
|
+
"secrets": {
|
|
122
|
+
"url": {
|
|
123
|
+
"dev": "https://workspace-workspace-secrets-api.dev.stackspot.com",
|
|
124
|
+
"stg": "https://workspace-workspace-secrets-api.stg.stackspot.com",
|
|
125
|
+
"prd": "https://secrets-api.v1.stackspot.com"
|
|
126
|
+
},
|
|
127
|
+
"docs": "/v3/api-docs"
|
|
120
128
|
}
|
|
121
129
|
}
|
package/src/client/account.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpError } from '@oazapfts/runtime'
|
|
1
|
+
import { HttpError, RequestOpts } from '@oazapfts/runtime'
|
|
2
2
|
import {
|
|
3
3
|
accountDataIsAvailable,
|
|
4
4
|
addResourcesToGroup,
|
|
@@ -7,12 +7,14 @@ import {
|
|
|
7
7
|
bindRoleGroups,
|
|
8
8
|
bindRoles,
|
|
9
9
|
bindToGroups, bindToRoles, create, createAccountRole, createPartner,
|
|
10
|
+
createPersonalAccessToken,
|
|
10
11
|
createUser,
|
|
11
12
|
deactivateFidoCredentials,
|
|
12
13
|
defaults,
|
|
13
14
|
deleteAccountRole,
|
|
14
15
|
deleteMember,
|
|
15
|
-
deletePartner, deleteResourceFromGroup, deleteRole, deleteV1GroupsByGroupId,
|
|
16
|
+
deletePartner, deleteResourceFromGroup, deleteRole, deleteV1GroupsByGroupId, disablePersonalAccessTokenGeneration, enableFidoCredentials,
|
|
17
|
+
getAccountMembers1,
|
|
16
18
|
getAllMemberFidoCredentials, getFeatures,
|
|
17
19
|
getGroupById,
|
|
18
20
|
getGroupResources,
|
|
@@ -29,7 +31,13 @@ import {
|
|
|
29
31
|
getRoleGroups,
|
|
30
32
|
getRoleMembers,
|
|
31
33
|
getRoles,
|
|
32
|
-
getRoles1, getRoles2,
|
|
34
|
+
getRoles1, getRoles2,
|
|
35
|
+
getScmProvider,
|
|
36
|
+
isCreatedScmCredentials,
|
|
37
|
+
isCreatedScmCredentials1, listScmCredentials, listScmCredentials1, personalAccessTokenAuthorization, removeRoleFromMember,
|
|
38
|
+
resetPassword, save,
|
|
39
|
+
scmCredentialSave, scmCredentialSave1, scmCredentialUpdate, scmCredentialUpdate1, scmDelete, sendDownloadEmail, update1,
|
|
40
|
+
updateAccountRole,
|
|
33
41
|
updatePartnerAccountAdminData,
|
|
34
42
|
updatePartnerAccountData,
|
|
35
43
|
updateRoleWithNewActions,
|
|
@@ -42,6 +50,7 @@ import { DefaultAPIError } from '../error/DefaultAPIError'
|
|
|
42
50
|
import { accountDictionary } from '../error/dictionary/account'
|
|
43
51
|
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
44
52
|
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
53
|
+
import { CreateSCMRequest, SCMStatus, UpdateSCMRequest } from './types'
|
|
45
54
|
|
|
46
55
|
class AccountClient extends ReactQueryNetworkClient {
|
|
47
56
|
constructor() {
|
|
@@ -290,6 +299,102 @@ class AccountClient extends ReactQueryNetworkClient {
|
|
|
290
299
|
* Sends an email for downloading the CLI
|
|
291
300
|
*/
|
|
292
301
|
sendDownloadCLIEmail = this.mutation(sendDownloadEmail)
|
|
302
|
+
/**
|
|
303
|
+
* Creates an SCM credential (account level).
|
|
304
|
+
*/
|
|
305
|
+
createSCMCredential = this.mutation(scmCredentialSave1 as (variables: CreateSCMRequest, opts?: RequestOpts) => Promise<unknown>)
|
|
306
|
+
/**
|
|
307
|
+
* Updates an SCM credential (account level).
|
|
308
|
+
*/
|
|
309
|
+
updateSCMCredential = this.mutation(scmCredentialUpdate1 as (variables: UpdateSCMRequest, opts?: RequestOpts) => Promise<unknown>)
|
|
310
|
+
/**
|
|
311
|
+
* Gets all SCM credentials (account level).
|
|
312
|
+
*/
|
|
313
|
+
allSCMCredentials = this.query(listScmCredentials1)
|
|
314
|
+
/**
|
|
315
|
+
* Gets the status for the SCM credential.
|
|
316
|
+
*
|
|
317
|
+
* - If the SCM status is invalid because there's no configuration at the account level, it returns `{ status: 'missing-account' }`.
|
|
318
|
+
* - If the SCM status is invalid because, although the SCM integration is configured, the SCM access is not, it returns
|
|
319
|
+
* `{ status: 'missing-user' }`.
|
|
320
|
+
* - If the SCM status is valid, it returns `{ status: 'valid', mandate: boolean, hasUserConfiguration: boolean }`. `mandate` indicates
|
|
321
|
+
* if the SCM credential is mandatory at the account level for every user. `hasUserConfiguration` indicates if the user currently logged
|
|
322
|
+
* in has an SCM credential configured or not.
|
|
323
|
+
*/
|
|
324
|
+
scmCredentialStatus = this.query({
|
|
325
|
+
name: 'account.scmStatus',
|
|
326
|
+
request: async (signal): Promise<SCMStatus> => {
|
|
327
|
+
try {
|
|
328
|
+
const data = await isCreatedScmCredentials1({ signal })
|
|
329
|
+
return { status: 'valid', ...data }
|
|
330
|
+
} catch (error) {
|
|
331
|
+
if (error instanceof HttpError) {
|
|
332
|
+
// 404 means that the scm integration was not configured
|
|
333
|
+
if (error.status === 404) return { status: 'missing-account' }
|
|
334
|
+
// 422 means that the scm integration is configured, but the scm access is not
|
|
335
|
+
if (error.status === 422) return { status: 'missing-user' }
|
|
336
|
+
}
|
|
337
|
+
throw error
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
})
|
|
341
|
+
/**
|
|
342
|
+
* Enables Personal Access Token (PAT) generation.
|
|
343
|
+
*/
|
|
344
|
+
enablePATGeneration = this.mutation(createPersonalAccessToken)
|
|
345
|
+
/**
|
|
346
|
+
* Disables Personal Access Token (PAT) generation.
|
|
347
|
+
*/
|
|
348
|
+
disablePATGeneration = this.mutation(disablePersonalAccessTokenGeneration)
|
|
349
|
+
/**
|
|
350
|
+
* Verifies if Personal Access Token (PAT) generation is enabled.
|
|
351
|
+
*/
|
|
352
|
+
patGenerationEnabled = this.query({
|
|
353
|
+
name: 'account.patEnabled',
|
|
354
|
+
request: async (signal) => {
|
|
355
|
+
try {
|
|
356
|
+
await personalAccessTokenAuthorization({ signal })
|
|
357
|
+
return true
|
|
358
|
+
} catch (error) {
|
|
359
|
+
if (error instanceof HttpError && error.status === 404) return false
|
|
360
|
+
throw error
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
})
|
|
364
|
+
/**
|
|
365
|
+
* Verifies if the current user has an SCM credential configured.
|
|
366
|
+
*/
|
|
367
|
+
userHasSCMCredential = this.query({
|
|
368
|
+
name: 'account.userHasSCMCredential',
|
|
369
|
+
request: async (signal) => {
|
|
370
|
+
try {
|
|
371
|
+
await isCreatedScmCredentials({ signal })
|
|
372
|
+
return true
|
|
373
|
+
} catch {
|
|
374
|
+
return false
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
})
|
|
378
|
+
/**
|
|
379
|
+
* Creates an SCM credential for the user currently logged in.
|
|
380
|
+
*/
|
|
381
|
+
createUserSCMCredential = this.mutation(scmCredentialSave)
|
|
382
|
+
/**
|
|
383
|
+
* Updates an SCM credential for the user currently logged in.
|
|
384
|
+
*/
|
|
385
|
+
updateUserSCMCredential = this.mutation(scmCredentialUpdate)
|
|
386
|
+
/**
|
|
387
|
+
* Gets all SCM credentials for the user currently logged in.
|
|
388
|
+
*/
|
|
389
|
+
allUserSCMCredentials = this.query(listScmCredentials)
|
|
390
|
+
/**
|
|
391
|
+
* Gets the SCM provider.
|
|
392
|
+
*/
|
|
393
|
+
scmProvider = this.query(getScmProvider)
|
|
394
|
+
/**
|
|
395
|
+
* Deletes the SCM credentials for the user currently logged in.
|
|
396
|
+
*/
|
|
397
|
+
deleteSCMCredentials = this.mutation(scmDelete)
|
|
293
398
|
}
|
|
294
399
|
|
|
295
400
|
export const accountClient = new AccountClient()
|