@go-to-k/cdkd 0.135.0 → 0.135.1

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 CHANGED
@@ -42012,29 +42012,50 @@ function selectIntegrationResponse(entries, matchTarget, fallbackStatusCode = 20
42012
42012
  try {
42013
42013
  if (new RegExp(`^${entry.SelectionPattern}$`).test(matchTarget)) return {
42014
42014
  entry,
42015
- statusCode: parseStatus$1(entry.StatusCode, fallbackStatusCode)
42015
+ statusCode: parseStatus(entry.StatusCode, fallbackStatusCode)
42016
42016
  };
42017
42017
  } catch {}
42018
42018
  }
42019
42019
  const entry = defaultEntry ?? null;
42020
42020
  return {
42021
42021
  entry,
42022
- statusCode: entry !== null ? parseStatus$1(entry.StatusCode, fallbackStatusCode) : fallbackStatusCode
42022
+ statusCode: entry !== null ? parseStatus(entry.StatusCode, fallbackStatusCode) : fallbackStatusCode
42023
42023
  };
42024
42024
  }
42025
- function parseStatus$1(raw, fallback) {
42025
+ /**
42026
+ * Parse an `IntegrationResponse.StatusCode` value into an HTTP status
42027
+ * code, returning `undefined` when the value is malformed or outside
42028
+ * the valid `[100, 600)` range.
42029
+ *
42030
+ * Issue (#507) items 6 + 7 + PR #515 item 4: this is the single source
42031
+ * of truth for "is `raw` a usable HTTP status code?" — `parseStatus`
42032
+ * in `rest-v1-integrations.ts` and this module's `parseStatus(raw, fallback)`
42033
+ * both delegate here so future shape-tightening (e.g. accepting `0x10`
42034
+ * the way `Number("0x10") === 16` does) lands in one place.
42035
+ *
42036
+ * Validation rules:
42037
+ * - non-string non-number → undefined
42038
+ * - empty / whitespace-only string → undefined
42039
+ * - NaN / non-integer → undefined
42040
+ * - integer outside `[100, 600)` (HTTP valid range) → undefined
42041
+ * - hex literal `"0x10"` → Number coerces to 16 but below 100 → undefined
42042
+ */
42043
+ function tryParseStatus(raw) {
42026
42044
  if (typeof raw === "number") {
42027
42045
  if (Number.isInteger(raw) && raw >= 100 && raw < 600) return raw;
42028
- return fallback;
42046
+ return;
42029
42047
  }
42030
- if (typeof raw !== "string") return fallback;
42048
+ if (typeof raw !== "string") return void 0;
42031
42049
  const trimmed = raw.trim();
42032
- if (trimmed === "") return fallback;
42050
+ if (trimmed === "") return void 0;
42033
42051
  const parsed = Number(trimmed);
42034
- if (!Number.isInteger(parsed)) return fallback;
42035
- if (parsed < 100 || parsed >= 600) return fallback;
42052
+ if (!Number.isInteger(parsed)) return void 0;
42053
+ if (parsed < 100 || parsed >= 600) return void 0;
42036
42054
  return parsed;
42037
42055
  }
42056
+ function parseStatus(raw, fallback) {
42057
+ return tryParseStatus(raw) ?? fallback;
42058
+ }
42038
42059
  /**
42039
42060
  * Evaluate `IntegrationResponse.ResponseParameters` — header literals
42040
42061
  * mapped onto the HTTP response. Returns `{name: value}` for every entry
@@ -42140,7 +42161,7 @@ function dispatchMockIntegration(config, req) {
42140
42161
  return vtlFailure("request", err, config.requestTemplate);
42141
42162
  }
42142
42163
  let entry = null;
42143
- if (pickedStatus !== void 0) entry = config.responses.find((e) => parseStatus(e.StatusCode) === pickedStatus) ?? defaultResponseEntry(config.responses);
42164
+ if (pickedStatus !== void 0) entry = config.responses.find((e) => tryParseStatus(e.StatusCode) === pickedStatus) ?? defaultResponseEntry(config.responses);
42144
42165
  else entry = defaultResponseEntry(config.responses);
42145
42166
  if (!entry) return {
42146
42167
  statusCode: pickedStatus ?? 200,
@@ -42164,7 +42185,7 @@ function dispatchMockIntegration(config, req) {
42164
42185
  Object.assign(headers, evaluateResponseParameters(entry.ResponseParameters, { onUnsupported: (_k, _v, reason) => logger.warn(`MOCK response: ${reason}`) }));
42165
42186
  if (body === "" && headers["content-type"] === contentType) delete headers["content-type"];
42166
42187
  return {
42167
- statusCode: parseStatus(entry.StatusCode) ?? 200,
42188
+ statusCode: tryParseStatus(entry.StatusCode) ?? 200,
42168
42189
  headers,
42169
42190
  body
42170
42191
  };
@@ -42469,19 +42490,6 @@ function extractStatusCodeFromRendered(rendered) {
42469
42490
  function defaultResponseEntry(entries) {
42470
42491
  return entries.find((e) => e.SelectionPattern === void 0 || e.SelectionPattern === "") ?? null;
42471
42492
  }
42472
- function parseStatus(raw) {
42473
- if (typeof raw === "number") {
42474
- if (Number.isInteger(raw) && raw >= 100 && raw < 600) return raw;
42475
- return;
42476
- }
42477
- if (typeof raw !== "string") return void 0;
42478
- const trimmed = raw.trim();
42479
- if (trimmed === "") return void 0;
42480
- const n = Number(trimmed);
42481
- if (!Number.isInteger(n)) return void 0;
42482
- if (n < 100 || n >= 600) return void 0;
42483
- return n;
42484
- }
42485
42493
  /**
42486
42494
  * Heuristic: is the given HTTP `Content-Type` header value likely to
42487
42495
  * carry text content that VTL ResponseTemplates can safely render
@@ -43789,6 +43797,38 @@ function matchHeaderList(headerList, allowed) {
43789
43797
  return true;
43790
43798
  }
43791
43799
 
43800
+ //#endregion
43801
+ //#region src/local/authorizer-context.ts
43802
+ /**
43803
+ * Build the per-kind context shape for the authorizer pipeline. Returns
43804
+ * an empty object only when nothing in the result is surfaceable (e.g.
43805
+ * a Lambda authorizer with no `principalId` and no `context`); callers
43806
+ * decide whether to skip surfacing in that case.
43807
+ *
43808
+ * For Lambda kinds: callers may need to wrap the returned shape in a
43809
+ * `lambda` namespace for HTTP API v2 (`{ lambda: shape }`); the wrap
43810
+ * is consumer-specific so it's NOT done here. The shape returned is
43811
+ * the always-flat REST v1 form.
43812
+ */
43813
+ function buildAuthorizerContextShape(authorizer, result) {
43814
+ if (authorizer.kind === "lambda-token" || authorizer.kind === "lambda-request") {
43815
+ const ctx = {};
43816
+ if (result.principalId !== void 0) ctx["principalId"] = result.principalId;
43817
+ if (result.context) Object.assign(ctx, result.context);
43818
+ return ctx;
43819
+ }
43820
+ if (authorizer.kind === "iam") {
43821
+ const ctx = {};
43822
+ if (result.principalId !== void 0) ctx["principalId"] = result.principalId;
43823
+ return ctx;
43824
+ }
43825
+ if (authorizer.kind === "cognito") return { claims: { ...result.context ?? {} } };
43826
+ return { jwt: {
43827
+ claims: { ...result.context ?? {} },
43828
+ scopes: []
43829
+ } };
43830
+ }
43831
+
43792
43832
  //#endregion
43793
43833
  //#region src/local/authorizer-resolver.ts
43794
43834
  /**
@@ -46300,22 +46340,7 @@ function buildServiceIntegrationContextVars(req, route) {
46300
46340
  */
46301
46341
  function buildAuthorizerContextForServiceIntegration(authorizer, result) {
46302
46342
  if (!authorizer || !result) return void 0;
46303
- if (authorizer.kind === "lambda-token" || authorizer.kind === "lambda-request") {
46304
- const ctx = {};
46305
- if (result.principalId !== void 0) ctx["principalId"] = result.principalId;
46306
- if (result.context) Object.assign(ctx, result.context);
46307
- return ctx;
46308
- }
46309
- if (authorizer.kind === "iam") {
46310
- const ctx = {};
46311
- if (result.principalId !== void 0) ctx["principalId"] = result.principalId;
46312
- return ctx;
46313
- }
46314
- if (authorizer.kind === "cognito") return { claims: { ...result.context ?? {} } };
46315
- return { jwt: {
46316
- claims: { ...result.context ?? {} },
46317
- scopes: []
46318
- } };
46343
+ return buildAuthorizerContextShape(authorizer, result);
46319
46344
  }
46320
46345
  /**
46321
46346
  * Write the 501 Not Implemented response surfaced for routes the
@@ -49528,8 +49553,10 @@ const defaultWaitForExitImpl = async (containerId) => {
49528
49553
  * test-overridable function so unit tests do not need a real container.
49529
49554
  */
49530
49555
  let waitForExitImpl = defaultWaitForExitImpl;
49556
+ const defaultSleepImpl = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
49557
+ let sleepImpl = defaultSleepImpl;
49531
49558
  function sleep(ms) {
49532
- return new Promise((resolve) => setTimeout(resolve, ms));
49559
+ return sleepImpl(ms);
49533
49560
  }
49534
49561
 
49535
49562
  //#endregion
@@ -52972,7 +52999,7 @@ function reorderArgs(argv) {
52972
52999
  */
52973
53000
  async function main() {
52974
53001
  const program = new Command();
52975
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.135.0");
53002
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.135.1");
52976
53003
  program.addCommand(createBootstrapCommand());
52977
53004
  program.addCommand(createSynthCommand());
52978
53005
  program.addCommand(createListCommand());