aws-iam-managed-policies 0.0.3 → 0.0.6

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/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # aws-iam-managed-policies
2
- Automatically populated repository of AWS IAM Managed Policies, which also updates a npm package containing the full history of AWS IAM Managed Policies.
2
+ Automatically populated (every morning at 6AM UTC) repository of AWS IAM Managed Policies, which also updates a npm package containing the full history of AWS IAM Managed Policies.
3
+
4
+ ## Data
5
+ The raw IAM Managed Policies data can be found in the [data/json](https://github.com/tobilg/aws-iam-managed-policies/tree/main/data/json) directory. It is categorized by Managed Policy name and version id.
3
6
 
4
7
  ## Usage
5
8
 
@@ -11,5 +14,4 @@ npm i --save aws-iam-managed-policies
11
14
  ```
12
15
 
13
16
  ### API
14
-
15
-
17
+ The API docs can be found at [https://tobilg.github.io/aws-iam-managed-policies](https://tobilg.github.io/aws-iam-managed-policies).
package/dist/index.d.ts CHANGED
@@ -1,7 +1,34 @@
1
1
  import { ManagedPolicies, ManagedPolicy } from '../src/types';
2
+ /**
3
+ * Retrieve a list of all included IAM Managed Polcies.
4
+ * @returns {Array} An array of IAM Managed Policy names.
5
+ */
2
6
  export declare const listPolicies: () => string[];
7
+ /**
8
+ * Get the number of included IAM Managed Polcies.
9
+ * @returns {number} The count of IAM Managed Policies.
10
+ */
3
11
  export declare const getPolicyCount: () => number;
4
- export declare const getPolicyByName: (policyName: string) => ManagedPolicy | undefined;
5
- export declare const getLatestPolicyDocument: (policyName: string) => object | undefined;
6
- export declare const getPolicyDocumentByVersion: (policyName: string, policyVersion: number) => object | undefined;
12
+ /**
13
+ * Get the IAM Managed Policy by name
14
+ * @param {string} policyName The IAM Managed Policy name.
15
+ * @returns {object} The IAM Managed Policy if found.
16
+ * @throws Will throw an error if not found by the name.
17
+ */
18
+ export declare const getPolicyByName: (policyName: string) => ManagedPolicy;
19
+ /**
20
+ * Get the latest policy document for a IAM Managed Policy by name
21
+ * @param {string} policyName The IAM Managed Policy name.
22
+ * @returns {object} The IAM Managed Policy document if found.
23
+ * @throws Will throw an error if not found by the name.
24
+ */
25
+ export declare const getLatestPolicyDocument: (policyName: string) => object;
26
+ /**
27
+ * Get the latest policy document for a IAM Managed Policy by name
28
+ * @param {string} policyName The IAM Managed Policy name.
29
+ * @param {number} policyVersion The version id of the IAM Managed Policy.
30
+ * @returns {object} The IAM Managed Policy document if found.
31
+ * @throws Will throw an error if not found by the name.
32
+ */
33
+ export declare const getPolicyDocumentByVersion: (policyName: string, policyVersion: number) => object;
7
34
  export { ManagedPolicies, };
package/dist/index.js CHANGED
@@ -9,18 +9,44 @@ var sortObjectByPropertyNames = function (obj) { return Object.keys(obj).sort().
9
9
  objEntries[key] = obj[key];
10
10
  return objEntries;
11
11
  }, {}); };
12
+ /**
13
+ * Retrieve a list of all included IAM Managed Polcies.
14
+ * @returns {Array} An array of IAM Managed Policy names.
15
+ */
12
16
  var listPolicies = function () {
13
17
  return Object.keys(sortObjectByPropertyNames(managedPolicies_json_1.default));
14
18
  };
15
19
  exports.listPolicies = listPolicies;
20
+ /**
21
+ * Get the number of included IAM Managed Polcies.
22
+ * @returns {number} The count of IAM Managed Policies.
23
+ */
16
24
  var getPolicyCount = function () {
17
25
  return Object.keys(managedPolicies_json_1.default).length;
18
26
  };
19
27
  exports.getPolicyCount = getPolicyCount;
28
+ /**
29
+ * Get the IAM Managed Policy by name
30
+ * @param {string} policyName The IAM Managed Policy name.
31
+ * @returns {object} The IAM Managed Policy if found.
32
+ * @throws Will throw an error if not found by the name.
33
+ */
20
34
  var getPolicyByName = function (policyName) {
21
- return managedPolicies_json_1.default[policyName];
35
+ var policy = managedPolicies_json_1.default[policyName];
36
+ if (policy) {
37
+ return policy;
38
+ }
39
+ else {
40
+ throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found!"));
41
+ }
22
42
  };
23
43
  exports.getPolicyByName = getPolicyByName;
44
+ /**
45
+ * Get the latest policy document for a IAM Managed Policy by name
46
+ * @param {string} policyName The IAM Managed Policy name.
47
+ * @returns {object} The IAM Managed Policy document if found.
48
+ * @throws Will throw an error if not found by the name.
49
+ */
24
50
  var getLatestPolicyDocument = function (policyName) {
25
51
  var policy = managedPolicies_json_1.default[policyName];
26
52
  if (policy) {
@@ -28,17 +54,24 @@ var getLatestPolicyDocument = function (policyName) {
28
54
  return policy.versions[latestVersionId].document;
29
55
  }
30
56
  else {
31
- return undefined;
57
+ throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found!"));
32
58
  }
33
59
  };
34
60
  exports.getLatestPolicyDocument = getLatestPolicyDocument;
61
+ /**
62
+ * Get the latest policy document for a IAM Managed Policy by name
63
+ * @param {string} policyName The IAM Managed Policy name.
64
+ * @param {number} policyVersion The version id of the IAM Managed Policy.
65
+ * @returns {object} The IAM Managed Policy document if found.
66
+ * @throws Will throw an error if not found by the name.
67
+ */
35
68
  var getPolicyDocumentByVersion = function (policyName, policyVersion) {
36
69
  var policy = managedPolicies_json_1.default[policyName];
37
- if (policy) {
70
+ if (policy && policy.versions[policyVersion]) {
38
71
  return policy.versions[policyVersion].document;
39
72
  }
40
73
  else {
41
- return undefined;
74
+ throw new Error("IAM Managed Policy '".concat(policyName, "' wasn't found in version '").concat(policyVersion, "'!"));
42
75
  }
43
76
  };
44
77
  exports.getPolicyDocumentByVersion = getPolicyDocumentByVersion;