@rockcarver/frodo-lib 0.12.2-2 → 0.12.2-5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockcarver/frodo-lib",
3
- "version": "0.12.2-2",
3
+ "version": "0.12.2-5",
4
4
  "type": "commonjs",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.mjs",
@@ -1,10 +1,73 @@
1
+ /**
2
+ * Get all secrets
3
+ * @returns {Promise<unknown[]>} a promise that resolves to an array of secrets
4
+ */
1
5
  export declare function getSecrets(): Promise<any>;
6
+ /**
7
+ * Get secret
8
+ * @param secretId secret id/name
9
+ * @returns {Promise<unknown>} a promise that resolves to a secret
10
+ */
2
11
  export declare function getSecret(secretId: any): Promise<any>;
12
+ /**
13
+ * Create secret
14
+ * @param {string} secretId secret id/name
15
+ * @param {string} value secret value
16
+ * @param {string} description secret description
17
+ * @param {string} encoding secret encoding (only `generic` is supported)
18
+ * @param {boolean} useInPlaceholders flag indicating if the secret can be used in placeholders
19
+ * @returns {Promise<unknown>} a promise that resolves to a secret
20
+ */
3
21
  export declare function putSecret(secretId: any, value: any, description: any, encoding?: string, useInPlaceholders?: boolean): Promise<any>;
22
+ /**
23
+ * Set secret description
24
+ * @param {string} secretId secret id/name
25
+ * @param {string} description secret description
26
+ * @returns {Promise<unknown>} a promise that resolves to a status object
27
+ */
4
28
  export declare function setSecretDescription(secretId: any, description: any): Promise<any>;
29
+ /**
30
+ * Delete secret
31
+ * @param {string} secretId secret id/name
32
+ * @returns {Promise<unknown>} a promise that resolves to a secret object
33
+ */
5
34
  export declare function deleteSecret(secretId: any): Promise<any>;
35
+ /**
36
+ * Get secret versions
37
+ * @param {string} secretId secret id/name
38
+ * @returns {Promise<unknown>} a promise that resolves to an array of secret versions
39
+ */
6
40
  export declare function getSecretVersions(secretId: any): Promise<any>;
41
+ /**
42
+ * Create new secret version
43
+ * @param {string} secretId secret id/name
44
+ * @param {string} value secret value
45
+ * @returns {Promise<unknown>} a promise that resolves to a version object
46
+ */
7
47
  export declare function createNewVersionOfSecret(secretId: any, value: any): Promise<any>;
48
+ /**
49
+ * Get version of secret
50
+ * @param {string} secretId secret id/name
51
+ * @param {string} version secret version
52
+ * @returns {Promise<unknown>} a promise that resolves to a version object
53
+ */
8
54
  export declare function getVersionOfSecret(secretId: any, version: any): Promise<any>;
9
- export declare function setStatusOfVersionOfSecret(secretId: any, version: any, status: any): Promise<any>;
55
+ export declare enum VersionOfSecretStatus {
56
+ DISABLED = "DISABLED",
57
+ ENABLED = "ENABLED"
58
+ }
59
+ /**
60
+ * Update the status of a version of a secret
61
+ * @param {string} secretId secret id/name
62
+ * @param {string} version secret version
63
+ * @param {VersionOfSecretStatus} status status
64
+ * @returns {Promise<unknown>} a promise that resolves to a status object
65
+ */
66
+ export declare function setStatusOfVersionOfSecret(secretId: string, version: string, status: VersionOfSecretStatus): Promise<any>;
67
+ /**
68
+ * Delete version of secret
69
+ * @param {string} secretId secret id/name
70
+ * @param {string} version secret version
71
+ * @returns {Promise<unknown>} a promise that resolves to a version object
72
+ */
10
73
  export declare function deleteVersionOfSecret(secretId: any, version: any): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/SecretsApi.ts"],"names":[],"mappings":"AAoBA,wBAAsB,UAAU,iBAS/B;AAED,wBAAsB,SAAS,CAAC,QAAQ,KAAA,gBAUvC;AAED,wBAAsB,SAAS,CAC7B,QAAQ,KAAA,EACR,KAAK,KAAA,EACL,WAAW,KAAA,EACX,QAAQ,SAAY,EACpB,iBAAiB,UAAO,gBAuBzB;AAED,wBAAsB,oBAAoB,CAAC,QAAQ,KAAA,EAAE,WAAW,KAAA,gBAY/D;AAED,wBAAsB,YAAY,CAAC,QAAQ,KAAA,gBAU1C;AAED,wBAAsB,iBAAiB,CAAC,QAAQ,KAAA,gBAU/C;AAED,wBAAsB,wBAAwB,CAAC,QAAQ,KAAA,EAAE,KAAK,KAAA,gBAY7D;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,gBAWzD;AAED,wBAAsB,0BAA0B,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,EAAE,MAAM,KAAA,gBAazE;AAED,wBAAsB,qBAAqB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,gBAW5D","file":"SecretsApi.d.ts","sourcesContent":["import util from 'util';\nimport { encode } from './utils/Base64';\nimport { getTenantURL } from './utils/ApiUtils';\nimport { generateESVApi } from './BaseApi';\nimport storage from '../storage/SessionStorage';\n\nconst secretsListURLTemplate = '%s/environment/secrets';\nconst secretListVersionsURLTemplate = '%s/environment/secrets/%s/versions';\nconst secretCreateNewVersionURLTemplate = `${secretListVersionsURLTemplate}?_action=create`;\nconst secretGetVersionURLTemplate = `${secretListVersionsURLTemplate}/%s`;\nconst secretVersionStatusURLTemplate = `${secretGetVersionURLTemplate}?_action=changestatus`;\nconst secretURLTemplate = '%s/environment/secrets/%s';\nconst secretSetDescriptionURLTemplate = `${secretURLTemplate}?_action=setDescription`;\n\nconst apiVersion = 'protocol=1.0,resource=1.0';\nconst getApiConfig = () => ({\n path: `/environment/secrets`,\n apiVersion,\n});\n\nexport async function getSecrets() {\n const urlString = util.format(\n secretsListURLTemplate,\n getTenantURL(storage.session.getTenant())\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data.result;\n}\n\nexport async function getSecret(secretId) {\n const urlString = util.format(\n secretURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\nexport async function putSecret(\n secretId,\n value,\n description,\n encoding = 'generic',\n useInPlaceholders = true\n) {\n if (encoding !== 'generic')\n throw new Error(`Unsupported encoding: ${encoding}`);\n const secretData = {\n valueBase64: encode(value),\n description,\n encoding,\n useInPlaceholders,\n };\n const urlString = util.format(\n secretURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).put(\n urlString,\n secretData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\nexport async function setSecretDescription(secretId, description) {\n const urlString = util.format(\n secretSetDescriptionURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).post(\n urlString,\n { description },\n { withCredentials: true }\n );\n return data;\n}\n\nexport async function deleteSecret(secretId) {\n const urlString = util.format(\n secretURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).delete(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\nexport async function getSecretVersions(secretId) {\n const urlString = util.format(\n secretListVersionsURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\nexport async function createNewVersionOfSecret(secretId, value) {\n const urlString = util.format(\n secretCreateNewVersionURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).post(\n urlString,\n { valueBase64: encode(value) },\n { withCredentials: true }\n );\n return data;\n}\n\nexport async function getVersionOfSecret(secretId, version) {\n const urlString = util.format(\n secretGetVersionURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId,\n version\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\nexport async function setStatusOfVersionOfSecret(secretId, version, status) {\n const urlString = util.format(\n secretVersionStatusURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId,\n version\n );\n const { data } = await generateESVApi(getApiConfig()).post(\n urlString,\n { status },\n { withCredentials: true }\n );\n return data;\n}\n\nexport async function deleteVersionOfSecret(secretId, version) {\n const urlString = util.format(\n secretGetVersionURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId,\n version\n );\n const { data } = await generateESVApi(getApiConfig()).delete(urlString, {\n withCredentials: true,\n });\n return data;\n}\n"]}
1
+ {"version":3,"sources":["../src/api/SecretsApi.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,wBAAsB,UAAU,iBAS/B;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,QAAQ,KAAA,gBAUvC;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,KAAA,EACR,KAAK,KAAA,EACL,WAAW,KAAA,EACX,QAAQ,SAAY,EACpB,iBAAiB,UAAO,gBAuBzB;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,KAAA,EAAE,WAAW,KAAA,gBAY/D;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,QAAQ,KAAA,gBAU1C;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,KAAA,gBAU/C;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,QAAQ,KAAA,EAAE,KAAK,KAAA,gBAY7D;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,gBAWzD;AAED,oBAAY,qBAAqB;IAC/B,QAAQ,aAAa;IACrB,OAAO,YAAY;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,qBAAqB,gBAc9B;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,gBAW5D","file":"SecretsApi.d.ts","sourcesContent":["import util from 'util';\nimport { encode } from './utils/Base64';\nimport { getTenantURL } from './utils/ApiUtils';\nimport { generateESVApi } from './BaseApi';\nimport storage from '../storage/SessionStorage';\n\nconst secretsListURLTemplate = '%s/environment/secrets';\nconst secretListVersionsURLTemplate = '%s/environment/secrets/%s/versions';\nconst secretCreateNewVersionURLTemplate = `${secretListVersionsURLTemplate}?_action=create`;\nconst secretGetVersionURLTemplate = `${secretListVersionsURLTemplate}/%s`;\nconst secretVersionStatusURLTemplate = `${secretGetVersionURLTemplate}?_action=changestatus`;\nconst secretURLTemplate = '%s/environment/secrets/%s';\nconst secretSetDescriptionURLTemplate = `${secretURLTemplate}?_action=setDescription`;\n\nconst apiVersion = 'protocol=1.0,resource=1.0';\nconst getApiConfig = () => ({\n path: `/environment/secrets`,\n apiVersion,\n});\n\n/**\n * Get all secrets\n * @returns {Promise<unknown[]>} a promise that resolves to an array of secrets\n */\nexport async function getSecrets() {\n const urlString = util.format(\n secretsListURLTemplate,\n getTenantURL(storage.session.getTenant())\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get secret\n * @param secretId secret id/name\n * @returns {Promise<unknown>} a promise that resolves to a secret\n */\nexport async function getSecret(secretId) {\n const urlString = util.format(\n secretURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Create secret\n * @param {string} secretId secret id/name\n * @param {string} value secret value\n * @param {string} description secret description\n * @param {string} encoding secret encoding (only `generic` is supported)\n * @param {boolean} useInPlaceholders flag indicating if the secret can be used in placeholders\n * @returns {Promise<unknown>} a promise that resolves to a secret\n */\nexport async function putSecret(\n secretId,\n value,\n description,\n encoding = 'generic',\n useInPlaceholders = true\n) {\n if (encoding !== 'generic')\n throw new Error(`Unsupported encoding: ${encoding}`);\n const secretData = {\n valueBase64: encode(value),\n description,\n encoding,\n useInPlaceholders,\n };\n const urlString = util.format(\n secretURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).put(\n urlString,\n secretData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Set secret description\n * @param {string} secretId secret id/name\n * @param {string} description secret description\n * @returns {Promise<unknown>} a promise that resolves to a status object\n */\nexport async function setSecretDescription(secretId, description) {\n const urlString = util.format(\n secretSetDescriptionURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).post(\n urlString,\n { description },\n { withCredentials: true }\n );\n return data;\n}\n\n/**\n * Delete secret\n * @param {string} secretId secret id/name\n * @returns {Promise<unknown>} a promise that resolves to a secret object\n */\nexport async function deleteSecret(secretId) {\n const urlString = util.format(\n secretURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).delete(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get secret versions\n * @param {string} secretId secret id/name\n * @returns {Promise<unknown>} a promise that resolves to an array of secret versions\n */\nexport async function getSecretVersions(secretId) {\n const urlString = util.format(\n secretListVersionsURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Create new secret version\n * @param {string} secretId secret id/name\n * @param {string} value secret value\n * @returns {Promise<unknown>} a promise that resolves to a version object\n */\nexport async function createNewVersionOfSecret(secretId, value) {\n const urlString = util.format(\n secretCreateNewVersionURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId\n );\n const { data } = await generateESVApi(getApiConfig()).post(\n urlString,\n { valueBase64: encode(value) },\n { withCredentials: true }\n );\n return data;\n}\n\n/**\n * Get version of secret\n * @param {string} secretId secret id/name\n * @param {string} version secret version\n * @returns {Promise<unknown>} a promise that resolves to a version object\n */\nexport async function getVersionOfSecret(secretId, version) {\n const urlString = util.format(\n secretGetVersionURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId,\n version\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\nexport enum VersionOfSecretStatus {\n DISABLED = 'DISABLED',\n ENABLED = 'ENABLED',\n}\n\n/**\n * Update the status of a version of a secret\n * @param {string} secretId secret id/name\n * @param {string} version secret version\n * @param {VersionOfSecretStatus} status status\n * @returns {Promise<unknown>} a promise that resolves to a status object\n */\nexport async function setStatusOfVersionOfSecret(\n secretId: string,\n version: string,\n status: VersionOfSecretStatus\n) {\n const urlString = util.format(\n secretVersionStatusURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId,\n version\n );\n const { data } = await generateESVApi(getApiConfig()).post(\n urlString,\n { status },\n { withCredentials: true }\n );\n return data;\n}\n\n/**\n * Delete version of secret\n * @param {string} secretId secret id/name\n * @param {string} version secret version\n * @returns {Promise<unknown>} a promise that resolves to a version object\n */\nexport async function deleteVersionOfSecret(secretId, version) {\n const urlString = util.format(\n secretGetVersionURLTemplate,\n getTenantURL(storage.session.getTenant()),\n secretId,\n version\n );\n const { data } = await generateESVApi(getApiConfig()).delete(urlString, {\n withCredentials: true,\n });\n return data;\n}\n"]}
@@ -1,32 +1,32 @@
1
1
  /**
2
2
  * Get all variables
3
- * @returns {Promise} a promise that resolves to an object containing an array of variable objects
3
+ * @returns {Promise<unknown[]>} a promise that resolves to an array of variable objects
4
4
  */
5
5
  export declare function getVariables(): Promise<any>;
6
6
  /**
7
7
  * Get variable by id/name
8
- * @param {String} variableId variable id/name
9
- * @returns {Promise} a promise that resolves to an object containing a variable object
8
+ * @param {string} variableId variable id/name
9
+ * @returns {Promise<unknown>} a promise that resolves to a variable object
10
10
  */
11
11
  export declare function getVariable(variableId: any): Promise<any>;
12
12
  /**
13
13
  * Put variable by id/name
14
- * @param {String} variableId variable id/name
15
- * @param {String} value variable value
16
- * @param {String} description variable description
17
- * @returns {Promise} a promise that resolves to an object containing a variable object
14
+ * @param {string} variableId variable id/name
15
+ * @param {string} value variable value
16
+ * @param {string} description variable description
17
+ * @returns {Promise<unknown>} a promise that resolves to a variable object
18
18
  */
19
19
  export declare function putVariable(variableId: any, value: any, description: any): Promise<any>;
20
20
  /**
21
21
  * Set variable description
22
- * @param {*} variableId variable id/name
23
- * @param {*} description variable description
24
- * @returns {Promise} a promise that resolves to an object containing a status object
22
+ * @param {string} variableId variable id/name
23
+ * @param {string} description variable description
24
+ * @returns {Promise<unknown>} a promise that resolves to a status object
25
25
  */
26
26
  export declare function setVariableDescription(variableId: any, description: any): Promise<any>;
27
27
  /**
28
28
  * Delete variable by id/name
29
- * @param {String} variableId variable id/name
30
- * @returns {Promise} a promise that resolves to an object containing a variable object
29
+ * @param {string} variableId variable id/name
30
+ * @returns {Promise<unknown>} a promise that resolves to a variable object
31
31
  */
32
32
  export declare function deleteVariable(variableId: any): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/VariablesApi.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,wBAAsB,YAAY,iBASjC;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,UAAU,KAAA,gBAU3C;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,UAAU,KAAA,EAAE,KAAK,KAAA,EAAE,WAAW,KAAA,gBAiB/D;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,UAAU,KAAA,EAAE,WAAW,KAAA,gBAYnE;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,UAAU,KAAA,gBAU9C","file":"VariablesApi.d.ts","sourcesContent":["import util from 'util';\nimport { encode } from './utils/Base64';\nimport { getTenantURL, getCurrentRealmPath } from './utils/ApiUtils';\nimport { generateESVApi } from './BaseApi';\nimport storage from '../storage/SessionStorage';\n\nconst variablesListURLTemplate = '%s/environment/variables';\nconst variableURLTemplate = '%s/environment/variables/%s';\nconst variableSetDescriptionURLTemplate = `${variableURLTemplate}?_action=setDescription`;\n\nconst apiVersion = 'protocol=1.0,resource=1.0';\nconst getApiConfig = () => {\n const configPath = getCurrentRealmPath();\n return {\n path: `${configPath}/environment/secrets`,\n apiVersion,\n };\n};\n\n/**\n * Get all variables\n * @returns {Promise} a promise that resolves to an object containing an array of variable objects\n */\nexport async function getVariables() {\n const urlString = util.format(\n variablesListURLTemplate,\n getTenantURL(storage.session.getTenant())\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data.result;\n}\n\n/**\n * Get variable by id/name\n * @param {String} variableId variable id/name\n * @returns {Promise} a promise that resolves to an object containing a variable object\n */\nexport async function getVariable(variableId) {\n const urlString = util.format(\n variableURLTemplate,\n getTenantURL(storage.session.getTenant()),\n variableId\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Put variable by id/name\n * @param {String} variableId variable id/name\n * @param {String} value variable value\n * @param {String} description variable description\n * @returns {Promise} a promise that resolves to an object containing a variable object\n */\nexport async function putVariable(variableId, value, description) {\n const variableData = {};\n if (value) variableData['valueBase64'] = encode(value);\n if (description) variableData['description'] = description;\n const urlString = util.format(\n variableURLTemplate,\n getTenantURL(storage.session.getTenant()),\n variableId\n );\n const { data } = await generateESVApi(getApiConfig()).put(\n urlString,\n variableData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Set variable description\n * @param {*} variableId variable id/name\n * @param {*} description variable description\n * @returns {Promise} a promise that resolves to an object containing a status object\n */\nexport async function setVariableDescription(variableId, description) {\n const urlString = util.format(\n variableSetDescriptionURLTemplate,\n getTenantURL(storage.session.getTenant()),\n variableId\n );\n const { data } = await generateESVApi(getApiConfig()).post(\n urlString,\n { description },\n { withCredentials: true }\n );\n return data;\n}\n\n/**\n * Delete variable by id/name\n * @param {String} variableId variable id/name\n * @returns {Promise} a promise that resolves to an object containing a variable object\n */\nexport async function deleteVariable(variableId) {\n const urlString = util.format(\n variableURLTemplate,\n getTenantURL(storage.session.getTenant()),\n variableId\n );\n const { data } = await generateESVApi(getApiConfig()).delete(urlString, {\n withCredentials: true,\n });\n return data;\n}\n"]}
1
+ {"version":3,"sources":["../src/api/VariablesApi.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,wBAAsB,YAAY,iBASjC;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,UAAU,KAAA,gBAU3C;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,UAAU,KAAA,EAAE,KAAK,KAAA,EAAE,WAAW,KAAA,gBAiB/D;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,UAAU,KAAA,EAAE,WAAW,KAAA,gBAYnE;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,UAAU,KAAA,gBAU9C","file":"VariablesApi.d.ts","sourcesContent":["import util from 'util';\nimport { encode } from './utils/Base64';\nimport { getTenantURL, getCurrentRealmPath } from './utils/ApiUtils';\nimport { generateESVApi } from './BaseApi';\nimport storage from '../storage/SessionStorage';\n\nconst variablesListURLTemplate = '%s/environment/variables';\nconst variableURLTemplate = '%s/environment/variables/%s';\nconst variableSetDescriptionURLTemplate = `${variableURLTemplate}?_action=setDescription`;\n\nconst apiVersion = 'protocol=1.0,resource=1.0';\nconst getApiConfig = () => {\n const configPath = getCurrentRealmPath();\n return {\n path: `${configPath}/environment/secrets`,\n apiVersion,\n };\n};\n\n/**\n * Get all variables\n * @returns {Promise<unknown[]>} a promise that resolves to an array of variable objects\n */\nexport async function getVariables() {\n const urlString = util.format(\n variablesListURLTemplate,\n getTenantURL(storage.session.getTenant())\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get variable by id/name\n * @param {string} variableId variable id/name\n * @returns {Promise<unknown>} a promise that resolves to a variable object\n */\nexport async function getVariable(variableId) {\n const urlString = util.format(\n variableURLTemplate,\n getTenantURL(storage.session.getTenant()),\n variableId\n );\n const { data } = await generateESVApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Put variable by id/name\n * @param {string} variableId variable id/name\n * @param {string} value variable value\n * @param {string} description variable description\n * @returns {Promise<unknown>} a promise that resolves to a variable object\n */\nexport async function putVariable(variableId, value, description) {\n const variableData = {};\n if (value) variableData['valueBase64'] = encode(value);\n if (description) variableData['description'] = description;\n const urlString = util.format(\n variableURLTemplate,\n getTenantURL(storage.session.getTenant()),\n variableId\n );\n const { data } = await generateESVApi(getApiConfig()).put(\n urlString,\n variableData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Set variable description\n * @param {string} variableId variable id/name\n * @param {string} description variable description\n * @returns {Promise<unknown>} a promise that resolves to a status object\n */\nexport async function setVariableDescription(variableId, description) {\n const urlString = util.format(\n variableSetDescriptionURLTemplate,\n getTenantURL(storage.session.getTenant()),\n variableId\n );\n const { data } = await generateESVApi(getApiConfig()).post(\n urlString,\n { description },\n { withCredentials: true }\n );\n return data;\n}\n\n/**\n * Delete variable by id/name\n * @param {string} variableId variable id/name\n * @returns {Promise<unknown>} a promise that resolves to a variable object\n */\nexport async function deleteVariable(variableId) {\n const urlString = util.format(\n variableURLTemplate,\n getTenantURL(storage.session.getTenant()),\n variableId\n );\n const { data } = await generateESVApi(getApiConfig()).delete(urlString, {\n withCredentials: true,\n });\n return data;\n}\n"]}
package/types/index.d.ts CHANGED
@@ -2,6 +2,8 @@ export declare function getVersion(): string;
2
2
  export * as NodeRaw from './api/NodeApi';
3
3
  export * as TreeRaw from './api/TreeApi';
4
4
  export * as StartupRaw from './api/StartupApi';
5
+ export * as SecretsRaw from './api/SecretsApi';
6
+ export * as VariablesRaw from './api/VariablesApi';
5
7
  export * as Admin from './ops/AdminOps';
6
8
  export * as Authenticate from './ops/AuthenticateOps';
7
9
  export * as CirclesOfTrust from './ops/CirclesOfTrustOps';
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAUA,wBAAgB,UAAU,WAEzB;AAGD,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAG/C,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,iBAAiB,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAG9C,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAIlD,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC","file":"index.d.ts","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')\n);\n\nexport function getVersion() {\n return `v${pkg.version}`;\n}\n\n// Api Layer\nexport * as NodeRaw from './api/NodeApi';\nexport * as TreeRaw from './api/TreeApi';\nexport * as StartupRaw from './api/StartupApi';\n\n// Ops Layer\nexport * as Admin from './ops/AdminOps';\nexport * as Authenticate from './ops/AuthenticateOps';\nexport * as CirclesOfTrust from './ops/CirclesOfTrustOps';\nexport * as ConnectionProfile from './ops/ConnectionProfileOps';\nexport * as EmailTemplate from './ops/EmailTemplateOps';\nexport * as Idm from './ops/IdmOps';\nexport * as Idp from './ops/IdmOps';\nexport * as Journey from './ops/JourneyOps';\nexport * as Log from './ops/LogOps';\nexport * as ManagedObject from './ops/ManagedObjectOps';\nexport * as OAuth2Client from './ops/OAuth2ClientOps';\nexport * as Organization from './ops/OrganizationOps';\nexport * as Realm from './ops/RealmOps';\nexport * as Saml from './ops/SamlOps';\nexport * as Script from './ops/ScriptOps';\nexport * as Secrets from './ops/SecretsOps';\nexport * as Startup from './ops/StartupOps';\nexport * as Theme from './ops/ThemeOps';\nexport * as Variables from './ops/VariablesOps';\n// TODO: revisit if there are better ways\nexport * as Utils from './ops/utils/OpsUtils';\n// TODO: reconsider the aproach to pass in state from client\n// lib should be stateless, an aplication should own its state\nexport * as state from './storage/SessionStorage';\n// TODO: need to figure out if this is the right approach or if we should even\n// use a public oauth2/oidc library. might be ok for now since there is only\n// one place where the cli needs to execute an oauth flow.\nexport * as OAuth2OIDCApi from './api/OAuth2OIDCApi';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAUA,wBAAgB,UAAU,WAEzB;AAGD,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AAGnD,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,iBAAiB,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAG9C,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAIlD,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC","file":"index.d.ts","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')\n);\n\nexport function getVersion() {\n return `v${pkg.version}`;\n}\n\n// Api Layer\nexport * as NodeRaw from './api/NodeApi';\nexport * as TreeRaw from './api/TreeApi';\nexport * as StartupRaw from './api/StartupApi';\nexport * as SecretsRaw from './api/SecretsApi';\nexport * as VariablesRaw from './api/VariablesApi';\n\n// Ops Layer\nexport * as Admin from './ops/AdminOps';\nexport * as Authenticate from './ops/AuthenticateOps';\nexport * as CirclesOfTrust from './ops/CirclesOfTrustOps';\nexport * as ConnectionProfile from './ops/ConnectionProfileOps';\nexport * as EmailTemplate from './ops/EmailTemplateOps';\nexport * as Idm from './ops/IdmOps';\nexport * as Idp from './ops/IdmOps';\nexport * as Journey from './ops/JourneyOps';\nexport * as Log from './ops/LogOps';\nexport * as ManagedObject from './ops/ManagedObjectOps';\nexport * as OAuth2Client from './ops/OAuth2ClientOps';\nexport * as Organization from './ops/OrganizationOps';\nexport * as Realm from './ops/RealmOps';\nexport * as Saml from './ops/SamlOps';\nexport * as Script from './ops/ScriptOps';\nexport * as Secrets from './ops/SecretsOps';\nexport * as Startup from './ops/StartupOps';\nexport * as Theme from './ops/ThemeOps';\nexport * as Variables from './ops/VariablesOps';\n// TODO: revisit if there are better ways\nexport * as Utils from './ops/utils/OpsUtils';\n// TODO: reconsider the aproach to pass in state from client\n// lib should be stateless, an aplication should own its state\nexport * as state from './storage/SessionStorage';\n// TODO: need to figure out if this is the right approach or if we should even\n// use a public oauth2/oidc library. might be ok for now since there is only\n// one place where the cli needs to execute an oauth flow.\nexport * as OAuth2OIDCApi from './api/OAuth2OIDCApi';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ops/SecretsOps.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AACH,wBAAsB,WAAW,CAAC,IAAI,KAAA,iBAqCrC;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,EAAE,KAAA,EACF,KAAK,KAAA,EACL,WAAW,KAAA,EACX,QAAQ,KAAA,EACR,iBAAiB,KAAA,iBAgBlB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,QAAQ,KAAA,EAAE,WAAW,KAAA,iBAejE;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,QAAQ,KAAA,iBAe7C;AAED;;GAEG;AACH,wBAAsB,gBAAgB,kBAuBrC;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,KAAA,iBA6BnD;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,QAAQ,KAAA,iBAyB5C;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,QAAQ,KAAA,EAAE,KAAK,KAAA,iBAkBhE;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,iBAkB9D;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,iBAkBhE;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,iBAkB/D","file":"SecretsOps.d.ts","sourcesContent":["import {\n createKeyValueTable,\n createProgressIndicator,\n createTable,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport {\n createNewVersionOfSecret,\n deleteSecret,\n deleteVersionOfSecret,\n getSecret,\n getSecrets,\n getSecretVersions,\n putSecret,\n setSecretDescription,\n setStatusOfVersionOfSecret,\n} from '../api/SecretsApi';\nimport wordwrap from './utils/Wordwrap';\nimport { resolveUserName } from './ManagedObjectOps';\n\n/**\n * List secrets\n * @param {boolean} long Long version, all the fields\n */\nexport async function listSecrets(long) {\n let secrets = [];\n try {\n secrets = await getSecrets();\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.data, 'error');\n }\n if (long) {\n const table = createTable([\n 'Id'['brightCyan'],\n { hAlign: 'right', content: 'Active\\nVersion'['brightCyan'] },\n { hAlign: 'right', content: 'Loaded\\nVersion'['brightCyan'] },\n 'Status'['brightCyan'],\n 'Description'['brightCyan'],\n 'Modifier'['brightCyan'],\n 'Modified'['brightCyan'],\n ]);\n secrets.sort((a, b) => a._id.localeCompare(b._id));\n for (const secret of secrets) {\n table.push([\n secret._id,\n { hAlign: 'right', content: secret.activeVersion },\n { hAlign: 'right', content: secret.loadedVersion },\n secret.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'],\n wordwrap(secret.description, 40),\n // eslint-disable-next-line no-await-in-loop\n await resolveUserName('teammember', secret.lastChangedBy),\n new Date(secret.lastChangeDate).toLocaleString(),\n ]);\n }\n printMessage(table.toString());\n } else {\n secrets.forEach((secret) => {\n printMessage(secret._id);\n });\n }\n}\n\n/**\n * Create secret\n * @param {String} id secret id\n * @param {String} value secret value\n * @param {String} description secret description\n * @param {String} encoding secret encoding\n * @param {boolean} useInPlaceholders use secret in placeholders\n */\nexport async function createSecret(\n id,\n value,\n description,\n encoding,\n useInPlaceholders\n) {\n createProgressIndicator(\n undefined,\n `Creating secret ${id}...`,\n 'indeterminate'\n );\n try {\n await putSecret(id, value, description, encoding, useInPlaceholders);\n stopProgressIndicator(`Created secret ${id}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Set description of secret\n * @param {String} secretId secret id\n * @param {String} description secret description\n */\nexport async function setDescriptionOfSecret(secretId, description) {\n createProgressIndicator(\n undefined,\n `Setting description of secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n await setSecretDescription(secretId, description);\n stopProgressIndicator(`Set description of secret ${secretId}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Delete a secret\n * @param {String} secretId secret id\n */\nexport async function deleteSecretCmd(secretId) {\n createProgressIndicator(\n undefined,\n `Deleting secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n await deleteSecret(secretId);\n stopProgressIndicator(`Deleted secret ${secretId}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Delete all secrets\n */\nexport async function deleteSecretsCmd() {\n try {\n const secrets = await getSecrets();\n createProgressIndicator(secrets.length, `Deleting secrets...`);\n for (const secret of secrets) {\n try {\n // eslint-disable-next-line no-await-in-loop\n await deleteSecret(secret._id);\n updateProgressIndicator(`Deleted secret ${secret._id}`);\n } catch (error) {\n printMessage(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'error'\n );\n }\n }\n stopProgressIndicator(`Secrets deleted.`);\n } catch (error) {\n printMessage(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all the versions of the secret\n * @param {String} secretId secret id\n */\nexport async function listSecretVersionsCmd(secretId) {\n let versions = [];\n try {\n versions = await getSecretVersions(secretId);\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.data, 'error');\n }\n const table = createTable([\n { hAlign: 'right', content: 'Version'['brightCyan'] },\n 'Status'['brightCyan'],\n 'Loaded'['brightCyan'],\n 'Created'['brightCyan'],\n ]);\n // versions.sort((a, b) => a._id.localeCompare(b._id));\n const statusMap = {\n ENABLED: 'active'['brightGreen'],\n DISABLED: 'inactive'['brightRed'],\n DESTROYED: 'deleted'['brightRed'],\n };\n for (const version of versions) {\n table.push([\n { hAlign: 'right', content: version.version },\n statusMap[version.status],\n version.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'],\n new Date(version.createDate).toLocaleString(),\n ]);\n }\n printMessage(table.toString());\n}\n\n/**\n * Describe a secret\n * @param {String} secretId Secret id\n */\nexport async function describeSecret(secretId) {\n const secret = await getSecret(secretId);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], secret._id]);\n table.push(['Active Version'['brightCyan'], secret.activeVersion]);\n table.push(['Loaded Version'['brightCyan'], secret.loadedVersion]);\n table.push([\n 'Status'['brightCyan'],\n secret.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'],\n ]);\n table.push(['Description'['brightCyan'], wordwrap(secret.description, 60)]);\n table.push([\n 'Modified'['brightCyan'],\n new Date(secret.lastChangeDate).toLocaleString(),\n ]);\n table.push([\n 'Modifier'['brightCyan'],\n await resolveUserName('teammember', secret.lastChangedBy),\n ]);\n table.push(['Modifier UUID'['brightCyan'], secret.lastChangedBy]);\n table.push(['Encoding'['brightCyan'], secret.encoding]);\n table.push(['Use In Placeholders'['brightCyan'], secret.useInPlaceholders]);\n printMessage(table.toString());\n printMessage('\\nSecret Versions:');\n await listSecretVersionsCmd(secretId);\n}\n\n/**\n * Create new version of secret\n * @param {String} secretId secret id\n * @param {String} value secret value\n */\nexport async function createNewVersionOfSecretCmd(secretId, value) {\n createProgressIndicator(\n undefined,\n `Creating new version of secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n const version = await createNewVersionOfSecret(secretId, value);\n stopProgressIndicator(\n `Created version ${version.version} of secret ${secretId}`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Activate a version of a secret\n * @param {String} secretId secret id\n * @param {Number} version version of secret\n */\nexport async function activateVersionOfSecret(secretId, version) {\n createProgressIndicator(\n undefined,\n `Activating version ${version} of secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n await setStatusOfVersionOfSecret(secretId, version, 'ENABLED');\n stopProgressIndicator(\n `Activated version ${version} of secret ${secretId}`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Deactivate a version of a secret\n * @param {String} secretId secret id\n * @param {Number} version version of secret\n */\nexport async function deactivateVersionOfSecret(secretId, version) {\n createProgressIndicator(\n undefined,\n `Deactivating version ${version} of secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n await setStatusOfVersionOfSecret(secretId, version, 'DISABLED');\n stopProgressIndicator(\n `Deactivated version ${version} of secret ${secretId}`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Delete version of secret\n * @param {String} secretId secret id\n * @param {Number} version version of secret\n */\nexport async function deleteVersionOfSecretCmd(secretId, version) {\n createProgressIndicator(\n undefined,\n `Deleting version ${version} of secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n await deleteVersionOfSecret(secretId, version);\n stopProgressIndicator(\n `Deleted version ${version} of secret ${secretId}`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/ops/SecretsOps.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,wBAAsB,WAAW,CAAC,IAAI,KAAA,iBAqCrC;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,EAAE,KAAA,EACF,KAAK,KAAA,EACL,WAAW,KAAA,EACX,QAAQ,KAAA,EACR,iBAAiB,KAAA,iBAgBlB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,QAAQ,KAAA,EAAE,WAAW,KAAA,iBAejE;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,QAAQ,KAAA,iBAe7C;AAED;;GAEG;AACH,wBAAsB,gBAAgB,kBAuBrC;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,KAAA,iBA6BnD;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,QAAQ,KAAA,iBAyB5C;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,QAAQ,KAAA,EAAE,KAAK,KAAA,iBAkBhE;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,iBAsB9D;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,iBAsBhE;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA,iBAkB/D","file":"SecretsOps.d.ts","sourcesContent":["import {\n createKeyValueTable,\n createProgressIndicator,\n createTable,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport {\n createNewVersionOfSecret,\n deleteSecret,\n deleteVersionOfSecret,\n getSecret,\n getSecrets,\n getSecretVersions,\n putSecret,\n setSecretDescription,\n setStatusOfVersionOfSecret,\n VersionOfSecretStatus,\n} from '../api/SecretsApi';\nimport wordwrap from './utils/Wordwrap';\nimport { resolveUserName } from './ManagedObjectOps';\n\n/**\n * List secrets\n * @param {boolean} long Long version, all the fields\n */\nexport async function listSecrets(long) {\n let secrets = [];\n try {\n secrets = (await getSecrets()).result;\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.data, 'error');\n }\n if (long) {\n const table = createTable([\n 'Id'['brightCyan'],\n { hAlign: 'right', content: 'Active\\nVersion'['brightCyan'] },\n { hAlign: 'right', content: 'Loaded\\nVersion'['brightCyan'] },\n 'Status'['brightCyan'],\n 'Description'['brightCyan'],\n 'Modifier'['brightCyan'],\n 'Modified'['brightCyan'],\n ]);\n secrets.sort((a, b) => a._id.localeCompare(b._id));\n for (const secret of secrets) {\n table.push([\n secret._id,\n { hAlign: 'right', content: secret.activeVersion },\n { hAlign: 'right', content: secret.loadedVersion },\n secret.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'],\n wordwrap(secret.description, 40),\n // eslint-disable-next-line no-await-in-loop\n await resolveUserName('teammember', secret.lastChangedBy),\n new Date(secret.lastChangeDate).toLocaleString(),\n ]);\n }\n printMessage(table.toString());\n } else {\n secrets.forEach((secret) => {\n printMessage(secret._id);\n });\n }\n}\n\n/**\n * Create secret\n * @param {String} id secret id\n * @param {String} value secret value\n * @param {String} description secret description\n * @param {String} encoding secret encoding\n * @param {boolean} useInPlaceholders use secret in placeholders\n */\nexport async function createSecret(\n id,\n value,\n description,\n encoding,\n useInPlaceholders\n) {\n createProgressIndicator(\n undefined,\n `Creating secret ${id}...`,\n 'indeterminate'\n );\n try {\n await putSecret(id, value, description, encoding, useInPlaceholders);\n stopProgressIndicator(`Created secret ${id}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Set description of secret\n * @param {String} secretId secret id\n * @param {String} description secret description\n */\nexport async function setDescriptionOfSecret(secretId, description) {\n createProgressIndicator(\n undefined,\n `Setting description of secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n await setSecretDescription(secretId, description);\n stopProgressIndicator(`Set description of secret ${secretId}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Delete a secret\n * @param {String} secretId secret id\n */\nexport async function deleteSecretCmd(secretId) {\n createProgressIndicator(\n undefined,\n `Deleting secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n await deleteSecret(secretId);\n stopProgressIndicator(`Deleted secret ${secretId}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Delete all secrets\n */\nexport async function deleteSecretsCmd() {\n try {\n const secrets = (await getSecrets()).result;\n createProgressIndicator(secrets.length, `Deleting secrets...`);\n for (const secret of secrets) {\n try {\n // eslint-disable-next-line no-await-in-loop\n await deleteSecret(secret._id);\n updateProgressIndicator(`Deleted secret ${secret._id}`);\n } catch (error) {\n printMessage(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'error'\n );\n }\n }\n stopProgressIndicator(`Secrets deleted.`);\n } catch (error) {\n printMessage(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all the versions of the secret\n * @param {String} secretId secret id\n */\nexport async function listSecretVersionsCmd(secretId) {\n let versions = [];\n try {\n versions = await getSecretVersions(secretId);\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.data, 'error');\n }\n const table = createTable([\n { hAlign: 'right', content: 'Version'['brightCyan'] },\n 'Status'['brightCyan'],\n 'Loaded'['brightCyan'],\n 'Created'['brightCyan'],\n ]);\n // versions.sort((a, b) => a._id.localeCompare(b._id));\n const statusMap = {\n ENABLED: 'active'['brightGreen'],\n DISABLED: 'inactive'['brightRed'],\n DESTROYED: 'deleted'['brightRed'],\n };\n for (const version of versions) {\n table.push([\n { hAlign: 'right', content: version.version },\n statusMap[version.status],\n version.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'],\n new Date(version.createDate).toLocaleString(),\n ]);\n }\n printMessage(table.toString());\n}\n\n/**\n * Describe a secret\n * @param {String} secretId Secret id\n */\nexport async function describeSecret(secretId) {\n const secret = await getSecret(secretId);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], secret._id]);\n table.push(['Active Version'['brightCyan'], secret.activeVersion]);\n table.push(['Loaded Version'['brightCyan'], secret.loadedVersion]);\n table.push([\n 'Status'['brightCyan'],\n secret.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'],\n ]);\n table.push(['Description'['brightCyan'], wordwrap(secret.description, 60)]);\n table.push([\n 'Modified'['brightCyan'],\n new Date(secret.lastChangeDate).toLocaleString(),\n ]);\n table.push([\n 'Modifier'['brightCyan'],\n await resolveUserName('teammember', secret.lastChangedBy),\n ]);\n table.push(['Modifier UUID'['brightCyan'], secret.lastChangedBy]);\n table.push(['Encoding'['brightCyan'], secret.encoding]);\n table.push(['Use In Placeholders'['brightCyan'], secret.useInPlaceholders]);\n printMessage(table.toString());\n printMessage('\\nSecret Versions:');\n await listSecretVersionsCmd(secretId);\n}\n\n/**\n * Create new version of secret\n * @param {String} secretId secret id\n * @param {String} value secret value\n */\nexport async function createNewVersionOfSecretCmd(secretId, value) {\n createProgressIndicator(\n undefined,\n `Creating new version of secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n const version = await createNewVersionOfSecret(secretId, value);\n stopProgressIndicator(\n `Created version ${version.version} of secret ${secretId}`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Activate a version of a secret\n * @param {String} secretId secret id\n * @param {Number} version version of secret\n */\nexport async function activateVersionOfSecret(secretId, version) {\n createProgressIndicator(\n undefined,\n `Activating version ${version} of secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n await setStatusOfVersionOfSecret(\n secretId,\n version,\n VersionOfSecretStatus.ENABLED\n );\n stopProgressIndicator(\n `Activated version ${version} of secret ${secretId}`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Deactivate a version of a secret\n * @param {String} secretId secret id\n * @param {Number} version version of secret\n */\nexport async function deactivateVersionOfSecret(secretId, version) {\n createProgressIndicator(\n undefined,\n `Deactivating version ${version} of secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n await setStatusOfVersionOfSecret(\n secretId,\n version,\n VersionOfSecretStatus.DISABLED\n );\n stopProgressIndicator(\n `Deactivated version ${version} of secret ${secretId}`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Delete version of secret\n * @param {String} secretId secret id\n * @param {Number} version version of secret\n */\nexport async function deleteVersionOfSecretCmd(secretId, version) {\n createProgressIndicator(\n undefined,\n `Deleting version ${version} of secret ${secretId}...`,\n 'indeterminate'\n );\n try {\n await deleteVersionOfSecret(secretId, version);\n stopProgressIndicator(\n `Deleted version ${version} of secret ${secretId}`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ops/StartupOps.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CA8BxD;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,SAAiB,oBAmDzE","file":"StartupOps.d.ts","sourcesContent":["import {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from './utils/Console';\nimport { getSecrets } from '../api/SecretsApi';\nimport { getStatus, initiateRestart, RestartStatus } from '../api/StartupApi';\nimport { getVariables } from '../api/VariablesApi';\n\n/**\n * Updates that need to be applied.\n */\nexport interface Updates {\n /**\n * Array of secrets that need applying\n */\n secrets?: unknown[];\n /**\n * Array of variables that need applying\n */\n variables?: unknown[];\n}\n\n/**\n * Check for updates that need applying\n * @returns {Promise<boolean>} true if there are updates that need to be applied, false otherwise\n */\nexport async function checkForUpdates(): Promise<Updates> {\n const updates: Updates = { secrets: [], variables: [] };\n createProgressIndicator(\n undefined,\n `Checking for updates to apply...`,\n 'indeterminate'\n );\n try {\n updates.secrets = (await getSecrets()).filter(\n (secret: { loaded: unknown }) => !secret.loaded\n );\n updates.variables = (await getVariables()).filter(\n (variable: { loaded: unknown }) => !variable.loaded\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n const updateCount = updates.secrets?.length + updates.variables?.length || 0;\n if (updateCount > 0) {\n stopProgressIndicator(\n `${updateCount} update(s) need to be applied`,\n 'success'\n );\n } else {\n stopProgressIndicator(`No updates need to be applied`, 'success');\n }\n return updates;\n}\n\n/**\n * Apply updates\n * @param {boolean} wait wait for the operation to complete or not\n * @param {number} timeout timeout in milliseconds\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function applyUpdates(wait: boolean, timeout = 10 * 60 * 1000) {\n createProgressIndicator(undefined, `Applying updates...`, 'indeterminate');\n try {\n let status = await initiateRestart();\n if (wait) {\n const start = new Date().getTime();\n let runtime = 0;\n while (\n status !== RestartStatus.ready &&\n start + timeout > new Date().getTime()\n ) {\n // eslint-disable-next-line no-await-in-loop, no-promise-executor-return\n await new Promise((resolve) => setTimeout(resolve, 5000));\n // eslint-disable-next-line no-await-in-loop\n status = await getStatus();\n runtime = new Date().getTime() - start;\n updateProgressIndicator(`${status} (${Math.round(runtime / 1000)}s)`);\n }\n if (runtime < timeout) {\n stopProgressIndicator(\n `Updates applied in ${Math.round(\n runtime / 1000\n )}s with final status: ${status}`,\n 'success'\n );\n return true;\n } else {\n stopProgressIndicator(\n `Updates timed out after ${Math.round(\n runtime / 1000\n )}s with final status: ${status}`,\n 'warn'\n );\n return false;\n }\n } else {\n stopProgressIndicator(\n `Updates are being applied. Changes may take up to 10 minutes to propagate, during which time you will not be able to make further updates.`,\n 'success'\n );\n return true;\n }\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response?.data?.code || error} - ${\n error.response?.data?.message\n }`,\n 'fail'\n );\n return false;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/ops/StartupOps.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CA8BxD;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,SAAiB,oBAmDzE","file":"StartupOps.d.ts","sourcesContent":["import {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from './utils/Console';\nimport { getSecrets } from '../api/SecretsApi';\nimport { getStatus, initiateRestart, RestartStatus } from '../api/StartupApi';\nimport { getVariables } from '../api/VariablesApi';\n\n/**\n * Updates that need to be applied.\n */\nexport interface Updates {\n /**\n * Array of secrets that need applying\n */\n secrets?: unknown[];\n /**\n * Array of variables that need applying\n */\n variables?: unknown[];\n}\n\n/**\n * Check for updates that need applying\n * @returns {Promise<boolean>} true if there are updates that need to be applied, false otherwise\n */\nexport async function checkForUpdates(): Promise<Updates> {\n const updates: Updates = { secrets: [], variables: [] };\n createProgressIndicator(\n undefined,\n `Checking for updates to apply...`,\n 'indeterminate'\n );\n try {\n updates.secrets = (await getSecrets()).result.filter(\n (secret: { loaded: unknown }) => !secret.loaded\n );\n updates.variables = (await getVariables()).result.filter(\n (variable: { loaded: unknown }) => !variable.loaded\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n const updateCount = updates.secrets?.length + updates.variables?.length || 0;\n if (updateCount > 0) {\n stopProgressIndicator(\n `${updateCount} update(s) need to be applied`,\n 'success'\n );\n } else {\n stopProgressIndicator(`No updates need to be applied`, 'success');\n }\n return updates;\n}\n\n/**\n * Apply updates\n * @param {boolean} wait wait for the operation to complete or not\n * @param {number} timeout timeout in milliseconds\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function applyUpdates(wait: boolean, timeout = 10 * 60 * 1000) {\n createProgressIndicator(undefined, `Applying updates...`, 'indeterminate');\n try {\n let status = await initiateRestart();\n if (wait) {\n const start = new Date().getTime();\n let runtime = 0;\n while (\n status !== RestartStatus.ready &&\n start + timeout > new Date().getTime()\n ) {\n // eslint-disable-next-line no-await-in-loop, no-promise-executor-return\n await new Promise((resolve) => setTimeout(resolve, 5000));\n // eslint-disable-next-line no-await-in-loop\n status = await getStatus();\n runtime = new Date().getTime() - start;\n updateProgressIndicator(`${status} (${Math.round(runtime / 1000)}s)`);\n }\n if (runtime < timeout) {\n stopProgressIndicator(\n `Updates applied in ${Math.round(\n runtime / 1000\n )}s with final status: ${status}`,\n 'success'\n );\n return true;\n } else {\n stopProgressIndicator(\n `Updates timed out after ${Math.round(\n runtime / 1000\n )}s with final status: ${status}`,\n 'warn'\n );\n return false;\n }\n } else {\n stopProgressIndicator(\n `Updates are being applied. Changes may take up to 10 minutes to propagate, during which time you will not be able to make further updates.`,\n 'success'\n );\n return true;\n }\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response?.data?.code || error} - ${\n error.response?.data?.message\n }`,\n 'fail'\n );\n return false;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ops/VariablesOps.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,wBAAsB,aAAa,CAAC,IAAI,KAAA,iBAmCvC;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,UAAU,KAAA,EAAE,KAAK,KAAA,EAAE,WAAW,KAAA,iBAelE;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,UAAU,KAAA,EAAE,KAAK,KAAA,EAAE,WAAW,KAAA,iBAelE;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,UAAU,KAAA,EAAE,WAAW,KAAA,iBAkBrE;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,KAAA,iBAejD;AAED;;GAEG;AACH,wBAAsB,kBAAkB,kBAuBvC;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,KAAA,iBAuBhD","file":"VariablesOps.d.ts","sourcesContent":["import {\n createKeyValueTable,\n createProgressIndicator,\n createTable,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport {\n deleteVariable,\n getVariable,\n getVariables,\n putVariable,\n setVariableDescription,\n} from '../api/VariablesApi';\nimport wordwrap from './utils/Wordwrap';\nimport { resolveUserName } from './ManagedObjectOps';\nimport { decode } from '../api/utils/Base64';\n\n/**\n * List variables\n * @param {boolean} long Long version, all the fields\n */\nexport async function listVariables(long) {\n let variables = [];\n try {\n variables = await getVariables();\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.data, 'error');\n }\n if (long) {\n const table = createTable([\n 'Id'['brightCyan'],\n 'Value'['brightCyan'],\n 'Status'['brightCyan'],\n 'Description'['brightCyan'],\n 'Modifier'['brightCyan'],\n 'Modified'['brightCyan'],\n ]);\n variables.sort((a, b) => a._id.localeCompare(b._id));\n for (const variable of variables) {\n table.push([\n variable._id,\n wordwrap(decode(variable.valueBase64), 40),\n variable.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'],\n wordwrap(variable.description, 40),\n // eslint-disable-next-line no-await-in-loop\n await resolveUserName('teammember', variable.lastChangedBy),\n new Date(variable.lastChangeDate).toLocaleString(),\n ]);\n }\n printMessage(table.toString());\n } else {\n variables.forEach((secret) => {\n printMessage(secret._id);\n });\n }\n}\n\n/**\n * Create variable\n * @param {String} variableId variable id\n * @param {String} value variable value\n * @param {String} description variable description\n */\nexport async function createVariable(variableId, value, description) {\n createProgressIndicator(\n undefined,\n `Creating variable ${variableId}...`,\n 'indeterminate'\n );\n try {\n await putVariable(variableId, value, description);\n stopProgressIndicator(`Created variable ${variableId}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Update variable\n * @param {String} variableId variable id\n * @param {String} value variable value\n * @param {String} description variable description\n */\nexport async function updateVariable(variableId, value, description) {\n createProgressIndicator(\n undefined,\n `Updating variable ${variableId}...`,\n 'indeterminate'\n );\n try {\n await putVariable(variableId, value, description);\n stopProgressIndicator(`Updated variable ${variableId}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Set description of variable\n * @param {String} variableId variable id\n * @param {String} description variable description\n */\nexport async function setDescriptionOfVariable(variableId, description) {\n createProgressIndicator(\n undefined,\n `Setting description of variable ${variableId}...`,\n 'indeterminate'\n );\n try {\n await setVariableDescription(variableId, description);\n stopProgressIndicator(\n `Set description of variable ${variableId}`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Delete a variable\n * @param {String} variableId variable id\n */\nexport async function deleteVariableCmd(variableId) {\n createProgressIndicator(\n undefined,\n `Deleting variable ${variableId}...`,\n 'indeterminate'\n );\n try {\n await deleteVariable(variableId);\n stopProgressIndicator(`Deleted variable ${variableId}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Delete all variables\n */\nexport async function deleteVariablesCmd() {\n try {\n const variables = await getVariables();\n createProgressIndicator(variables.length, `Deleting variable...`);\n for (const variable of variables) {\n try {\n // eslint-disable-next-line no-await-in-loop\n await deleteVariable(variable._id);\n updateProgressIndicator(`Deleted variable ${variable._id}`);\n } catch (error) {\n printMessage(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'error'\n );\n }\n }\n stopProgressIndicator(`Variables deleted.`);\n } catch (error) {\n printMessage(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'error'\n );\n }\n}\n\n/**\n * Describe a variable\n * @param {String} variableId variable id\n */\nexport async function describeVariable(variableId) {\n const variable = await getVariable(variableId);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], variable._id]);\n table.push([\n 'Value'['brightCyan'],\n wordwrap(decode(variable.valueBase64), 40),\n ]);\n table.push([\n 'Status'['brightCyan'],\n variable.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'],\n ]);\n table.push(['Description'['brightCyan'], wordwrap(variable.description, 60)]);\n table.push([\n 'Modified'['brightCyan'],\n new Date(variable.lastChangeDate).toLocaleString(),\n ]);\n table.push([\n 'Modifier'['brightCyan'],\n await resolveUserName('teammember', variable.lastChangedBy),\n ]);\n table.push(['Modifier UUID'['brightCyan'], variable.lastChangedBy]);\n printMessage(table.toString());\n}\n"]}
1
+ {"version":3,"sources":["../src/ops/VariablesOps.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,wBAAsB,aAAa,CAAC,IAAI,KAAA,iBAmCvC;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,UAAU,KAAA,EAAE,KAAK,KAAA,EAAE,WAAW,KAAA,iBAelE;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,UAAU,KAAA,EAAE,KAAK,KAAA,EAAE,WAAW,KAAA,iBAelE;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,UAAU,KAAA,EAAE,WAAW,KAAA,iBAkBrE;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,KAAA,iBAejD;AAED;;GAEG;AACH,wBAAsB,kBAAkB,kBAuBvC;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,KAAA,iBAuBhD","file":"VariablesOps.d.ts","sourcesContent":["import {\n createKeyValueTable,\n createProgressIndicator,\n createTable,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport {\n deleteVariable,\n getVariable,\n getVariables,\n putVariable,\n setVariableDescription,\n} from '../api/VariablesApi';\nimport wordwrap from './utils/Wordwrap';\nimport { resolveUserName } from './ManagedObjectOps';\nimport { decode } from '../api/utils/Base64';\n\n/**\n * List variables\n * @param {boolean} long Long version, all the fields\n */\nexport async function listVariables(long) {\n let variables = [];\n try {\n variables = (await getVariables()).result;\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.data, 'error');\n }\n if (long) {\n const table = createTable([\n 'Id'['brightCyan'],\n 'Value'['brightCyan'],\n 'Status'['brightCyan'],\n 'Description'['brightCyan'],\n 'Modifier'['brightCyan'],\n 'Modified'['brightCyan'],\n ]);\n variables.sort((a, b) => a._id.localeCompare(b._id));\n for (const variable of variables) {\n table.push([\n variable._id,\n wordwrap(decode(variable.valueBase64), 40),\n variable.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'],\n wordwrap(variable.description, 40),\n // eslint-disable-next-line no-await-in-loop\n await resolveUserName('teammember', variable.lastChangedBy),\n new Date(variable.lastChangeDate).toLocaleString(),\n ]);\n }\n printMessage(table.toString());\n } else {\n variables.forEach((secret) => {\n printMessage(secret._id);\n });\n }\n}\n\n/**\n * Create variable\n * @param {String} variableId variable id\n * @param {String} value variable value\n * @param {String} description variable description\n */\nexport async function createVariable(variableId, value, description) {\n createProgressIndicator(\n undefined,\n `Creating variable ${variableId}...`,\n 'indeterminate'\n );\n try {\n await putVariable(variableId, value, description);\n stopProgressIndicator(`Created variable ${variableId}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Update variable\n * @param {String} variableId variable id\n * @param {String} value variable value\n * @param {String} description variable description\n */\nexport async function updateVariable(variableId, value, description) {\n createProgressIndicator(\n undefined,\n `Updating variable ${variableId}...`,\n 'indeterminate'\n );\n try {\n await putVariable(variableId, value, description);\n stopProgressIndicator(`Updated variable ${variableId}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Set description of variable\n * @param {String} variableId variable id\n * @param {String} description variable description\n */\nexport async function setDescriptionOfVariable(variableId, description) {\n createProgressIndicator(\n undefined,\n `Setting description of variable ${variableId}...`,\n 'indeterminate'\n );\n try {\n await setVariableDescription(variableId, description);\n stopProgressIndicator(\n `Set description of variable ${variableId}`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Delete a variable\n * @param {String} variableId variable id\n */\nexport async function deleteVariableCmd(variableId) {\n createProgressIndicator(\n undefined,\n `Deleting variable ${variableId}...`,\n 'indeterminate'\n );\n try {\n await deleteVariable(variableId);\n stopProgressIndicator(`Deleted variable ${variableId}`, 'success');\n } catch (error) {\n stopProgressIndicator(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'fail'\n );\n }\n}\n\n/**\n * Delete all variables\n */\nexport async function deleteVariablesCmd() {\n try {\n const variables = (await getVariables()).result;\n createProgressIndicator(variables.length, `Deleting variable...`);\n for (const variable of variables) {\n try {\n // eslint-disable-next-line no-await-in-loop\n await deleteVariable(variable._id);\n updateProgressIndicator(`Deleted variable ${variable._id}`);\n } catch (error) {\n printMessage(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'error'\n );\n }\n }\n stopProgressIndicator(`Variables deleted.`);\n } catch (error) {\n printMessage(\n `Error: ${error.response.data.code} - ${error.response.data.message}`,\n 'error'\n );\n }\n}\n\n/**\n * Describe a variable\n * @param {String} variableId variable id\n */\nexport async function describeVariable(variableId) {\n const variable = await getVariable(variableId);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], variable._id]);\n table.push([\n 'Value'['brightCyan'],\n wordwrap(decode(variable.valueBase64), 40),\n ]);\n table.push([\n 'Status'['brightCyan'],\n variable.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'],\n ]);\n table.push(['Description'['brightCyan'], wordwrap(variable.description, 60)]);\n table.push([\n 'Modified'['brightCyan'],\n new Date(variable.lastChangeDate).toLocaleString(),\n ]);\n table.push([\n 'Modifier'['brightCyan'],\n await resolveUserName('teammember', variable.lastChangedBy),\n ]);\n table.push(['Modifier UUID'['brightCyan'], variable.lastChangedBy]);\n printMessage(table.toString());\n}\n"]}