@8ms/helpers 3.0.21 → 3.0.22
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/dist/api/ApiResponseClass.cjs +2 -1
- package/dist/api/ApiResponseClass.mjs +2 -1
- package/dist/aws/server/getAwsConfig.cjs +3 -1
- package/dist/aws/server/getAwsConfig.mjs +3 -1
- package/dist/date/format.cjs +8 -4
- package/dist/date/format.mjs +8 -4
- package/dist/environment/environment.cjs +3 -7
- package/dist/environment/environment.d.cts +1 -0
- package/dist/environment/environment.d.mts +1 -0
- package/dist/environment/environment.mjs +3 -7
- package/dist/util/isUndefined.cjs +2 -1
- package/dist/util/isUndefined.mjs +2 -1
- package/package.json +1 -1
|
@@ -97,8 +97,9 @@ var ApiResponseClass = class ApiResponseClass {
|
|
|
97
97
|
};
|
|
98
98
|
validateZod = (schema) => {
|
|
99
99
|
try {
|
|
100
|
+
const validatedBody = schema.parse(this.body);
|
|
100
101
|
return new ApiResponseClass({
|
|
101
|
-
body:
|
|
102
|
+
body: validatedBody,
|
|
102
103
|
state: this.state
|
|
103
104
|
});
|
|
104
105
|
} catch (error) {
|
|
@@ -96,8 +96,9 @@ var ApiResponseClass = class ApiResponseClass {
|
|
|
96
96
|
};
|
|
97
97
|
validateZod = (schema) => {
|
|
98
98
|
try {
|
|
99
|
+
const validatedBody = schema.parse(this.body);
|
|
99
100
|
return new ApiResponseClass({
|
|
100
|
-
body:
|
|
101
|
+
body: validatedBody,
|
|
101
102
|
state: this.state
|
|
102
103
|
});
|
|
103
104
|
} catch (error) {
|
|
@@ -28,8 +28,10 @@ const getAwsConfig = async (props) => {
|
|
|
28
28
|
if (props.oidcRoleArn && require_environment_environment.isVercel()) {
|
|
29
29
|
const { awsCredentialsProvider } = await import("@vercel/oidc-aws-credentials-provider");
|
|
30
30
|
credentials = await awsCredentialsProvider({ roleArn: props.oidcRoleArn })();
|
|
31
|
+
} else if (props.oidcRoleArn && require_environment_environment.isGoogleCloud()) {
|
|
32
|
+
const gcpToken = await getGcpOidcToken();
|
|
33
|
+
credentials = await assumeAwsRoleWithGcpToken(gcpToken, props);
|
|
31
34
|
}
|
|
32
|
-
if (props.oidcRoleArn && require_environment_environment.isGoogleCloud()) credentials = await assumeAwsRoleWithGcpToken(await getGcpOidcToken(), props);
|
|
33
35
|
return { credentials };
|
|
34
36
|
};
|
|
35
37
|
//#endregion
|
|
@@ -27,8 +27,10 @@ const getAwsConfig = async (props) => {
|
|
|
27
27
|
if (props.oidcRoleArn && isVercel()) {
|
|
28
28
|
const { awsCredentialsProvider } = await import("@vercel/oidc-aws-credentials-provider");
|
|
29
29
|
credentials = await awsCredentialsProvider({ roleArn: props.oidcRoleArn })();
|
|
30
|
+
} else if (props.oidcRoleArn && isGoogleCloud()) {
|
|
31
|
+
const gcpToken = await getGcpOidcToken();
|
|
32
|
+
credentials = await assumeAwsRoleWithGcpToken(gcpToken, props);
|
|
30
33
|
}
|
|
31
|
-
if (props.oidcRoleArn && isGoogleCloud()) credentials = await assumeAwsRoleWithGcpToken(await getGcpOidcToken(), props);
|
|
32
34
|
return { credentials };
|
|
33
35
|
};
|
|
34
36
|
//#endregion
|
package/dist/date/format.cjs
CHANGED
|
@@ -86,25 +86,29 @@ const getYearMonthString = (input) => {
|
|
|
86
86
|
* Shorthand to get the current date.
|
|
87
87
|
*/
|
|
88
88
|
const getTodayYmdString = (setMidnight) => {
|
|
89
|
-
|
|
89
|
+
const today = require_date_calculation.getToday(setMidnight);
|
|
90
|
+
return getYmdString(today);
|
|
90
91
|
};
|
|
91
92
|
/**
|
|
92
93
|
* Shorthand to get the current date.
|
|
93
94
|
*/
|
|
94
95
|
const getTodayYmdHisString = (setMidnight) => {
|
|
95
|
-
|
|
96
|
+
const today = require_date_calculation.getToday(setMidnight);
|
|
97
|
+
return getYmdHisString(today);
|
|
96
98
|
};
|
|
97
99
|
/**
|
|
98
100
|
* Shorthand to get the current date.
|
|
99
101
|
*/
|
|
100
102
|
const getTodayYmdNumber = (setMidnight) => {
|
|
101
|
-
|
|
103
|
+
const today = require_date_calculation.getToday(setMidnight);
|
|
104
|
+
return getYmdNumber(today);
|
|
102
105
|
};
|
|
103
106
|
/**
|
|
104
107
|
* Shorthand to get the current date.
|
|
105
108
|
*/
|
|
106
109
|
const getTodayYmdHisNumber = (setMidnight) => {
|
|
107
|
-
|
|
110
|
+
const today = require_date_calculation.getToday(setMidnight);
|
|
111
|
+
return getYmdHisNumber(today);
|
|
108
112
|
};
|
|
109
113
|
/**
|
|
110
114
|
* Convert a Date into a YYYY number.
|
package/dist/date/format.mjs
CHANGED
|
@@ -85,25 +85,29 @@ const getYearMonthString = (input) => {
|
|
|
85
85
|
* Shorthand to get the current date.
|
|
86
86
|
*/
|
|
87
87
|
const getTodayYmdString = (setMidnight) => {
|
|
88
|
-
|
|
88
|
+
const today = getToday(setMidnight);
|
|
89
|
+
return getYmdString(today);
|
|
89
90
|
};
|
|
90
91
|
/**
|
|
91
92
|
* Shorthand to get the current date.
|
|
92
93
|
*/
|
|
93
94
|
const getTodayYmdHisString = (setMidnight) => {
|
|
94
|
-
|
|
95
|
+
const today = getToday(setMidnight);
|
|
96
|
+
return getYmdHisString(today);
|
|
95
97
|
};
|
|
96
98
|
/**
|
|
97
99
|
* Shorthand to get the current date.
|
|
98
100
|
*/
|
|
99
101
|
const getTodayYmdNumber = (setMidnight) => {
|
|
100
|
-
|
|
102
|
+
const today = getToday(setMidnight);
|
|
103
|
+
return getYmdNumber(today);
|
|
101
104
|
};
|
|
102
105
|
/**
|
|
103
106
|
* Shorthand to get the current date.
|
|
104
107
|
*/
|
|
105
108
|
const getTodayYmdHisNumber = (setMidnight) => {
|
|
106
|
-
|
|
109
|
+
const today = getToday(setMidnight);
|
|
110
|
+
return getYmdHisNumber(today);
|
|
107
111
|
};
|
|
108
112
|
/**
|
|
109
113
|
* Convert a Date into a YYYY number.
|
|
@@ -7,6 +7,7 @@ const environment = {
|
|
|
7
7
|
};
|
|
8
8
|
const platform = {
|
|
9
9
|
AWS: "AWS",
|
|
10
|
+
LOCALHOST: "LOCALHOST",
|
|
10
11
|
VERCEL: "VERCEL",
|
|
11
12
|
GCP: "GCP"
|
|
12
13
|
};
|
|
@@ -37,7 +38,7 @@ const getEnvironment = () => {
|
|
|
37
38
|
* Check to see if we are working on AWS Lambda.
|
|
38
39
|
*/
|
|
39
40
|
const isAws = () => platform.AWS === process.env["EMS_PLATFORM"];
|
|
40
|
-
const isVercel = () =>
|
|
41
|
+
const isVercel = () => platform.VERCEL === process.env["EMS_PLATFORM"];
|
|
41
42
|
const isGoogleCloud = () => platform.GCP === process.env["EMS_PLATFORM"];
|
|
42
43
|
/**
|
|
43
44
|
* Some code should only run on the server side to protect the data.
|
|
@@ -52,12 +53,7 @@ const isProduction = () => environment.PRODUCTION === getEnvironment();
|
|
|
52
53
|
/**
|
|
53
54
|
* Check to see if we are developing locally or on the hosted platform.
|
|
54
55
|
*/
|
|
55
|
-
const isLocalhost = () =>
|
|
56
|
-
if ("true" === process.env["IS_LOCAL"]) return true;
|
|
57
|
-
if (isAws()) return "true" === process.env["AWS_SAM_LOCAL"];
|
|
58
|
-
if (isVercel()) return "undefined" === typeof process.env["NEXT_PUBLIC_VERCEL_GIT_REPO_ID"];
|
|
59
|
-
return false;
|
|
60
|
-
};
|
|
56
|
+
const isLocalhost = () => platform.LOCALHOST === process.env["EMS_PLATFORM"];
|
|
61
57
|
//#endregion
|
|
62
58
|
exports.environment = environment;
|
|
63
59
|
exports.getEnvironment = getEnvironment;
|
|
@@ -6,6 +6,7 @@ const environment = {
|
|
|
6
6
|
};
|
|
7
7
|
const platform = {
|
|
8
8
|
AWS: "AWS",
|
|
9
|
+
LOCALHOST: "LOCALHOST",
|
|
9
10
|
VERCEL: "VERCEL",
|
|
10
11
|
GCP: "GCP"
|
|
11
12
|
};
|
|
@@ -36,7 +37,7 @@ const getEnvironment = () => {
|
|
|
36
37
|
* Check to see if we are working on AWS Lambda.
|
|
37
38
|
*/
|
|
38
39
|
const isAws = () => platform.AWS === process.env["EMS_PLATFORM"];
|
|
39
|
-
const isVercel = () =>
|
|
40
|
+
const isVercel = () => platform.VERCEL === process.env["EMS_PLATFORM"];
|
|
40
41
|
const isGoogleCloud = () => platform.GCP === process.env["EMS_PLATFORM"];
|
|
41
42
|
/**
|
|
42
43
|
* Some code should only run on the server side to protect the data.
|
|
@@ -51,11 +52,6 @@ const isProduction = () => environment.PRODUCTION === getEnvironment();
|
|
|
51
52
|
/**
|
|
52
53
|
* Check to see if we are developing locally or on the hosted platform.
|
|
53
54
|
*/
|
|
54
|
-
const isLocalhost = () =>
|
|
55
|
-
if ("true" === process.env["IS_LOCAL"]) return true;
|
|
56
|
-
if (isAws()) return "true" === process.env["AWS_SAM_LOCAL"];
|
|
57
|
-
if (isVercel()) return "undefined" === typeof process.env["NEXT_PUBLIC_VERCEL_GIT_REPO_ID"];
|
|
58
|
-
return false;
|
|
59
|
-
};
|
|
55
|
+
const isLocalhost = () => platform.LOCALHOST === process.env["EMS_PLATFORM"];
|
|
60
56
|
//#endregion
|
|
61
57
|
export { environment, getEnvironment, isAws, isDevelopment, isGoogleCloud, isLocalhost, isProduction, isServer, isStaging, isVercel, platform };
|
|
@@ -6,7 +6,8 @@ const undefinedValue = "__!!UNDEFINED!!__";
|
|
|
6
6
|
* Check to see if a value is undefined.
|
|
7
7
|
*/
|
|
8
8
|
const isUndefined = (instance, keys) => {
|
|
9
|
-
|
|
9
|
+
const value = require_util_defaultTo.defaultTo(instance, keys, undefinedValue);
|
|
10
|
+
return undefinedValue === value;
|
|
10
11
|
};
|
|
11
12
|
//#endregion
|
|
12
13
|
exports.isUndefined = isUndefined;
|
|
@@ -5,7 +5,8 @@ const undefinedValue = "__!!UNDEFINED!!__";
|
|
|
5
5
|
* Check to see if a value is undefined.
|
|
6
6
|
*/
|
|
7
7
|
const isUndefined = (instance, keys) => {
|
|
8
|
-
|
|
8
|
+
const value = defaultTo(instance, keys, undefinedValue);
|
|
9
|
+
return undefinedValue === value;
|
|
9
10
|
};
|
|
10
11
|
//#endregion
|
|
11
12
|
export { isUndefined };
|