@stackfactor/client-api 1.9.2 → 1.9.4

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.
Files changed (41) hide show
  1. package/dist/cjs/lib/control.d.ts +9 -0
  2. package/dist/cjs/lib/control.d.ts.map +1 -1
  3. package/dist/cjs/lib/control.js +10 -1
  4. package/dist/cjs/lib/control.js.map +1 -1
  5. package/dist/cjs/lib/controlTemplate.d.ts +9 -0
  6. package/dist/cjs/lib/controlTemplate.d.ts.map +1 -1
  7. package/dist/cjs/lib/controlTemplate.js +10 -1
  8. package/dist/cjs/lib/controlTemplate.js.map +1 -1
  9. package/dist/cjs/lib/index.d.ts +2 -0
  10. package/dist/cjs/lib/index.d.ts.map +1 -1
  11. package/dist/cjs/lib/index.js +4 -2
  12. package/dist/cjs/lib/index.js.map +1 -1
  13. package/dist/cjs/lib/metric.d.ts +171 -0
  14. package/dist/cjs/lib/metric.d.ts.map +1 -0
  15. package/dist/cjs/lib/metric.js +170 -0
  16. package/dist/cjs/lib/metric.js.map +1 -0
  17. package/dist/cjs/lib/metricTemplate.d.ts +119 -0
  18. package/dist/cjs/lib/metricTemplate.d.ts.map +1 -0
  19. package/dist/cjs/lib/metricTemplate.js +145 -0
  20. package/dist/cjs/lib/metricTemplate.js.map +1 -0
  21. package/dist/esm/lib/control.d.ts +9 -0
  22. package/dist/esm/lib/control.d.ts.map +1 -1
  23. package/dist/esm/lib/control.js +8 -0
  24. package/dist/esm/lib/control.js.map +1 -1
  25. package/dist/esm/lib/controlTemplate.d.ts +9 -0
  26. package/dist/esm/lib/controlTemplate.d.ts.map +1 -1
  27. package/dist/esm/lib/controlTemplate.js +9 -1
  28. package/dist/esm/lib/controlTemplate.js.map +1 -1
  29. package/dist/esm/lib/index.d.ts +2 -0
  30. package/dist/esm/lib/index.d.ts.map +1 -1
  31. package/dist/esm/lib/index.js +2 -0
  32. package/dist/esm/lib/index.js.map +1 -1
  33. package/dist/esm/lib/metric.d.ts +171 -0
  34. package/dist/esm/lib/metric.d.ts.map +1 -0
  35. package/dist/esm/lib/metric.js +152 -0
  36. package/dist/esm/lib/metric.js.map +1 -0
  37. package/dist/esm/lib/metricTemplate.d.ts +119 -0
  38. package/dist/esm/lib/metricTemplate.d.ts.map +1 -0
  39. package/dist/esm/lib/metricTemplate.js +130 -0
  40. package/dist/esm/lib/metricTemplate.js.map +1 -0
  41. package/package.json +1 -1
@@ -0,0 +1,171 @@
1
+ import type { FrameworkRecordSummary, TemplateFieldDiff, TemplateMergeSelection } from "./frameworkTemplateMerge.js";
2
+ /** 1 = higher is better, 2 = lower is better; null when unset. */
3
+ export type MetricDirection = 1 | 2 | null;
4
+ /** The warning and critical thresholds of a metric; each is null when unset. */
5
+ export interface MetricThresholds {
6
+ warning: number | null;
7
+ critical: number | null;
8
+ }
9
+ /** The content held by both the draft and the published side of a metric. */
10
+ export interface MetricContent {
11
+ version?: number;
12
+ name: string;
13
+ summary: string;
14
+ description: string;
15
+ unit: string;
16
+ direction: MetricDirection;
17
+ targetValue: number | null;
18
+ thresholds: MetricThresholds | null;
19
+ frequency: string;
20
+ calculation: string;
21
+ dataSource: string;
22
+ references?: unknown[];
23
+ }
24
+ /** A metric record as returned by the server; sides may be absent. */
25
+ export interface MetricRecord {
26
+ _id: string;
27
+ draft?: MetricContent;
28
+ published?: MetricContent;
29
+ [key: string]: unknown;
30
+ }
31
+ /** A record related to a metric (control, requirement, standard or policy). */
32
+ export interface MetricRelatedRecord {
33
+ _id: string;
34
+ name?: string;
35
+ [key: string]: unknown;
36
+ }
37
+ /** A relation result: a bare id string when `details` is "ID", otherwise the row. */
38
+ export type RelatedRecordOrId = string | MetricRelatedRecord;
39
+ /**
40
+ * Create metric and set information
41
+ * @param {Object} data
42
+ * @param {String} token Authorization token
43
+ * @returns {Promise<MetricRecord>}
44
+ */
45
+ export declare const createMetric: (data: Partial<MetricContent>, token: string) => Promise<MetricRecord>;
46
+ /**
47
+ * Delete metric
48
+ * @param {String} id The id of the record to be deleted
49
+ * @param {String} comments The comments included with the deletion
50
+ * @param {String} token Authorization token
51
+ * @returns {Promise<MetricRecord>}
52
+ */
53
+ export declare const deleteMetric: (id: string, comments: string, token: string) => Promise<MetricRecord>;
54
+ /**
55
+ * Discard the metric draft changes
56
+ * @param {String} id The id of the record to be discarded
57
+ * @param {String} token Authorization token
58
+ * @returns {Promise<MetricRecord>}
59
+ */
60
+ export declare const discardMetricChanges: (id: string, token: string) => Promise<MetricRecord>;
61
+ /**
62
+ * Get metric information
63
+ * @param {String} id The id of the record
64
+ * @param {String} version The version of the record
65
+ * @param {Boolean} returnNullIfVersionNotFound When true it will return null if the version is not found
66
+ * @param {String} token Authorization token
67
+ * @returns {Promise<MetricRecord | null>}
68
+ */
69
+ export declare const getMetricInformationById: (id: string, version: string, returnNullIfVersionNotFound: boolean, token: string) => Promise<MetricRecord | null>;
70
+ /**
71
+ * Get metric list
72
+ * @param {Array<String>} filter The filter used to select the records
73
+ * @param {String} version The version to be retrieved
74
+ * @param {Boolean} includeDeleted If true it will return deleted records as well
75
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
76
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
77
+ * @param {String} token Authorization token
78
+ * @returns {Promise<MetricRecord[]>}
79
+ */
80
+ export declare const getMetricList: (filter: string[], version: string, includeDeleted: boolean, returnDefaultIfVersionNotAvailable: boolean, details: string, token: string) => Promise<MetricRecord[]>;
81
+ /**
82
+ * Publish metric
83
+ * @param {String} id The id of the record to be published
84
+ * @param {String} comments The comments to be include with the request
85
+ * @param {String} token Authorization token
86
+ * @returns {Promise<MetricRecord>}
87
+ */
88
+ export declare const publishMetric: (id: string, comments: string, token: string) => Promise<MetricRecord>;
89
+ /**
90
+ * Set metric information
91
+ * @param {String} id The id of the record to be updated
92
+ * @param {Object} data Data used to update the record
93
+ * @param {String} token Authorization token
94
+ * @returns {Promise<MetricRecord>}
95
+ */
96
+ export declare const setMetricInformation: (id: string, data: Partial<MetricContent>, token: string) => Promise<MetricRecord>;
97
+ /**
98
+ * Create metrics from templates
99
+ * @param {Array<String>} templateIds
100
+ * @param {String} token Authorization token
101
+ * @returns {Promise<MetricRecord[]>}
102
+ */
103
+ export declare const createMetricsFromTemplates: (templateIds: string[], token: string) => Promise<MetricRecord[]>;
104
+ /**
105
+ * The differences between a metric and its template, per field
106
+ * @param {String} id The id of the metric
107
+ * @param {String} token Authorization token
108
+ * @returns {Promise<TemplateFieldDiff[]>}
109
+ */
110
+ export declare const getMetricTemplateUpdates: (id: string, token: string) => Promise<TemplateFieldDiff[]>;
111
+ /**
112
+ * Set the metric information from template
113
+ * @param {String} id The id of the metric to be updated
114
+ * @param {TemplateMergeSelection} data The diff with `merge` set on the accepted changes
115
+ * @param {String} token Authorization token
116
+ * @returns {Promise<FrameworkRecordSummary>}
117
+ */
118
+ export declare const setMetricInformationFromTemplate: (id: string, data: TemplateMergeSelection, token: string) => Promise<FrameworkRecordSummary>;
119
+ /**
120
+ * Watch metric
121
+ * @param {String} id The id of the metric
122
+ * @param {Boolean} watch Set to true or false
123
+ * @param {String} token Authorization token
124
+ * @returns {Promise<MetricRecord>}
125
+ */
126
+ export declare const watchMetric: (id: string, watch: boolean, token: string) => Promise<MetricRecord>;
127
+ /**
128
+ * Get the metric related controls
129
+ * @param {String} id The id of the record
130
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
131
+ * @param {String} version The version to be retrieved
132
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
133
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
134
+ * @param {String} token Authorization token
135
+ * @returns {Promise<RelatedRecordOrId[]>}
136
+ */
137
+ export declare const getMetricRelatedControls: (id: string, details: string, version: string, includeDeleted: boolean, returnDefaultIfVersionNotAvailable: boolean, token: string) => Promise<RelatedRecordOrId[]>;
138
+ /**
139
+ * Get the metric related requirements
140
+ * @param {String} id The id of the record
141
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
142
+ * @param {String} version The version to be retrieved
143
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
144
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
145
+ * @param {String} token Authorization token
146
+ * @returns {Promise<RelatedRecordOrId[]>}
147
+ */
148
+ export declare const getMetricRelatedRequirements: (id: string, details: string, version: string, includeDeleted: boolean, returnDefaultIfVersionNotAvailable: boolean, token: string) => Promise<RelatedRecordOrId[]>;
149
+ /**
150
+ * Get the metric related standards
151
+ * @param {String} id The id of the record
152
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
153
+ * @param {String} version The version to be retrieved
154
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
155
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
156
+ * @param {String} token Authorization token
157
+ * @returns {Promise<RelatedRecordOrId[]>}
158
+ */
159
+ export declare const getMetricRelatedStandards: (id: string, details: string, version: string, includeDeleted: boolean, returnDefaultIfVersionNotAvailable: boolean, token: string) => Promise<RelatedRecordOrId[]>;
160
+ /**
161
+ * Get the metric related policies
162
+ * @param {String} id The id of the record
163
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
164
+ * @param {String} version The version to be retrieved
165
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
166
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
167
+ * @param {String} token Authorization token
168
+ * @returns {Promise<RelatedRecordOrId[]>}
169
+ */
170
+ export declare const getMetricRelatedPolicies: (id: string, details: string, version: string, includeDeleted: boolean, returnDefaultIfVersionNotAvailable: boolean, token: string) => Promise<RelatedRecordOrId[]>;
171
+ //# sourceMappingURL=metric.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metric.d.ts","sourceRoot":"","sources":["../../../src/lib/metric.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,6B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EACV,MAAM,sBAAsB,EAC5B,OAAO,MAAM,KACZ,OAAO,CAAC,sBAAsB,CAO9B,CAAC;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GACtB,IAAI,MAAM,EACV,OAAO,OAAO,EACd,OAAO,MAAM,KACZ,OAAO,CAAC,YAAY,CAKpB,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GACnC,IAAI,MAAM,EACV,SAAS,MAAM,EACf,SAAS,MAAM,EACf,gBAAgB,OAAO,EACvB,oCAAoC,OAAO,EAC3C,OAAO,MAAM,KACZ,OAAO,CAAC,iBAAiB,EAAE,CAO3B,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,GACvC,IAAI,MAAM,EACV,SAAS,MAAM,EACf,SAAS,MAAM,EACf,gBAAgB,OAAO,EACvB,oCAAoC,OAAO,EAC3C,OAAO,MAAM,KACZ,OAAO,CAAC,iBAAiB,EAAE,CAO3B,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GACpC,IAAI,MAAM,EACV,SAAS,MAAM,EACf,SAAS,MAAM,EACf,gBAAgB,OAAO,EACvB,oCAAoC,OAAO,EAC3C,OAAO,MAAM,KACZ,OAAO,CAAC,iBAAiB,EAAE,CAO3B,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GACnC,IAAI,MAAM,EACV,SAAS,MAAM,EACf,SAAS,MAAM,EACf,gBAAgB,OAAO,EACvB,oCAAoC,OAAO,EAC3C,OAAO,MAAM,KACZ,OAAO,CAAC,iBAAiB,EAAE,CAO3B,CAAC"}
@@ -0,0 +1,152 @@
1
+ import { client, request } from "./axiosClient.js";
2
+ /**
3
+ * Create metric and set information
4
+ * @param {Object} data
5
+ * @param {String} token Authorization token
6
+ * @returns {Promise<MetricRecord>}
7
+ */
8
+ export const createMetric = (data, token) => request(client.put("/api/v1/shield/metrics", { data }, { headers: { authorization: token } }));
9
+ /**
10
+ * Delete metric
11
+ * @param {String} id The id of the record to be deleted
12
+ * @param {String} comments The comments included with the deletion
13
+ * @param {String} token Authorization token
14
+ * @returns {Promise<MetricRecord>}
15
+ */
16
+ export const deleteMetric = (id, comments, token) => {
17
+ const data = { id };
18
+ if (comments)
19
+ data.comments = comments;
20
+ return request(client.delete("/api/v1/shield/metrics/", { headers: { authorization: token }, data }));
21
+ };
22
+ /**
23
+ * Discard the metric draft changes
24
+ * @param {String} id The id of the record to be discarded
25
+ * @param {String} token Authorization token
26
+ * @returns {Promise<MetricRecord>}
27
+ */
28
+ export const discardMetricChanges = (id, token) => request(client.get(`/api/v1/shield/metrics/discard/${id}`, { headers: { authorization: token } }));
29
+ /**
30
+ * Get metric information
31
+ * @param {String} id The id of the record
32
+ * @param {String} version The version of the record
33
+ * @param {Boolean} returnNullIfVersionNotFound When true it will return null if the version is not found
34
+ * @param {String} token Authorization token
35
+ * @returns {Promise<MetricRecord | null>}
36
+ */
37
+ export const getMetricInformationById = (id, version, returnNullIfVersionNotFound, token) => request(client.get(`/api/v1/shield/metrics/${id}/${version}/${returnNullIfVersionNotFound}`, {
38
+ headers: { authorization: token },
39
+ }));
40
+ /**
41
+ * Get metric list
42
+ * @param {Array<String>} filter The filter used to select the records
43
+ * @param {String} version The version to be retrieved
44
+ * @param {Boolean} includeDeleted If true it will return deleted records as well
45
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
46
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
47
+ * @param {String} token Authorization token
48
+ * @returns {Promise<MetricRecord[]>}
49
+ */
50
+ export const getMetricList = (filter, version, includeDeleted, returnDefaultIfVersionNotAvailable, details, token) => request(client.post("/api/v1/shield/metrics", { includeDeleted, details, returnDefaultIfVersionNotAvailable, version, filter }, { headers: { authorization: token } }));
51
+ /**
52
+ * Publish metric
53
+ * @param {String} id The id of the record to be published
54
+ * @param {String} comments The comments to be include with the request
55
+ * @param {String} token Authorization token
56
+ * @returns {Promise<MetricRecord>}
57
+ */
58
+ export const publishMetric = (id, comments, token) => {
59
+ const data = {};
60
+ if (comments)
61
+ data.comments = comments;
62
+ return request(client.post(`/api/v1/shield/metrics/publish/${id}`, data, { headers: { authorization: token } }));
63
+ };
64
+ /**
65
+ * Set metric information
66
+ * @param {String} id The id of the record to be updated
67
+ * @param {Object} data Data used to update the record
68
+ * @param {String} token Authorization token
69
+ * @returns {Promise<MetricRecord>}
70
+ */
71
+ export const setMetricInformation = (id, data, token) => request(client.post(`/api/v1/shield/metrics/update`, { data, id }, { headers: { authorization: token } }));
72
+ /**
73
+ * Create metrics from templates
74
+ * @param {Array<String>} templateIds
75
+ * @param {String} token Authorization token
76
+ * @returns {Promise<MetricRecord[]>}
77
+ */
78
+ export const createMetricsFromTemplates = (templateIds, token) => request(client.put(`/api/v1/shield/metrics/createfromtemplate/`, { templateIds }, {
79
+ headers: { authorization: token },
80
+ }));
81
+ /**
82
+ * The differences between a metric and its template, per field
83
+ * @param {String} id The id of the metric
84
+ * @param {String} token Authorization token
85
+ * @returns {Promise<TemplateFieldDiff[]>}
86
+ */
87
+ export const getMetricTemplateUpdates = (id, token) => request(client.get(`/api/v1/shield/metrics/templateupdates/${id}`, {
88
+ headers: { authorization: token },
89
+ }));
90
+ /**
91
+ * Set the metric information from template
92
+ * @param {String} id The id of the metric to be updated
93
+ * @param {TemplateMergeSelection} data The diff with `merge` set on the accepted changes
94
+ * @param {String} token Authorization token
95
+ * @returns {Promise<FrameworkRecordSummary>}
96
+ */
97
+ export const setMetricInformationFromTemplate = (id, data, token) => request(client.post(`/api/v1/shield/metrics/updatefromtemplate/`, { data, id }, { headers: { authorization: token } }));
98
+ /**
99
+ * Watch metric
100
+ * @param {String} id The id of the metric
101
+ * @param {Boolean} watch Set to true or false
102
+ * @param {String} token Authorization token
103
+ * @returns {Promise<MetricRecord>}
104
+ */
105
+ export const watchMetric = (id, watch, token) => request(client.post(`/api/v1/shield/metrics/watch`, { id, watch }, {
106
+ headers: { authorization: token },
107
+ }));
108
+ /**
109
+ * Get the metric related controls
110
+ * @param {String} id The id of the record
111
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
112
+ * @param {String} version The version to be retrieved
113
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
114
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
115
+ * @param {String} token Authorization token
116
+ * @returns {Promise<RelatedRecordOrId[]>}
117
+ */
118
+ export const getMetricRelatedControls = (id, details, version, includeDeleted, returnDefaultIfVersionNotAvailable, token) => request(client.post(`/api/v1/shield/metrics/controls/${id}`, { details, version, includeDeleted, returnDefaultIfVersionNotAvailable }, { headers: { authorization: token } }));
119
+ /**
120
+ * Get the metric related requirements
121
+ * @param {String} id The id of the record
122
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
123
+ * @param {String} version The version to be retrieved
124
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
125
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
126
+ * @param {String} token Authorization token
127
+ * @returns {Promise<RelatedRecordOrId[]>}
128
+ */
129
+ export const getMetricRelatedRequirements = (id, details, version, includeDeleted, returnDefaultIfVersionNotAvailable, token) => request(client.post(`/api/v1/shield/metrics/requirements/${id}`, { details, version, includeDeleted, returnDefaultIfVersionNotAvailable }, { headers: { authorization: token } }));
130
+ /**
131
+ * Get the metric related standards
132
+ * @param {String} id The id of the record
133
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
134
+ * @param {String} version The version to be retrieved
135
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
136
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
137
+ * @param {String} token Authorization token
138
+ * @returns {Promise<RelatedRecordOrId[]>}
139
+ */
140
+ export const getMetricRelatedStandards = (id, details, version, includeDeleted, returnDefaultIfVersionNotAvailable, token) => request(client.post(`/api/v1/shield/metrics/standards/${id}`, { details, version, includeDeleted, returnDefaultIfVersionNotAvailable }, { headers: { authorization: token } }));
141
+ /**
142
+ * Get the metric related policies
143
+ * @param {String} id The id of the record
144
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
145
+ * @param {String} version The version to be retrieved
146
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
147
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
148
+ * @param {String} token Authorization token
149
+ * @returns {Promise<RelatedRecordOrId[]>}
150
+ */
151
+ export const getMetricRelatedPolicies = (id, details, version, includeDeleted, returnDefaultIfVersionNotAvailable, token) => request(client.post(`/api/v1/shield/metrics/policies/${id}`, { details, version, includeDeleted, returnDefaultIfVersionNotAvailable }, { headers: { authorization: token } }));
152
+ //# sourceMappingURL=metric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metric.js","sourceRoot":"","sources":["../../../src/lib/metric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAkDnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAA4B,EAAE,KAAa,EAAyB,EAAE,CACjG,OAAO,CAAe,MAAM,CAAC,GAAG,CAAC,wBAAwB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;AAE/G;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAU,EAAE,QAAgB,EAAE,KAAa,EAAyB,EAAE;IACjG,MAAM,IAAI,GAAsC,EAAE,EAAE,EAAE,CAAC;IACvD,IAAI,QAAQ;QAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACvC,OAAO,OAAO,CACZ,MAAM,CAAC,MAAM,CAAC,yBAAyB,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CACtF,CAAC;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,EACiB,EAAE,CAChC,OAAO,CACL,MAAM,CAAC,IAAI,CACT,mCAAmC,EAAE,EAAE,EACvC,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,kCAAkC,EAAE,EACxE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,CACtC,CACF,CAAC"}
@@ -0,0 +1,119 @@
1
+ import type { MetricContent, RelatedRecordOrId } from "./metric.js";
2
+ /** A metric template as returned by the server; sides may be absent. */
3
+ export interface MetricTemplateRecord {
4
+ _id: string;
5
+ draft?: MetricContent;
6
+ published?: MetricContent;
7
+ tags?: Record<string, unknown>;
8
+ [key: string]: unknown;
9
+ }
10
+ /**
11
+ * Create metric template and set information
12
+ * @param {Object} data
13
+ * @param {String} token Authorization token
14
+ * @returns {Promise<MetricTemplateRecord>}
15
+ */
16
+ export declare const createMetricTemplate: (data: Partial<MetricContent>, token: string) => Promise<MetricTemplateRecord>;
17
+ /**
18
+ * Delete metric template
19
+ * @param {String} id The id of the record to be deleted
20
+ * @param {String} comments The comments included with the deletion
21
+ * @param {String} token Authorization token
22
+ * @returns {Promise<MetricTemplateRecord>}
23
+ */
24
+ export declare const deleteMetricTemplate: (id: string, comments: string, token: string) => Promise<MetricTemplateRecord>;
25
+ /**
26
+ * Discard the metric template draft changes
27
+ * @param {String} id The id of the record to be discarded
28
+ * @param {String} token Authorization token
29
+ * @returns {Promise<MetricTemplateRecord>}
30
+ */
31
+ export declare const discardMetricTemplateChanges: (id: string, token: string) => Promise<MetricTemplateRecord>;
32
+ /**
33
+ * Get metric template information
34
+ * @param {String} id The id of the record
35
+ * @param {String} version The version of the record
36
+ * @param {Boolean} returnNullIfVersionNotFound When true it will return null if the version is not found
37
+ * @param {String} token Authorization token
38
+ * @returns {Promise<MetricTemplateRecord | null>}
39
+ */
40
+ export declare const getMetricTemplateInformationById: (id: string, version: string, returnNullIfVersionNotFound: boolean, token: string) => Promise<MetricTemplateRecord | null>;
41
+ /**
42
+ * Get metric template list
43
+ * @param {Array<String>} filter The filter used to select the records
44
+ * @param {String} version The version to be retrieved
45
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
46
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
47
+ * @param {String} token Authorization token
48
+ * @returns {Promise<MetricTemplateRecord[]>}
49
+ */
50
+ export declare const getMetricTemplateList: (filter: string[], version: string, includeDeleted: boolean, details: string, token: string) => Promise<MetricTemplateRecord[]>;
51
+ /**
52
+ * Publish metric template
53
+ * @param {String} id The id of the record to be published
54
+ * @param {String} comments The comments to be include with the request
55
+ * @param {String} token Authorization token
56
+ * @returns {Promise<MetricTemplateRecord>}
57
+ */
58
+ export declare const publishMetricTemplate: (id: string, comments: string, token: string) => Promise<MetricTemplateRecord>;
59
+ /**
60
+ * Set metric template information
61
+ * @param {String} id The id of the record to be updated
62
+ * @param {Object} data Data used to update the record
63
+ * @param {String} token Authorization token
64
+ * @returns {Promise<MetricTemplateRecord>}
65
+ */
66
+ export declare const setMetricTemplateInformation: (id: string, data: Partial<MetricContent>, token: string) => Promise<MetricTemplateRecord>;
67
+ /**
68
+ * Update the metric template tags
69
+ * @param {String} id The id of the template to be updated
70
+ * @param {Object} tags Updated template tags
71
+ * @param {String} token Authorization token
72
+ * @returns {Promise<MetricTemplateRecord>}
73
+ */
74
+ export declare const setMetricTemplateTags: (id: string, tags: Record<string, unknown>, token: string) => Promise<MetricTemplateRecord>;
75
+ /**
76
+ * Get the metric template related control templates
77
+ * @param {String} id The id of the record
78
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
79
+ * @param {String} version The version to be retrieved
80
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
81
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
82
+ * @param {String} token Authorization token
83
+ * @returns {Promise<RelatedRecordOrId[]>}
84
+ */
85
+ export declare const getMetricTemplateRelatedControlTemplates: (id: string, details: string, version: string, includeDeleted: boolean, returnDefaultIfVersionNotAvailable: boolean, token: string) => Promise<RelatedRecordOrId[]>;
86
+ /**
87
+ * Get the metric template related requirement templates
88
+ * @param {String} id The id of the record
89
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
90
+ * @param {String} version The version to be retrieved
91
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
92
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
93
+ * @param {String} token Authorization token
94
+ * @returns {Promise<RelatedRecordOrId[]>}
95
+ */
96
+ export declare const getMetricTemplateRelatedRequirementTemplates: (id: string, details: string, version: string, includeDeleted: boolean, returnDefaultIfVersionNotAvailable: boolean, token: string) => Promise<RelatedRecordOrId[]>;
97
+ /**
98
+ * Get the metric template related standard templates
99
+ * @param {String} id The id of the record
100
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
101
+ * @param {String} version The version to be retrieved
102
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
103
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
104
+ * @param {String} token Authorization token
105
+ * @returns {Promise<RelatedRecordOrId[]>}
106
+ */
107
+ export declare const getMetricTemplateRelatedStandardTemplates: (id: string, details: string, version: string, includeDeleted: boolean, returnDefaultIfVersionNotAvailable: boolean, token: string) => Promise<RelatedRecordOrId[]>;
108
+ /**
109
+ * Get the metric template related policy templates
110
+ * @param {String} id The id of the record
111
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
112
+ * @param {String} version The version to be retrieved
113
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
114
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
115
+ * @param {String} token Authorization token
116
+ * @returns {Promise<RelatedRecordOrId[]>}
117
+ */
118
+ export declare const getMetricTemplateRelatedPolicyTemplates: (id: string, details: string, version: string, includeDeleted: boolean, returnDefaultIfVersionNotAvailable: boolean, token: string) => Promise<RelatedRecordOrId[]>;
119
+ //# sourceMappingURL=metricTemplate.d.ts.map
@@ -0,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1,130 @@
1
+ import { client, request } from "./axiosClient.js";
2
+ /**
3
+ * Create metric template and set information
4
+ * @param {Object} data
5
+ * @param {String} token Authorization token
6
+ * @returns {Promise<MetricTemplateRecord>}
7
+ */
8
+ export const createMetricTemplate = (data, token) => request(client.put("/api/v1/admin/metrictemplates", { data }, { headers: { authorization: token } }));
9
+ /**
10
+ * Delete metric template
11
+ * @param {String} id The id of the record to be deleted
12
+ * @param {String} comments The comments included with the deletion
13
+ * @param {String} token Authorization token
14
+ * @returns {Promise<MetricTemplateRecord>}
15
+ */
16
+ export const deleteMetricTemplate = (id, comments, token) => {
17
+ const data = { id };
18
+ if (comments)
19
+ data.comments = comments;
20
+ return request(client.delete("/api/v1/admin/metrictemplates/", { headers: { authorization: token }, data }));
21
+ };
22
+ /**
23
+ * Discard the metric template draft changes
24
+ * @param {String} id The id of the record to be discarded
25
+ * @param {String} token Authorization token
26
+ * @returns {Promise<MetricTemplateRecord>}
27
+ */
28
+ export const discardMetricTemplateChanges = (id, token) => request(client.get(`/api/v1/admin/metrictemplates/discard/${id}`, { headers: { authorization: token } }));
29
+ /**
30
+ * Get metric template information
31
+ * @param {String} id The id of the record
32
+ * @param {String} version The version of the record
33
+ * @param {Boolean} returnNullIfVersionNotFound When true it will return null if the version is not found
34
+ * @param {String} token Authorization token
35
+ * @returns {Promise<MetricTemplateRecord | null>}
36
+ */
37
+ export const getMetricTemplateInformationById = (id, version, returnNullIfVersionNotFound, token) => request(client.get(`/api/v1/admin/metrictemplates/${id}/${version}/${returnNullIfVersionNotFound}`, {
38
+ headers: { authorization: token },
39
+ }));
40
+ /**
41
+ * Get metric template list
42
+ * @param {Array<String>} filter The filter used to select the records
43
+ * @param {String} version The version to be retrieved
44
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
45
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
46
+ * @param {String} token Authorization token
47
+ * @returns {Promise<MetricTemplateRecord[]>}
48
+ */
49
+ export const getMetricTemplateList = (filter, version, includeDeleted, details, token) => {
50
+ const requestData = { includeDeleted, details, version };
51
+ if (filter)
52
+ requestData.filter = filter;
53
+ return request(client.post("/api/v1/admin/metrictemplates", requestData, { headers: { authorization: token } }));
54
+ };
55
+ /**
56
+ * Publish metric template
57
+ * @param {String} id The id of the record to be published
58
+ * @param {String} comments The comments to be include with the request
59
+ * @param {String} token Authorization token
60
+ * @returns {Promise<MetricTemplateRecord>}
61
+ */
62
+ export const publishMetricTemplate = (id, comments, token) => {
63
+ const data = {};
64
+ if (comments)
65
+ data.comments = comments;
66
+ return request(client.post(`/api/v1/admin/metrictemplates/publish/${id}`, data, { headers: { authorization: token } }));
67
+ };
68
+ /**
69
+ * Set metric template information
70
+ * @param {String} id The id of the record to be updated
71
+ * @param {Object} data Data used to update the record
72
+ * @param {String} token Authorization token
73
+ * @returns {Promise<MetricTemplateRecord>}
74
+ */
75
+ export const setMetricTemplateInformation = (id, data, token) => request(client.post(`/api/v1/admin/metrictemplates/update`, { data, id }, { headers: { authorization: token } }));
76
+ /**
77
+ * Update the metric template tags
78
+ * @param {String} id The id of the template to be updated
79
+ * @param {Object} tags Updated template tags
80
+ * @param {String} token Authorization token
81
+ * @returns {Promise<MetricTemplateRecord>}
82
+ */
83
+ export const setMetricTemplateTags = (id, tags, token) => request(client.post(`/api/v1/admin/metrictemplates/updatetags`, { tags, id }, {
84
+ headers: { authorization: token },
85
+ }));
86
+ /**
87
+ * Get the metric template related control templates
88
+ * @param {String} id The id of the record
89
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
90
+ * @param {String} version The version to be retrieved
91
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
92
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
93
+ * @param {String} token Authorization token
94
+ * @returns {Promise<RelatedRecordOrId[]>}
95
+ */
96
+ export const getMetricTemplateRelatedControlTemplates = (id, details, version, includeDeleted, returnDefaultIfVersionNotAvailable, token) => request(client.post(`/api/v1/admin/metrictemplates/controltemplates/${id}`, { details, version, includeDeleted, returnDefaultIfVersionNotAvailable }, { headers: { authorization: token } }));
97
+ /**
98
+ * Get the metric template related requirement templates
99
+ * @param {String} id The id of the record
100
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
101
+ * @param {String} version The version to be retrieved
102
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
103
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
104
+ * @param {String} token Authorization token
105
+ * @returns {Promise<RelatedRecordOrId[]>}
106
+ */
107
+ export const getMetricTemplateRelatedRequirementTemplates = (id, details, version, includeDeleted, returnDefaultIfVersionNotAvailable, token) => request(client.post(`/api/v1/admin/metrictemplates/requirementtemplates/${id}`, { details, version, includeDeleted, returnDefaultIfVersionNotAvailable }, { headers: { authorization: token } }));
108
+ /**
109
+ * Get the metric template related standard templates
110
+ * @param {String} id The id of the record
111
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
112
+ * @param {String} version The version to be retrieved
113
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
114
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
115
+ * @param {String} token Authorization token
116
+ * @returns {Promise<RelatedRecordOrId[]>}
117
+ */
118
+ export const getMetricTemplateRelatedStandardTemplates = (id, details, version, includeDeleted, returnDefaultIfVersionNotAvailable, token) => request(client.post(`/api/v1/admin/metrictemplates/standardtemplates/${id}`, { details, version, includeDeleted, returnDefaultIfVersionNotAvailable }, { headers: { authorization: token } }));
119
+ /**
120
+ * Get the metric template related policy templates
121
+ * @param {String} id The id of the record
122
+ * @param {String} details The level of detail to return ("ID", "NAME", "DEFAULT")
123
+ * @param {String} version The version to be retrieved
124
+ * @param {Boolean} includeDeleted When true it will return the deleted records as well
125
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
126
+ * @param {String} token Authorization token
127
+ * @returns {Promise<RelatedRecordOrId[]>}
128
+ */
129
+ export const getMetricTemplateRelatedPolicyTemplates = (id, details, version, includeDeleted, returnDefaultIfVersionNotAvailable, token) => request(client.post(`/api/v1/admin/metrictemplates/policytemplates/${id}`, { details, version, includeDeleted, returnDefaultIfVersionNotAvailable }, { headers: { authorization: token } }));
130
+ //# sourceMappingURL=metricTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metricTemplate.js","sourceRoot":"","sources":["../../../src/lib/metricTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAYnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAA4B,EAAE,KAAa,EAAiC,EAAE,CACjH,OAAO,CAAuB,MAAM,CAAC,GAAG,CAAC,+BAA+B,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;AAE9H;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAU,EAAE,QAAgB,EAAE,KAAa,EAAiC,EAAE;IACjH,MAAM,IAAI,GAAsC,EAAE,EAAE,EAAE,CAAC;IACvD,IAAI,QAAQ;QAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACvC,OAAO,OAAO,CACZ,MAAM,CAAC,MAAM,CAAC,gCAAgC,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAC7F,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAAU,EAAE,KAAa,EAAiC,EAAE,CACvG,OAAO,CACL,MAAM,CAAC,GAAG,CAAC,yCAAyC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,CAAC,CACjG,CAAC;AAEJ;;;;;;;GAOG;AACH,MAAM,CA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,IAAI,CACT,mDAAmD,EAAE,EAAE,EACvD,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,kCAAkC,EAAE,EACxE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,CACtC,CACF,CAAC;AAEJ;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,CACrD,EAAU,EACV,OAAe,EACf,OAAe,EACf,cAAuB,EACvB,kCAA2C,EAC3C,KAAa,EACiB,EAAE,CAChC,OAAO,CACL,MAAM,CAAC,IAAI,CACT,iDAAiD,EAAE,EAAE,EACrD,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,kCAAkC,EAAE,EACxE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,CACtC,CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackfactor/client-api",
3
- "version": "1.9.2",
3
+ "version": "1.9.4",
4
4
  "description": "Node.js library for the StackFactor API",
5
5
  "publishConfig": {
6
6
  "access": "public"