@adobe/aio-cli-plugin-api-mesh 5.2.3 → 5.2.4-alpha.1
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/oclif.manifest.json +1 -1
- package/package.json +4 -2
- package/src/commands/api-mesh/__tests__/cache-purge.test.js +3 -4
- package/src/commands/api-mesh/__tests__/create.test.js +4 -19
- package/src/commands/api-mesh/__tests__/delete-log-forwarding.test.js +106 -0
- package/src/commands/api-mesh/__tests__/delete.test.js +3 -4
- package/src/commands/api-mesh/__tests__/describe.test.js +3 -5
- package/src/commands/api-mesh/__tests__/get-log-forwarding.test.js +149 -0
- package/src/commands/api-mesh/__tests__/get.test.js +4 -4
- package/src/commands/api-mesh/__tests__/log-get-bulk.test.js +21 -215
- package/src/commands/api-mesh/__tests__/log-get.test.js +2 -2
- package/src/commands/api-mesh/__tests__/log-list.test.js +2 -2
- package/src/commands/api-mesh/__tests__/run.test.js +2 -2
- package/src/commands/api-mesh/__tests__/set-log-forwarding.test.js +246 -0
- package/src/commands/api-mesh/__tests__/status.test.js +2 -2
- package/src/commands/api-mesh/__tests__/update.test.js +6 -7
- package/src/commands/api-mesh/cache/purge.js +2 -4
- package/src/commands/api-mesh/config/delete/log-forwarding.js +80 -0
- package/src/commands/api-mesh/config/get/log-forwarding.js +78 -0
- package/src/commands/api-mesh/config/set/log-forwarding.js +156 -0
- package/src/commands/api-mesh/create.js +21 -4
- package/src/commands/api-mesh/delete.js +2 -4
- package/src/commands/api-mesh/describe.js +2 -4
- package/src/commands/api-mesh/get.js +2 -4
- package/src/commands/api-mesh/log-get-bulk.js +6 -27
- package/src/commands/api-mesh/log-get.js +2 -4
- package/src/commands/api-mesh/log-list.js +2 -4
- package/src/commands/api-mesh/run.js +2 -9
- package/src/commands/api-mesh/source/__tests__/install.test.js +2 -2
- package/src/commands/api-mesh/source/discover.js +2 -9
- package/src/commands/api-mesh/source/get.js +1 -8
- package/src/commands/api-mesh/source/install.js +2 -3
- package/src/commands/api-mesh/status.js +2 -3
- package/src/commands/api-mesh/update.js +20 -4
- package/src/helpers.js +72 -5
- package/src/hooks/initMetadata.js +8 -0
- package/src/lib/{devConsole.js → smsClient.js} +299 -0
- package/src/utils.js +60 -22
package/src/utils.js
CHANGED
|
@@ -6,7 +6,6 @@ const { readFile } = require('fs/promises');
|
|
|
6
6
|
const { interpolateMesh } = require('./helpers');
|
|
7
7
|
const dotenv = require('dotenv');
|
|
8
8
|
const YAML = require('yaml');
|
|
9
|
-
const ms = require('ms');
|
|
10
9
|
const parseEnv = require('envsub/js/envsub-parser');
|
|
11
10
|
const os = require('os');
|
|
12
11
|
const chalk = require('chalk');
|
|
@@ -94,11 +93,7 @@ const endTimeFlag = Flags.string({
|
|
|
94
93
|
});
|
|
95
94
|
|
|
96
95
|
const pastFlag = Flags.string({
|
|
97
|
-
description: 'Past time window in
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
const fromFlag = Flags.string({
|
|
101
|
-
description: `The from time in YYYY-MM-DD:HH:MM:SS format based on your system's time zone. It is used to fetch logs from the past and is the starting time for the past time duration.`,
|
|
96
|
+
description: 'Past time window in minutes',
|
|
102
97
|
});
|
|
103
98
|
|
|
104
99
|
const logFilenameFlag = Flags.string({
|
|
@@ -106,6 +101,49 @@ const logFilenameFlag = Flags.string({
|
|
|
106
101
|
required: true,
|
|
107
102
|
});
|
|
108
103
|
|
|
104
|
+
// The `destinations` object to hold the configuration for log forwarding destinations.
|
|
105
|
+
// It prompts for the required inputs for the destination.
|
|
106
|
+
// Each destination can have different key/value pairs of configuration credentials.
|
|
107
|
+
// and applies the validation logic accordingly.
|
|
108
|
+
const destinations = {
|
|
109
|
+
// Configuration for the 'New Relic' destination
|
|
110
|
+
'New Relic': {
|
|
111
|
+
name: 'newrelic', // internal value that will be used
|
|
112
|
+
// Required inputs for the 'New Relic' destination
|
|
113
|
+
inputs: [
|
|
114
|
+
{
|
|
115
|
+
name: 'baseUri',
|
|
116
|
+
promptMessage: 'Enter base URI:',
|
|
117
|
+
isSecret: false,
|
|
118
|
+
validate: value => {
|
|
119
|
+
if (!value) {
|
|
120
|
+
throw new Error('Base URI is required');
|
|
121
|
+
}
|
|
122
|
+
if (!value.startsWith('https://')) {
|
|
123
|
+
throw new Error('The URI value must include the protocol (https://)');
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'licenseKey',
|
|
129
|
+
promptMessage: 'Enter license key:',
|
|
130
|
+
isSecret: true,
|
|
131
|
+
validate: value => {
|
|
132
|
+
if (!value) {
|
|
133
|
+
throw new Error('License key is required');
|
|
134
|
+
}
|
|
135
|
+
if (value.length !== 40) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`The license key is in the wrong format. Expected: 40 characters (received: ${value.length})`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
// Additional destinations can be added here
|
|
145
|
+
};
|
|
146
|
+
|
|
109
147
|
/**
|
|
110
148
|
* Parse the meshConfig and get the list of (local) files to be imported
|
|
111
149
|
*
|
|
@@ -622,23 +660,21 @@ function suggestCorrectedDateFormat(inputDate) {
|
|
|
622
660
|
/**
|
|
623
661
|
* Parses a duration string representing a past time window and converts it to milliseconds.
|
|
624
662
|
*
|
|
625
|
-
* @param {string} pastTimeWindow - The past time duration
|
|
663
|
+
* @param {string} pastTimeWindow - The past time duration in minutes, e.g., "20", "15".
|
|
626
664
|
* @returns {number} The duration in milliseconds.
|
|
627
665
|
*/
|
|
628
666
|
function parsePastDuration(pastTimeWindow) {
|
|
629
|
-
//
|
|
630
|
-
const
|
|
631
|
-
|
|
667
|
+
// Check if pastTimeWindow contains non-numeric characters
|
|
668
|
+
const match = pastTimeWindow.match(/^(\d+)$/);
|
|
669
|
+
|
|
670
|
+
const durationInMs = Number(pastTimeWindow) * 60 * 1000;
|
|
632
671
|
|
|
633
|
-
if (!match) {
|
|
672
|
+
if (isNaN(durationInMs) || !match) {
|
|
634
673
|
throw new Error(
|
|
635
|
-
'Invalid format. The
|
|
674
|
+
'Invalid format. The time window must be an integer, for example "20" or "15".',
|
|
636
675
|
);
|
|
637
676
|
}
|
|
638
677
|
|
|
639
|
-
// Convert the matched duration to milliseconds
|
|
640
|
-
const durationInMs = ms(pastTimeWindow);
|
|
641
|
-
|
|
642
678
|
return durationInMs;
|
|
643
679
|
}
|
|
644
680
|
|
|
@@ -678,14 +714,15 @@ function validateDateTimeRange(startTime, endTime) {
|
|
|
678
714
|
throw new Error('endTime cannot be in the future. Provide a valid endTime.');
|
|
679
715
|
}
|
|
680
716
|
|
|
681
|
-
if (start.getTime() === end.getTime()) {
|
|
682
|
-
throw new Error('The minimum duration is 1 minutes. The current duration is 0 minutes.');
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
// Check if the duration between start and end times is greater than 30 minutes (1800 seconds)
|
|
686
717
|
const timeDifferenceInSeconds = (end.getTime() - start.getTime()) / 1000;
|
|
687
718
|
|
|
688
|
-
if (timeDifferenceInSeconds
|
|
719
|
+
if (timeDifferenceInSeconds < 60) {
|
|
720
|
+
// Check if the duration between start and end times is less than 1 minute (60 seconds)
|
|
721
|
+
throw new Error(
|
|
722
|
+
`The minimum duration is 1 minute. The current duration is ${timeDifferenceInSeconds} seconds.`,
|
|
723
|
+
);
|
|
724
|
+
} else if (timeDifferenceInSeconds > 1800) {
|
|
725
|
+
// Check if the duration between start and end times is greater than 30 minutes (1800 seconds)
|
|
689
726
|
const hours = Math.floor(timeDifferenceInSeconds / 3600); // Hours calculation
|
|
690
727
|
const minutes = Math.floor((timeDifferenceInSeconds % 3600) / 60); // Minutes calculation
|
|
691
728
|
const seconds = timeDifferenceInSeconds % 60; // Seconds calculation
|
|
@@ -726,6 +763,7 @@ function validateDateTimeFormat(time) {
|
|
|
726
763
|
return timeString.replace(/-|:|Z/g, '').replace('T', 'T');
|
|
727
764
|
}
|
|
728
765
|
|
|
766
|
+
// can be used later if we want to take --startTime and --endTime in local time
|
|
729
767
|
/**
|
|
730
768
|
* Convert a given local time string to UTC time string
|
|
731
769
|
* @param {string} timeString - The time string in the format YYYY-MM-DD:HH:MM:SS
|
|
@@ -779,11 +817,11 @@ module.exports = {
|
|
|
779
817
|
endTimeFlag,
|
|
780
818
|
logFilenameFlag,
|
|
781
819
|
pastFlag,
|
|
782
|
-
fromFlag,
|
|
783
820
|
suggestCorrectedDateFormat,
|
|
784
821
|
parsePastDuration,
|
|
785
822
|
validateDateTimeRange,
|
|
786
823
|
validateDateTimeFormat,
|
|
787
824
|
localToUTCTime,
|
|
788
825
|
cachePurgeAllActionFlag,
|
|
826
|
+
destinations,
|
|
789
827
|
};
|