aws-cdk
Version:
AWS CDK CLI, the command line tool for CDK apps
1,101 lines (1,088 loc) • 15.7 MB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
var __typeError = (msg) => {
throw TypeError(msg);
};
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __decorateClass = (decorators, target, key, kind) => {
var result3 = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
for (var i3 = decorators.length - 1, decorator; i3 >= 0; i3--)
if (decorator = decorators[i3])
result3 = (kind ? decorator(target, key, result3) : decorator(result3)) || result3;
if (kind && result3) __defProp(target, key, result3);
return result3;
};
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
var __privateWrapper = (obj, member, setter, getter) => ({
set _(value) {
__privateSet(obj, member, value, setter);
},
get _() {
return __privateGet(obj, member, getter);
}
});
var __using = (stack, value, async) => {
if (value != null) {
if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
var dispose, inner;
if (async) dispose = value[__knownSymbol("asyncDispose")];
if (dispose === void 0) {
dispose = value[__knownSymbol("dispose")];
if (async) inner = dispose;
}
if (typeof dispose !== "function") __typeError("Object not disposable");
if (inner) dispose = function() {
try {
inner.call(this);
} catch (e3) {
return Promise.reject(e3);
}
};
stack.push([async, dispose, value]);
} else if (async) {
stack.push([async]);
}
return value;
};
var __callDispose = (stack, error5, hasError) => {
var E2 = typeof SuppressedError === "function" ? SuppressedError : function(e3, s3, m3, _3) {
return _3 = Error(m3), _3.name = "SuppressedError", _3.error = e3, _3.suppressed = s3, _3;
};
var fail = (e3) => error5 = hasError ? new E2(e3, error5, "An error was suppressed during disposal") : (hasError = true, e3);
var next = (it) => {
while (it = stack.pop()) {
try {
var result3 = it[1] && it[1].call(it[2]);
if (it[0]) return Promise.resolve(result3).then(next, (e3) => (fail(e3), next()));
} catch (e3) {
fail(e3);
}
}
if (hasError) throw error5;
};
return next();
};
// ../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/schema.ts
var ArtifactType;
var init_schema = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/schema.ts"() {
"use strict";
ArtifactType = /* @__PURE__ */ ((ArtifactType3) => {
ArtifactType3["NONE"] = "none";
ArtifactType3["AWS_CLOUDFORMATION_STACK"] = "aws:cloudformation:stack";
ArtifactType3["CDK_TREE"] = "cdk:tree";
ArtifactType3["ASSET_MANIFEST"] = "cdk:asset-manifest";
ArtifactType3["NESTED_CLOUD_ASSEMBLY"] = "cdk:cloud-assembly";
return ArtifactType3;
})(ArtifactType || {});
}
});
// ../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/metadata-schema.ts
var ArtifactMetadataEntryType;
var init_metadata_schema = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/metadata-schema.ts"() {
"use strict";
ArtifactMetadataEntryType = /* @__PURE__ */ ((ArtifactMetadataEntryType4) => {
ArtifactMetadataEntryType4["ASSET"] = "aws:cdk:asset";
ArtifactMetadataEntryType4["INFO"] = "aws:cdk:info";
ArtifactMetadataEntryType4["WARN"] = "aws:cdk:warning";
ArtifactMetadataEntryType4["ERROR"] = "aws:cdk:error";
ArtifactMetadataEntryType4["LOGICAL_ID"] = "aws:cdk:logicalId";
ArtifactMetadataEntryType4["STACK_TAGS"] = "aws:cdk:stack-tags";
return ArtifactMetadataEntryType4;
})(ArtifactMetadataEntryType || {});
}
});
// ../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/artifact-schema.ts
var init_artifact_schema = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/artifact-schema.ts"() {
"use strict";
}
});
// ../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts
var ContextProvider, LoadBalancerType, LoadBalancerListenerProtocol;
var init_context_queries = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts"() {
"use strict";
ContextProvider = /* @__PURE__ */ ((ContextProvider3) => {
ContextProvider3["AMI_PROVIDER"] = "ami";
ContextProvider3["AVAILABILITY_ZONE_PROVIDER"] = "availability-zones";
ContextProvider3["HOSTED_ZONE_PROVIDER"] = "hosted-zone";
ContextProvider3["SSM_PARAMETER_PROVIDER"] = "ssm";
ContextProvider3["VPC_PROVIDER"] = "vpc-provider";
ContextProvider3["ENDPOINT_SERVICE_AVAILABILITY_ZONE_PROVIDER"] = "endpoint-service-availability-zones";
ContextProvider3["LOAD_BALANCER_PROVIDER"] = "load-balancer";
ContextProvider3["LOAD_BALANCER_LISTENER_PROVIDER"] = "load-balancer-listener";
ContextProvider3["SECURITY_GROUP_PROVIDER"] = "security-group";
ContextProvider3["KEY_PROVIDER"] = "key-provider";
ContextProvider3["CC_API_PROVIDER"] = "cc-api-provider";
ContextProvider3["PLUGIN"] = "plugin";
return ContextProvider3;
})(ContextProvider || {});
LoadBalancerType = /* @__PURE__ */ ((LoadBalancerType2) => {
LoadBalancerType2["NETWORK"] = "network";
LoadBalancerType2["APPLICATION"] = "application";
return LoadBalancerType2;
})(LoadBalancerType || {});
LoadBalancerListenerProtocol = /* @__PURE__ */ ((LoadBalancerListenerProtocol2) => {
LoadBalancerListenerProtocol2["HTTP"] = "HTTP";
LoadBalancerListenerProtocol2["HTTPS"] = "HTTPS";
LoadBalancerListenerProtocol2["TCP"] = "TCP";
LoadBalancerListenerProtocol2["TLS"] = "TLS";
LoadBalancerListenerProtocol2["UDP"] = "UDP";
LoadBalancerListenerProtocol2["TCP_UDP"] = "TCP_UDP";
return LoadBalancerListenerProtocol2;
})(LoadBalancerListenerProtocol || {});
}
});
// ../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/interfaces.ts
var init_interfaces = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/interfaces.ts"() {
"use strict";
}
});
// ../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/index.ts
var cloud_assembly_exports = {};
__export(cloud_assembly_exports, {
ArtifactMetadataEntryType: () => ArtifactMetadataEntryType,
ArtifactType: () => ArtifactType,
ContextProvider: () => ContextProvider,
LoadBalancerListenerProtocol: () => LoadBalancerListenerProtocol,
LoadBalancerType: () => LoadBalancerType
});
var init_cloud_assembly = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/index.ts"() {
"use strict";
init_schema();
init_metadata_schema();
init_artifact_schema();
init_context_queries();
init_interfaces();
}
});
// ../@aws-cdk/cloud-assembly-schema/lib/assets/schema.ts
var init_schema2 = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/assets/schema.ts"() {
"use strict";
}
});
// ../@aws-cdk/cloud-assembly-schema/lib/assets/docker-image-asset.ts
var init_docker_image_asset = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/assets/docker-image-asset.ts"() {
"use strict";
}
});
// ../@aws-cdk/cloud-assembly-schema/lib/assets/file-asset.ts
var FileAssetPackaging;
var init_file_asset = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/assets/file-asset.ts"() {
"use strict";
FileAssetPackaging = /* @__PURE__ */ ((FileAssetPackaging4) => {
FileAssetPackaging4["FILE"] = "file";
FileAssetPackaging4["ZIP_DIRECTORY"] = "zip";
return FileAssetPackaging4;
})(FileAssetPackaging || {});
}
});
// ../@aws-cdk/cloud-assembly-schema/lib/assets/aws-destination.ts
var init_aws_destination = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/assets/aws-destination.ts"() {
"use strict";
}
});
// ../@aws-cdk/cloud-assembly-schema/lib/assets/index.ts
var assets_exports = {};
__export(assets_exports, {
FileAssetPackaging: () => FileAssetPackaging
});
var init_assets = __esm({
"../@aws-cdk/cloud-assembly-schema/lib/assets/index.ts"() {
"use strict";
init_schema2();
init_docker_image_asset();
init_file_asset();
init_aws_destination();
}
});
// ../@aws-cdk/cloud-assembly-schema/node_modules/jsonschema/lib/helpers.js
var require_helpers = __commonJS({
"../@aws-cdk/cloud-assembly-schema/node_modules/jsonschema/lib/helpers.js"(exports2, module2) {
"use strict";
var uri = require("url");
var ValidationError = exports2.ValidationError = function ValidationError2(message2, instance, schema, path33, name, argument) {
if (Array.isArray(path33)) {
this.path = path33;
this.property = path33.reduce(function(sum3, item) {
return sum3 + makeSuffix(item);
}, "instance");
} else if (path33 !== void 0) {
this.property = path33;
}
if (message2) {
this.message = message2;
}
if (schema) {
var id = schema.$id || schema.id;
this.schema = id || schema;
}
if (instance !== void 0) {
this.instance = instance;
}
this.name = name;
this.argument = argument;
this.stack = this.toString();
};
ValidationError.prototype.toString = function toString() {
return this.property + " " + this.message;
};
var ValidatorResult = exports2.ValidatorResult = function ValidatorResult2(instance, schema, options, ctx) {
this.instance = instance;
this.schema = schema;
this.options = options;
this.path = ctx.path;
this.propertyPath = ctx.propertyPath;
this.errors = [];
this.throwError = options && options.throwError;
this.throwFirst = options && options.throwFirst;
this.throwAll = options && options.throwAll;
this.disableFormat = options && options.disableFormat === true;
};
ValidatorResult.prototype.addError = function addError(detail) {
var err;
if (typeof detail == "string") {
err = new ValidationError(detail, this.instance, this.schema, this.path);
} else {
if (!detail) throw new Error("Missing error detail");
if (!detail.message) throw new Error("Missing error message");
if (!detail.name) throw new Error("Missing validator type");
err = new ValidationError(detail.message, this.instance, this.schema, this.path, detail.name, detail.argument);
}
this.errors.push(err);
if (this.throwFirst) {
throw new ValidatorResultError(this);
} else if (this.throwError) {
throw err;
}
return err;
};
ValidatorResult.prototype.importErrors = function importErrors(res) {
if (typeof res == "string" || res && res.validatorType) {
this.addError(res);
} else if (res && res.errors) {
this.errors = this.errors.concat(res.errors);
}
};
function stringizer(v6, i3) {
return i3 + ": " + v6.toString() + "\n";
}
ValidatorResult.prototype.toString = function toString(res) {
return this.errors.map(stringizer).join("");
};
Object.defineProperty(ValidatorResult.prototype, "valid", { get: function() {
return !this.errors.length;
} });
module2.exports.ValidatorResultError = ValidatorResultError;
function ValidatorResultError(result3) {
if (Error.captureStackTrace) {
Error.captureStackTrace(this, ValidatorResultError);
}
this.instance = result3.instance;
this.schema = result3.schema;
this.options = result3.options;
this.errors = result3.errors;
}
ValidatorResultError.prototype = new Error();
ValidatorResultError.prototype.constructor = ValidatorResultError;
ValidatorResultError.prototype.name = "Validation Error";
var SchemaError = exports2.SchemaError = function SchemaError2(msg, schema) {
this.message = msg;
this.schema = schema;
Error.call(this, msg);
Error.captureStackTrace(this, SchemaError2);
};
SchemaError.prototype = Object.create(
Error.prototype,
{
constructor: { value: SchemaError, enumerable: false },
name: { value: "SchemaError", enumerable: false }
}
);
var SchemaContext = exports2.SchemaContext = function SchemaContext2(schema, options, path33, base, schemas) {
this.schema = schema;
this.options = options;
if (Array.isArray(path33)) {
this.path = path33;
this.propertyPath = path33.reduce(function(sum3, item) {
return sum3 + makeSuffix(item);
}, "instance");
} else {
this.propertyPath = path33;
}
this.base = base;
this.schemas = schemas;
};
SchemaContext.prototype.resolve = function resolve11(target) {
return uri.resolve(this.base, target);
};
SchemaContext.prototype.makeChild = function makeChild(schema, propertyName) {
var path33 = propertyName === void 0 ? this.path : this.path.concat([propertyName]);
var id = schema.$id || schema.id;
var base = uri.resolve(this.base, id || "");
var ctx = new SchemaContext(schema, this.options, path33, base, Object.create(this.schemas));
if (id && !ctx.schemas[base]) {
ctx.schemas[base] = schema;
}
return ctx;
};
var FORMAT_REGEXPS = exports2.FORMAT_REGEXPS = {
// 7.3.1. Dates, Times, and Duration
"date-time": /^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])[tT ](2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])(\.\d+)?([zZ]|[+-]([0-5][0-9]):(60|[0-5][0-9]))$/,
"date": /^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])$/,
"time": /^(2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])$/,
"duration": /P(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S)|\d+(D|M(\d+D)?|Y(\d+M(\d+D)?)?)(T\d+(H(\d+M(\d+S)?)?|M(\d+S)?|S))?|\d+W)/i,
// 7.3.2. Email Addresses
// TODO: fix the email production
"email": /^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/,
"idn-email": /^("(?:[!#-\[\]-\u{10FFFF}]|\\[\t -\u{10FFFF}])*"|[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*)@([!#-'*+\-/-9=?A-Z\^-\u{10FFFF}](?:\.?[!#-'*+\-/-9=?A-Z\^-\u{10FFFF}])*|\[[!-Z\^-\u{10FFFF}]*\])$/u,
// 7.3.3. Hostnames
// 7.3.4. IP Addresses
"ip-address": /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
// FIXME whitespace is invalid
"ipv6": /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,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(\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?:\d*|\[(([Vv][0-9A-Fa-f]+\.[!$&-.0-;=A-Z_a-z~-\u{10FFFF}]+)?|[.0-:A-Fa-f]+)\])?)?|[A-Za-z][+\-.0-9A-Za-z]*:?)?$/u,
"uuid": /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
// 7.3.6. uri-template
"uri-template": /(%[0-9a-f]{2}|[!#$&(-;=?@\[\]_a-z~]|\{[!#&+,./;=?@|]?(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?(,(%[0-9a-f]{2}|[0-9_a-z])(\.?(%[0-9a-f]{2}|[0-9_a-z]))*(:[1-9]\d{0,3}|\*)?)*\})*/iu,
// 7.3.7. JSON Pointers
"json-pointer": /^(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*$/iu,
"relative-json-pointer": /^\d+(#|(\/([\x00-\x2e0-@\[-}\x7f]|~[01])*)*)$/iu,
// hostname regex from: http://stackoverflow.com/a/1420225/5628
"hostname": /^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,
"host-name": /^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,
"utc-millisec": function(input) {
return typeof input === "string" && parseFloat(input) === parseInt(input, 10) && !isNaN(input);
},
// 7.3.8. regex
"regex": function(input) {
var result3 = true;
try {
new RegExp(input);
} catch (e3) {
result3 = false;
}
return result3;
},
// Other definitions
// "style" was removed from JSON Schema in draft-4 and is deprecated
"style": /[\r\n\t ]*[^\r\n\t ][^:]*:[\r\n\t ]*[^\r\n\t ;]*[\r\n\t ]*;?/,
// "color" was removed from JSON Schema in draft-4 and is deprecated
"color": /^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,
"phone": /^\+(?:[0-9] ?){6,14}[0-9]$/,
"alpha": /^[a-zA-Z]+$/,
"alphanumeric": /^[a-zA-Z0-9]+$/
};
FORMAT_REGEXPS.regexp = FORMAT_REGEXPS.regex;
FORMAT_REGEXPS.pattern = FORMAT_REGEXPS.regex;
FORMAT_REGEXPS.ipv4 = FORMAT_REGEXPS["ip-address"];
exports2.isFormat = function isFormat(input, format24, validator) {
if (typeof input === "string" && FORMAT_REGEXPS[format24] !== void 0) {
if (FORMAT_REGEXPS[format24] instanceof RegExp) {
return FORMAT_REGEXPS[format24].test(input);
}
if (typeof FORMAT_REGEXPS[format24] === "function") {
return FORMAT_REGEXPS[format24](input);
}
} else if (validator && validator.customFormats && typeof validator.customFormats[format24] === "function") {
return validator.customFormats[format24](input);
}
return true;
};
var makeSuffix = exports2.makeSuffix = function makeSuffix2(key) {
key = key.toString();
if (!key.match(/[.\s\[\]]/) && !key.match(/^[\d]/)) {
return "." + key;
}
if (key.match(/^\d+$/)) {
return "[" + key + "]";
}
return "[" + JSON.stringify(key) + "]";
};
exports2.deepCompareStrict = function deepCompareStrict(a3, b3) {
if (typeof a3 !== typeof b3) {
return false;
}
if (Array.isArray(a3)) {
if (!Array.isArray(b3)) {
return false;
}
if (a3.length !== b3.length) {
return false;
}
return a3.every(function(v6, i3) {
return deepCompareStrict(a3[i3], b3[i3]);
});
}
if (typeof a3 === "object") {
if (!a3 || !b3) {
return a3 === b3;
}
var aKeys = Object.keys(a3);
var bKeys = Object.keys(b3);
if (aKeys.length !== bKeys.length) {
return false;
}
return aKeys.every(function(v6) {
return deepCompareStrict(a3[v6], b3[v6]);
});
}
return a3 === b3;
};
function deepMerger(target, dst, e3, i3) {
if (typeof e3 === "object") {
dst[i3] = deepMerge2(target[i3], e3);
} else {
if (target.indexOf(e3) === -1) {
dst.push(e3);
}
}
}
function copyist(src, dst, key) {
dst[key] = src[key];
}
function copyistWithDeepMerge(target, src, dst, key) {
if (typeof src[key] !== "object" || !src[key]) {
dst[key] = src[key];
} else {
if (!target[key]) {
dst[key] = src[key];
} else {
dst[key] = deepMerge2(target[key], src[key]);
}
}
}
function deepMerge2(target, src) {
var array = Array.isArray(src);
var dst = array && [] || {};
if (array) {
target = target || [];
dst = dst.concat(target);
src.forEach(deepMerger.bind(null, target, dst));
} else {
if (target && typeof target === "object") {
Object.keys(target).forEach(copyist.bind(null, target, dst));
}
Object.keys(src).forEach(copyistWithDeepMerge.bind(null, target, src, dst));
}
return dst;
}
module2.exports.deepMerge = deepMerge2;
exports2.objectGetPath = function objectGetPath(o3, s3) {
var parts = s3.split("/").slice(1);
var k3;
while (typeof (k3 = parts.shift()) == "string") {
var n3 = decodeURIComponent(k3.replace(/~0/, "~").replace(/~1/g, "/"));
if (!(n3 in o3)) return;
o3 = o3[n3];
}
return o3;
};
function pathEncoder(v6) {
return "/" + encodeURIComponent(v6).replace(/~/g, "%7E");
}
exports2.encodePath = function encodePointer(a3) {
return a3.map(pathEncoder).join("");
};
exports2.getDecimalPlaces = function getDecimalPlaces(number) {
var decimalPlaces = 0;
if (isNaN(number)) return decimalPlaces;
if (typeof number !== "number") {
number = Number(number);
}
var parts = number.toString().split("e");
if (parts.length === 2) {
if (parts[1][0] !== "-") {
return decimalPlaces;
} else {
decimalPlaces = Number(parts[1].slice(1));
}
}
var decimalParts = parts[0].split(".");
if (decimalParts.length === 2) {
decimalPlaces += decimalParts[1].length;
}
return decimalPlaces;
};
exports2.isSchema = function isSchema(val2) {
return typeof val2 === "object" && val2 || typeof val2 === "boolean";
};
}
});
// ../@aws-cdk/cloud-assembly-schema/node_modules/jsonschema/lib/attribute.js
var require_attribute = __commonJS({
"../@aws-cdk/cloud-assembly-schema/node_modules/jsonschema/lib/attribute.js"(exports2, module2) {
"use strict";
var helpers = require_helpers();
var ValidatorResult = helpers.ValidatorResult;
var SchemaError = helpers.SchemaError;
var attribute = {};
attribute.ignoreProperties = {
// informative properties
"id": true,
"default": true,
"description": true,
"title": true,
// arguments to other properties
"additionalItems": true,
"then": true,
"else": true,
// special-handled properties
"$schema": true,
"$ref": true,
"extends": true
};
var validators = attribute.validators = {};
validators.type = function validateType(instance, schema, options, ctx) {
if (instance === void 0) {
return null;
}
var result3 = new ValidatorResult(instance, schema, options, ctx);
var types5 = Array.isArray(schema.type) ? schema.type : [schema.type];
if (!types5.some(this.testType.bind(this, instance, schema, options, ctx))) {
var list = types5.map(function(v6) {
if (!v6) return;
var id = v6.$id || v6.id;
return id ? "<" + id + ">" : v6 + "";
});
result3.addError({
name: "type",
argument: list,
message: "is not of a type(s) " + list
});
}
return result3;
};
function testSchemaNoThrow(instance, options, ctx, callback, schema) {
var throwError = options.throwError;
var throwAll = options.throwAll;
options.throwError = false;
options.throwAll = false;
var res = this.validateSchema(instance, schema, options, ctx);
options.throwError = throwError;
options.throwAll = throwAll;
if (!res.valid && callback instanceof Function) {
callback(res);
}
return res.valid;
}
validators.anyOf = function validateAnyOf(instance, schema, options, ctx) {
if (instance === void 0) {
return null;
}
var result3 = new ValidatorResult(instance, schema, options, ctx);
var inner = new ValidatorResult(instance, schema, options, ctx);
if (!Array.isArray(schema.anyOf)) {
throw new SchemaError("anyOf must be an array");
}
if (!schema.anyOf.some(
testSchemaNoThrow.bind(
this,
instance,
options,
ctx,
function(res) {
inner.importErrors(res);
}
)
)) {
var list = schema.anyOf.map(function(v6, i3) {
var id = v6.$id || v6.id;
if (id) return "<" + id + ">";
return v6.title && JSON.stringify(v6.title) || v6["$ref"] && "<" + v6["$ref"] + ">" || "[subschema " + i3 + "]";
});
if (options.nestedErrors) {
result3.importErrors(inner);
}
result3.addError({
name: "anyOf",
argument: list,
message: "is not any of " + list.join(",")
});
}
return result3;
};
validators.allOf = function validateAllOf(instance, schema, options, ctx) {
if (instance === void 0) {
return null;
}
if (!Array.isArray(schema.allOf)) {
throw new SchemaError("allOf must be an array");
}
var result3 = new ValidatorResult(instance, schema, options, ctx);
var self2 = this;
schema.allOf.forEach(function(v6, i3) {
var valid3 = self2.validateSchema(instance, v6, options, ctx);
if (!valid3.valid) {
var id = v6.$id || v6.id;
var msg = id || v6.title && JSON.stringify(v6.title) || v6["$ref"] && "<" + v6["$ref"] + ">" || "[subschema " + i3 + "]";
result3.addError({
name: "allOf",
argument: { id: msg, length: valid3.errors.length, valid: valid3 },
message: "does not match allOf schema " + msg + " with " + valid3.errors.length + " error[s]:"
});
result3.importErrors(valid3);
}
});
return result3;
};
validators.oneOf = function validateOneOf(instance, schema, options, ctx) {
if (instance === void 0) {
return null;
}
if (!Array.isArray(schema.oneOf)) {
throw new SchemaError("oneOf must be an array");
}
var result3 = new ValidatorResult(instance, schema, options, ctx);
var inner = new ValidatorResult(instance, schema, options, ctx);
var count = schema.oneOf.filter(
testSchemaNoThrow.bind(
this,
instance,
options,
ctx,
function(res) {
inner.importErrors(res);
}
)
).length;
var list = schema.oneOf.map(function(v6, i3) {
var id = v6.$id || v6.id;
return id || v6.title && JSON.stringify(v6.title) || v6["$ref"] && "<" + v6["$ref"] + ">" || "[subschema " + i3 + "]";
});
if (count !== 1) {
if (options.nestedErrors) {
result3.importErrors(inner);
}
result3.addError({
name: "oneOf",
argument: list,
message: "is not exactly one from " + list.join(",")
});
}
return result3;
};
validators.if = function validateIf(instance, schema, options, ctx) {
if (instance === void 0) return null;
if (!helpers.isSchema(schema.if)) throw new Error('Expected "if" keyword to be a schema');
var ifValid = testSchemaNoThrow.call(this, instance, options, ctx, null, schema.if);
var result3 = new ValidatorResult(instance, schema, options, ctx);
var res;
if (ifValid) {
if (schema.then === void 0) return;
if (!helpers.isSchema(schema.then)) throw new Error('Expected "then" keyword to be a schema');
res = this.validateSchema(instance, schema.then, options, ctx.makeChild(schema.then));
result3.importErrors(res);
} else {
if (schema.else === void 0) return;
if (!helpers.isSchema(schema.else)) throw new Error('Expected "else" keyword to be a schema');
res = this.validateSchema(instance, schema.else, options, ctx.makeChild(schema.else));
result3.importErrors(res);
}
return result3;
};
function getEnumerableProperty(object, key) {
if (Object.hasOwnProperty.call(object, key)) return object[key];
if (!(key in object)) return;
while (object = Object.getPrototypeOf(object)) {
if (Object.propertyIsEnumerable.call(object, key)) return object[key];
}
}
validators.propertyNames = function validatePropertyNames(instance, schema, options, ctx) {
if (!this.types.object(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
var subschema = schema.propertyNames !== void 0 ? schema.propertyNames : {};
if (!helpers.isSchema(subschema)) throw new SchemaError('Expected "propertyNames" to be a schema (object or boolean)');
for (var property in instance) {
if (getEnumerableProperty(instance, property) !== void 0) {
var res = this.validateSchema(property, subschema, options, ctx.makeChild(subschema));
result3.importErrors(res);
}
}
return result3;
};
validators.properties = function validateProperties(instance, schema, options, ctx) {
if (!this.types.object(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
var properties = schema.properties || {};
for (var property in properties) {
var subschema = properties[property];
if (subschema === void 0) {
continue;
} else if (subschema === null) {
throw new SchemaError('Unexpected null, expected schema in "properties"');
}
if (typeof options.preValidateProperty == "function") {
options.preValidateProperty(instance, property, subschema, options, ctx);
}
var prop = getEnumerableProperty(instance, property);
var res = this.validateSchema(prop, subschema, options, ctx.makeChild(subschema, property));
if (res.instance !== result3.instance[property]) result3.instance[property] = res.instance;
result3.importErrors(res);
}
return result3;
};
function testAdditionalProperty(instance, schema, options, ctx, property, result3) {
if (!this.types.object(instance)) return;
if (schema.properties && schema.properties[property] !== void 0) {
return;
}
if (schema.additionalProperties === false) {
result3.addError({
name: "additionalProperties",
argument: property,
message: "is not allowed to have the additional property " + JSON.stringify(property)
});
} else {
var additionalProperties = schema.additionalProperties || {};
if (typeof options.preValidateProperty == "function") {
options.preValidateProperty(instance, property, additionalProperties, options, ctx);
}
var res = this.validateSchema(instance[property], additionalProperties, options, ctx.makeChild(additionalProperties, property));
if (res.instance !== result3.instance[property]) result3.instance[property] = res.instance;
result3.importErrors(res);
}
}
validators.patternProperties = function validatePatternProperties(instance, schema, options, ctx) {
if (!this.types.object(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
var patternProperties = schema.patternProperties || {};
for (var property in instance) {
var test = true;
for (var pattern in patternProperties) {
var subschema = patternProperties[pattern];
if (subschema === void 0) {
continue;
} else if (subschema === null) {
throw new SchemaError('Unexpected null, expected schema in "patternProperties"');
}
try {
var regexp = new RegExp(pattern, "u");
} catch (_e) {
regexp = new RegExp(pattern);
}
if (!regexp.test(property)) {
continue;
}
test = false;
if (typeof options.preValidateProperty == "function") {
options.preValidateProperty(instance, property, subschema, options, ctx);
}
var res = this.validateSchema(instance[property], subschema, options, ctx.makeChild(subschema, property));
if (res.instance !== result3.instance[property]) result3.instance[property] = res.instance;
result3.importErrors(res);
}
if (test) {
testAdditionalProperty.call(this, instance, schema, options, ctx, property, result3);
}
}
return result3;
};
validators.additionalProperties = function validateAdditionalProperties(instance, schema, options, ctx) {
if (!this.types.object(instance)) return;
if (schema.patternProperties) {
return null;
}
var result3 = new ValidatorResult(instance, schema, options, ctx);
for (var property in instance) {
testAdditionalProperty.call(this, instance, schema, options, ctx, property, result3);
}
return result3;
};
validators.minProperties = function validateMinProperties(instance, schema, options, ctx) {
if (!this.types.object(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
var keys = Object.keys(instance);
if (!(keys.length >= schema.minProperties)) {
result3.addError({
name: "minProperties",
argument: schema.minProperties,
message: "does not meet minimum property length of " + schema.minProperties
});
}
return result3;
};
validators.maxProperties = function validateMaxProperties(instance, schema, options, ctx) {
if (!this.types.object(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
var keys = Object.keys(instance);
if (!(keys.length <= schema.maxProperties)) {
result3.addError({
name: "maxProperties",
argument: schema.maxProperties,
message: "does not meet maximum property length of " + schema.maxProperties
});
}
return result3;
};
validators.items = function validateItems(instance, schema, options, ctx) {
var self2 = this;
if (!this.types.array(instance)) return;
if (schema.items === void 0) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
instance.every(function(value, i3) {
if (Array.isArray(schema.items)) {
var items = schema.items[i3] === void 0 ? schema.additionalItems : schema.items[i3];
} else {
var items = schema.items;
}
if (items === void 0) {
return true;
}
if (items === false) {
result3.addError({
name: "items",
message: "additionalItems not permitted"
});
return false;
}
var res = self2.validateSchema(value, items, options, ctx.makeChild(items, i3));
if (res.instance !== result3.instance[i3]) result3.instance[i3] = res.instance;
result3.importErrors(res);
return true;
});
return result3;
};
validators.contains = function validateContains(instance, schema, options, ctx) {
var self2 = this;
if (!this.types.array(instance)) return;
if (schema.contains === void 0) return;
if (!helpers.isSchema(schema.contains)) throw new Error('Expected "contains" keyword to be a schema');
var result3 = new ValidatorResult(instance, schema, options, ctx);
var count = instance.some(function(value, i3) {
var res = self2.validateSchema(value, schema.contains, options, ctx.makeChild(schema.contains, i3));
return res.errors.length === 0;
});
if (count === false) {
result3.addError({
name: "contains",
argument: schema.contains,
message: "must contain an item matching given schema"
});
}
return result3;
};
validators.minimum = function validateMinimum(instance, schema, options, ctx) {
if (!this.types.number(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
if (schema.exclusiveMinimum && schema.exclusiveMinimum === true) {
if (!(instance > schema.minimum)) {
result3.addError({
name: "minimum",
argument: schema.minimum,
message: "must be greater than " + schema.minimum
});
}
} else {
if (!(instance >= schema.minimum)) {
result3.addError({
name: "minimum",
argument: schema.minimum,
message: "must be greater than or equal to " + schema.minimum
});
}
}
return result3;
};
validators.maximum = function validateMaximum(instance, schema, options, ctx) {
if (!this.types.number(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
if (schema.exclusiveMaximum && schema.exclusiveMaximum === true) {
if (!(instance < schema.maximum)) {
result3.addError({
name: "maximum",
argument: schema.maximum,
message: "must be less than " + schema.maximum
});
}
} else {
if (!(instance <= schema.maximum)) {
result3.addError({
name: "maximum",
argument: schema.maximum,
message: "must be less than or equal to " + schema.maximum
});
}
}
return result3;
};
validators.exclusiveMinimum = function validateExclusiveMinimum(instance, schema, options, ctx) {
if (typeof schema.exclusiveMinimum === "boolean") return;
if (!this.types.number(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
var valid3 = instance > schema.exclusiveMinimum;
if (!valid3) {
result3.addError({
name: "exclusiveMinimum",
argument: schema.exclusiveMinimum,
message: "must be strictly greater than " + schema.exclusiveMinimum
});
}
return result3;
};
validators.exclusiveMaximum = function validateExclusiveMaximum(instance, schema, options, ctx) {
if (typeof schema.exclusiveMaximum === "boolean") return;
if (!this.types.number(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
var valid3 = instance < schema.exclusiveMaximum;
if (!valid3) {
result3.addError({
name: "exclusiveMaximum",
argument: schema.exclusiveMaximum,
message: "must be strictly less than " + schema.exclusiveMaximum
});
}
return result3;
};
var validateMultipleOfOrDivisbleBy = function validateMultipleOfOrDivisbleBy2(instance, schema, options, ctx, validationType, errorMessage) {
if (!this.types.number(instance)) return;
var validationArgument = schema[validationType];
if (validationArgument == 0) {
throw new SchemaError(validationType + " cannot be zero");
}
var result3 = new ValidatorResult(instance, schema, options, ctx);
var instanceDecimals = helpers.getDecimalPlaces(instance);
var divisorDecimals = helpers.getDecimalPlaces(validationArgument);
var maxDecimals = Math.max(instanceDecimals, divisorDecimals);
var multiplier = Math.pow(10, maxDecimals);
if (Math.round(instance * multiplier) % Math.round(validationArgument * multiplier) !== 0) {
result3.addError({
name: validationType,
argument: validationArgument,
message: errorMessage + JSON.stringify(validationArgument)
});
}
return result3;
};
validators.multipleOf = function validateMultipleOf(instance, schema, options, ctx) {
return validateMultipleOfOrDivisbleBy.call(this, instance, schema, options, ctx, "multipleOf", "is not a multiple of (divisible by) ");
};
validators.divisibleBy = function validateDivisibleBy(instance, schema, options, ctx) {
return validateMultipleOfOrDivisbleBy.call(this, instance, schema, options, ctx, "divisibleBy", "is not divisible by (multiple of) ");
};
validators.required = function validateRequired(instance, schema, options, ctx) {
var result3 = new ValidatorResult(instance, schema, options, ctx);
if (instance === void 0 && schema.required === true) {
result3.addError({
name: "required",
message: "is required"
});
} else if (this.types.object(instance) && Array.isArray(schema.required)) {
schema.required.forEach(function(n3) {
if (getEnumerableProperty(instance, n3) === void 0) {
result3.addError({
name: "required",
argument: n3,
message: "requires property " + JSON.stringify(n3)
});
}
});
}
return result3;
};
validators.pattern = function validatePattern(instance, schema, options, ctx) {
if (!this.types.string(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
var pattern = schema.pattern;
try {
var regexp = new RegExp(pattern, "u");
} catch (_e) {
regexp = new RegExp(pattern);
}
if (!instance.match(regexp)) {
result3.addError({
name: "pattern",
argument: schema.pattern,
message: "does not match pattern " + JSON.stringify(schema.pattern.toString())
});
}
return result3;
};
validators.format = function validateFormat(instance, schema, options, ctx) {
if (instance === void 0) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
if (!result3.disableFormat && !helpers.isFormat(instance, schema.format, this)) {
result3.addError({
name: "format",
argument: schema.format,
message: "does not conform to the " + JSON.stringify(schema.format) + " format"
});
}
return result3;
};
validators.minLength = function validateMinLength(instance, schema, options, ctx) {
if (!this.types.string(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
var hsp = instance.match(/[\uDC00-\uDFFF]/g);
var length = instance.length - (hsp ? hsp.length : 0);
if (!(length >= schema.minLength)) {
result3.addError({
name: "minLength",
argument: schema.minLength,
message: "does not meet minimum length of " + schema.minLength
});
}
return result3;
};
validators.maxLength = function validateMaxLength(instance, schema, options, ctx) {
if (!this.types.string(instance)) return;
var result3 = new ValidatorResult(instance, schema, options, ctx);
var hsp = instance.match(/[\uDC00-\uDFFF]/g);
var length = instance.length - (hsp ? hsp.length : 0);
if (!(length <= schema.maxLength)) {
result3.addError({
name: "maxLength",
argument: schema.maxLength,
message: "does not meet maximum length