@jaypie/constructs 1.1.60 → 1.1.61

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.
@@ -17,7 +17,7 @@ export interface JaypieEnvSecretProps {
17
17
  export declare class JaypieEnvSecret extends Construct implements ISecret {
18
18
  private readonly _envKey?;
19
19
  private readonly _secret;
20
- constructor(scope: Construct, id: string, props?: JaypieEnvSecretProps);
20
+ constructor(scope: Construct, idOrEnvKey: string, props?: JaypieEnvSecretProps);
21
21
  get stack(): Stack;
22
22
  get env(): {
23
23
  account: string;
package/dist/esm/index.js CHANGED
@@ -1659,9 +1659,17 @@ function exportEnvName(name, env = process.env) {
1659
1659
  return cleanName(rawName);
1660
1660
  }
1661
1661
  class JaypieEnvSecret extends Construct {
1662
- constructor(scope, id, props) {
1662
+ constructor(scope, idOrEnvKey, props) {
1663
+ // Check if idOrEnvKey should be treated as envKey:
1664
+ // - No props provided OR props.envKey is not set
1665
+ // - AND idOrEnvKey exists as a non-empty string in process.env
1666
+ const treatAsEnvKey = (!props || props.envKey === undefined) &&
1667
+ typeof process.env[idOrEnvKey] === "string" &&
1668
+ process.env[idOrEnvKey] !== "";
1669
+ const id = treatAsEnvKey ? `EnvSecret_${idOrEnvKey}` : idOrEnvKey;
1663
1670
  super(scope, id);
1664
- const { consumer = checkEnvIsConsumer(), envKey, export: exportParam, generateSecretString, provider = checkEnvIsProvider(), roleTag, vendorTag, value, } = props || {};
1671
+ const { consumer = checkEnvIsConsumer(), envKey: envKeyProp, export: exportParam, generateSecretString, provider = checkEnvIsProvider(), roleTag, vendorTag, value, } = props || {};
1672
+ const envKey = treatAsEnvKey ? idOrEnvKey : envKeyProp;
1665
1673
  this._envKey = envKey;
1666
1674
  let exportName;
1667
1675
  if (!exportParam) {