@fjall/components-infrastructure 14.2.0 → 14.3.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.
@@ -20,7 +20,7 @@
20
20
  * layer (generator-standards § Infrastructure Layer Boundaries).
21
21
  */
22
22
  import type { Node } from "constructs";
23
- import type { ManagedDomainBinding, ManagedDomainCoverage } from "@fjall/util";
23
+ import { type ManagedDomainBinding, type ManagedDomainCoverage, type ManagedDomainExports } from "@fjall/util";
24
24
  export declare const MANAGED_DOMAIN_CONTEXT_PREFIX: "fjall:managedDomain:";
25
25
  export declare function getManagedDomainContextKey(zoneName: string): string;
26
26
  /**
@@ -60,3 +60,35 @@ export declare function readInjectedManagedDomainBinding(node: Node, domainName:
60
60
  * forced this channel off the binding JSON in the first place.
61
61
  */
62
62
  export declare function readInjectedManagedDomainCoverage(node: Node, zoneName: string, context: string): ManagedDomainCoverage | undefined;
63
+ /**
64
+ * The one managed-domain identity a consumer acts on, resolved by the D2
65
+ * precedence every lane shares: an EXPLICIT `managedDomain` prop wins over
66
+ * the CLI-injected context binding (explicit beats injected); bare-CDK
67
+ * synth carries no context entry and yields undefined.
68
+ */
69
+ export interface EffectiveManagedDomain {
70
+ managed: ManagedDomainBinding | ManagedDomainExports;
71
+ zoneName: string;
72
+ /**
73
+ * Zone id ready for `HostedZone.fromHostedZoneAttributes`: the binding's
74
+ * literal (crosses accounts and regions), or an `Fn.importValue` token on
75
+ * the exports form (same-account, same-region only).
76
+ */
77
+ hostedZoneId: string;
78
+ /**
79
+ * True when the identity is an EXPLICIT binding prop. An explicit binding
80
+ * may pin certificate ARNs older than the zone's current ones, so the
81
+ * injected coverage context — which describes the CURRENT certificates —
82
+ * must not be applied to it (the D5 provenance gate): folding it would
83
+ * over-claim coverage and invert P3. Injected bindings and the exports
84
+ * form (which resolves at deploy to the current certificate) are safe.
85
+ */
86
+ explicitPinnedBinding: boolean;
87
+ }
88
+ /**
89
+ * Resolve the effective managed-domain identity for `domainName` — the
90
+ * SINGLE home of the explicit-beats-injected precedence and of the
91
+ * binding-vs-exports zone-id branch, shared by the resources layer
92
+ * (`ecsNetworking.addHostedZone`) and the patterns layer (`patternDomain`).
93
+ */
94
+ export declare function resolveEffectiveManagedDomain(node: Node, explicit: ManagedDomainBinding | ManagedDomainExports | undefined, domainName: string, context: string): EffectiveManagedDomain | undefined;
@@ -19,6 +19,8 @@
19
19
  * (`patternDomain.resolvePatternZone`), and utils is their lowest common
20
20
  * layer (generator-standards § Infrastructure Layer Boundaries).
21
21
  */
22
+ import { Fn } from "aws-cdk-lib";
23
+ import { isManagedDomainBinding } from "@fjall/util";
22
24
  export const MANAGED_DOMAIN_CONTEXT_PREFIX = "fjall:managedDomain:";
23
25
  export function getManagedDomainContextKey(zoneName) {
24
26
  return `${MANAGED_DOMAIN_CONTEXT_PREFIX}${zoneName}`;
@@ -114,10 +116,15 @@ export function readInjectedManagedDomainCoverage(node, zoneName, context) {
114
116
  const fieldValue = record[field];
115
117
  if (fieldValue === undefined)
116
118
  continue;
119
+ // An empty array is corruption, never data: a real certificate always
120
+ // covers at least its domain name, and the CLI never emits []. Letting
121
+ // it through would read as an enumerated "covers nothing" fact and turn
122
+ // an UNKNOWN coverage state into a definite (false) not-covered verdict.
117
123
  if (!Array.isArray(fieldValue) ||
124
+ fieldValue.length === 0 ||
118
125
  fieldValue.some((h) => typeof h !== "string" || h === "")) {
119
- throw new Error(`${context}: CDK context '${key}' field '${field}' must be an array ` +
120
- `of non-empty strings when present (got ` +
126
+ throw new Error(`${context}: CDK context '${key}' field '${field}' must be a ` +
127
+ `non-empty array of non-empty strings when present (got ` +
121
128
  `${JSON.stringify(fieldValue)}). Re-run the deploy through the ` +
122
129
  "Fjall CLI, or correct the hand-set context entry.");
123
130
  }
@@ -125,6 +132,26 @@ export function readInjectedManagedDomainCoverage(node, zoneName, context) {
125
132
  }
126
133
  return coverage;
127
134
  }
135
+ /**
136
+ * Resolve the effective managed-domain identity for `domainName` — the
137
+ * SINGLE home of the explicit-beats-injected precedence and of the
138
+ * binding-vs-exports zone-id branch, shared by the resources layer
139
+ * (`ecsNetworking.addHostedZone`) and the patterns layer (`patternDomain`).
140
+ */
141
+ export function resolveEffectiveManagedDomain(node, explicit, domainName, context) {
142
+ const managed = explicit ?? readInjectedManagedDomainBinding(node, domainName, context);
143
+ if (managed === undefined)
144
+ return undefined;
145
+ const isBinding = isManagedDomainBinding(managed);
146
+ return {
147
+ managed,
148
+ zoneName: managed.zoneName,
149
+ hostedZoneId: isBinding
150
+ ? managed.hostedZoneId
151
+ : Fn.importValue(managed.hostedZoneIdExport),
152
+ explicitPinnedBinding: explicit !== undefined && isBinding
153
+ };
154
+ }
128
155
  function parseManagedDomainBinding(raw, zoneName, key, context) {
129
156
  let value = raw;
130
157
  if (typeof raw === "string") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjall/components-infrastructure",
3
- "version": "14.2.0",
3
+ "version": "14.3.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/fjall-tech/fjall.git",
@@ -80,8 +80,8 @@
80
80
  },
81
81
  "dependencies": {
82
82
  "@aws-sdk/client-organizations": "^3.1098.0",
83
- "@fjall/generator": "^14.2.0",
84
- "@fjall/util": "^14.2.0",
83
+ "@fjall/generator": "^14.3.0",
84
+ "@fjall/util": "^14.3.0",
85
85
  "constructs": "^10.7.2"
86
86
  },
87
87
  "overrides": {