@cdkd/cli 0.0.1 → 0.323.0

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.
Files changed (35) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +179 -2
  3. package/dist/asg-provider-4rNFSmz9.js +1277 -0
  4. package/dist/asg-provider-4rNFSmz9.js.map +1 -0
  5. package/dist/aws-client-defaults-BLXFsfMa.js +275 -0
  6. package/dist/aws-client-defaults-BLXFsfMa.js.map +1 -0
  7. package/dist/aws-clients-DWpHZk2l.js +440 -0
  8. package/dist/aws-clients-DWpHZk2l.js.map +1 -0
  9. package/dist/aws-failure-text-DiHodi76.js +1158 -0
  10. package/dist/aws-failure-text-DiHodi76.js.map +1 -0
  11. package/dist/cli.d.ts +1 -0
  12. package/dist/cli.js +135 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/created-resource-sink-CmrPwGge.js +2343 -0
  15. package/dist/created-resource-sink-CmrPwGge.js.map +1 -0
  16. package/dist/db-instance-modify-retry-DCLA_p9I.js +43 -0
  17. package/dist/db-instance-modify-retry-DCLA_p9I.js.map +1 -0
  18. package/dist/deploy-engine-dYZ0v6Kz.js +55863 -0
  19. package/dist/deploy-engine-dYZ0v6Kz.js.map +1 -0
  20. package/dist/iam-role-provider-Bp4osNrj.js +698 -0
  21. package/dist/iam-role-provider-Bp4osNrj.js.map +1 -0
  22. package/dist/index.d.ts +1629 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +7 -0
  25. package/dist/neptune-provider-BqtKFZaE.js +1470 -0
  26. package/dist/neptune-provider-BqtKFZaE.js.map +1 -0
  27. package/dist/program-BYT8z2ca.js +31547 -0
  28. package/dist/program-BYT8z2ca.js.map +1 -0
  29. package/dist/provider-classes-KPYbVTtY.js +55302 -0
  30. package/dist/provider-classes-KPYbVTtY.js.map +1 -0
  31. package/dist/rds-provider-C8enyD9d.js +1749 -0
  32. package/dist/rds-provider-C8enyD9d.js.map +1 -0
  33. package/dist/version-kAoaNHQI.js +11 -0
  34. package/dist/version-kAoaNHQI.js.map +1 -0
  35. package/package.json +139 -3
@@ -0,0 +1,1158 @@
1
+ import { createHash } from "node:crypto";
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
+
4
+ // src/utils/display-safe.ts
5
+ const UNRENDERABLE = "<unrenderable>";
6
+ function toDisplayText(value) {
7
+ if (value === void 0 || value === null) return "";
8
+ try {
9
+ return String(value);
10
+ } catch {
11
+ try {
12
+ return Object.prototype.toString.call(value);
13
+ } catch {
14
+ return UNRENDERABLE;
15
+ }
16
+ }
17
+ }
18
+ function sanitizeAsciiOnly(text) {
19
+ return text.replace(/[^ -~]/g, " ").trim();
20
+ }
21
+ function displaySafe(value, opts) {
22
+ const text = toDisplayText(value);
23
+ if (text === "") return "";
24
+ if (opts?.asciiOnly) return sanitizeAsciiOnly(text);
25
+ return text.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g, " ").trim();
26
+ }
27
+ const JSON_PAYLOAD_ESCAPED = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu;
28
+ function stringifyJsonPayload(value) {
29
+ return JSON.stringify(value, null, 2).replace(JSON_PAYLOAD_ESCAPED, (match) => {
30
+ if (match === "\n") return match;
31
+ let out = "";
32
+ for (let i = 0; i < match.length; i++) out += `\\u${match.charCodeAt(i).toString(16).padStart(4, "0")}`;
33
+ return out;
34
+ });
35
+ }
36
+ const OWN_SGR = /^\x1b\[(?:0|1|2|3[1-6]|90)m$/;
37
+ const SGR_RESET = "\x1B[0m";
38
+ const CSI = String.raw`\x1b\[[0-?]*[ -/]*[@-~]|\x9b[0-?]*[ -/]*[@-~]`;
39
+ const OSC = String.raw`\x1b\][^\x07\x1b\x9c]*(?:\x07|\x1b\\|\x9c)`;
40
+ const CONTROL_EXCEPT_NEWLINE_AND_TAB = String.raw`[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u2028\u2029\u202a-\u202e\u2066-\u2069]`;
41
+ const TERMINAL_UNSAFE = new RegExp(`${CSI}|${CONTROL_EXCEPT_NEWLINE_AND_TAB}`, "g");
42
+ const SAFE_MSG_ALTERED_CHAR = new RegExp(`${CONTROL_EXCEPT_NEWLINE_AND_TAB}|[\\t\\n]`);
43
+ const TERMINAL_UNSAFE_OR_LINE_BREAK = new RegExp(`${CSI}|${OSC}|${CONTROL_EXCEPT_NEWLINE_AND_TAB}|[\\t\\n]`, "g");
44
+ function replaceUnsafe(text, pattern) {
45
+ return text.replace(pattern, (match) => {
46
+ if (match.length === 1) return " ";
47
+ if (OWN_SGR.test(match)) return match;
48
+ return match.endsWith("m") ? SGR_RESET : "";
49
+ });
50
+ }
51
+ function terminalSafe(text) {
52
+ return replaceUnsafe(text, TERMINAL_UNSAFE);
53
+ }
54
+ var AsIsMessage = class {
55
+ text;
56
+ constructor(text) {
57
+ this.text = text;
58
+ }
59
+ };
60
+ function safeMsg(strings, ...values) {
61
+ let out = strings[0] ?? "";
62
+ values.forEach((value, i) => {
63
+ out += (value instanceof AsIsMessage ? value.text : replaceUnsafe(toDisplayText(value), TERMINAL_UNSAFE_OR_LINE_BREAK)) + strings[i + 1];
64
+ });
65
+ return out;
66
+ }
67
+ function asIsMessage(text) {
68
+ return new AsIsMessage(text);
69
+ }
70
+ function truncateCodePoints(text, maxCodePoints) {
71
+ const codePoints = Array.from(text);
72
+ if (codePoints.length <= maxCodePoints) return {
73
+ text,
74
+ truncated: false
75
+ };
76
+ return {
77
+ text: codePoints.slice(0, maxCodePoints).join(""),
78
+ truncated: true
79
+ };
80
+ }
81
+ const IDENT_MAX_CODE_POINTS = 255;
82
+ const STACK_REF_MAX_CODE_POINTS = 1152;
83
+ const SECRET_REF_MAX_CODE_POINTS = 2048;
84
+ const AWS_MESSAGE_MAX_CODE_POINTS = 4096;
85
+ function displayAwsMessage(value) {
86
+ const sanitized = displaySafe(value);
87
+ const { text, truncated } = truncateCodePoints(sanitized, AWS_MESSAGE_MAX_CODE_POINTS);
88
+ if (!truncated) return text;
89
+ return `${text} ${cutMarker(Array.from(sanitized).length - Array.from(text).length)}`;
90
+ }
91
+ const CUT_DIGEST_HEX_CHARS = 32;
92
+ function cutMarker(withheld, digestOf) {
93
+ return `[cut: ${withheld} more characters withheld${digestOf === void 0 ? "" : `, tail sha256:${createHash("sha256").update(digestOf).digest("hex").slice(0, CUT_DIGEST_HEX_CHARS)}`}]`;
94
+ }
95
+ const PLAIN_IDENT = /^[A-Za-z0-9:_@./+=,~-]+$/;
96
+ function displayIdent(value, opts) {
97
+ const raw = toDisplayText(value);
98
+ if (raw === "") return UNRENDERABLE;
99
+ const clean = sanitizeAsciiOnly(raw);
100
+ if (!clean) return UNRENDERABLE;
101
+ const requested = opts?.maxCodePoints ?? 255;
102
+ const { text, truncated } = truncateCodePoints(clean, Number.isFinite(requested) ? Math.max(1, Math.floor(requested)) : 255);
103
+ const altered = clean !== raw;
104
+ const plain = PLAIN_IDENT.test(text) && !(opts?.listMember === true && text.includes(","));
105
+ const shown = !altered && plain ? text : JSON.stringify(text);
106
+ return truncated ? `${shown} ${cutMarker(clean.length - text.length, clean.slice(text.length))}` : shown;
107
+ }
108
+ function displayStackName(value) {
109
+ return displayIdent(value, { maxCodePoints: STACK_REF_MAX_CODE_POINTS });
110
+ }
111
+ function plainIdentOr(value, description, opts) {
112
+ return isPlainIdent(value, opts) ? value : description;
113
+ }
114
+ function isPlainIdent(value, opts) {
115
+ return !/\s/.test(value) && displayIdent(value, opts) === value;
116
+ }
117
+ const PASTEABLE_STATE_IDENT = /^[A-Za-z0-9][A-Za-z0-9~_.-]*$/;
118
+ function isPasteableIdent(value) {
119
+ if (!PASTEABLE_STATE_IDENT.test(value)) return false;
120
+ return displayIdent(value, { maxCodePoints: STACK_REF_MAX_CODE_POINTS }) === value;
121
+ }
122
+
123
+ // src/provisioning/resource-name.ts
124
+ const stackScopeStore = new AsyncLocalStorage();
125
+ function withStackScopeBeforeStateRead(stackName, fn) {
126
+ return stackScopeStore.run({
127
+ stackName,
128
+ stackInstanceId: void 0,
129
+ nameGenerations: void 0,
130
+ beforeStateRead: true
131
+ }, fn);
132
+ }
133
+ function withStackScope(scope, fn) {
134
+ return nameGenerationStore.exit(() => stackScopeStore.run({
135
+ stackName: scope.stackName,
136
+ stackInstanceId: scope.stackInstanceId,
137
+ nameGenerations: scope.nameGenerations
138
+ }, fn));
139
+ }
140
+ const nameGenerationStore = new AsyncLocalStorage();
141
+ function isNameGeneration(value) {
142
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
143
+ }
144
+ function withNameGeneration(binding, fn) {
145
+ if (!isNameGeneration(binding.generation)) throw new Error(`cdkd internal error: name generation ${String(binding.generation)} for ${binding.logicalId} is not a non-negative integer`);
146
+ return nameGenerationStore.run({
147
+ logicalId: binding.logicalId,
148
+ generation: binding.generation
149
+ }, fn);
150
+ }
151
+ function currentNameGeneration(logicalId) {
152
+ const bound = nameGenerationStore.getStore();
153
+ if (bound !== void 0 && bound.logicalId === logicalId) return bound.generation;
154
+ const scope = stackScopeStore.getStore();
155
+ if (scope?.nameGenerations === void 0) return scope?.stackInstanceId === void 0 ? 0 : void 0;
156
+ return scope.nameGenerations.get(logicalId) ?? 0;
157
+ }
158
+ function getCurrentStackName() {
159
+ return stackScopeStore.getStore()?.stackName;
160
+ }
161
+ function isBeforeStateRead() {
162
+ return stackScopeStore.getStore()?.beforeStateRead === true;
163
+ }
164
+ function getCurrentStackInstanceId() {
165
+ return stackScopeStore.getStore()?.stackInstanceId;
166
+ }
167
+ const skipPrefixStore = new AsyncLocalStorage();
168
+ function withSkipPrefix(skip, fn) {
169
+ return skipPrefixStore.run(skip, fn);
170
+ }
171
+ function getCurrentSkipPrefix() {
172
+ return skipPrefixStore.getStore() ?? false;
173
+ }
174
+ const PATTERN_B_RESOURCE_TYPES = [
175
+ "AWS::IAM::Role",
176
+ "AWS::IAM::User",
177
+ "AWS::IAM::Group",
178
+ "AWS::IAM::InstanceProfile",
179
+ "AWS::IAM::ManagedPolicy",
180
+ "AWS::ElasticLoadBalancingV2::LoadBalancer",
181
+ "AWS::ElasticLoadBalancingV2::TargetGroup"
182
+ ];
183
+ const PATTERN_B_NAME_PROPERTIES = {
184
+ "AWS::IAM::Role": "RoleName",
185
+ "AWS::IAM::User": "UserName",
186
+ "AWS::IAM::Group": "GroupName",
187
+ "AWS::IAM::InstanceProfile": "InstanceProfileName",
188
+ "AWS::IAM::ManagedPolicy": "ManagedPolicyName",
189
+ "AWS::ElasticLoadBalancingV2::LoadBalancer": "Name",
190
+ "AWS::ElasticLoadBalancingV2::TargetGroup": "Name"
191
+ };
192
+ const PATTERN_B_NAME_OPTIONS = {
193
+ "AWS::IAM::Role": { maxLength: 64 },
194
+ "AWS::IAM::User": { maxLength: 64 },
195
+ "AWS::IAM::Group": { maxLength: 128 },
196
+ "AWS::IAM::InstanceProfile": { maxLength: 128 },
197
+ "AWS::IAM::ManagedPolicy": { maxLength: 128 },
198
+ "AWS::ElasticLoadBalancingV2::LoadBalancer": { maxLength: 32 },
199
+ "AWS::ElasticLoadBalancingV2::TargetGroup": { maxLength: 32 }
200
+ };
201
+ function derivesPatternBName(resourceType, declared, live) {
202
+ if (!Object.prototype.hasOwnProperty.call(PATTERN_B_NAME_OPTIONS, resourceType)) return false;
203
+ if (typeof declared !== "string" || declared === "") return false;
204
+ if (typeof live !== "string" || live === "") return false;
205
+ const options = PATTERN_B_NAME_OPTIONS[resourceType];
206
+ return [true, false].some((skip) => withSkipPrefix(skip, () => generateResourceName(declared, {
207
+ ...options,
208
+ userSupplied: true
209
+ })) === live);
210
+ }
211
+ const STACK_INSTANCE_SUFFIX_LENGTH = 12;
212
+ const MAX_RECOGNIZED_GENERATION = 1024;
213
+ function stackInstanceNameSuffix(stackInstanceId, name, generation = 0) {
214
+ const hash = createHash("sha256").update(stackInstanceId).update("\0").update(name);
215
+ if (generation !== 0) hash.update("\0").update(String(generation));
216
+ return hash.digest("hex").substring(0, 12);
217
+ }
218
+ function generateResourceName(name, options) {
219
+ const scope = stackScopeStore.getStore();
220
+ if (scope?.beforeStateRead === true && options.userSupplied !== true) throw new Error(`cdkd internal error: a generated name for ${name} was derived before the state record of ${scope.stackName} was read, so it cannot carry the stack's instance id`);
221
+ let generation = 0;
222
+ if (scope?.stackInstanceId !== void 0 && options.userSupplied !== true) {
223
+ const known = currentNameGeneration(name);
224
+ if (known === void 0) throw new Error(`cdkd internal error: a generated name for ${name} was derived in a scope of ${scope.stackName} that carries no name generations, so it could name the resource after an earlier generation`);
225
+ generation = known;
226
+ }
227
+ return deriveResourceName(name, options, scope?.stackName, scope?.stackInstanceId, generation);
228
+ }
229
+ function deriveResourceName(name, options, currentStackName, stackInstanceId, generation = 0) {
230
+ const { maxLength, lowercase = false, allowedPattern = /[^a-zA-Z0-9-]/g, userSupplied = false } = options;
231
+ const shouldPrefix = currentStackName && !(userSupplied && getCurrentSkipPrefix());
232
+ const fullName = shouldPrefix ? `${currentStackName}-${name}` : name;
233
+ let sanitized = lowercase ? fullName.toLowerCase() : fullName;
234
+ sanitized = sanitized.replace(allowedPattern, "-");
235
+ sanitized = sanitized.replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
236
+ if (shouldPrefix && !userSupplied && stackInstanceId !== void 0) {
237
+ const suffix = stackInstanceNameSuffix(stackInstanceId, name, generation);
238
+ const base = sanitized.substring(0, maxLength - suffix.length - 1).replace(/-+$/, "");
239
+ return base === "" ? suffix : `${base}-${suffix}`;
240
+ }
241
+ if (sanitized.length <= maxLength) return sanitized;
242
+ const hash = createHash("sha256").update(fullName).digest("hex").substring(0, 8);
243
+ const maxPrefixLength = maxLength - hash.length - 1;
244
+ return `${sanitized.substring(0, maxPrefixLength).replace(/-+$/, "")}-${hash}`;
245
+ }
246
+ function looksLikeCdkdGeneratedName(physicalId, logicalId, stackName, stackInstanceId, generations) {
247
+ if (!physicalId || !logicalId || !stackName) return false;
248
+ const skeleton = (value) => value.toLowerCase().replace(/[^a-z0-9]/g, "");
249
+ const derived = skeleton(`${stackName}-${logicalId}`);
250
+ if (skeleton(physicalId) === derived) return true;
251
+ if (stackInstanceId !== void 0) {
252
+ const suffixed = /^(.*)-([0-9a-f]{12})$/.exec(physicalId.toLowerCase());
253
+ if (suffixed !== null) {
254
+ const base = skeleton(suffixed[1]);
255
+ const through = Math.min(generations?.through ?? (currentNameGeneration(logicalId) ?? 0) + 1, MAX_RECOGNIZED_GENERATION);
256
+ for (let g = 0; g <= through; g++) {
257
+ if (suffixed[2] !== stackInstanceNameSuffix(stackInstanceId, logicalId, g)) continue;
258
+ if (base.length > 0 && derived.startsWith(base)) return true;
259
+ }
260
+ }
261
+ }
262
+ const truncated = /^(.*)-([0-9a-f]{8})$/.exec(physicalId.toLowerCase());
263
+ if (!truncated) return false;
264
+ const prefix = skeleton(truncated[1]);
265
+ return prefix.length > 0 && derived.startsWith(prefix);
266
+ }
267
+ function generateResourceNameWithFallback(userSuppliedName, logicalId, options) {
268
+ if (userSuppliedName !== void 0 && userSuppliedName !== "") return generateResourceName(userSuppliedName, {
269
+ ...options,
270
+ userSupplied: true
271
+ });
272
+ return generateResourceName(logicalId, {
273
+ ...options,
274
+ userSupplied: false
275
+ });
276
+ }
277
+ function isDeclaredName(value) {
278
+ return value !== void 0 && value !== "";
279
+ }
280
+ function isGeneratedNameOfEitherScheme(recorded, logicalId, options) {
281
+ const scope = stackScopeStore.getStore();
282
+ if (!scope?.stackName || recorded === "") return false;
283
+ const opts = {
284
+ ...options,
285
+ userSupplied: false
286
+ };
287
+ if (recorded === deriveResourceName(logicalId, opts, scope.stackName, void 0)) return true;
288
+ const probe = deriveResourceName(logicalId, opts, scope.stackName, "00000000-0000-4000-8000-000000000000");
289
+ const base = probe.slice(0, probe.length - 12);
290
+ return recorded.startsWith(base) && /^[0-9a-f]{12}$/.test(recorded.slice(base.length));
291
+ }
292
+ function recordedGeneratedNameKept(input) {
293
+ if (input.derived === input.recorded) return false;
294
+ if (isDeclaredName(input.declaredName) || isDeclaredName(input.previousDeclaredName)) return false;
295
+ return isGeneratedNameOfEitherScheme(input.recorded, input.logicalId, input.options);
296
+ }
297
+ const FALLBACK_NAME_RULES = {
298
+ "AWS::S3::Bucket": {
299
+ nameProperty: "BucketName",
300
+ options: {
301
+ maxLength: 63,
302
+ lowercase: true,
303
+ allowedPattern: /[^a-z0-9.-]/g
304
+ }
305
+ },
306
+ "AWS::SQS::Queue": {
307
+ nameProperty: "QueueName",
308
+ options: { maxLength: 80 }
309
+ },
310
+ "AWS::SNS::Topic": {
311
+ nameProperty: "TopicName",
312
+ options: { maxLength: 256 }
313
+ },
314
+ "AWS::Lambda::Function": {
315
+ nameProperty: "FunctionName",
316
+ options: { maxLength: 64 }
317
+ },
318
+ "AWS::Lambda::LayerVersion": {
319
+ nameProperty: "LayerName",
320
+ options: { maxLength: 64 }
321
+ },
322
+ "AWS::Lambda::CapacityProvider": {
323
+ nameProperty: "CapacityProviderName",
324
+ options: { maxLength: 64 }
325
+ },
326
+ "AWS::IAM::Role": {
327
+ nameProperty: "RoleName",
328
+ options: { maxLength: 64 }
329
+ },
330
+ "AWS::IAM::Policy": {
331
+ nameProperty: "PolicyName",
332
+ options: { maxLength: 64 }
333
+ },
334
+ "AWS::IAM::ManagedPolicy": {
335
+ nameProperty: "ManagedPolicyName",
336
+ options: { maxLength: 128 }
337
+ },
338
+ "AWS::IAM::User": {
339
+ nameProperty: "UserName",
340
+ options: { maxLength: 64 }
341
+ },
342
+ "AWS::IAM::Group": {
343
+ nameProperty: "GroupName",
344
+ options: { maxLength: 128 }
345
+ },
346
+ "AWS::IAM::InstanceProfile": {
347
+ nameProperty: "InstanceProfileName",
348
+ options: { maxLength: 128 }
349
+ },
350
+ "AWS::DynamoDB::Table": {
351
+ nameProperty: "TableName",
352
+ options: { maxLength: 255 }
353
+ },
354
+ "AWS::ECR::Repository": {
355
+ nameProperty: "RepositoryName",
356
+ options: {
357
+ maxLength: 256,
358
+ lowercase: true
359
+ }
360
+ },
361
+ "AWS::ECS::Cluster": {
362
+ nameProperty: "ClusterName",
363
+ options: { maxLength: 255 }
364
+ },
365
+ "AWS::ECS::Service": {
366
+ nameProperty: "ServiceName",
367
+ options: { maxLength: 255 }
368
+ },
369
+ "AWS::Logs::LogGroup": {
370
+ nameProperty: "LogGroupName",
371
+ options: {
372
+ maxLength: 506,
373
+ allowedPattern: /[^a-zA-Z0-9-/_]/g
374
+ },
375
+ prefix: "/cdkd/",
376
+ legacy: { cloudControl: { maxLength: 512 } }
377
+ },
378
+ "AWS::CloudWatch::Alarm": {
379
+ nameProperty: "AlarmName",
380
+ options: { maxLength: 255 }
381
+ },
382
+ "AWS::Events::Rule": {
383
+ nameProperty: "Name",
384
+ options: { maxLength: 64 }
385
+ },
386
+ "AWS::Kinesis::Stream": {
387
+ nameProperty: "Name",
388
+ options: { maxLength: 128 }
389
+ },
390
+ "AWS::StepFunctions::StateMachine": {
391
+ nameProperty: "StateMachineName",
392
+ options: { maxLength: 80 }
393
+ },
394
+ "AWS::SecretsManager::Secret": {
395
+ nameProperty: "Name",
396
+ options: {
397
+ maxLength: 512,
398
+ allowedPattern: /[^a-zA-Z0-9-/_]/g
399
+ }
400
+ },
401
+ "AWS::SSM::Parameter": {
402
+ nameProperty: "Name",
403
+ options: {
404
+ maxLength: 1023,
405
+ allowedPattern: /[^a-zA-Z0-9-/_]/g
406
+ },
407
+ prefix: "/",
408
+ legacy: { cloudControl: { maxLength: 2048 } }
409
+ },
410
+ "AWS::Cognito::UserPool": {
411
+ nameProperty: "UserPoolName",
412
+ options: { maxLength: 128 }
413
+ },
414
+ "AWS::ElastiCache::SubnetGroup": {
415
+ nameProperty: "CacheSubnetGroupName",
416
+ options: {
417
+ maxLength: 255,
418
+ lowercase: true
419
+ }
420
+ },
421
+ "AWS::ElastiCache::CacheCluster": {
422
+ nameProperty: "ClusterName",
423
+ options: {
424
+ maxLength: 40,
425
+ lowercase: true
426
+ }
427
+ },
428
+ "AWS::RDS::DBSubnetGroup": {
429
+ nameProperty: "DBSubnetGroupName",
430
+ options: {
431
+ maxLength: 255,
432
+ lowercase: true
433
+ }
434
+ },
435
+ "AWS::RDS::DBCluster": {
436
+ nameProperty: "DBClusterIdentifier",
437
+ options: {
438
+ maxLength: 63,
439
+ lowercase: true
440
+ }
441
+ },
442
+ "AWS::RDS::DBInstance": {
443
+ nameProperty: "DBInstanceIdentifier",
444
+ options: {
445
+ maxLength: 63,
446
+ lowercase: true
447
+ }
448
+ },
449
+ "AWS::DocDB::DBSubnetGroup": {
450
+ nameProperty: "DBSubnetGroupName",
451
+ options: {
452
+ maxLength: 255,
453
+ lowercase: true
454
+ }
455
+ },
456
+ "AWS::DocDB::DBCluster": {
457
+ nameProperty: "DBClusterIdentifier",
458
+ options: {
459
+ maxLength: 63,
460
+ lowercase: true
461
+ }
462
+ },
463
+ "AWS::DocDB::DBInstance": {
464
+ nameProperty: "DBInstanceIdentifier",
465
+ options: {
466
+ maxLength: 63,
467
+ lowercase: true
468
+ }
469
+ },
470
+ "AWS::Neptune::DBSubnetGroup": {
471
+ nameProperty: "DBSubnetGroupName",
472
+ options: {
473
+ maxLength: 255,
474
+ lowercase: true
475
+ }
476
+ },
477
+ "AWS::Neptune::DBCluster": {
478
+ nameProperty: "DBClusterIdentifier",
479
+ options: {
480
+ maxLength: 63,
481
+ lowercase: true
482
+ }
483
+ },
484
+ "AWS::Neptune::DBInstance": {
485
+ nameProperty: "DBInstanceIdentifier",
486
+ options: {
487
+ maxLength: 63,
488
+ lowercase: true
489
+ }
490
+ },
491
+ "AWS::ElasticLoadBalancingV2::LoadBalancer": {
492
+ nameProperty: "Name",
493
+ options: { maxLength: 32 }
494
+ },
495
+ "AWS::ElasticLoadBalancingV2::TargetGroup": {
496
+ nameProperty: "Name",
497
+ options: { maxLength: 32 }
498
+ },
499
+ "AWS::WAFv2::WebACL": {
500
+ nameProperty: "Name",
501
+ options: { maxLength: 128 }
502
+ },
503
+ "AWS::CodeBuild::Project": {
504
+ nameProperty: "Name",
505
+ options: { maxLength: 150 },
506
+ legacy: { sdk: "logicalId" }
507
+ },
508
+ "AWS::S3Express::DirectoryBucket": {
509
+ nameProperty: "BucketName",
510
+ options: {
511
+ maxLength: 63,
512
+ lowercase: true
513
+ },
514
+ zoneSuffix: true
515
+ },
516
+ "AWS::CodeCommit::Repository": {
517
+ nameProperty: "RepositoryName",
518
+ options: { maxLength: 100 }
519
+ },
520
+ "AWS::RDS::DBProxy": {
521
+ nameProperty: "DBProxyName",
522
+ options: { maxLength: 64 }
523
+ },
524
+ "AWS::RDS::DBProxyEndpoint": {
525
+ nameProperty: "DBProxyEndpointName",
526
+ options: { maxLength: 64 }
527
+ },
528
+ "AWS::S3Vectors::VectorBucket": {
529
+ nameProperty: "VectorBucketName",
530
+ options: {
531
+ maxLength: 63,
532
+ lowercase: true
533
+ },
534
+ legacy: { cloudControl: "none" },
535
+ notAdopted: true
536
+ },
537
+ "AWS::ServiceDiscovery::Service": {
538
+ nameProperty: "Name",
539
+ options: { maxLength: 63 },
540
+ legacy: { cloudControl: "none" },
541
+ notAdopted: true
542
+ },
543
+ "AWS::Scheduler::Schedule": {
544
+ nameProperty: "Name",
545
+ options: { maxLength: 64 },
546
+ legacy: { cloudControl: "none" }
547
+ },
548
+ "AWS::AutoScaling::AutoScalingGroup": {
549
+ nameProperty: "AutoScalingGroupName",
550
+ options: { maxLength: 255 },
551
+ legacy: { cloudControl: "none" }
552
+ },
553
+ "AWS::DynamoDB::GlobalTable": {
554
+ nameProperty: "TableName",
555
+ options: { maxLength: 255 },
556
+ legacy: { cloudControl: "none" }
557
+ },
558
+ "AWS::ECS::TaskDefinition": {
559
+ nameProperty: "Family",
560
+ options: { maxLength: 255 },
561
+ legacy: { cloudControl: "none" },
562
+ notAdopted: true
563
+ },
564
+ "AWS::Lambda::NetworkConnector": {
565
+ nameProperty: "Name",
566
+ options: { maxLength: 64 },
567
+ legacy: { cloudControl: "none" },
568
+ notAdopted: true
569
+ },
570
+ "AWS::Pipes::Pipe": {
571
+ nameProperty: "Name",
572
+ options: { maxLength: 64 },
573
+ legacy: { cloudControl: "none" },
574
+ notAdopted: true
575
+ },
576
+ "AWS::EC2::SecurityGroup": {
577
+ nameProperty: "GroupName",
578
+ options: { maxLength: 255 },
579
+ refusedPrefix: "sg-",
580
+ legacy: {
581
+ sdk: "logicalId",
582
+ cloudControl: "none"
583
+ },
584
+ notAdopted: true
585
+ },
586
+ "AWS::CloudTrail::Trail": {
587
+ nameProperty: "TrailName",
588
+ options: { maxLength: 128 },
589
+ legacy: {
590
+ sdk: "logicalId",
591
+ cloudControl: "none"
592
+ },
593
+ notAdopted: true
594
+ },
595
+ "AWS::Glue::Job": {
596
+ nameProperty: "Name",
597
+ options: { maxLength: 255 },
598
+ legacy: {
599
+ sdk: "logicalId",
600
+ cloudControl: "none"
601
+ },
602
+ notAdopted: true
603
+ },
604
+ "AWS::Glue::Crawler": {
605
+ nameProperty: "Name",
606
+ options: { maxLength: 255 },
607
+ legacy: {
608
+ sdk: "logicalId",
609
+ cloudControl: "none"
610
+ },
611
+ notAdopted: true
612
+ },
613
+ "AWS::Glue::Connection": {
614
+ nameProperty: "Name",
615
+ nestedIn: "ConnectionInput",
616
+ options: { maxLength: 255 },
617
+ legacy: {
618
+ sdk: "logicalId",
619
+ cloudControl: "none"
620
+ },
621
+ notAdopted: true
622
+ },
623
+ "AWS::Glue::Trigger": {
624
+ nameProperty: "Name",
625
+ options: { maxLength: 255 },
626
+ legacy: {
627
+ sdk: "logicalId",
628
+ cloudControl: "none"
629
+ },
630
+ notAdopted: true
631
+ },
632
+ "AWS::KinesisFirehose::DeliveryStream": {
633
+ nameProperty: "DeliveryStreamName",
634
+ options: { maxLength: 64 },
635
+ legacy: {
636
+ sdk: "logicalId",
637
+ cloudControl: "none"
638
+ },
639
+ notAdopted: true
640
+ }
641
+ };
642
+ function scopeHasStackInstanceId() {
643
+ return stackScopeStore.getStore()?.stackInstanceId !== void 0;
644
+ }
645
+ function deriveRuleName(rule, logicalId, input) {
646
+ if (rule.zoneSuffix === true) {
647
+ if (input.zoneId === void 0 || input.zoneId === "") return void 0;
648
+ const suffix = `--${input.zoneId}--x-s3`;
649
+ return `${generateResourceName(logicalId, {
650
+ ...rule.options,
651
+ maxLength: rule.options.maxLength - suffix.length
652
+ })}${suffix}`;
653
+ }
654
+ const name = `${rule.prefix ?? ""}${generateResourceName(logicalId, rule.options)}`;
655
+ const refused = rule.refusedPrefix;
656
+ if (refused !== void 0 && name.toLowerCase().startsWith(refused.toLowerCase())) return `${name.slice(0, refused.length - 1)}${name.slice(refused.length)}`;
657
+ return name;
658
+ }
659
+ function generatedNameFor(resourceType, logicalId, input = {}) {
660
+ const rule = FALLBACK_NAME_RULES[resourceType];
661
+ if (rule === void 0) throw new Error(`cdkd internal error: ${resourceType} has no generated-name rule`);
662
+ if (rule.legacy?.sdk === "logicalId" && !scopeHasStackInstanceId() && stackScopeStore.getStore()?.beforeStateRead !== true) return logicalId;
663
+ const name = deriveRuleName(rule, logicalId, input);
664
+ if (name === void 0) throw new Error(`cdkd internal error: the generated ${resourceType} name needs a zone id`);
665
+ return name;
666
+ }
667
+ function nameContainer(rule, properties) {
668
+ if (rule.nestedIn === void 0) return properties;
669
+ const nested = properties[rule.nestedIn];
670
+ return typeof nested === "object" && nested !== null && !Array.isArray(nested) ? nested : void 0;
671
+ }
672
+ function directoryBucketZoneId(properties) {
673
+ const location = properties["LocationName"];
674
+ if (typeof location !== "string") return void 0;
675
+ const zone = location.replace(/--x-s3$/, "");
676
+ return /^[a-z0-9]+(?:-[a-z0-9]+)*-az[0-9]+$/.test(zone) ? zone : void 0;
677
+ }
678
+ function applyDefaultNameForFallback(logicalId, resourceType, properties, underivable = "refuse") {
679
+ const rule = FALLBACK_NAME_RULES[resourceType];
680
+ if (!rule) return properties;
681
+ const container = nameContainer(rule, properties);
682
+ if (container === void 0) return properties;
683
+ if (container[rule.nameProperty]) return properties;
684
+ let generatedName;
685
+ const legacy = scopeHasStackInstanceId() ? void 0 : rule.legacy?.cloudControl;
686
+ if (legacy === "none") return properties;
687
+ if (legacy !== void 0) generatedName = generateResourceName(logicalId, legacy);
688
+ else {
689
+ const zoneId = rule.zoneSuffix === true ? directoryBucketZoneId(properties) : void 0;
690
+ generatedName = deriveRuleName(rule, logicalId, zoneId === void 0 ? {} : { zoneId });
691
+ }
692
+ if (generatedName === void 0) {
693
+ if (underivable === "omit") return properties;
694
+ const location = properties["LocationName"] === void 0 ? "the resource declares no LocationName" : "its LocationName is not a zone id such as use1-az5";
695
+ throw new Error(`${logicalId} (${resourceType}): cdkd cannot generate a ${rule.nameProperty} for the Cloud Control create. A directory bucket's name must end with --<zone id>--x-s3, and ${location}. Set LocationName to the zone id, or declare ${rule.nameProperty}.`);
696
+ }
697
+ if (rule.nestedIn !== void 0) return {
698
+ ...properties,
699
+ [rule.nestedIn]: {
700
+ ...container,
701
+ [rule.nameProperty]: generatedName
702
+ }
703
+ };
704
+ return {
705
+ ...properties,
706
+ [rule.nameProperty]: generatedName
707
+ };
708
+ }
709
+ function fallbackNamePropertyFor(resourceType) {
710
+ const rule = FALLBACK_NAME_RULES[resourceType];
711
+ return rule?.nestedIn === void 0 ? rule?.nameProperty : void 0;
712
+ }
713
+ function withoutGeneratedFallbackName(resourceType, resolvedProps, prepared) {
714
+ const rule = FALLBACK_NAME_RULES[resourceType];
715
+ if (rule?.nestedIn !== void 0) {
716
+ const outer = rule.nestedIn;
717
+ const resolvedInner = nameContainer(rule, resolvedProps);
718
+ const preparedInner = nameContainer(rule, prepared);
719
+ if (resolvedInner === void 0 || preparedInner === void 0) return prepared;
720
+ const inner = withoutGeneratedFallbackNameAt(rule.nameProperty, resolvedInner, preparedInner);
721
+ return inner === preparedInner ? prepared : {
722
+ ...prepared,
723
+ [outer]: inner
724
+ };
725
+ }
726
+ const nameProperty = fallbackNamePropertyFor(resourceType);
727
+ if (nameProperty === void 0) return prepared;
728
+ return withoutGeneratedFallbackNameAt(nameProperty, resolvedProps, prepared);
729
+ }
730
+ function withoutGeneratedFallbackNameAt(nameProperty, resolvedProps, prepared) {
731
+ if (resolvedProps[nameProperty] || !(nameProperty in prepared)) return prepared;
732
+ const restored = { ...prepared };
733
+ if (nameProperty in resolvedProps) restored[nameProperty] = resolvedProps[nameProperty];
734
+ else delete restored[nameProperty];
735
+ return restored;
736
+ }
737
+ function explicitNamePropertyFor(resourceType) {
738
+ const rule = FALLBACK_NAME_RULES[resourceType];
739
+ if (rule !== void 0 && rule.notAdopted !== true) return rule.nameProperty;
740
+ return ADOPTION_ONLY_NAME_PROPERTIES[resourceType];
741
+ }
742
+ const ADOPTION_ONLY_NAME_PROPERTIES = { "AWS::Events::EventBus": "Name" };
743
+ function alternateNamePropertiesFor(resourceType) {
744
+ return resourceType === "AWS::S3::Bucket" ? ["BucketNamePrefix"] : [];
745
+ }
746
+
747
+ // src/utils/live-renderer.ts
748
+ const SPINNER_FRAMES = [
749
+ "⠋",
750
+ "⠙",
751
+ "⠹",
752
+ "⠸",
753
+ "⠼",
754
+ "⠴",
755
+ "⠦",
756
+ "⠧",
757
+ "⠇",
758
+ "⠏"
759
+ ];
760
+ const FRAME_INTERVAL_MS = 80;
761
+ const ESC = "\x1B[";
762
+ function scopedKey(id, stackName) {
763
+ return stackName ? `${stackName}:${id}` : id;
764
+ }
765
+ var LiveRenderer = class {
766
+ tasks = /* @__PURE__ */ new Map();
767
+ active = false;
768
+ suspended = false;
769
+ spinnerIndex = 0;
770
+ interval = null;
771
+ linesDrawn = 0;
772
+ cursorHidden = false;
773
+ exitListener = null;
774
+ stream;
775
+ constructor(stream = process.stdout) {
776
+ this.stream = stream;
777
+ }
778
+ isActive() {
779
+ return this.active;
780
+ }
781
+ start() {
782
+ if (this.active) return true;
783
+ if (!this.stream.isTTY) return false;
784
+ if (process.env["CDKD_NO_LIVE"] === "1") return false;
785
+ this.active = true;
786
+ this.hideCursor();
787
+ if (!this.exitListener) {
788
+ this.exitListener = () => this.showCursor();
789
+ process.on("exit", this.exitListener);
790
+ }
791
+ this.interval = setInterval(() => this.draw(), FRAME_INTERVAL_MS);
792
+ if (typeof this.interval.unref === "function") this.interval.unref();
793
+ return true;
794
+ }
795
+ stop() {
796
+ if (!this.active) return;
797
+ if (this.interval) {
798
+ clearInterval(this.interval);
799
+ this.interval = null;
800
+ }
801
+ this.clear();
802
+ this.showCursor();
803
+ if (this.exitListener) {
804
+ process.removeListener("exit", this.exitListener);
805
+ this.exitListener = null;
806
+ }
807
+ this.tasks.clear();
808
+ this.active = false;
809
+ }
810
+ addTask(id, label) {
811
+ const stackName = getCurrentStackName();
812
+ this.tasks.set(scopedKey(id, stackName), {
813
+ label,
814
+ startedAt: Date.now(),
815
+ stackName
816
+ });
817
+ if (this.active) this.draw();
818
+ }
819
+ removeTask(id) {
820
+ const stackName = getCurrentStackName();
821
+ if (!this.tasks.delete(scopedKey(id, stackName))) return;
822
+ if (this.active) this.draw();
823
+ }
824
+ updateTaskLabel(id, label) {
825
+ const stackName = getCurrentStackName();
826
+ const task = this.tasks.get(scopedKey(id, stackName));
827
+ if (!task) return;
828
+ task.label = label;
829
+ if (this.active) this.draw();
830
+ }
831
+ printAbove(write) {
832
+ if (!this.active || this.suspended) {
833
+ write();
834
+ return;
835
+ }
836
+ this.clear();
837
+ write();
838
+ this.draw();
839
+ }
840
+ clear() {
841
+ if (this.linesDrawn === 0) return;
842
+ this.stream.write("\r");
843
+ for (let i = 0; i < this.linesDrawn; i++) this.stream.write(`${ESC}1A${ESC}2K`);
844
+ this.linesDrawn = 0;
845
+ }
846
+ async suspendWhile(fn) {
847
+ if (!this.active || this.suspended) return fn();
848
+ this.suspended = true;
849
+ this.clear();
850
+ this.showCursor();
851
+ try {
852
+ return await fn();
853
+ } finally {
854
+ this.suspended = false;
855
+ if (this.active) {
856
+ this.hideCursor();
857
+ this.draw();
858
+ }
859
+ }
860
+ }
861
+ draw() {
862
+ if (!this.active || this.suspended) return;
863
+ this.clear();
864
+ if (this.tasks.size === 0) return;
865
+ const frame = SPINNER_FRAMES[this.spinnerIndex % SPINNER_FRAMES.length];
866
+ this.spinnerIndex++;
867
+ const distinctStacks = /* @__PURE__ */ new Set();
868
+ for (const task of this.tasks.values()) distinctStacks.add(task.stackName);
869
+ const showStackPrefix = distinctStacks.size > 1;
870
+ const cols = this.stream.columns ?? 80;
871
+ const lines = [];
872
+ for (const task of this.tasks.values()) {
873
+ const elapsed = ((Date.now() - task.startedAt) / 1e3).toFixed(1);
874
+ const raw = ` ${frame} ${showStackPrefix && task.stackName ? `[${displayStackName(task.stackName)}] ` : ""}${displaySafe(task.label)} (${elapsed}s)`;
875
+ lines.push(this.truncate(raw, cols));
876
+ }
877
+ this.stream.write(lines.join("\n") + "\n");
878
+ this.linesDrawn = lines.length;
879
+ }
880
+ truncate(s, maxLen) {
881
+ if (s.length <= maxLen) return s;
882
+ if (maxLen <= 1) return "…";
883
+ return s.substring(0, maxLen - 1) + "…";
884
+ }
885
+ hideCursor() {
886
+ if (this.cursorHidden) return;
887
+ this.stream.write(`${ESC}?25l`);
888
+ this.cursorHidden = true;
889
+ }
890
+ showCursor() {
891
+ if (!this.cursorHidden) return;
892
+ this.stream.write(`${ESC}?25h`);
893
+ this.cursorHidden = false;
894
+ }
895
+ };
896
+ let globalRenderer = null;
897
+ function getLiveRenderer() {
898
+ if (!globalRenderer) globalRenderer = new LiveRenderer();
899
+ return globalRenderer;
900
+ }
901
+
902
+ // src/utils/log-line-masker.ts
903
+ let source;
904
+ function installLogLineMaskerSource(next) {
905
+ if (source !== void 0) throw new Error("log line masker source is already installed");
906
+ source = next;
907
+ }
908
+ function currentLogLineMasker() {
909
+ return source?.();
910
+ }
911
+
912
+ // src/utils/stack-context.ts
913
+ const outputBufferStore = new AsyncLocalStorage();
914
+ async function runStackBuffered(fn) {
915
+ const buffer = { lines: [] };
916
+ return outputBufferStore.run(buffer, async () => {
917
+ try {
918
+ return {
919
+ ok: true,
920
+ result: await fn(),
921
+ lines: buffer.lines
922
+ };
923
+ } catch (error) {
924
+ return {
925
+ ok: false,
926
+ error,
927
+ lines: buffer.lines
928
+ };
929
+ }
930
+ });
931
+ }
932
+ function getCurrentStackOutputBuffer() {
933
+ return outputBufferStore.getStore();
934
+ }
935
+
936
+ // src/utils/logger.ts
937
+ const colors = {
938
+ reset: "\x1B[0m",
939
+ bright: "\x1B[1m",
940
+ dim: "\x1B[2m",
941
+ red: "\x1B[31m",
942
+ green: "\x1B[32m",
943
+ yellow: "\x1B[33m",
944
+ blue: "\x1B[34m",
945
+ cyan: "\x1B[36m",
946
+ gray: "\x1B[90m"
947
+ };
948
+ let stdoutReservedForPayload = false;
949
+ function reserveStdoutForPayload() {
950
+ stdoutReservedForPayload = true;
951
+ }
952
+ function isStdoutReservedForPayload() {
953
+ return stdoutReservedForPayload;
954
+ }
955
+ function renderArgs(args, mask) {
956
+ if (mask === void 0) return args.map((a) => JSON.stringify(a)).join(" ");
957
+ const rebuilt = /* @__PURE__ */ new WeakMap();
958
+ const replacer = (_key, value) => {
959
+ if (typeof value === "string") return mask(value);
960
+ if (value instanceof String) return mask(String(value));
961
+ if (typeof value === "number") {
962
+ const masked = mask(String(value));
963
+ return masked === String(value) ? value : masked;
964
+ }
965
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
966
+ const seen = rebuilt.get(value);
967
+ if (seen !== void 0) return seen;
968
+ const entries = Object.entries(value);
969
+ if (entries.every(([k]) => mask(k) === k)) return value;
970
+ const copy = Object.create(null);
971
+ for (const [k, v] of entries) {
972
+ let key = mask(k);
973
+ for (let n = 2; Object.hasOwn(copy, key); n++) key = `${mask(k)}#${n}`;
974
+ copy[key] = v;
975
+ }
976
+ rebuilt.set(value, copy);
977
+ return copy;
978
+ };
979
+ return args.map((a) => JSON.stringify(a, replacer)).join(" ");
980
+ }
981
+ function formatTimestamp() {
982
+ return (/* @__PURE__ */ new Date()).toISOString();
983
+ }
984
+ var ConsoleLogger = class {
985
+ level;
986
+ useColors;
987
+ constructor(level = "info", useColors = true) {
988
+ this.level = level;
989
+ this.useColors = useColors;
990
+ }
991
+ shouldLog(level) {
992
+ const levels = [
993
+ "debug",
994
+ "info",
995
+ "warn",
996
+ "error"
997
+ ];
998
+ const currentLevelIndex = levels.indexOf(this.level);
999
+ return levels.indexOf(level) >= currentLevelIndex;
1000
+ }
1001
+ formatMessage(level, message, ...args) {
1002
+ const mask = currentLogLineMasker();
1003
+ const formattedArgs = args.length > 0 ? " " + displaySafe(renderArgs(args, mask)) : "";
1004
+ message = terminalSafe(mask === void 0 ? message : mask(message));
1005
+ if (this.level === "debug") {
1006
+ const timestamp = formatTimestamp();
1007
+ const levelStr = level.toUpperCase().padEnd(5);
1008
+ if (this.useColors) {
1009
+ const levelColor = {
1010
+ debug: colors.gray,
1011
+ info: colors.blue,
1012
+ warn: colors.yellow,
1013
+ error: colors.red
1014
+ }[level];
1015
+ return `${colors.dim}${timestamp}${colors.reset} ${levelColor}${levelStr}${colors.reset} ${message}${formattedArgs}`;
1016
+ }
1017
+ return `${timestamp} ${levelStr} ${message}${formattedArgs}`;
1018
+ }
1019
+ if (this.useColors) {
1020
+ if (level === "error") return `${colors.red}${message}${formattedArgs}${colors.reset}`;
1021
+ if (level === "warn") return `${colors.yellow}${message}${formattedArgs}${colors.reset}`;
1022
+ return `${message}${formattedArgs}`;
1023
+ }
1024
+ return `${message}${formattedArgs}`;
1025
+ }
1026
+ emit(level, formatted) {
1027
+ const buffer = getCurrentStackOutputBuffer();
1028
+ if (buffer) {
1029
+ buffer.lines.push(formatted);
1030
+ return;
1031
+ }
1032
+ getLiveRenderer().printAbove(() => {
1033
+ if (level === "error") console.error(formatted);
1034
+ else if (level === "warn") console.warn(formatted);
1035
+ else if (stdoutReservedForPayload) console.error(formatted);
1036
+ else if (level === "info") console.info(formatted);
1037
+ else console.debug(formatted);
1038
+ });
1039
+ }
1040
+ debug(message, ...args) {
1041
+ if (this.shouldLog("debug")) this.emit("debug", this.formatMessage("debug", message, ...args));
1042
+ }
1043
+ info(message, ...args) {
1044
+ if (this.shouldLog("info")) this.emit("info", this.formatMessage("info", message, ...args));
1045
+ }
1046
+ warn(message, ...args) {
1047
+ if (this.shouldLog("warn")) this.emit("warn", this.formatMessage("warn", message, ...args));
1048
+ }
1049
+ error(message, ...args) {
1050
+ if (this.shouldLog("error")) this.emit("error", this.formatMessage("error", message, ...args));
1051
+ }
1052
+ setLevel(level) {
1053
+ this.level = level;
1054
+ }
1055
+ getLevel() {
1056
+ return this.level;
1057
+ }
1058
+ child(prefix) {
1059
+ return new ChildLogger(prefix, this.useColors);
1060
+ }
1061
+ };
1062
+ var ChildLogger = class extends ConsoleLogger {
1063
+ prefix;
1064
+ constructor(prefix, useColors) {
1065
+ super("info", useColors);
1066
+ this.prefix = prefix;
1067
+ }
1068
+ syncLevel() {
1069
+ if (globalLogger) this.setLevel(globalLogger.getLevel());
1070
+ }
1071
+ debug(message, ...args) {
1072
+ this.syncLevel();
1073
+ super.debug(`[${this.prefix}] ${message}`, ...args);
1074
+ }
1075
+ info(message, ...args) {
1076
+ this.syncLevel();
1077
+ const msg = this.getLevel() === "debug" ? `[${this.prefix}] ${message}` : message;
1078
+ super.info(msg, ...args);
1079
+ }
1080
+ warn(message, ...args) {
1081
+ this.syncLevel();
1082
+ const msg = this.getLevel() === "debug" ? `[${this.prefix}] ${message}` : message;
1083
+ super.warn(msg, ...args);
1084
+ }
1085
+ error(message, ...args) {
1086
+ this.syncLevel();
1087
+ const msg = this.getLevel() === "debug" ? `[${this.prefix}] ${message}` : message;
1088
+ super.error(msg, ...args);
1089
+ }
1090
+ };
1091
+ let globalLogger = null;
1092
+ function getLogger() {
1093
+ if (!globalLogger) globalLogger = new ConsoleLogger();
1094
+ return globalLogger;
1095
+ }
1096
+ function setLogger(logger) {
1097
+ globalLogger = logger;
1098
+ }
1099
+
1100
+ // src/utils/aws-failure-text.ts
1101
+ const VERBOSE_POINTER = "Re-run with --verbose for AWS's own message.";
1102
+ function redactedAwsFailureSummary(error) {
1103
+ const raw = error.name;
1104
+ return `${(raw ? safeStringify(raw) : "") || "Error"}. ${VERBOSE_POINTER}`;
1105
+ }
1106
+ function isAwsAuthoredFailure(error) {
1107
+ const candidate = error;
1108
+ return candidate.$fault !== void 0 || typeof candidate.$metadata?.httpStatusCode === "number" || error.name === "CredentialsProviderError";
1109
+ }
1110
+ function safeStringify(value) {
1111
+ try {
1112
+ return String(value);
1113
+ } catch {
1114
+ return "a value that could not be converted to text";
1115
+ }
1116
+ }
1117
+ function describeAwsFailure(error) {
1118
+ if (error instanceof Error) {
1119
+ if (!isAwsAuthoredFailure(error)) return {
1120
+ summary: error.message,
1121
+ detail: error.message,
1122
+ redacted: false
1123
+ };
1124
+ return {
1125
+ summary: redactedAwsFailureSummary(error),
1126
+ detail: error.message,
1127
+ redacted: true
1128
+ };
1129
+ }
1130
+ let detail;
1131
+ try {
1132
+ detail = String(error);
1133
+ } catch {
1134
+ detail = "a value that could not be converted to text";
1135
+ }
1136
+ return {
1137
+ summary: `a non-Error value of type ${typeof error}. ${VERBOSE_POINTER}`,
1138
+ detail,
1139
+ redacted: true
1140
+ };
1141
+ }
1142
+ function describeAwsStatusReason(reason, fallback) {
1143
+ const message = reason?.message;
1144
+ if (message === void 0 || message === "") return {
1145
+ summary: fallback,
1146
+ detail: fallback,
1147
+ redacted: false
1148
+ };
1149
+ const code = reason?.code;
1150
+ return {
1151
+ summary: `${code ? `${code}. ` : ""}${VERBOSE_POINTER}`,
1152
+ detail: message,
1153
+ redacted: true
1154
+ };
1155
+ }
1156
+
1157
+ export { safeMsg as $, isBeforeStateRead as A, SAFE_MSG_ALTERED_CHAR as B, fallbackNamePropertyFor as C, getCurrentSkipPrefix as D, generatedNameFor as E, withNameGeneration as F, cutMarker as G, STACK_REF_MAX_CODE_POINTS as H, withSkipPrefix as I, displaySafe as J, displayAwsMessage as K, withStackScope as L, looksLikeCdkdGeneratedName as M, recordedGeneratedNameKept as N, getCurrentStackInstanceId as O, stackInstanceNameSuffix as P, plainIdentOr as Q, withStackScopeBeforeStateRead as R, explicitNamePropertyFor as S, generateResourceNameWithFallback as T, UNRENDERABLE as U, SECRET_REF_MAX_CODE_POINTS as V, asIsMessage as W, isPasteableIdent as X, displayStackName as Y, isPlainIdent as Z, PATTERN_B_RESOURCE_TYPES as _, safeStringify as a, currentNameGeneration as b, isStdoutReservedForPayload as c, runStackBuffered as d, stringifyJsonPayload as et, currentLogLineMasker as f, PATTERN_B_NAME_PROPERTIES as g, PATTERN_B_NAME_OPTIONS as h, isAwsAuthoredFailure as i, isNameGeneration as j, getCurrentStackName as k, reserveStdoutForPayload as l, getLiveRenderer as m, describeAwsFailure as n, truncateCodePoints as nt, ConsoleLogger as o, installLogLineMaskerSource as p, displayIdent as q, describeAwsStatusReason as r, getLogger as s, VERBOSE_POINTER as t, terminalSafe as tt, setLogger as u, alternateNamePropertiesFor as v, generateResourceName as w, derivesPatternBName as x, applyDefaultNameForFallback as y, withoutGeneratedFallbackName as z };
1158
+ //# sourceMappingURL=aws-failure-text-DiHodi76.js.map