cdk-real-drift 0.4.15 → 0.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +47 -0
- package/dist/cli.js.map +1 -1
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ import { CloudControlClient, DeleteResourceCommand, GetResourceCommand, GetResou
|
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { BaseCredentials, CdkAppMultiContext, NonInteractiveIoHost, StackSelectionStrategy, Toolkit } from "@aws-cdk/toolkit-lib";
|
|
9
9
|
import { CloudFormationClient, DescribeStackResourcesCommand, DescribeStacksCommand, DescribeTypeCommand, GetTemplateCommand, ListExportsCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
|
|
10
|
+
import jsonata from "jsonata";
|
|
10
11
|
import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
|
|
11
12
|
import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
|
|
12
13
|
import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
|
|
@@ -4827,6 +4828,47 @@ function expandExecuteApiResources(policy, arnPrefix) {
|
|
|
4827
4828
|
Statement: newStmts
|
|
4828
4829
|
};
|
|
4829
4830
|
}
|
|
4831
|
+
const transformCache = /* @__PURE__ */ new Map();
|
|
4832
|
+
function compileTransform(expr) {
|
|
4833
|
+
if (transformCache.has(expr)) return transformCache.get(expr) ?? null;
|
|
4834
|
+
let compiled = null;
|
|
4835
|
+
try {
|
|
4836
|
+
compiled = jsonata(expr);
|
|
4837
|
+
} catch {
|
|
4838
|
+
compiled = null;
|
|
4839
|
+
}
|
|
4840
|
+
transformCache.set(expr, compiled);
|
|
4841
|
+
return compiled;
|
|
4842
|
+
}
|
|
4843
|
+
function matchesPropertyTransform(transformExpr, declaredValue, parentObject, rootObject, liveValue, leafName) {
|
|
4844
|
+
const scopes = [
|
|
4845
|
+
parentObject,
|
|
4846
|
+
rootObject,
|
|
4847
|
+
{ [leafName]: declaredValue },
|
|
4848
|
+
declaredValue
|
|
4849
|
+
];
|
|
4850
|
+
for (const alt of transformExpr.split(" $OR ")) {
|
|
4851
|
+
const expr = alt.trim();
|
|
4852
|
+
if (!expr) continue;
|
|
4853
|
+
const compiled = compileTransform(expr);
|
|
4854
|
+
if (!compiled) continue;
|
|
4855
|
+
for (const scope of scopes) try {
|
|
4856
|
+
const out = compiled.evaluate(scope);
|
|
4857
|
+
if (out !== void 0 && deepEqual(out, liveValue)) return true;
|
|
4858
|
+
} catch {}
|
|
4859
|
+
}
|
|
4860
|
+
return false;
|
|
4861
|
+
}
|
|
4862
|
+
function resolveParentObject(root, dottedPath) {
|
|
4863
|
+
const segs = dottedPath.split(".");
|
|
4864
|
+
if (segs.length <= 1) return root;
|
|
4865
|
+
let node = root;
|
|
4866
|
+
for (const seg of segs.slice(0, -1)) {
|
|
4867
|
+
if (node == null || typeof node !== "object") return void 0;
|
|
4868
|
+
node = node[seg];
|
|
4869
|
+
}
|
|
4870
|
+
return node;
|
|
4871
|
+
}
|
|
4830
4872
|
function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
4831
4873
|
const { logicalId, resourceType, physicalId, declared: declaredIn } = resource;
|
|
4832
4874
|
const findings = [];
|
|
@@ -5366,6 +5408,8 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
5366
5408
|
declared,
|
|
5367
5409
|
live
|
|
5368
5410
|
}) ?? false)) continue;
|
|
5411
|
+
const transformExpr = schema.propertyTransforms?.[d.path] ?? schema.propertyTransforms?.[d.path.replace(/\.\d+(?=\.|$)/g, ".*")];
|
|
5412
|
+
if (transformExpr !== void 0 && matchesPropertyTransform(transformExpr, d.stateValue, resolveParentObject(declared, d.path), declared, d.awsValue, d.path.split(".").at(-1) ?? d.path)) continue;
|
|
5369
5413
|
const unorderedExtra = unorderedObjArray && Array.isArray(declaredVal) && declaredRemapSource ? {
|
|
5370
5414
|
path: remapSortedIndexToDeclared(d.path, k, declaredVal, declaredRemapSource),
|
|
5371
5415
|
wholeArrayRevert: {
|
|
@@ -9340,6 +9384,8 @@ function parseSchema(schemaJson) {
|
|
|
9340
9384
|
const unorderedArrayPaths = collectUnorderedArrayPaths(schema.definitions ?? {}, schema.properties ?? {});
|
|
9341
9385
|
const freeFormMapPaths = collectFreeFormMapPaths(schema.definitions ?? {}, schema.properties ?? {});
|
|
9342
9386
|
const updatable = schema.handlers === void 0 ? void 0 : Object.hasOwn(schema.handlers, "update");
|
|
9387
|
+
const propertyTransforms = {};
|
|
9388
|
+
for (const [ptr, expr] of Object.entries(schema.propertyTransform ?? {})) if (typeof expr === "string") propertyTransforms[pointerToDotted$1(ptr)] = expr;
|
|
9343
9389
|
return {
|
|
9344
9390
|
readOnly: topLevel(readOnlyPaths),
|
|
9345
9391
|
writeOnly: topLevel(writeOnlyPaths),
|
|
@@ -9352,6 +9398,7 @@ function parseSchema(schemaJson) {
|
|
|
9352
9398
|
unorderedScalarPaths: unorderedArrayPaths.scalar,
|
|
9353
9399
|
unorderedObjectArrayPaths: unorderedArrayPaths.object,
|
|
9354
9400
|
freeFormMapPaths,
|
|
9401
|
+
...Object.keys(propertyTransforms).length > 0 && { propertyTransforms },
|
|
9355
9402
|
updatable
|
|
9356
9403
|
};
|
|
9357
9404
|
}
|