@fjall/components-infrastructure 2.34.0 → 3.0.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 (62) hide show
  1. package/dist/lib/app.d.ts +19 -2
  2. package/dist/lib/app.js +46 -3
  3. package/dist/lib/patterns/aws/apexDomainPattern.d.ts +11 -12
  4. package/dist/lib/patterns/aws/apexDomainPattern.js +11 -31
  5. package/dist/lib/patterns/aws/cdn.js +25 -10
  6. package/dist/lib/patterns/aws/computeEcs.js +6 -1
  7. package/dist/lib/patterns/aws/computeEcsTypes.d.ts +8 -3
  8. package/dist/lib/patterns/aws/delegatedDomainPattern.d.ts +13 -4
  9. package/dist/lib/patterns/aws/delegatedDomainPattern.js +57 -8
  10. package/dist/lib/patterns/aws/devSubstrate.d.ts +2 -1
  11. package/dist/lib/patterns/aws/devSubstrate.js +18 -8
  12. package/dist/lib/patterns/aws/dnsRecordComposer.d.ts +2 -9
  13. package/dist/lib/patterns/aws/dnsRecordComposer.js +5 -97
  14. package/dist/lib/patterns/aws/domain.d.ts +3 -2
  15. package/dist/lib/patterns/aws/domain.js +3 -2
  16. package/dist/lib/patterns/aws/domainValidation.js +71 -46
  17. package/dist/lib/patterns/aws/externalRecordsPattern.js +2 -11
  18. package/dist/lib/patterns/aws/index.d.ts +1 -3
  19. package/dist/lib/patterns/aws/index.js +2 -3
  20. package/dist/lib/patterns/aws/interfaces/domain.d.ts +22 -8
  21. package/dist/lib/patterns/aws/interfaces/index.d.ts +0 -1
  22. package/dist/lib/patterns/aws/interfaces/index.js +3 -0
  23. package/dist/lib/patterns/aws/interfaces/pattern.d.ts +55 -10
  24. package/dist/lib/patterns/aws/patternDomain.d.ts +77 -0
  25. package/dist/lib/patterns/aws/patternDomain.js +198 -0
  26. package/dist/lib/patterns/aws/payload.js +23 -30
  27. package/dist/lib/patterns/aws/staticSite.d.ts +1 -0
  28. package/dist/lib/patterns/aws/staticSite.js +28 -33
  29. package/dist/lib/resources/aws/base/awsStack.d.ts +8 -0
  30. package/dist/lib/resources/aws/base/awsStack.js +20 -17
  31. package/dist/lib/resources/aws/compute/ecs.d.ts +1 -1
  32. package/dist/lib/resources/aws/compute/ecs.js +1 -1
  33. package/dist/lib/resources/aws/compute/ecsNetworking.d.ts +1 -1
  34. package/dist/lib/resources/aws/compute/ecsNetworking.js +212 -47
  35. package/dist/lib/resources/aws/compute/ecsTypes.d.ts +60 -9
  36. package/dist/lib/resources/aws/compute/ecsValidation.d.ts +14 -1
  37. package/dist/lib/resources/aws/compute/ecsValidation.js +51 -0
  38. package/dist/lib/resources/aws/networking/dnsRecord/aRecord.js +3 -2
  39. package/dist/lib/resources/aws/networking/dnsRecord/aaaaRecord.js +3 -2
  40. package/dist/lib/resources/aws/networking/dnsRecord/aliasRecord.d.ts +23 -1
  41. package/dist/lib/resources/aws/networking/dnsRecord/aliasRecord.js +14 -3
  42. package/dist/lib/resources/aws/networking/dnsRecord/caaRecord.js +3 -2
  43. package/dist/lib/resources/aws/networking/dnsRecord/cnameRecord.js +3 -2
  44. package/dist/lib/resources/aws/networking/dnsRecord/dnsRecordBase.d.ts +10 -1
  45. package/dist/lib/resources/aws/networking/dnsRecord/dnsRecordBase.js +21 -4
  46. package/dist/lib/resources/aws/networking/dnsRecord/mxRecord.js +3 -2
  47. package/dist/lib/resources/aws/networking/dnsRecord/nsRecord.js +3 -2
  48. package/dist/lib/resources/aws/networking/dnsRecord/srvRecord.js +3 -2
  49. package/dist/lib/resources/aws/networking/dnsRecord/txtRecord.js +3 -2
  50. package/dist/lib/resources/aws/networking/domainCertificate.d.ts +28 -4
  51. package/dist/lib/resources/aws/networking/domainCertificate.js +24 -10
  52. package/dist/lib/resources/aws/networking/hostedZone.d.ts +11 -0
  53. package/dist/lib/resources/aws/networking/hostedZone.js +6 -0
  54. package/dist/lib/utils/costAllocationTags.d.ts +9 -0
  55. package/dist/lib/utils/costAllocationTags.js +6 -1
  56. package/dist/lib/utils/dnsRecordRegistry.d.ts +52 -0
  57. package/dist/lib/utils/dnsRecordRegistry.js +64 -0
  58. package/dist/lib/utils/domainTypes.d.ts +43 -36
  59. package/dist/lib/utils/domainTypes.js +65 -2
  60. package/dist/lib/utils/managedDomainContext.d.ts +37 -0
  61. package/dist/lib/utils/managedDomainContext.js +111 -0
  62. package/package.json +4 -4
@@ -0,0 +1,111 @@
1
+ /**
2
+ * CDK-context channel for CLI-injected managed-domain bindings (design
3
+ * 2026-07-17 domain-management gold-plating, D2 — resolution by injection).
4
+ *
5
+ * At deploy time the Fjall CLI resolves each app-consumed domain against the
6
+ * declared `fjall/domains/` components (DescribeStacks on the domain stack)
7
+ * and injects one context entry per zone:
8
+ *
9
+ * -c fjall:managedDomain:<zoneName>=<JSON ManagedDomainBinding>
10
+ *
11
+ * (emitter: deploy-core `CdkArgumentBuilder.buildContextArgs` — keep the
12
+ * prefix literal in sync). Constructs read the entry ahead of their BYO
13
+ * `zoneName`/`hostedZone` props; an EXPLICIT `managedDomain` prop still wins
14
+ * over the injected value. Bare-CDK synth simply lacks the context and falls
15
+ * back to explicit props.
16
+ *
17
+ * Utils layer on purpose: consumed by both the resources layer
18
+ * (`ecsNetworking.addHostedZone`) and the patterns layer
19
+ * (`patternDomain.resolvePatternZone`), and utils is their lowest common
20
+ * layer (generator-standards § Infrastructure Layer Boundaries).
21
+ */
22
+ export const MANAGED_DOMAIN_CONTEXT_PREFIX = "fjall:managedDomain:";
23
+ export function getManagedDomainContextKey(zoneName) {
24
+ return `${MANAGED_DOMAIN_CONTEXT_PREFIX}${zoneName}`;
25
+ }
26
+ const REQUIRED_STRING_FIELDS = ["zoneName", "hostedZoneId"];
27
+ const OPTIONAL_STRING_FIELDS = [
28
+ "certificateArn",
29
+ "usEast1CertificateArn",
30
+ "delegationRoleArn"
31
+ ];
32
+ const KNOWN_FIELDS = [
33
+ ...REQUIRED_STRING_FIELDS,
34
+ ...OPTIONAL_STRING_FIELDS
35
+ ];
36
+ /**
37
+ * Read the CLI-injected {@link ManagedDomainBinding} for `domainName`,
38
+ * walking exact → parent zones (mirroring the CLI's
39
+ * `DomainService.matchManagedDomain` semantics: `app.example.com` matches a
40
+ * binding injected for `example.com`). Returns undefined when no entry is
41
+ * present (bare-CDK synth); throws a context-prefixed, value-echoing,
42
+ * cure-naming error when an entry exists but is malformed — a corrupt
43
+ * binding must fail the synth, never fall through to a guessed zone.
44
+ *
45
+ * `context` prefixes every error, e.g. `Static site 'marketing'`.
46
+ */
47
+ export function readInjectedManagedDomainBinding(node, domainName, context) {
48
+ const labels = domainName.split(".");
49
+ for (let i = 0; i < labels.length; i++) {
50
+ const candidate = labels.slice(i).join(".");
51
+ const key = getManagedDomainContextKey(candidate);
52
+ const raw = node.tryGetContext(key);
53
+ if (raw === undefined)
54
+ continue;
55
+ return parseManagedDomainBinding(raw, candidate, key, context);
56
+ }
57
+ return undefined;
58
+ }
59
+ function parseManagedDomainBinding(raw, zoneName, key, context) {
60
+ let value = raw;
61
+ if (typeof raw === "string") {
62
+ try {
63
+ value = JSON.parse(raw);
64
+ }
65
+ catch {
66
+ throw new Error(`${context}: CDK context '${key}' is not valid JSON (got '${raw}'). ` +
67
+ "The value must be a JSON ManagedDomainBinding " +
68
+ "({ zoneName, hostedZoneId, certificateArn?, " +
69
+ "usEast1CertificateArn?, delegationRoleArn? }) — re-run the deploy " +
70
+ "through the Fjall CLI, or correct the hand-set context entry.");
71
+ }
72
+ }
73
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
74
+ throw new Error(`${context}: CDK context '${key}' must be a JSON object ` +
75
+ `ManagedDomainBinding (got ${JSON.stringify(value)}). Re-run the ` +
76
+ "deploy through the Fjall CLI, or correct the hand-set context entry.");
77
+ }
78
+ const record = value;
79
+ for (const field of Object.keys(record)) {
80
+ if (!KNOWN_FIELDS.includes(field)) {
81
+ throw new Error(`${context}: CDK context '${key}' carries unknown field '${field}' ` +
82
+ `(got ${JSON.stringify(record)}). Known fields: ` +
83
+ `${KNOWN_FIELDS.join(", ")}. Re-run the deploy through the Fjall ` +
84
+ "CLI, or correct the hand-set context entry.");
85
+ }
86
+ }
87
+ for (const field of REQUIRED_STRING_FIELDS) {
88
+ if (typeof record[field] !== "string" || record[field] === "") {
89
+ throw new Error(`${context}: CDK context '${key}' is missing required string field ` +
90
+ `'${field}' (got ${JSON.stringify(record[field])}). Redeploy the ` +
91
+ `domain stack ('fjall domain deploy ${zoneName}') so the CLI ` +
92
+ "injects a complete binding, or correct the hand-set context entry.");
93
+ }
94
+ }
95
+ for (const field of OPTIONAL_STRING_FIELDS) {
96
+ const fieldValue = record[field];
97
+ if (fieldValue !== undefined && typeof fieldValue !== "string") {
98
+ throw new Error(`${context}: CDK context '${key}' field '${field}' must be a string ` +
99
+ `when present (got ${JSON.stringify(fieldValue)}). Re-run the ` +
100
+ "deploy through the Fjall CLI, or correct the hand-set context entry.");
101
+ }
102
+ }
103
+ if (record.zoneName !== zoneName) {
104
+ throw new Error(`${context}: CDK context '${key}' declares zoneName ` +
105
+ `'${String(record.zoneName)}', which does not match the key's zone ` +
106
+ `'${zoneName}'. The injection contract keys each binding by its own ` +
107
+ "zone — re-run the deploy through the Fjall CLI, or correct the " +
108
+ "hand-set context entry.");
109
+ }
110
+ return record;
111
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjall/components-infrastructure",
3
- "version": "2.34.0",
3
+ "version": "3.0.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "bin": {
@@ -67,8 +67,8 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@aws-sdk/client-organizations": "^3.1038.0",
70
- "@fjall/generator": "^2.34.0",
71
- "@fjall/util": "^2.34.0",
70
+ "@fjall/generator": "^3.0.0",
71
+ "@fjall/util": "^3.0.0",
72
72
  "constructs": "^10.6.0"
73
73
  },
74
74
  "overrides": {
@@ -82,5 +82,5 @@
82
82
  "engines": {
83
83
  "node": ">=18.0.0"
84
84
  },
85
- "gitHead": "8c553fca8f9737d445061ea75cf6c6c7db0d24c9"
85
+ "gitHead": "848a386e3e2244401b76faabd02818c682d231e8"
86
86
  }