@aws-cdk/toolkit-lib 0.1.5 → 0.1.7

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.
@@ -55,6 +55,7 @@ __export(util_exports, {
55
55
  isEmpty: () => isEmpty,
56
56
  isObject: () => isObject,
57
57
  loadStructuredFile: () => loadStructuredFile,
58
+ lowerCaseFirstCharacter: () => lowerCaseFirstCharacter,
58
59
  makeObject: () => makeObject,
59
60
  mapObject: () => mapObject,
60
61
  maxResourceTypeLength: () => maxResourceTypeLength,
@@ -71,6 +72,7 @@ __export(util_exports, {
71
72
  splitBySize: () => splitBySize,
72
73
  stackEventHasErrorMessage: () => stackEventHasErrorMessage,
73
74
  toYAML: () => toYAML,
75
+ transformObjectKeys: () => transformObjectKeys,
74
76
  validateSnsTopicArn: () => validateSnsTopicArn,
75
77
  zipDirectory: () => zipDirectory
76
78
  });
@@ -276,6 +278,12 @@ var ToolkitError = class _ToolkitError extends Error {
276
278
  static isContextProviderError(x) {
277
279
  return this.isToolkitError(x) && CONTEXT_PROVIDER_ERROR_SYMBOL in x;
278
280
  }
281
+ /**
282
+ * An AssemblyError with an original error as cause
283
+ */
284
+ static withCause(message, error2) {
285
+ return new _ToolkitError(message, "toolkit", error2);
286
+ }
279
287
  /**
280
288
  * The type of the error, defaults to "toolkit".
281
289
  */
@@ -284,13 +292,18 @@ var ToolkitError = class _ToolkitError extends Error {
284
292
  * Denotes the source of the error as the toolkit.
285
293
  */
286
294
  source;
287
- constructor(message, type = "toolkit") {
295
+ /**
296
+ * The specific original cause of the error, if available
297
+ */
298
+ cause;
299
+ constructor(message, type = "toolkit", cause) {
288
300
  super(message);
289
301
  Object.setPrototypeOf(this, _ToolkitError.prototype);
290
302
  Object.defineProperty(this, TOOLKIT_ERROR_SYMBOL, { value: true });
291
303
  this.name = new.target.name;
292
304
  this.type = type;
293
305
  this.source = "toolkit";
306
+ this.cause = cause;
294
307
  }
295
308
  };
296
309
 
@@ -418,6 +431,9 @@ function deepSet(x, path3, value) {
418
431
  }
419
432
  while (path3.length > 1 && isObject(x)) {
420
433
  const key = path3.shift();
434
+ if (isPrototypePollutingKey(key)) {
435
+ continue;
436
+ }
421
437
  if (!(key in x)) {
422
438
  x[key] = {};
423
439
  }
@@ -426,16 +442,23 @@ function deepSet(x, path3, value) {
426
442
  if (!isObject(x)) {
427
443
  throw new ToolkitError(`Expected an object, got '${x}'`);
428
444
  }
445
+ const finalKey = path3[0];
446
+ if (isPrototypePollutingKey(finalKey)) {
447
+ return;
448
+ }
429
449
  if (value !== void 0) {
430
- x[path3[0]] = value;
450
+ x[finalKey] = value;
431
451
  } else {
432
- delete x[path3[0]];
452
+ delete x[finalKey];
433
453
  }
434
454
  }
455
+ function isPrototypePollutingKey(key) {
456
+ return key === "__proto__" || key === "constructor" || key === "prototype";
457
+ }
435
458
  function deepMerge(...objects) {
436
459
  function mergeOne(target, source) {
437
460
  for (const key of Object.keys(source)) {
438
- if (key === "__proto__" || key === "constructor") {
461
+ if (isPrototypePollutingKey(key)) {
439
462
  continue;
440
463
  }
441
464
  const value = source[key];
@@ -480,6 +503,24 @@ function splitBySize(data, maxSizeBytes) {
480
503
  ];
481
504
  }
482
505
  }
506
+ function transformObjectKeys(val, transform, exclude = {}) {
507
+ if (val == null || typeof val !== "object") {
508
+ return val;
509
+ }
510
+ if (Array.isArray(val)) {
511
+ return val.map((input) => transformObjectKeys(input, transform, exclude));
512
+ }
513
+ const ret = {};
514
+ for (const [k, v] of Object.entries(val)) {
515
+ const childExclude = exclude[k];
516
+ if (childExclude === true) {
517
+ ret[transform(k)] = v;
518
+ } else {
519
+ ret[transform(k)] = transformObjectKeys(v, transform, childExclude);
520
+ }
521
+ }
522
+ return ret;
523
+ }
483
524
 
484
525
  // ../tmp-toolkit-helpers/src/util/parallel.ts
485
526
  async function parallelPromises(n, promises) {
@@ -635,6 +676,9 @@ function roundPercentage(num) {
635
676
  function millisecondsToSeconds(num) {
636
677
  return num / 1e3;
637
678
  }
679
+ function lowerCaseFirstCharacter(str) {
680
+ return str.length > 0 ? `${str[0].toLowerCase()}${str.slice(1)}` : str;
681
+ }
638
682
 
639
683
  // ../tmp-toolkit-helpers/src/util/type-brands.ts
640
684
  function createBranded(value) {
@@ -698,6 +742,7 @@ function rangeFromSemver(ver, targetType) {
698
742
  isEmpty,
699
743
  isObject,
700
744
  loadStructuredFile,
745
+ lowerCaseFirstCharacter,
701
746
  makeObject,
702
747
  mapObject,
703
748
  maxResourceTypeLength,
@@ -714,6 +759,7 @@ function rangeFromSemver(ver, targetType) {
714
759
  splitBySize,
715
760
  stackEventHasErrorMessage,
716
761
  toYAML,
762
+ transformObjectKeys,
717
763
  validateSnsTopicArn,
718
764
  zipDirectory
719
765
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["util.ts", "../../../tmp-toolkit-helpers/src/util/archive.ts", "../../../tmp-toolkit-helpers/src/util/format-error.ts", "../../../tmp-toolkit-helpers/src/util/arrays.ts", "../../../tmp-toolkit-helpers/src/util/bool.ts", "../../../tmp-toolkit-helpers/src/util/bytes.ts", "../../../tmp-toolkit-helpers/src/util/cloudformation.ts", "../../../tmp-toolkit-helpers/src/util/content-hash.ts", "../../../tmp-toolkit-helpers/src/util/directories.ts", "../../../tmp-toolkit-helpers/src/api/toolkit-error.ts", "../../../tmp-toolkit-helpers/src/util/json.ts", "../../../tmp-toolkit-helpers/src/util/types.ts", "../../../tmp-toolkit-helpers/src/util/objects.ts", "../../../tmp-toolkit-helpers/src/util/parallel.ts", "../../../tmp-toolkit-helpers/src/util/serialize.ts", "../../../tmp-toolkit-helpers/src/util/yaml-cfn.ts", "../../../tmp-toolkit-helpers/src/util/string-manipulation.ts", "../../../tmp-toolkit-helpers/src/util/type-brands.ts", "../../../tmp-toolkit-helpers/src/util/version-range.ts"],
4
- "sourcesContent": ["/* eslint-disable import/no-restricted-paths */\n\nexport * from '../../../tmp-toolkit-helpers/src/util';\n", "import { error } from 'console';\nimport { createWriteStream, promises as fs } from 'fs';\nimport * as path from 'path';\nimport * as glob from 'glob';\nimport { formatErrorMessage } from './format-error';\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst archiver = require('archiver');\n\n// Adapted from cdk-assets\nexport async function zipDirectory(directory: string, outputFile: string): Promise<void> {\n // We write to a temporary file and rename at the last moment. This is so that if we are\n // interrupted during this process, we don't leave a half-finished file in the target location.\n const temporaryOutputFile = `${outputFile}.${randomString()}._tmp`;\n await writeZipFile(directory, temporaryOutputFile);\n await moveIntoPlace(temporaryOutputFile, outputFile);\n}\n\nfunction writeZipFile(directory: string, outputFile: string): Promise<void> {\n return new Promise(async (ok, fail) => {\n // The below options are needed to support following symlinks when building zip files:\n // - nodir: This will prevent symlinks themselves from being copied into the zip.\n // - follow: This will follow symlinks and copy the files within.\n const globOptions = {\n dot: true,\n nodir: true,\n follow: true,\n cwd: directory,\n };\n const files = glob.sync('**', globOptions); // The output here is already sorted\n\n const output = createWriteStream(outputFile);\n\n const archive = archiver('zip');\n archive.on('warning', fail);\n archive.on('error', fail);\n\n // archive has been finalized and the output file descriptor has closed, resolve promise\n // this has to be done before calling `finalize` since the events may fire immediately after.\n // see https://www.npmjs.com/package/archiver\n output.once('close', ok);\n\n archive.pipe(output);\n\n // Append files serially to ensure file order\n for (const file of files) {\n const fullPath = path.resolve(directory, file);\n // Exactly 2 promises\n // eslint-disable-next-line @cdklabs/promiseall-no-unbounded-parallelism\n const [data, stat] = await Promise.all([fs.readFile(fullPath), fs.stat(fullPath)]);\n archive.append(data, {\n name: file,\n mode: stat.mode,\n });\n }\n\n await archive.finalize();\n });\n}\n\n/**\n * Rename the file to the target location, taking into account:\n *\n * - That we may see EPERM on Windows while an Antivirus scanner still has the\n * file open, so retry a couple of times.\n * - This same function may be called in parallel and be interrupted at any point.\n */\nasync function moveIntoPlace(source: string, target: string) {\n let delay = 100;\n let attempts = 5;\n while (true) {\n try {\n // 'rename' is guaranteed to overwrite an existing target, as long as it is a file (not a directory)\n await fs.rename(source, target);\n return;\n } catch (e: any) {\n if (e.code !== 'EPERM' || attempts-- <= 0) {\n throw e;\n }\n error(formatErrorMessage(e));\n await sleep(Math.floor(Math.random() * delay));\n delay *= 2;\n }\n }\n}\n\nfunction sleep(ms: number) {\n return new Promise(ok => setTimeout(ok, ms));\n}\n\nfunction randomString() {\n return Math.random().toString(36).replace(/[^a-z0-9]+/g, '');\n}\n", "/**\n * Takes in an error and returns a correctly formatted string of its error message.\n * If it is an AggregateError, it will return a string with all the inner errors\n * formatted and separated by a newline.\n *\n * @param error The error to format\n * @returns A string with the error message(s) of the error\n */\nexport function formatErrorMessage(error: any): string {\n if (error && Array.isArray(error.errors)) {\n const innerMessages = error.errors\n .map((innerError: { message: any; toString: () => any }) => (innerError?.message || innerError?.toString()))\n .join('\\n');\n return `AggregateError: ${innerMessages}`;\n }\n\n // Fallback for regular Error or other types\n return error?.message || error?.toString() || 'Unknown error';\n}\n", "/**\n * Map a function over an array and concatenate the results\n */\nexport function flatMap<T, U>(xs: T[], fn: ((x: T, i: number) => U[])): U[] {\n return flatten(xs.map(fn));\n}\n\n/**\n * Flatten a list of lists into a list of elements\n */\nexport function flatten<T>(xs: T[][]): T[] {\n return Array.prototype.concat.apply([], xs);\n}\n\n/**\n * Partition a collection by removing and returning all elements that match a predicate\n *\n * Note: the input collection is modified in-place!\n */\nexport function partition<T>(collection: T[], pred: (x: T) => boolean): T[] {\n const ret: T[] = [];\n let i = 0;\n while (i < collection.length) {\n if (pred(collection[i])) {\n ret.push(collection.splice(i, 1)[0]);\n } else {\n i++;\n }\n }\n return ret;\n}\n", "/**\n * Converts a boolean into a number.\n *\n * @param bool input boolean\n * @returns 1 if bool is true, and 0 if false\n */\nexport function numberFromBool(bool: boolean): number {\n return +bool;\n}\n", "/**\n * Format bytes as a human readable string\n *\n * @param bytes Number of bytes to format\n * @param decimals Number of decimal places to show (default 2)\n * @returns Formatted string with appropriate unit suffix\n */\nexport function formatBytes(bytes: number, decimals: number = 2): string {\n decimals = decimals < 0 ? 0 : decimals;\n\n if (bytes === 0) {\n return '0 Bytes';\n }\n\n const k = 1024;\n const sizes = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];\n\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${sizes[i]}`;\n}\n", "/**\n * Validate SNS topic arn\n */\nexport function validateSnsTopicArn(arn: string): boolean {\n return /^arn:aws:sns:[a-z0-9\\-]+:[0-9]+:[a-z0-9\\-\\_]+$/i.test(arn);\n}\n\n/**\n * Does a Stack Event have an error message based on the status.\n */\nexport function stackEventHasErrorMessage(status: string): boolean {\n return status.endsWith('_FAILED') || status === 'ROLLBACK_IN_PROGRESS' || status === 'UPDATE_ROLLBACK_IN_PROGRESS';\n}\n\n/**\n * Calculate the maximal length of all resource types for a given template.\n *\n * @param template the stack template to analyze\n * @param startWidth the initial width to start with. Defaults to the length of 'AWS::CloudFormation::Stack'.\n * @returns the determined width\n */\nexport function maxResourceTypeLength(template: any, startWidth = 'AWS::CloudFormation::Stack'.length): number {\n const resources = (template && template.Resources) || {};\n let maxWidth = startWidth;\n for (const id of Object.keys(resources)) {\n const type = resources[id].Type || '';\n if (type.length > maxWidth) {\n maxWidth = type.length;\n }\n }\n return maxWidth;\n}\n", "import * as crypto from 'crypto';\n\nexport function contentHash(data: string | Buffer | DataView) {\n return crypto.createHash('sha256').update(data).digest('hex');\n}\n\n/**\n * A stably sorted hash of an arbitrary JS object\n */\nexport function contentHashAny(value: unknown) {\n const ret = crypto.createHash('sha256');\n recurse(value);\n return ret.digest('hex');\n\n function recurse(x: unknown) {\n if (typeof x === 'string') {\n ret.update(x);\n return;\n }\n\n if (Array.isArray(x)) {\n ret.update('[');\n for (const e of x) {\n recurse(e);\n ret.update('||');\n }\n ret.update(']');\n return;\n }\n\n if (x && typeof x === 'object') {\n ret.update('{');\n for (const key of Object.keys(x).sort()) {\n ret.update(key);\n ret.update(':');\n recurse((x as any)[key]);\n }\n ret.update('}');\n return;\n }\n\n ret.update(`${x}${typeof x}`); // typeof to make sure hash('123') !== hash(123)\n }\n}\n", "import * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { ToolkitError } from '../api/toolkit-error';\n\n/**\n * Return a location that will be used as the CDK home directory.\n * Currently the only thing that is placed here is the cache.\n *\n * First try to use the users home directory (i.e. /home/someuser/),\n * but if that directory does not exist for some reason create a tmp directory.\n *\n * Typically it wouldn't make sense to create a one time use tmp directory for\n * the purpose of creating a cache, but since this only applies to users that do\n * not have a home directory (some CI systems?) this should be fine.\n */\nexport function cdkHomeDir() {\n const tmpDir = fs.realpathSync(os.tmpdir());\n let home;\n try {\n let userInfoHome: string | undefined = os.userInfo().homedir;\n // Node returns this if the user doesn't have a home directory\n /* istanbul ignore if: will not happen in normal setups */\n if (userInfoHome == '/var/empty') {\n userInfoHome = undefined;\n }\n home = path.join((userInfoHome ?? os.homedir()).trim(), '.cdk');\n } catch {\n }\n return process.env.CDK_HOME\n ? path.resolve(process.env.CDK_HOME)\n : home || fs.mkdtempSync(path.join(tmpDir, '.cdk')).trim();\n}\n\nexport function cdkCacheDir() {\n return path.join(cdkHomeDir(), 'cache');\n}\n\n/**\n * From the start location, find the directory that contains the bundled package's package.json\n *\n * You must assume the caller of this function will be bundled and the package root dir\n * is not going to be the same as the package the caller currently lives in.\n */\nexport function bundledPackageRootDir(start: string): string;\nexport function bundledPackageRootDir(start: string, fail: true): string;\nexport function bundledPackageRootDir(start: string, fail: false): string | undefined;\nexport function bundledPackageRootDir(start: string, fail?: boolean) {\n function _rootDir(dirname: string): string | undefined {\n const manifestPath = path.join(dirname, 'package.json');\n if (fs.existsSync(manifestPath)) {\n return dirname;\n }\n if (path.dirname(dirname) === dirname) {\n if (fail ?? true) {\n throw new ToolkitError('Unable to find package manifest');\n }\n return undefined;\n }\n return _rootDir(path.dirname(dirname));\n }\n\n return _rootDir(start);\n}\n", "import type * as cxapi from '@aws-cdk/cx-api';\n\nconst TOOLKIT_ERROR_SYMBOL = Symbol.for('@aws-cdk/toolkit-lib.ToolkitError');\nconst AUTHENTICATION_ERROR_SYMBOL = Symbol.for('@aws-cdk/toolkit-lib.AuthenticationError');\nconst ASSEMBLY_ERROR_SYMBOL = Symbol.for('@aws-cdk/toolkit-lib.AssemblyError');\nconst CONTEXT_PROVIDER_ERROR_SYMBOL = Symbol.for('@aws-cdk/toolkit-lib.ContextProviderError');\n\n/**\n * Represents a general toolkit error in the AWS CDK Toolkit.\n */\nexport class ToolkitError extends Error {\n /**\n * Determines if a given error is an instance of ToolkitError.\n */\n public static isToolkitError(x: any): x is ToolkitError {\n return x !== null && typeof(x) === 'object' && TOOLKIT_ERROR_SYMBOL in x;\n }\n\n /**\n * Determines if a given error is an instance of AuthenticationError.\n */\n public static isAuthenticationError(x: any): x is AuthenticationError {\n return this.isToolkitError(x) && AUTHENTICATION_ERROR_SYMBOL in x;\n }\n\n /**\n * Determines if a given error is an instance of AssemblyError.\n */\n public static isAssemblyError(x: any): x is AssemblyError {\n return this.isToolkitError(x) && ASSEMBLY_ERROR_SYMBOL in x;\n }\n\n /**\n * Determines if a given error is an instance of AssemblyError.\n */\n public static isContextProviderError(x: any): x is ContextProviderError {\n return this.isToolkitError(x) && CONTEXT_PROVIDER_ERROR_SYMBOL in x;\n }\n\n /**\n * The type of the error, defaults to \"toolkit\".\n */\n public readonly type: string;\n\n /**\n * Denotes the source of the error as the toolkit.\n */\n public readonly source: 'toolkit' | 'user';\n\n constructor(message: string, type: string = 'toolkit') {\n super(message);\n Object.setPrototypeOf(this, ToolkitError.prototype);\n Object.defineProperty(this, TOOLKIT_ERROR_SYMBOL, { value: true });\n this.name = new.target.name;\n this.type = type;\n this.source = 'toolkit';\n }\n}\n\n/**\n * Represents an authentication-specific error in the AWS CDK Toolkit.\n */\nexport class AuthenticationError extends ToolkitError {\n /**\n * Denotes the source of the error as user.\n */\n public readonly source = 'user';\n\n constructor(message: string) {\n super(message, 'authentication');\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n Object.defineProperty(this, AUTHENTICATION_ERROR_SYMBOL, { value: true });\n }\n}\n\n/**\n * Represents an error causes by cloud assembly synthesis\n *\n * This includes errors thrown during app execution, as well as failing annotations.\n */\nexport class AssemblyError extends ToolkitError {\n /**\n * An AssemblyError with an original error as cause\n */\n public static withCause(message: string, error: unknown): AssemblyError {\n return new AssemblyError(message, undefined, error);\n }\n\n /**\n * An AssemblyError with a list of stacks as cause\n */\n public static withStacks(message: string, stacks?: cxapi.CloudFormationStackArtifact[]): AssemblyError {\n return new AssemblyError(message, stacks);\n }\n\n /**\n * Denotes the source of the error as user.\n */\n public readonly source = 'user';\n\n /**\n * The stacks that caused the error, if available\n *\n * The `messages` property of each `cxapi.CloudFormationStackArtifact` will contain the respective errors.\n * Absence indicates synthesis didn't fully complete.\n */\n public readonly stacks?: cxapi.CloudFormationStackArtifact[];\n\n /**\n * The specific original cause of the error, if available\n */\n public readonly cause?: unknown;\n\n private constructor(message: string, stacks?: cxapi.CloudFormationStackArtifact[], cause?: unknown) {\n super(message, 'assembly');\n Object.setPrototypeOf(this, AssemblyError.prototype);\n Object.defineProperty(this, ASSEMBLY_ERROR_SYMBOL, { value: true });\n this.stacks = stacks;\n this.cause = cause;\n }\n}\n\n/**\n * Represents an error originating from a Context Provider\n */\nexport class ContextProviderError extends ToolkitError {\n /**\n * Denotes the source of the error as user.\n */\n public readonly source = 'user';\n\n constructor(message: string) {\n super(message, 'context-provider');\n Object.setPrototypeOf(this, ContextProviderError.prototype);\n Object.defineProperty(this, CONTEXT_PROVIDER_ERROR_SYMBOL, { value: true });\n }\n}\n", "/**\n * This gets the values of the jsonObject at the paths specified in propertiesToReturn.\n *\n * For example, jsonObject = {\n * key1: 'abc',\n * key2: {\n * foo: 'qwerty',\n * bar: 'data',\n * }\n * }\n *\n * propertiesToReturn = ['key1', 'key2.foo'];\n *\n * The returned object is:\n *\n * ```\n * {\n * key1: 'abc',\n * 'key2.foo': 'qwerty',\n * Identifier: identifier\n * }\n * ```\n */\nexport function getResultObj(jsonObject: any, identifier: string, propertiesToReturn: string[]): {[key: string]: any} {\n const propsObj = {};\n propertiesToReturn.forEach((propName) => {\n Object.assign(propsObj, { [propName]: findJsonValue(jsonObject, propName) });\n });\n Object.assign(propsObj, { ['Identifier']: identifier });\n return propsObj;\n}\n\n/**\n * This finds the value of the jsonObject at the path. Path is delimited by '.'.\n *\n * For example, jsonObject = {\n * key1: 'abc',\n * key2: {\n * foo: 'qwerty',\n * bar: 'data',\n * }\n * }\n *\n * If path is 'key1', then it will return 'abc'.\n * If path is 'key2.foo', then it will return 'qwerty'.\n * If path is 'key2', then it will return the object:\n * {\n * foo: 'qwerty',\n * bar: 'data',\n * }\n *\n * If the path is not found, an Error will be thrown stating which token is missing.\n */\nexport function findJsonValue(jsonObject: any, path: string): any {\n const paths = path.split('.');\n let obj = jsonObject;\n paths.forEach(p => {\n obj = obj[p];\n if (obj === undefined) {\n throw new TypeError(`Cannot read field ${path}. ${p} is not found.`);\n }\n });\n return obj;\n}\n", "/**\n * Type of a map mapping strings to some arbitrary type\n *\n * Name is not ideal, but:\n *\n * - Cannot call it Object, that already means something.\n * - Cannot call it Dict or Dictionary, since in other languages\n * those also allow specifying the key type.\n */\nexport type Obj<T> = {[key: string]: T};\n\n/**\n * Return whether the given value is an object\n *\n * Even though arrays technically are objects, we usually want to treat them differently,\n * so we return false in those cases.\n */\nexport function isObject(x: any): x is Obj<any> {\n return x !== null && typeof x === 'object' && !isArray(x);\n}\n\n/**\n * Return whether the given value is an array\n */\nexport const isArray = Array.isArray;\n\n/**\n * Return the value of the first argument if it's not undefined, otherwise the default\n */\nexport function ifDefined<T>(x: T | undefined, def: T): T {\n return typeof x !== 'undefined' ? x : def;\n}\n", "import type { Obj } from './types';\nimport { isArray, isObject } from './types';\nimport { ToolkitError } from '../api/toolkit-error';\n\n/**\n * Return a new object by adding missing keys into another object\n */\nexport function applyDefaults(hash: any, defaults: any) {\n const result: any = { };\n\n Object.keys(hash).forEach(k => result[k] = hash[k]);\n\n Object.keys(defaults)\n .filter(k => !(k in result))\n .forEach(k => result[k] = defaults[k]);\n\n return result;\n}\n\n/**\n * Return whether the given parameter is an empty object or empty list.\n */\nexport function isEmpty(x: any) {\n if (x == null) {\n return false;\n }\n if (isArray(x)) {\n return x.length === 0;\n }\n return Object.keys(x).length === 0;\n}\n\n/**\n * Deep clone a tree of objects, lists or scalars\n *\n * Does not support cycles.\n */\nexport function deepClone(x: any): any {\n if (typeof x === 'undefined') {\n return undefined;\n }\n if (x === null) {\n return null;\n }\n if (isArray(x)) {\n return x.map(deepClone);\n }\n if (isObject(x)) {\n return makeObject(mapObject(x, (k, v) => [k, deepClone(v)] as [string, any]));\n }\n return x;\n}\n\n/**\n * Map over an object, treating it as a dictionary\n */\nexport function mapObject<T, U>(x: Obj<T>, fn: (key: string, value: T) => U): U[] {\n const ret: U[] = [];\n Object.keys(x).forEach(key => {\n ret.push(fn(key, x[key]));\n });\n return ret;\n}\n\n/**\n * Construct an object from a list of (k, v) pairs\n */\nexport function makeObject<T>(pairs: Array<[string, T]>): Obj<T> {\n const ret: Obj<T> = {};\n for (const pair of pairs) {\n ret[pair[0]] = pair[1];\n }\n return ret;\n}\n\n/**\n * Deep get a value from a tree of nested objects\n *\n * Returns undefined if any part of the path was unset or\n * not an object.\n */\nexport function deepGet(x: any, path: string[]): any {\n path = path.slice();\n\n while (path.length > 0 && isObject(x)) {\n const key = path.shift()!;\n x = x[key];\n }\n return path.length === 0 ? x : undefined;\n}\n\n/**\n * Deep set a value in a tree of nested objects\n *\n * Throws an error if any part of the path is not an object.\n */\nexport function deepSet(x: any, path: string[], value: any) {\n path = path.slice();\n\n if (path.length === 0) {\n throw new ToolkitError('Path may not be empty');\n }\n\n while (path.length > 1 && isObject(x)) {\n const key = path.shift()!;\n if (!(key in x)) {\n x[key] = {};\n }\n x = x[key];\n }\n\n if (!isObject(x)) {\n throw new ToolkitError(`Expected an object, got '${x}'`);\n }\n\n if (value !== undefined) {\n x[path[0]] = value;\n } else {\n delete x[path[0]];\n }\n}\n\n/**\n * Recursively merge objects together\n *\n * The leftmost object is mutated and returned. Arrays are not merged\n * but overwritten just like scalars.\n *\n * If an object is merged into a non-object, the non-object is lost.\n */\nexport function deepMerge(...objects: Array<Obj<any> | undefined>) {\n function mergeOne(target: Obj<any>, source: Obj<any>) {\n for (const key of Object.keys(source)) {\n if (key === '__proto__' || key === 'constructor') {\n continue;\n }\n\n const value = source[key];\n\n if (isObject(value)) {\n if (!isObject(target[key])) {\n target[key] = {};\n } // Overwrite on purpose\n mergeOne(target[key], value);\n } else if (typeof value !== 'undefined') {\n target[key] = value;\n }\n }\n }\n\n const others = objects.filter(x => x != null) as Array<Obj<any>>;\n\n if (others.length === 0) {\n return {};\n }\n const into = others.splice(0, 1)[0];\n\n others.forEach(other => mergeOne(into, other));\n return into;\n}\n\n/**\n * Splits the given object into two, such that:\n *\n * 1. The size of the first object (after stringified in UTF-8) is less than or equal to the provided size limit.\n * 2. Merging the two objects results in the original one.\n */\nexport function splitBySize(data: any, maxSizeBytes: number): [any, any] {\n if (maxSizeBytes < 2) {\n // It's impossible to fit anything in the first object\n return [undefined, data];\n }\n const entries = Object.entries(data);\n return recurse(0, 0);\n\n function recurse(index: number, runningTotalSize: number): [any, any] {\n if (index >= entries.length) {\n // Everything fits in the first object\n return [data, undefined];\n }\n\n const size = runningTotalSize + entrySize(entries[index]);\n return (size > maxSizeBytes) ? cutAt(index) : recurse(index + 1, size);\n }\n\n function entrySize(entry: [string, unknown]) {\n return Buffer.byteLength(JSON.stringify(Object.fromEntries([entry])));\n }\n\n function cutAt(index: number): [any, any] {\n return [\n Object.fromEntries(entries.slice(0, index)),\n Object.fromEntries(entries.slice(index)),\n ];\n }\n}\n", "/**\n * Run a number of promise generators with max parallelism\n *\n * Order is not maintained between the input and output.\n */\nexport async function parallelPromises<A>(n: number, promises: Array<() => Promise<A>>): Promise<Array<A>> {\n const ret = new Array<A>();\n let count = 0;\n let error: Error | undefined;\n const queue = [...promises];\n\n return new Promise((ok, ko) => {\n tick();\n\n function tick() {\n if (count === 0 && error) {\n ko(error);\n return;\n }\n if (count === 0 && queue.length === 0) {\n ok(ret);\n return;\n }\n\n while (count < n && queue.length > 0 && !error) {\n const next = queue.shift();\n if (next !== undefined) {\n start(next);\n }\n }\n }\n\n function start(fn: () => Promise<A>) {\n count += 1;\n fn()\n .then((result) => {\n ret.push(result);\n })\n .catch((e) => {\n error = e;\n })\n .finally(() => {\n count -= 1;\n tick();\n });\n }\n });\n}\n", "import * as fs from 'fs/promises';\nimport { formatBytes } from './bytes';\nimport * as yaml_cfn from './yaml-cfn';\n\n/**\n * Stringify to YAML\n */\nexport function toYAML(obj: any): string {\n return yaml_cfn.serialize(obj);\n}\n\n/**\n * Parse either YAML or JSON\n */\nexport function deserializeStructure(str: string): any {\n return yaml_cfn.deserialize(str);\n}\n\n/**\n * Serialize to either YAML or JSON\n */\nexport function serializeStructure(object: any, json: boolean) {\n if (json) {\n return JSON.stringify(object, undefined, 2);\n } else {\n return toYAML(object);\n }\n}\n\n/**\n * Load a YAML or JSON file from disk\n */\nexport async function loadStructuredFile(fileName: string) {\n const contents = await fs.readFile(fileName, { encoding: 'utf-8' });\n return deserializeStructure(contents);\n}\n\n/**\n * Remove any template elements that we don't want to show users.\n */\nexport function obscureTemplate(template: any = {}) {\n if (template.Rules) {\n // see https://github.com/aws/aws-cdk/issues/17942\n if (template.Rules.CheckBootstrapVersion) {\n if (Object.keys(template.Rules).length > 1) {\n delete template.Rules.CheckBootstrapVersion;\n } else {\n delete template.Rules;\n }\n }\n }\n\n return template;\n}\n\n/**\n * Detects a buffer that has been converted to a JSON-like object\n * In Node, `Buffer`s have `toJSON()` method that converts the buffer\n * into a JS object that can be JSON stringified.\n * Unfortunately this conversion happens before the replacer is called,\n * so normal means of detecting a `Buffer` objet don't work anymore.\n * @see https://github.com/nodejs/node-v0.x-archive/issues/5110\n */\nfunction isJsonBuffer(value: any): value is {\n type: 'Buffer';\n data: number[];\n} {\n return typeof value === 'object'\n && 'type' in value\n && value.type === 'Buffer'\n && 'data' in value\n && Array.isArray(value.data);\n}\n\n/**\n * A JSON.stringify() replacer that converts Buffers into a string with information\n * Use this if you plan to print out JSON stringified objects that may contain a Buffer.\n * Without this, large buffers (think: Megabytes) will completely fill up the output\n * and even crash the system.\n */\nexport function replacerBufferWithInfo(_key: any, value: any): any {\n if (isJsonBuffer(value)) {\n return `<Buffer: ${formatBytes(value.data.length)}>`;\n }\n return value;\n}\n", "import * as yaml from 'yaml';\nimport type * as yaml_cst from 'yaml/parse-cst';\nimport * as yaml_types from 'yaml/types';\n\n/**\n * Serializes the given data structure into valid YAML.\n *\n * @param obj the data structure to serialize\n * @returns a string containing the YAML representation of {@param obj}\n */\nexport function serialize(obj: any): string {\n const oldFold = yaml_types.strOptions.fold.lineWidth;\n try {\n yaml_types.strOptions.fold.lineWidth = 0;\n return yaml.stringify(obj, { schema: 'yaml-1.1' });\n } finally {\n yaml_types.strOptions.fold.lineWidth = oldFold;\n }\n}\n\n/**\n * Deserialize the YAML into the appropriate data structure.\n *\n * @param str the string containing YAML\n * @returns the data structure the YAML represents\n * (most often in case of CloudFormation, an object)\n */\nexport function deserialize(str: string): any {\n return parseYamlStrWithCfnTags(str);\n}\n\nfunction makeTagForCfnIntrinsic(intrinsicName: string, addFnPrefix: boolean): yaml_types.Schema.CustomTag {\n return {\n identify(value: any) {\n return typeof value === 'string';\n },\n tag: `!${intrinsicName}`,\n resolve: (_doc: yaml.Document, cstNode: yaml_cst.CST.Node) => {\n const ret: any = {};\n ret[addFnPrefix ? `Fn::${intrinsicName}` : intrinsicName] =\n // the +1 is to account for the ! the short form begins with\n parseYamlStrWithCfnTags(cstNode.toString().substring(intrinsicName.length + 1));\n return ret;\n },\n };\n}\n\nconst shortForms: yaml_types.Schema.CustomTag[] = [\n 'Base64', 'Cidr', 'FindInMap', 'GetAZs', 'ImportValue', 'Join', 'Sub',\n 'Select', 'Split', 'Transform', 'And', 'Equals', 'If', 'Not', 'Or', 'GetAtt',\n].map(name => makeTagForCfnIntrinsic(name, true)).concat(\n makeTagForCfnIntrinsic('Ref', false),\n makeTagForCfnIntrinsic('Condition', false),\n);\n\nfunction parseYamlStrWithCfnTags(text: string): any {\n return yaml.parse(text, {\n customTags: shortForms,\n schema: 'core',\n });\n}\n", "/**\n * Pad 's' on the left with 'char' until it is n characters wide\n */\nexport function padLeft(n: number, x: string, char: string = ' '): string {\n return char.repeat(Math.max(0, n - x.length)) + x;\n}\n\n/**\n * Pad 's' on the right with 'char' until it is n characters wide\n */\nexport function padRight(n: number, x: string, char: string = ' '): string {\n return x + char.repeat(Math.max(0, n - x.length));\n}\n\n/**\n * Formats time in milliseconds (which we get from 'Date.getTime()')\n * to a human-readable time; returns time in seconds rounded to 2\n * decimal places.\n */\nexport function formatTime(num: number): number {\n return roundPercentage(millisecondsToSeconds(num));\n}\n\n/**\n * Rounds a decimal number to two decimal points.\n * The function is useful for fractions that need to be outputted as percentages.\n */\nfunction roundPercentage(num: number): number {\n return Math.round(100 * num) / 100;\n}\n\n/**\n * Given a time in milliseconds, return an equivalent amount in seconds.\n */\nfunction millisecondsToSeconds(num: number): number {\n return num / 1000;\n}\n", "/**\n * Type branding\n *\n * This allows marking certain types as having gone through particular operations.\n *\n * Branded types can be used anywhere the base type is expected, but the base type\n * cannot be used where a branded type is expected; the values have to go through\n * a type assertion operation to confirm their brand.\n *\n * Usage:\n *\n * ```\n * type ValidatedString = Branded<string, 'PassedMyValidation'>;\n *\n * function validate(x: string): asserts x is ValidatedString {\n * // ... throw an error if not\n * }\n *\n * function isValid(x: string): x is ValidatedString {\n * // ... throw an error if not\n * }\n * ```\n */\n\n// This construct purely happens at type checking time. There is no run-time impact.\n// Hence, we never even have to construct values of this type.\ndeclare const __brand: unique symbol;\n\nexport type Brand<B> = { [__brand]: B };\nexport type Branded<T, B> = T & Brand<B>;\n\n/**\n * Marks a value as being branded a certain way.\n *\n * You should in general avoid calling this, and use validation or\n * asserting functions instead. However, this can be useful to produce\n * values which are branded by construction (really just an elaborate\n * way to write 'as').\n */\n/* c8 ignore next 3 */\nexport function createBranded<A extends Branded<any, any>>(value: TypeUnderlyingBrand<A>): A {\n return value as A;\n}\n\ntype TypeUnderlyingBrand<A> = A extends Branded<infer T, any> ? T : never;\n", "import * as semver from 'semver';\nimport { ToolkitError } from '../api/toolkit-error';\n\n// bracket - https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN401\n// pep - https://www.python.org/dev/peps/pep-0440/#version-specifiers\nexport type RangeType = 'bracket' | 'pep'\n\nexport function rangeFromSemver(ver: string, targetType: RangeType) {\n const re = ver.match(/^([^\\d]*)([\\d.]*)$/);\n if (!re || !semver.valid(re[2])) {\n throw new ToolkitError('not a semver or unsupported range syntax');\n }\n const prefixPart = re[1];\n const verPart = re[2];\n\n switch (targetType) {\n case 'bracket':\n switch (prefixPart) {\n case '':\n // if there's no prefix and the remaining is a valid semver, there's no range specified\n return ver;\n case '^':\n return `[${verPart},${semver.major(verPart)+1}.0.0)`;\n default:\n throw new ToolkitError(`unsupported range syntax - ${prefixPart}`);\n }\n case 'pep':\n switch (prefixPart) {\n case '':\n // if there's no prefix and the remaining is a valid semver, there's no range specified\n return `==${ver}`;\n case '^':\n return `>=${verPart},<${semver.major(verPart)+1}.0.0`;\n default:\n throw new ToolkitError(`unsupported range syntax - ${prefixPart}`);\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AAW,aAAM,OAAO,IAAE,CAAC;AAAA,QAC/C;AACE,gBAAM,IAAI,aAAa,8BAA8B,UAAU,EAAE;AAAA,MACrE;AAAA,IACF,KAAK;AACH,cAAQ,YAAY;AAAA,QAClB,KAAK;AAEH,iBAAO,KAAK,GAAG;AAAA,QACjB,KAAK;AACH,iBAAO,KAAK,OAAO,KAAY,aAAM,OAAO,IAAE,CAAC;AAAA,QACjD;AACE,gBAAM,IAAI,aAAa,8BAA8B,UAAU,EAAE;AAAA,MACrE;AAAA,EACJ;AACF;",
6
- "names": ["error", "fs", "fs", "path", "dirname", "path", "path", "error", "fs"]
4
+ "sourcesContent": ["/* eslint-disable import/no-restricted-paths */\n\nexport * from '../../../tmp-toolkit-helpers/src/util';\n", "import { error } from 'console';\nimport { createWriteStream, promises as fs } from 'fs';\nimport * as path from 'path';\nimport * as glob from 'glob';\nimport { formatErrorMessage } from './format-error';\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst archiver = require('archiver');\n\n// Adapted from cdk-assets\nexport async function zipDirectory(directory: string, outputFile: string): Promise<void> {\n // We write to a temporary file and rename at the last moment. This is so that if we are\n // interrupted during this process, we don't leave a half-finished file in the target location.\n const temporaryOutputFile = `${outputFile}.${randomString()}._tmp`;\n await writeZipFile(directory, temporaryOutputFile);\n await moveIntoPlace(temporaryOutputFile, outputFile);\n}\n\nfunction writeZipFile(directory: string, outputFile: string): Promise<void> {\n return new Promise(async (ok, fail) => {\n // The below options are needed to support following symlinks when building zip files:\n // - nodir: This will prevent symlinks themselves from being copied into the zip.\n // - follow: This will follow symlinks and copy the files within.\n const globOptions = {\n dot: true,\n nodir: true,\n follow: true,\n cwd: directory,\n };\n const files = glob.sync('**', globOptions); // The output here is already sorted\n\n const output = createWriteStream(outputFile);\n\n const archive = archiver('zip');\n archive.on('warning', fail);\n archive.on('error', fail);\n\n // archive has been finalized and the output file descriptor has closed, resolve promise\n // this has to be done before calling `finalize` since the events may fire immediately after.\n // see https://www.npmjs.com/package/archiver\n output.once('close', ok);\n\n archive.pipe(output);\n\n // Append files serially to ensure file order\n for (const file of files) {\n const fullPath = path.resolve(directory, file);\n // Exactly 2 promises\n // eslint-disable-next-line @cdklabs/promiseall-no-unbounded-parallelism\n const [data, stat] = await Promise.all([fs.readFile(fullPath), fs.stat(fullPath)]);\n archive.append(data, {\n name: file,\n mode: stat.mode,\n });\n }\n\n await archive.finalize();\n });\n}\n\n/**\n * Rename the file to the target location, taking into account:\n *\n * - That we may see EPERM on Windows while an Antivirus scanner still has the\n * file open, so retry a couple of times.\n * - This same function may be called in parallel and be interrupted at any point.\n */\nasync function moveIntoPlace(source: string, target: string) {\n let delay = 100;\n let attempts = 5;\n while (true) {\n try {\n // 'rename' is guaranteed to overwrite an existing target, as long as it is a file (not a directory)\n await fs.rename(source, target);\n return;\n } catch (e: any) {\n if (e.code !== 'EPERM' || attempts-- <= 0) {\n throw e;\n }\n error(formatErrorMessage(e));\n await sleep(Math.floor(Math.random() * delay));\n delay *= 2;\n }\n }\n}\n\nfunction sleep(ms: number) {\n return new Promise(ok => setTimeout(ok, ms));\n}\n\nfunction randomString() {\n return Math.random().toString(36).replace(/[^a-z0-9]+/g, '');\n}\n", "/**\n * Takes in an error and returns a correctly formatted string of its error message.\n * If it is an AggregateError, it will return a string with all the inner errors\n * formatted and separated by a newline.\n *\n * @param error The error to format\n * @returns A string with the error message(s) of the error\n */\nexport function formatErrorMessage(error: any): string {\n if (error && Array.isArray(error.errors)) {\n const innerMessages = error.errors\n .map((innerError: { message: any; toString: () => any }) => (innerError?.message || innerError?.toString()))\n .join('\\n');\n return `AggregateError: ${innerMessages}`;\n }\n\n // Fallback for regular Error or other types\n return error?.message || error?.toString() || 'Unknown error';\n}\n", "/**\n * Map a function over an array and concatenate the results\n */\nexport function flatMap<T, U>(xs: T[], fn: ((x: T, i: number) => U[])): U[] {\n return flatten(xs.map(fn));\n}\n\n/**\n * Flatten a list of lists into a list of elements\n */\nexport function flatten<T>(xs: T[][]): T[] {\n return Array.prototype.concat.apply([], xs);\n}\n\n/**\n * Partition a collection by removing and returning all elements that match a predicate\n *\n * Note: the input collection is modified in-place!\n */\nexport function partition<T>(collection: T[], pred: (x: T) => boolean): T[] {\n const ret: T[] = [];\n let i = 0;\n while (i < collection.length) {\n if (pred(collection[i])) {\n ret.push(collection.splice(i, 1)[0]);\n } else {\n i++;\n }\n }\n return ret;\n}\n", "/**\n * Converts a boolean into a number.\n *\n * @param bool input boolean\n * @returns 1 if bool is true, and 0 if false\n */\nexport function numberFromBool(bool: boolean): number {\n return +bool;\n}\n", "/**\n * Format bytes as a human readable string\n *\n * @param bytes Number of bytes to format\n * @param decimals Number of decimal places to show (default 2)\n * @returns Formatted string with appropriate unit suffix\n */\nexport function formatBytes(bytes: number, decimals: number = 2): string {\n decimals = decimals < 0 ? 0 : decimals;\n\n if (bytes === 0) {\n return '0 Bytes';\n }\n\n const k = 1024;\n const sizes = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];\n\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${sizes[i]}`;\n}\n", "/**\n * Validate SNS topic arn\n */\nexport function validateSnsTopicArn(arn: string): boolean {\n return /^arn:aws:sns:[a-z0-9\\-]+:[0-9]+:[a-z0-9\\-\\_]+$/i.test(arn);\n}\n\n/**\n * Does a Stack Event have an error message based on the status.\n */\nexport function stackEventHasErrorMessage(status: string): boolean {\n return status.endsWith('_FAILED') || status === 'ROLLBACK_IN_PROGRESS' || status === 'UPDATE_ROLLBACK_IN_PROGRESS';\n}\n\n/**\n * Calculate the maximal length of all resource types for a given template.\n *\n * @param template the stack template to analyze\n * @param startWidth the initial width to start with. Defaults to the length of 'AWS::CloudFormation::Stack'.\n * @returns the determined width\n */\nexport function maxResourceTypeLength(template: any, startWidth = 'AWS::CloudFormation::Stack'.length): number {\n const resources = (template && template.Resources) || {};\n let maxWidth = startWidth;\n for (const id of Object.keys(resources)) {\n const type = resources[id].Type || '';\n if (type.length > maxWidth) {\n maxWidth = type.length;\n }\n }\n return maxWidth;\n}\n", "import * as crypto from 'crypto';\n\nexport function contentHash(data: string | Buffer | DataView) {\n return crypto.createHash('sha256').update(data).digest('hex');\n}\n\n/**\n * A stably sorted hash of an arbitrary JS object\n */\nexport function contentHashAny(value: unknown) {\n const ret = crypto.createHash('sha256');\n recurse(value);\n return ret.digest('hex');\n\n function recurse(x: unknown) {\n if (typeof x === 'string') {\n ret.update(x);\n return;\n }\n\n if (Array.isArray(x)) {\n ret.update('[');\n for (const e of x) {\n recurse(e);\n ret.update('||');\n }\n ret.update(']');\n return;\n }\n\n if (x && typeof x === 'object') {\n ret.update('{');\n for (const key of Object.keys(x).sort()) {\n ret.update(key);\n ret.update(':');\n recurse((x as any)[key]);\n }\n ret.update('}');\n return;\n }\n\n ret.update(`${x}${typeof x}`); // typeof to make sure hash('123') !== hash(123)\n }\n}\n", "import * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { ToolkitError } from '../api/toolkit-error';\n\n/**\n * Return a location that will be used as the CDK home directory.\n * Currently the only thing that is placed here is the cache.\n *\n * First try to use the users home directory (i.e. /home/someuser/),\n * but if that directory does not exist for some reason create a tmp directory.\n *\n * Typically it wouldn't make sense to create a one time use tmp directory for\n * the purpose of creating a cache, but since this only applies to users that do\n * not have a home directory (some CI systems?) this should be fine.\n */\nexport function cdkHomeDir() {\n const tmpDir = fs.realpathSync(os.tmpdir());\n let home;\n try {\n let userInfoHome: string | undefined = os.userInfo().homedir;\n // Node returns this if the user doesn't have a home directory\n /* istanbul ignore if: will not happen in normal setups */\n if (userInfoHome == '/var/empty') {\n userInfoHome = undefined;\n }\n home = path.join((userInfoHome ?? os.homedir()).trim(), '.cdk');\n } catch {\n }\n return process.env.CDK_HOME\n ? path.resolve(process.env.CDK_HOME)\n : home || fs.mkdtempSync(path.join(tmpDir, '.cdk')).trim();\n}\n\nexport function cdkCacheDir() {\n return path.join(cdkHomeDir(), 'cache');\n}\n\n/**\n * From the start location, find the directory that contains the bundled package's package.json\n *\n * You must assume the caller of this function will be bundled and the package root dir\n * is not going to be the same as the package the caller currently lives in.\n */\nexport function bundledPackageRootDir(start: string): string;\nexport function bundledPackageRootDir(start: string, fail: true): string;\nexport function bundledPackageRootDir(start: string, fail: false): string | undefined;\nexport function bundledPackageRootDir(start: string, fail?: boolean) {\n function _rootDir(dirname: string): string | undefined {\n const manifestPath = path.join(dirname, 'package.json');\n if (fs.existsSync(manifestPath)) {\n return dirname;\n }\n if (path.dirname(dirname) === dirname) {\n if (fail ?? true) {\n throw new ToolkitError('Unable to find package manifest');\n }\n return undefined;\n }\n return _rootDir(path.dirname(dirname));\n }\n\n return _rootDir(start);\n}\n", "import type * as cxapi from '@aws-cdk/cx-api';\n\nconst TOOLKIT_ERROR_SYMBOL = Symbol.for('@aws-cdk/toolkit-lib.ToolkitError');\nconst AUTHENTICATION_ERROR_SYMBOL = Symbol.for('@aws-cdk/toolkit-lib.AuthenticationError');\nconst ASSEMBLY_ERROR_SYMBOL = Symbol.for('@aws-cdk/toolkit-lib.AssemblyError');\nconst CONTEXT_PROVIDER_ERROR_SYMBOL = Symbol.for('@aws-cdk/toolkit-lib.ContextProviderError');\n\n/**\n * Represents a general toolkit error in the AWS CDK Toolkit.\n */\nexport class ToolkitError extends Error {\n /**\n * Determines if a given error is an instance of ToolkitError.\n */\n public static isToolkitError(x: any): x is ToolkitError {\n return x !== null && typeof(x) === 'object' && TOOLKIT_ERROR_SYMBOL in x;\n }\n\n /**\n * Determines if a given error is an instance of AuthenticationError.\n */\n public static isAuthenticationError(x: any): x is AuthenticationError {\n return this.isToolkitError(x) && AUTHENTICATION_ERROR_SYMBOL in x;\n }\n\n /**\n * Determines if a given error is an instance of AssemblyError.\n */\n public static isAssemblyError(x: any): x is AssemblyError {\n return this.isToolkitError(x) && ASSEMBLY_ERROR_SYMBOL in x;\n }\n\n /**\n * Determines if a given error is an instance of AssemblyError.\n */\n public static isContextProviderError(x: any): x is ContextProviderError {\n return this.isToolkitError(x) && CONTEXT_PROVIDER_ERROR_SYMBOL in x;\n }\n\n /**\n * An AssemblyError with an original error as cause\n */\n public static withCause(message: string, error: unknown): ToolkitError {\n return new ToolkitError(message, 'toolkit', error);\n }\n\n /**\n * The type of the error, defaults to \"toolkit\".\n */\n public readonly type: string;\n\n /**\n * Denotes the source of the error as the toolkit.\n */\n public readonly source: 'toolkit' | 'user';\n\n /**\n * The specific original cause of the error, if available\n */\n public readonly cause?: unknown;\n\n constructor(message: string, type: string = 'toolkit', cause?: unknown) {\n super(message);\n Object.setPrototypeOf(this, ToolkitError.prototype);\n Object.defineProperty(this, TOOLKIT_ERROR_SYMBOL, { value: true });\n this.name = new.target.name;\n this.type = type;\n this.source = 'toolkit';\n this.cause = cause;\n }\n}\n\n/**\n * Represents an authentication-specific error in the AWS CDK Toolkit.\n */\nexport class AuthenticationError extends ToolkitError {\n /**\n * Denotes the source of the error as user.\n */\n public readonly source = 'user';\n\n constructor(message: string) {\n super(message, 'authentication');\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n Object.defineProperty(this, AUTHENTICATION_ERROR_SYMBOL, { value: true });\n }\n}\n\n/**\n * Represents an error causes by cloud assembly synthesis\n *\n * This includes errors thrown during app execution, as well as failing annotations.\n */\nexport class AssemblyError extends ToolkitError {\n /**\n * An AssemblyError with an original error as cause\n */\n public static withCause(message: string, error: unknown): AssemblyError {\n return new AssemblyError(message, undefined, error);\n }\n\n /**\n * An AssemblyError with a list of stacks as cause\n */\n public static withStacks(message: string, stacks?: cxapi.CloudFormationStackArtifact[]): AssemblyError {\n return new AssemblyError(message, stacks);\n }\n\n /**\n * Denotes the source of the error as user.\n */\n public readonly source = 'user';\n\n /**\n * The stacks that caused the error, if available\n *\n * The `messages` property of each `cxapi.CloudFormationStackArtifact` will contain the respective errors.\n * Absence indicates synthesis didn't fully complete.\n */\n public readonly stacks?: cxapi.CloudFormationStackArtifact[];\n\n private constructor(message: string, stacks?: cxapi.CloudFormationStackArtifact[], cause?: unknown) {\n super(message, 'assembly', cause);\n Object.setPrototypeOf(this, AssemblyError.prototype);\n Object.defineProperty(this, ASSEMBLY_ERROR_SYMBOL, { value: true });\n this.stacks = stacks;\n }\n}\n\n/**\n * Represents an error originating from a Context Provider\n */\nexport class ContextProviderError extends ToolkitError {\n /**\n * Denotes the source of the error as user.\n */\n public readonly source = 'user';\n\n constructor(message: string) {\n super(message, 'context-provider');\n Object.setPrototypeOf(this, ContextProviderError.prototype);\n Object.defineProperty(this, CONTEXT_PROVIDER_ERROR_SYMBOL, { value: true });\n }\n}\n", "/**\n * This gets the values of the jsonObject at the paths specified in propertiesToReturn.\n *\n * For example, jsonObject = {\n * key1: 'abc',\n * key2: {\n * foo: 'qwerty',\n * bar: 'data',\n * }\n * }\n *\n * propertiesToReturn = ['key1', 'key2.foo'];\n *\n * The returned object is:\n *\n * ```\n * {\n * key1: 'abc',\n * 'key2.foo': 'qwerty',\n * Identifier: identifier\n * }\n * ```\n */\nexport function getResultObj(jsonObject: any, identifier: string, propertiesToReturn: string[]): {[key: string]: any} {\n const propsObj = {};\n propertiesToReturn.forEach((propName) => {\n Object.assign(propsObj, { [propName]: findJsonValue(jsonObject, propName) });\n });\n Object.assign(propsObj, { ['Identifier']: identifier });\n return propsObj;\n}\n\n/**\n * This finds the value of the jsonObject at the path. Path is delimited by '.'.\n *\n * For example, jsonObject = {\n * key1: 'abc',\n * key2: {\n * foo: 'qwerty',\n * bar: 'data',\n * }\n * }\n *\n * If path is 'key1', then it will return 'abc'.\n * If path is 'key2.foo', then it will return 'qwerty'.\n * If path is 'key2', then it will return the object:\n * {\n * foo: 'qwerty',\n * bar: 'data',\n * }\n *\n * If the path is not found, an Error will be thrown stating which token is missing.\n */\nexport function findJsonValue(jsonObject: any, path: string): any {\n const paths = path.split('.');\n let obj = jsonObject;\n paths.forEach(p => {\n obj = obj[p];\n if (obj === undefined) {\n throw new TypeError(`Cannot read field ${path}. ${p} is not found.`);\n }\n });\n return obj;\n}\n", "/**\n * Type of a map mapping strings to some arbitrary type\n *\n * Name is not ideal, but:\n *\n * - Cannot call it Object, that already means something.\n * - Cannot call it Dict or Dictionary, since in other languages\n * those also allow specifying the key type.\n */\nexport type Obj<T> = {[key: string]: T};\n\n/**\n * Return whether the given value is an object\n *\n * Even though arrays technically are objects, we usually want to treat them differently,\n * so we return false in those cases.\n */\nexport function isObject(x: any): x is Obj<any> {\n return x !== null && typeof x === 'object' && !isArray(x);\n}\n\n/**\n * Return whether the given value is an array\n */\nexport const isArray = Array.isArray;\n\n/**\n * Return the value of the first argument if it's not undefined, otherwise the default\n */\nexport function ifDefined<T>(x: T | undefined, def: T): T {\n return typeof x !== 'undefined' ? x : def;\n}\n", "import type { Obj } from './types';\nimport { isArray, isObject } from './types';\nimport { ToolkitError } from '../api/toolkit-error';\n\n/**\n * Return a new object by adding missing keys into another object\n */\nexport function applyDefaults(hash: any, defaults: any) {\n const result: any = { };\n\n Object.keys(hash).forEach(k => result[k] = hash[k]);\n\n Object.keys(defaults)\n .filter(k => !(k in result))\n .forEach(k => result[k] = defaults[k]);\n\n return result;\n}\n\n/**\n * Return whether the given parameter is an empty object or empty list.\n */\nexport function isEmpty(x: any) {\n if (x == null) {\n return false;\n }\n if (isArray(x)) {\n return x.length === 0;\n }\n return Object.keys(x).length === 0;\n}\n\n/**\n * Deep clone a tree of objects, lists or scalars\n *\n * Does not support cycles.\n */\nexport function deepClone(x: any): any {\n if (typeof x === 'undefined') {\n return undefined;\n }\n if (x === null) {\n return null;\n }\n if (isArray(x)) {\n return x.map(deepClone);\n }\n if (isObject(x)) {\n return makeObject(mapObject(x, (k, v) => [k, deepClone(v)] as [string, any]));\n }\n return x;\n}\n\n/**\n * Map over an object, treating it as a dictionary\n */\nexport function mapObject<T, U>(x: Obj<T>, fn: (key: string, value: T) => U): U[] {\n const ret: U[] = [];\n Object.keys(x).forEach(key => {\n ret.push(fn(key, x[key]));\n });\n return ret;\n}\n\n/**\n * Construct an object from a list of (k, v) pairs\n */\nexport function makeObject<T>(pairs: Array<[string, T]>): Obj<T> {\n const ret: Obj<T> = {};\n for (const pair of pairs) {\n ret[pair[0]] = pair[1];\n }\n return ret;\n}\n\n/**\n * Deep get a value from a tree of nested objects\n *\n * Returns undefined if any part of the path was unset or\n * not an object.\n */\nexport function deepGet(x: any, path: string[]): any {\n path = path.slice();\n\n while (path.length > 0 && isObject(x)) {\n const key = path.shift()!;\n x = x[key];\n }\n return path.length === 0 ? x : undefined;\n}\n\n/**\n * Deep set a value in a tree of nested objects\n *\n * Throws an error if any part of the path is not an object.\n */\nexport function deepSet(x: any, path: string[], value: any) {\n path = path.slice();\n\n if (path.length === 0) {\n throw new ToolkitError('Path may not be empty');\n }\n\n while (path.length > 1 && isObject(x)) {\n const key = path.shift()!;\n\n if (isPrototypePollutingKey(key)) {\n continue;\n }\n\n if (!(key in x)) {\n x[key] = {};\n }\n x = x[key];\n }\n\n if (!isObject(x)) {\n throw new ToolkitError(`Expected an object, got '${x}'`);\n }\n\n const finalKey = path[0];\n\n if (isPrototypePollutingKey(finalKey)) {\n return;\n }\n\n if (value !== undefined) {\n x[finalKey] = value;\n } else {\n delete x[finalKey];\n }\n}\n\n/**\n * Helper to detect prototype polluting keys\n *\n * A key matching this, MUST NOT be used in an assignment.\n * Use this to check user-input.\n */\nfunction isPrototypePollutingKey(key: string) {\n return key === '__proto__' || key === 'constructor' || key === 'prototype';\n}\n\n/**\n * Recursively merge objects together\n *\n * The leftmost object is mutated and returned. Arrays are not merged\n * but overwritten just like scalars.\n *\n * If an object is merged into a non-object, the non-object is lost.\n */\nexport function deepMerge(...objects: Array<Obj<any> | undefined>) {\n function mergeOne(target: Obj<any>, source: Obj<any>) {\n for (const key of Object.keys(source)) {\n if (isPrototypePollutingKey(key)) {\n continue;\n }\n\n const value = source[key];\n\n if (isObject(value)) {\n if (!isObject(target[key])) {\n target[key] = {};\n } // Overwrite on purpose\n mergeOne(target[key], value);\n } else if (typeof value !== 'undefined') {\n target[key] = value;\n }\n }\n }\n\n const others = objects.filter(x => x != null) as Array<Obj<any>>;\n\n if (others.length === 0) {\n return {};\n }\n const into = others.splice(0, 1)[0];\n\n others.forEach(other => mergeOne(into, other));\n return into;\n}\n\n/**\n * Splits the given object into two, such that:\n *\n * 1. The size of the first object (after stringified in UTF-8) is less than or equal to the provided size limit.\n * 2. Merging the two objects results in the original one.\n */\nexport function splitBySize(data: any, maxSizeBytes: number): [any, any] {\n if (maxSizeBytes < 2) {\n // It's impossible to fit anything in the first object\n return [undefined, data];\n }\n const entries = Object.entries(data);\n return recurse(0, 0);\n\n function recurse(index: number, runningTotalSize: number): [any, any] {\n if (index >= entries.length) {\n // Everything fits in the first object\n return [data, undefined];\n }\n\n const size = runningTotalSize + entrySize(entries[index]);\n return (size > maxSizeBytes) ? cutAt(index) : recurse(index + 1, size);\n }\n\n function entrySize(entry: [string, unknown]) {\n return Buffer.byteLength(JSON.stringify(Object.fromEntries([entry])));\n }\n\n function cutAt(index: number): [any, any] {\n return [\n Object.fromEntries(entries.slice(0, index)),\n Object.fromEntries(entries.slice(index)),\n ];\n }\n}\n\ntype Exclude = { [key: string]: Exclude | true };\n\n/**\n * This function transforms all keys (recursively) in the provided `val` object.\n *\n * @param val The object whose keys need to be transformed.\n * @param transform The function that will be applied to each key.\n * @param exclude The keys that will not be transformed and copied to output directly\n * @returns A new object with the same values as `val`, but with all keys transformed according to `transform`.\n */\nexport function transformObjectKeys(val: any, transform: (str: string) => string, exclude: Exclude = {}): any {\n if (val == null || typeof val !== 'object') {\n return val;\n }\n if (Array.isArray(val)) {\n // For arrays we just pass parent's exclude object directly\n // since it makes no sense to specify different exclude options for each array element\n return val.map((input: any) => transformObjectKeys(input, transform, exclude));\n }\n const ret: { [k: string]: any } = {};\n for (const [k, v] of Object.entries(val)) {\n const childExclude = exclude[k];\n if (childExclude === true) {\n // we don't transform this object if the key is specified in exclude\n ret[transform(k)] = v;\n } else {\n ret[transform(k)] = transformObjectKeys(v, transform, childExclude);\n }\n }\n return ret;\n}\n", "/**\n * Run a number of promise generators with max parallelism\n *\n * Order is not maintained between the input and output.\n */\nexport async function parallelPromises<A>(n: number, promises: Array<() => Promise<A>>): Promise<Array<A>> {\n const ret = new Array<A>();\n let count = 0;\n let error: Error | undefined;\n const queue = [...promises];\n\n return new Promise((ok, ko) => {\n tick();\n\n function tick() {\n if (count === 0 && error) {\n ko(error);\n return;\n }\n if (count === 0 && queue.length === 0) {\n ok(ret);\n return;\n }\n\n while (count < n && queue.length > 0 && !error) {\n const next = queue.shift();\n if (next !== undefined) {\n start(next);\n }\n }\n }\n\n function start(fn: () => Promise<A>) {\n count += 1;\n fn()\n .then((result) => {\n ret.push(result);\n })\n .catch((e) => {\n error = e;\n })\n .finally(() => {\n count -= 1;\n tick();\n });\n }\n });\n}\n", "import * as fs from 'fs/promises';\nimport { formatBytes } from './bytes';\nimport * as yaml_cfn from './yaml-cfn';\n\n/**\n * Stringify to YAML\n */\nexport function toYAML(obj: any): string {\n return yaml_cfn.serialize(obj);\n}\n\n/**\n * Parse either YAML or JSON\n */\nexport function deserializeStructure(str: string): any {\n return yaml_cfn.deserialize(str);\n}\n\n/**\n * Serialize to either YAML or JSON\n */\nexport function serializeStructure(object: any, json: boolean) {\n if (json) {\n return JSON.stringify(object, undefined, 2);\n } else {\n return toYAML(object);\n }\n}\n\n/**\n * Load a YAML or JSON file from disk\n */\nexport async function loadStructuredFile(fileName: string) {\n const contents = await fs.readFile(fileName, { encoding: 'utf-8' });\n return deserializeStructure(contents);\n}\n\n/**\n * Remove any template elements that we don't want to show users.\n */\nexport function obscureTemplate(template: any = {}) {\n if (template.Rules) {\n // see https://github.com/aws/aws-cdk/issues/17942\n if (template.Rules.CheckBootstrapVersion) {\n if (Object.keys(template.Rules).length > 1) {\n delete template.Rules.CheckBootstrapVersion;\n } else {\n delete template.Rules;\n }\n }\n }\n\n return template;\n}\n\n/**\n * Detects a buffer that has been converted to a JSON-like object\n * In Node, `Buffer`s have `toJSON()` method that converts the buffer\n * into a JS object that can be JSON stringified.\n * Unfortunately this conversion happens before the replacer is called,\n * so normal means of detecting a `Buffer` objet don't work anymore.\n * @see https://github.com/nodejs/node-v0.x-archive/issues/5110\n */\nfunction isJsonBuffer(value: any): value is {\n type: 'Buffer';\n data: number[];\n} {\n return typeof value === 'object'\n && 'type' in value\n && value.type === 'Buffer'\n && 'data' in value\n && Array.isArray(value.data);\n}\n\n/**\n * A JSON.stringify() replacer that converts Buffers into a string with information\n * Use this if you plan to print out JSON stringified objects that may contain a Buffer.\n * Without this, large buffers (think: Megabytes) will completely fill up the output\n * and even crash the system.\n */\nexport function replacerBufferWithInfo(_key: any, value: any): any {\n if (isJsonBuffer(value)) {\n return `<Buffer: ${formatBytes(value.data.length)}>`;\n }\n return value;\n}\n", "import * as yaml from 'yaml';\nimport type * as yaml_cst from 'yaml/parse-cst';\nimport * as yaml_types from 'yaml/types';\n\n/**\n * Serializes the given data structure into valid YAML.\n *\n * @param obj the data structure to serialize\n * @returns a string containing the YAML representation of {@param obj}\n */\nexport function serialize(obj: any): string {\n const oldFold = yaml_types.strOptions.fold.lineWidth;\n try {\n yaml_types.strOptions.fold.lineWidth = 0;\n return yaml.stringify(obj, { schema: 'yaml-1.1' });\n } finally {\n yaml_types.strOptions.fold.lineWidth = oldFold;\n }\n}\n\n/**\n * Deserialize the YAML into the appropriate data structure.\n *\n * @param str the string containing YAML\n * @returns the data structure the YAML represents\n * (most often in case of CloudFormation, an object)\n */\nexport function deserialize(str: string): any {\n return parseYamlStrWithCfnTags(str);\n}\n\nfunction makeTagForCfnIntrinsic(intrinsicName: string, addFnPrefix: boolean): yaml_types.Schema.CustomTag {\n return {\n identify(value: any) {\n return typeof value === 'string';\n },\n tag: `!${intrinsicName}`,\n resolve: (_doc: yaml.Document, cstNode: yaml_cst.CST.Node) => {\n const ret: any = {};\n ret[addFnPrefix ? `Fn::${intrinsicName}` : intrinsicName] =\n // the +1 is to account for the ! the short form begins with\n parseYamlStrWithCfnTags(cstNode.toString().substring(intrinsicName.length + 1));\n return ret;\n },\n };\n}\n\nconst shortForms: yaml_types.Schema.CustomTag[] = [\n 'Base64', 'Cidr', 'FindInMap', 'GetAZs', 'ImportValue', 'Join', 'Sub',\n 'Select', 'Split', 'Transform', 'And', 'Equals', 'If', 'Not', 'Or', 'GetAtt',\n].map(name => makeTagForCfnIntrinsic(name, true)).concat(\n makeTagForCfnIntrinsic('Ref', false),\n makeTagForCfnIntrinsic('Condition', false),\n);\n\nfunction parseYamlStrWithCfnTags(text: string): any {\n return yaml.parse(text, {\n customTags: shortForms,\n schema: 'core',\n });\n}\n", "/**\n * Pad 's' on the left with 'char' until it is n characters wide\n */\nexport function padLeft(n: number, x: string, char: string = ' '): string {\n return char.repeat(Math.max(0, n - x.length)) + x;\n}\n\n/**\n * Pad 's' on the right with 'char' until it is n characters wide\n */\nexport function padRight(n: number, x: string, char: string = ' '): string {\n return x + char.repeat(Math.max(0, n - x.length));\n}\n\n/**\n * Formats time in milliseconds (which we get from 'Date.getTime()')\n * to a human-readable time; returns time in seconds rounded to 2\n * decimal places.\n */\nexport function formatTime(num: number): number {\n return roundPercentage(millisecondsToSeconds(num));\n}\n\n/**\n * Rounds a decimal number to two decimal points.\n * The function is useful for fractions that need to be outputted as percentages.\n */\nfunction roundPercentage(num: number): number {\n return Math.round(100 * num) / 100;\n}\n\n/**\n * Given a time in milliseconds, return an equivalent amount in seconds.\n */\nfunction millisecondsToSeconds(num: number): number {\n return num / 1000;\n}\n\n/**\n * This function lower cases the first character of the string provided.\n */\nexport function lowerCaseFirstCharacter(str: string): string {\n return str.length > 0 ? `${str[0].toLowerCase()}${str.slice(1)}` : str;\n}\n", "/**\n * Type branding\n *\n * This allows marking certain types as having gone through particular operations.\n *\n * Branded types can be used anywhere the base type is expected, but the base type\n * cannot be used where a branded type is expected; the values have to go through\n * a type assertion operation to confirm their brand.\n *\n * Usage:\n *\n * ```\n * type ValidatedString = Branded<string, 'PassedMyValidation'>;\n *\n * function validate(x: string): asserts x is ValidatedString {\n * // ... throw an error if not\n * }\n *\n * function isValid(x: string): x is ValidatedString {\n * // ... throw an error if not\n * }\n * ```\n */\n\n// This construct purely happens at type checking time. There is no run-time impact.\n// Hence, we never even have to construct values of this type.\ndeclare const __brand: unique symbol;\n\nexport type Brand<B> = { [__brand]: B };\nexport type Branded<T, B> = T & Brand<B>;\n\n/**\n * Marks a value as being branded a certain way.\n *\n * You should in general avoid calling this, and use validation or\n * asserting functions instead. However, this can be useful to produce\n * values which are branded by construction (really just an elaborate\n * way to write 'as').\n */\n/* c8 ignore next 3 */\nexport function createBranded<A extends Branded<any, any>>(value: TypeUnderlyingBrand<A>): A {\n return value as A;\n}\n\ntype TypeUnderlyingBrand<A> = A extends Branded<infer T, any> ? T : never;\n", "import * as semver from 'semver';\nimport { ToolkitError } from '../api/toolkit-error';\n\n// bracket - https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN401\n// pep - https://www.python.org/dev/peps/pep-0440/#version-specifiers\nexport type RangeType = 'bracket' | 'pep'\n\nexport function rangeFromSemver(ver: string, targetType: RangeType) {\n const re = ver.match(/^([^\\d]*)([\\d.]*)$/);\n if (!re || !semver.valid(re[2])) {\n throw new ToolkitError('not a semver or unsupported range syntax');\n }\n const prefixPart = re[1];\n const verPart = re[2];\n\n switch (targetType) {\n case 'bracket':\n switch (prefixPart) {\n case '':\n // if there's no prefix and the remaining is a valid semver, there's no range specified\n return ver;\n case '^':\n return `[${verPart},${semver.major(verPart)+1}.0.0)`;\n default:\n throw new ToolkitError(`unsupported range syntax - ${prefixPart}`);\n }\n case 'pep':\n switch (prefixPart) {\n case '':\n // if there's no prefix and the remaining is a valid semver, there's no range specified\n return `==${ver}`;\n case '^':\n return `>=${verPart},<${semver.major(verPart)+1}.0.0`;\n default:\n throw new ToolkitError(`unsupported range syntax - ${prefixPart}`);\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;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AAAA,QAClB,KAAK;AAEH,iBAAO;AAAA,QACT,KAAK;AACH,iBAAO,IAAI,OAAO,IAAW,aAAM,OAAO,IAAE,CAAC;AAAA,QAC/C;AACE,gBAAM,IAAI,aAAa,8BAA8B,UAAU,EAAE;AAAA,MACrE;AAAA,IACF,KAAK;AACH,cAAQ,YAAY;AAAA,QAClB,KAAK;AAEH,iBAAO,KAAK,GAAG;AAAA,QACjB,KAAK;AACH,iBAAO,KAAK,OAAO,KAAY,aAAM,OAAO,IAAE,CAAC;AAAA,QACjD;AACE,gBAAM,IAAI,aAAa,8BAA8B,UAAU,EAAE;AAAA,MACrE;AAAA,EACJ;AACF;",
6
+ "names": ["error", "fs", "fs", "path", "error", "dirname", "path", "path", "error", "fs"]
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import type { ToolkitServices } from './private';
2
- import type { BootstrapEnvironments, BootstrapOptions } from '../actions/bootstrap';
2
+ import type { BootstrapEnvironments, BootstrapOptions, BootstrapResult } from '../actions/bootstrap';
3
3
  import { type DeployOptions } from '../actions/deploy';
4
4
  import { type DestroyOptions } from '../actions/destroy';
5
5
  import { type ListOptions } from '../actions/list';
@@ -76,7 +76,7 @@ export declare class Toolkit extends CloudAssemblySourceBuilder implements Async
76
76
  /**
77
77
  * Bootstrap Action
78
78
  */
79
- bootstrap(environments: BootstrapEnvironments, options: BootstrapOptions): Promise<void>;
79
+ bootstrap(environments: BootstrapEnvironments, options: BootstrapOptions): Promise<BootstrapResult>;
80
80
  /**
81
81
  * Synth Action
82
82
  */