@fjall/deploy-core 0.89.5 → 0.89.6

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 (198) hide show
  1. package/LICENSE +50 -21
  2. package/README.md +25 -0
  3. package/dist/.minified +1 -0
  4. package/dist/src/__test-utils__/awsMockHelpers.d.ts +20 -0
  5. package/dist/src/__test-utils__/awsMockHelpers.js +1 -0
  6. package/dist/src/__test-utils__/index.d.ts +1 -0
  7. package/dist/src/__test-utils__/index.js +1 -0
  8. package/dist/src/aws/AwsProvider.js +0 -1
  9. package/dist/src/aws/SimpleAwsProvider.js +1 -70
  10. package/dist/src/aws/index.d.ts +4 -2
  11. package/dist/src/aws/index.js +1 -3
  12. package/dist/src/aws/organisations/accounts.js +10 -10
  13. package/dist/src/aws/organisations/backup.js +4 -2
  14. package/dist/src/aws/organisations/costAllocation.js +4 -2
  15. package/dist/src/aws/organisations/delegatedAdmin.d.ts +9 -0
  16. package/dist/src/aws/organisations/delegatedAdmin.js +43 -0
  17. package/dist/src/aws/organisations/identityCentre.d.ts +1 -1
  18. package/dist/src/aws/organisations/identityCentre.js +6 -2
  19. package/dist/src/aws/organisations/index.d.ts +4 -3
  20. package/dist/src/aws/organisations/index.js +1 -12
  21. package/dist/src/aws/organisations/ipam.js +4 -2
  22. package/dist/src/aws/organisations/organisation.js +27 -18
  23. package/dist/src/aws/organisations/organisationalUnits.d.ts +26 -6
  24. package/dist/src/aws/organisations/organisationalUnits.js +149 -35
  25. package/dist/src/aws/organisations/policies.js +4 -3
  26. package/dist/src/aws/organisations/ram.js +6 -2
  27. package/dist/src/aws/organisations/serviceAccess.js +12 -6
  28. package/dist/src/aws/organisations/trustedAccess.js +6 -2
  29. package/dist/src/aws/organisations/types.d.ts +23 -1
  30. package/dist/src/aws/organisations/types.js +1 -16
  31. package/dist/src/aws/utils/__tests__/cloudformationTestHelpers.d.ts +6 -0
  32. package/dist/src/aws/utils/__tests__/cloudformationTestHelpers.js +1 -0
  33. package/dist/src/aws/utils/cloudformationEventHelpers.d.ts +48 -0
  34. package/dist/src/aws/utils/cloudformationEventHelpers.js +1 -0
  35. package/dist/src/aws/utils/cloudformationEventTypes.d.ts +45 -0
  36. package/dist/src/aws/utils/cloudformationEventTypes.js +1 -0
  37. package/dist/src/aws/utils/cloudformationEvents.d.ts +8 -54
  38. package/dist/src/aws/utils/cloudformationEvents.js +1 -596
  39. package/dist/src/aws/utils/index.d.ts +5 -0
  40. package/dist/src/aws/utils/index.js +1 -0
  41. package/dist/src/aws/utils/stackStatus.js +1 -90
  42. package/dist/src/events/index.d.ts +13 -0
  43. package/dist/src/events/index.js +1 -0
  44. package/dist/src/index.d.ts +34 -17
  45. package/dist/src/index.js +41 -21
  46. package/dist/src/orchestration/__tests__/cascadeTestHelpers.d.ts +12 -0
  47. package/dist/src/orchestration/__tests__/cascadeTestHelpers.js +78 -0
  48. package/dist/src/orchestration/activeDeploymentGuard.d.ts +10 -0
  49. package/dist/src/orchestration/activeDeploymentGuard.js +39 -0
  50. package/dist/src/orchestration/applicationDeploy.js +46 -229
  51. package/dist/src/orchestration/applicationDeployHelpers.d.ts +39 -0
  52. package/dist/src/orchestration/applicationDeployHelpers.js +223 -0
  53. package/dist/src/orchestration/applicationDestroy.d.ts +14 -0
  54. package/dist/src/orchestration/applicationDestroy.js +131 -0
  55. package/dist/src/orchestration/builders/dockerBuilder.d.ts +17 -0
  56. package/dist/src/orchestration/builders/dockerBuilder.js +98 -0
  57. package/dist/src/orchestration/builders/frameworkRegistry.d.ts +23 -0
  58. package/dist/src/orchestration/builders/frameworkRegistry.js +1 -0
  59. package/dist/src/orchestration/builders/index.d.ts +4 -0
  60. package/dist/src/orchestration/builders/index.js +1 -0
  61. package/dist/src/orchestration/builders/openNextBuilder.d.ts +21 -0
  62. package/dist/src/orchestration/builders/openNextBuilder.js +144 -0
  63. package/dist/src/orchestration/cascadeDestroyHelpers.d.ts +30 -0
  64. package/dist/src/orchestration/cascadeDestroyHelpers.js +1 -0
  65. package/dist/src/orchestration/cascadeHelpers.d.ts +46 -0
  66. package/dist/src/orchestration/cascadeHelpers.js +160 -0
  67. package/dist/src/orchestration/contextHelpers.d.ts +46 -2
  68. package/dist/src/orchestration/contextHelpers.js +93 -1
  69. package/dist/src/orchestration/destroy.d.ts +13 -0
  70. package/dist/src/orchestration/destroy.js +67 -0
  71. package/dist/src/orchestration/detectionPipeline.d.ts +2 -11
  72. package/dist/src/orchestration/detectionPipeline.js +29 -10
  73. package/dist/src/orchestration/dockerBuildHelper.d.ts +10 -0
  74. package/dist/src/orchestration/dockerBuildHelper.js +49 -0
  75. package/dist/src/orchestration/dockerInterface.d.ts +4 -2
  76. package/dist/src/orchestration/index.d.ts +8 -1
  77. package/dist/src/orchestration/index.js +1 -3
  78. package/dist/src/orchestration/manifestSecretParser.d.ts +11 -0
  79. package/dist/src/orchestration/manifestSecretParser.js +1 -0
  80. package/dist/src/orchestration/openNextBuild.d.ts +28 -0
  81. package/dist/src/orchestration/openNextBuild.js +243 -0
  82. package/dist/src/orchestration/organisationDeploy.js +110 -233
  83. package/dist/src/orchestration/organisationDestroy.d.ts +24 -0
  84. package/dist/src/orchestration/organisationDestroy.js +189 -0
  85. package/dist/src/orchestration/organisationSetup.d.ts +6 -4
  86. package/dist/src/orchestration/organisationSetup.js +28 -8
  87. package/dist/src/orchestration/resolveOperation.js +68 -6
  88. package/dist/src/orchestration/serviceFactory.d.ts +4 -0
  89. package/dist/src/orchestration/serviceFactory.js +1 -16
  90. package/dist/src/orchestration/spawnHelpers.d.ts +47 -0
  91. package/dist/src/orchestration/spawnHelpers.js +1 -0
  92. package/dist/src/orchestration/stackCleanup.d.ts +39 -0
  93. package/dist/src/orchestration/stackCleanup.js +1 -0
  94. package/dist/src/orchestration/welcomeImageHelper.d.ts +15 -0
  95. package/dist/src/orchestration/welcomeImageHelper.js +64 -0
  96. package/dist/src/services/application/ApplicationStackService.d.ts +21 -30
  97. package/dist/src/services/application/ApplicationStackService.js +16 -234
  98. package/dist/src/services/application/applicationStackHelpers.d.ts +46 -0
  99. package/dist/src/services/application/applicationStackHelpers.js +248 -0
  100. package/dist/src/services/application/index.d.ts +1 -0
  101. package/dist/src/services/application/index.js +1 -1
  102. package/dist/src/services/index.d.ts +6 -0
  103. package/dist/src/services/index.js +1 -0
  104. package/dist/src/services/infrastructure/CdkArgumentBuilder.js +1 -67
  105. package/dist/src/services/infrastructure/CdkCommandRunner.d.ts +10 -2
  106. package/dist/src/services/infrastructure/CdkCommandRunner.js +18 -15
  107. package/dist/src/services/infrastructure/CdkErrorFormatter.js +16 -194
  108. package/dist/src/services/infrastructure/CdkEventMonitoring.js +1 -41
  109. package/dist/src/services/infrastructure/CdkOutputAnalyser.js +1 -1
  110. package/dist/src/services/infrastructure/CdkOutputParser.js +2 -33
  111. package/dist/src/services/infrastructure/CdkProcessManager.d.ts +5 -0
  112. package/dist/src/services/infrastructure/CdkProcessManager.js +81 -47
  113. package/dist/src/services/infrastructure/CdkService.d.ts +7 -53
  114. package/dist/src/services/infrastructure/CdkService.js +41 -83
  115. package/dist/src/services/infrastructure/CdkServiceTypes.d.ts +50 -0
  116. package/dist/src/services/infrastructure/CdkServiceTypes.js +0 -0
  117. package/dist/src/services/infrastructure/CloudFormationService.js +9 -10
  118. package/dist/src/services/infrastructure/ICdkProcessManager.d.ts +27 -0
  119. package/dist/src/services/infrastructure/ICdkProcessManager.js +1 -0
  120. package/dist/src/services/infrastructure/__tests__/cloudFormationTestHelpers.d.ts +9 -0
  121. package/dist/src/services/infrastructure/__tests__/cloudFormationTestHelpers.js +1 -0
  122. package/dist/src/services/infrastructure/cdkServiceHelpers.d.ts +9 -0
  123. package/dist/src/services/infrastructure/cdkServiceHelpers.js +1 -0
  124. package/dist/src/services/infrastructure/constructMapEnrichment.d.ts +7 -0
  125. package/dist/src/services/infrastructure/constructMapEnrichment.js +1 -0
  126. package/dist/src/services/infrastructure/index.d.ts +3 -1
  127. package/dist/src/services/infrastructure/index.js +1 -7
  128. package/dist/src/services/supporting/TemplateHashService.js +1 -1
  129. package/dist/src/services/supporting/helpers.js +1 -81
  130. package/dist/src/services/supporting/index.js +1 -3
  131. package/dist/src/steps/index.d.ts +1 -0
  132. package/dist/src/steps/index.js +1 -0
  133. package/dist/src/steps/stepRegistry.d.ts +71 -0
  134. package/dist/src/steps/stepRegistry.js +505 -0
  135. package/dist/src/types/FjallState.js +1 -118
  136. package/dist/src/types/ProgressEvent.js +1 -48
  137. package/dist/src/types/application/ApplicationServiceTypes.js +1 -30
  138. package/dist/src/types/application/index.js +1 -1
  139. package/dist/src/types/callbacks.d.ts +76 -4
  140. package/dist/src/types/callbacks.js +0 -1
  141. package/dist/src/types/constants.d.ts +2 -0
  142. package/dist/src/types/constants.js +1 -6
  143. package/dist/src/types/credentials.js +0 -1
  144. package/dist/src/types/deployment/DeploymentServiceTypes.d.ts +5 -2
  145. package/dist/src/types/deployment/DeploymentServiceTypes.js +1 -1
  146. package/dist/src/types/deployment/DeploymentTypes.js +0 -1
  147. package/dist/src/types/deployment/cloudformation.js +0 -1
  148. package/dist/src/types/deployment/index.d.ts +3 -1
  149. package/dist/src/types/deployment/index.js +1 -1
  150. package/dist/src/types/deployment/parallel.js +1 -10
  151. package/dist/src/types/deploymentEventSchema.d.ts +158 -0
  152. package/dist/src/types/deploymentEventSchema.js +1 -0
  153. package/dist/src/types/detection.d.ts +22 -0
  154. package/dist/src/types/detection.js +1 -0
  155. package/dist/src/types/entitlements.d.ts +31 -0
  156. package/dist/src/types/entitlements.js +0 -0
  157. package/dist/src/types/errors/CdkError.js +1 -20
  158. package/dist/src/types/errors/ServiceError.d.ts +2 -1
  159. package/dist/src/types/errors/ServiceError.js +1 -119
  160. package/dist/src/types/errors/index.d.ts +2 -0
  161. package/dist/src/types/errors/index.js +1 -0
  162. package/dist/src/types/events.d.ts +3 -9
  163. package/dist/src/types/events.js +0 -5
  164. package/dist/src/types/frameworkBuilder.d.ts +96 -0
  165. package/dist/src/types/frameworkBuilder.js +8 -0
  166. package/dist/src/types/index.d.ts +19 -4
  167. package/dist/src/types/index.js +1 -9
  168. package/dist/src/types/operations.d.ts +3 -2
  169. package/dist/src/types/operations.js +1 -285
  170. package/dist/src/types/orgConfig.d.ts +2 -10
  171. package/dist/src/types/orgConfig.js +0 -11
  172. package/dist/src/types/params.d.ts +60 -1
  173. package/dist/src/types/patternDetection.d.ts +14 -16
  174. package/dist/src/types/patternDetection.js +14 -18
  175. package/dist/src/types/patternTypes.d.ts +19 -0
  176. package/dist/src/types/patternTypes.js +1 -0
  177. package/dist/src/types/stepDefinitions.d.ts +163 -0
  178. package/dist/src/types/stepDefinitions.js +98 -0
  179. package/dist/src/types/validation.js +0 -1
  180. package/dist/src/util/dockerfileDetection.d.ts +5 -0
  181. package/dist/src/util/dockerfileDetection.js +1 -0
  182. package/dist/src/util/index.d.ts +4 -3
  183. package/dist/src/util/index.js +1 -3
  184. package/dist/src/util/sequencedCallbacks.d.ts +44 -0
  185. package/dist/src/util/sequencedCallbacks.js +1 -0
  186. package/package.json +49 -8
  187. package/dist/src/aws/utils/CloudFormationFailureAnalyser.d.ts +0 -32
  188. package/dist/src/aws/utils/CloudFormationFailureAnalyser.js +0 -228
  189. package/dist/src/aws/utils/errors.d.ts +0 -26
  190. package/dist/src/aws/utils/errors.js +0 -59
  191. package/dist/src/util/fsHelpers.d.ts +0 -4
  192. package/dist/src/util/fsHelpers.js +0 -16
  193. package/dist/src/util/securityHelpers.d.ts +0 -31
  194. package/dist/src/util/securityHelpers.js +0 -124
  195. package/dist/src/util/singleton.d.ts +0 -2
  196. package/dist/src/util/singleton.js +0 -9
  197. package/dist/src/util/sleep.d.ts +0 -4
  198. package/dist/src/util/sleep.js +0 -4
@@ -1,19 +1,16 @@
1
1
  /**
2
- * Pattern detection types and functions.
2
+ * Filesystem-based pattern detection functions.
3
3
  *
4
- * Contains both pure predicates used by operations.ts and
5
- * filesystem-based detection functions used by orchestration services.
4
+ * Pure types and predicates live in patternTypes.ts (browser-safe).
5
+ * This file contains only functions that require Node fs access.
6
6
  */
7
7
  import { existsSync, readFileSync } from "fs";
8
8
  import { join } from "path";
9
- import { logger, getErrorMessage } from "@fjall/util";
9
+ import { logger } from "@fjall/util/logger";
10
+ import { getErrorMessage } from "@fjall/util";
10
11
  import { APPLICATION_STACKS } from "./operations.js";
11
12
  import { INFRASTRUCTURE_FILENAME } from "./constants.js";
12
- const OPENNEXT_PATTERNS_ARRAY = ["payload", "nextjs"];
13
- export const OPENNEXT_PATTERNS = new Set(OPENNEXT_PATTERNS_ARRAY);
14
- export function isOpenNextPattern(pattern) {
15
- return (pattern !== undefined && pattern !== null && OPENNEXT_PATTERNS.has(pattern));
16
- }
13
+ export { OPENNEXT_PATTERNS, isOpenNextPattern } from "./patternTypes.js";
17
14
  /** Derive resource flags from manifest stack names (authoritative, post-synth) */
18
15
  export function deriveResourcesFromManifestStacks(stackNames) {
19
16
  const has = (suffix) => stackNames.some((s) => s.endsWith(suffix));
@@ -30,7 +27,7 @@ export function deriveResourcesFromManifestStacks(stackNames) {
30
27
  * Read infrastructure.ts content from an app path.
31
28
  * Returns null if file doesn't exist or can't be read.
32
29
  */
33
- function readInfrastructureContent(appPath) {
30
+ export function readInfrastructureContent(appPath) {
34
31
  try {
35
32
  const filePath = join(appPath, INFRASTRUCTURE_FILENAME);
36
33
  if (!existsSync(filePath))
@@ -52,6 +49,9 @@ function readInfrastructureContent(appPath) {
52
49
  * project files like package.json. This ensures accurate detection even
53
50
  * when multiple apps coexist in the same project directory.
54
51
  *
52
+ * @deprecated Use FrameworkRegistry.resolve() instead. This function is retained
53
+ * for backwards compatibility with consumers that have not yet migrated.
54
+ *
55
55
  * @param appPath - The fjall app path (e.g., "fjall/app8" or absolute path)
56
56
  */
57
57
  export function detectPattern(appPath) {
@@ -76,17 +76,13 @@ export function detectPattern(appPath) {
76
76
  * Detect if infrastructure.ts contains a Payload CMS pattern.
77
77
  */
78
78
  export function detectPayloadPattern(appPath) {
79
- const content = readInfrastructureContent(appPath);
80
- if (!content)
81
- return false;
82
- return (content.includes("PatternFactory") && content.includes('type: "payload"'));
79
+ const { pattern } = detectPattern(appPath);
80
+ return pattern === "payload";
83
81
  }
84
82
  /**
85
83
  * Detect if infrastructure.ts contains a database resource.
86
84
  */
87
85
  export function detectDatabase(appPath) {
88
- const content = readInfrastructureContent(appPath);
89
- if (!content)
90
- return false;
91
- return content.includes("DatabaseFactory.build(");
86
+ const { hasDatabase } = detectPattern(appPath);
87
+ return hasDatabase;
92
88
  }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Pure pattern types and predicates — no filesystem dependencies.
3
+ *
4
+ * These are safe for browser bundles. Filesystem-based detection functions
5
+ * remain in patternDetection.ts.
6
+ */
7
+ declare const OPENNEXT_PATTERNS_ARRAY: readonly ["payload", "nextjs"];
8
+ export type OpenNextPattern = (typeof OPENNEXT_PATTERNS_ARRAY)[number];
9
+ export declare const OPENNEXT_PATTERNS: ReadonlySet<string>;
10
+ export declare function isOpenNextPattern(pattern: string | undefined | null): pattern is OpenNextPattern;
11
+ export interface AppResourceFlags {
12
+ hasNetwork: boolean;
13
+ hasCompute: boolean;
14
+ hasDatabase: boolean;
15
+ hasStorage: boolean;
16
+ hasMessaging: boolean;
17
+ hasCdn: boolean;
18
+ }
19
+ export {};
@@ -0,0 +1 @@
1
+ const e=["payload","nextjs"],t=new Set(e);function N(n){return n!=null&&t.has(n)}export{t as OPENNEXT_PATTERNS,N as isOpenNextPattern};
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Canonical step definitions for all deployment types.
3
+ *
4
+ * These constants and types define the deployment step metadata shared
5
+ * across CLI, webapp worker, and any other consumer. The filtering and
6
+ * registry logic (which steps to show, conditional visibility) lives
7
+ * in steps/stepRegistry.ts — this file is the data layer.
8
+ */
9
+ import type { PatternType } from "@fjall/generator";
10
+ import type { AppResourceFlags } from "./patternTypes.js";
11
+ /**
12
+ * Step IDs used throughout the deployment process.
13
+ * Centralised here to avoid magic strings and enable type safety.
14
+ */
15
+ export declare const STEP_IDS: {
16
+ readonly AUTH: "auth";
17
+ readonly DETECT_CONFIG: "detect-config";
18
+ readonly BOOTSTRAP: "bootstrap";
19
+ readonly CFN_CHECK: "cfn-check";
20
+ readonly DIFF: "diff";
21
+ readonly DEPLOY: "deploy";
22
+ readonly DESTROY: "destroy";
23
+ readonly VERIFY: "verify";
24
+ readonly OPENNEXT_BUILD: "opennext-build";
25
+ readonly CDK_SYNTH: "cdk-synth";
26
+ readonly DOCKER_OPERATIONS: "docker-operations";
27
+ readonly ECR_INIT: "ecr-init";
28
+ readonly DOCKER_DEPLOY: "docker-deploy";
29
+ readonly TAG_ECR_IMAGES: "tag-ecr-images";
30
+ readonly ECS_UPDATE: "ecs-update";
31
+ readonly ECS_MONITOR: "ecs-monitor";
32
+ readonly ORG_SETUP: "org-setup";
33
+ readonly ORG_ENSURE: "org-ensure";
34
+ readonly ORG_POLICY_TYPES: "policy-types";
35
+ readonly ORG_SERVICE_ACCESS: "service-access";
36
+ readonly ORG_CREATE_ACCOUNTS: "create-accounts";
37
+ readonly ORG_ENSURE_OUS: "ensure-ous";
38
+ readonly ORG_PLACE_ACCOUNTS: "place-accounts";
39
+ readonly IDENTITY_CENTRE: "identity-centre";
40
+ readonly ORG_ACCOUNTS: "accounts";
41
+ readonly ORG_COST_TAGS: "cost-tags";
42
+ readonly ORG_PROFILES: "profiles";
43
+ /** Organisation-level prepare (synth + hash-compare). For infra, use PREPARE_ENVIRONMENT. */
44
+ readonly PREPARE: "prepare";
45
+ readonly PREPARE_ENVIRONMENT: "prepare-environment";
46
+ readonly PLATFORM_ACCOUNT: "platform-account";
47
+ readonly ACCOUNT_CONTEXT: "account-context";
48
+ readonly CONNECT: "connect";
49
+ readonly MONITORING: "monitoring";
50
+ readonly ORG_DEPLOY: "organisation-deploy";
51
+ readonly ORG_DESTROY: "organisation-destroy";
52
+ readonly CASCADE_PLATFORM: "cascade-platform";
53
+ readonly CASCADE_DOMAINS: "cascade-domains";
54
+ readonly CASCADE_ACCOUNTS: "cascade-accounts";
55
+ readonly NETWORK: "network";
56
+ readonly STORAGE: "storage";
57
+ readonly MESSAGING: "messaging";
58
+ readonly DATABASE: "database";
59
+ readonly COMPUTE: "compute";
60
+ readonly CDN: "cdn";
61
+ readonly NETWORK_DESTROY: "network-destroy";
62
+ readonly STORAGE_DESTROY: "storage-destroy";
63
+ readonly MESSAGING_DESTROY: "messaging-destroy";
64
+ readonly DATABASE_DESTROY: "database-destroy";
65
+ readonly COMPUTE_DESTROY: "compute-destroy";
66
+ readonly CDN_DESTROY: "cdn-destroy";
67
+ };
68
+ export type StepId = (typeof STEP_IDS)[keyof typeof STEP_IDS];
69
+ /**
70
+ * Human-readable step names paired with STEP_IDS.
71
+ * Extracted because these strings are used at 3+ call sites.
72
+ */
73
+ export declare const STEP_NAMES: {
74
+ readonly AUTH: "Authenticating with AWS";
75
+ readonly PREPARE_DEPLOY: "Preparing deployment";
76
+ readonly PREPARE_DESTROY: "Preparing destruction";
77
+ readonly BOOTSTRAP: "Bootstrapping AWS environment";
78
+ readonly CHECK_INFRA_STATE: "Checking infrastructure state";
79
+ };
80
+ /**
81
+ * Canonical step names emitted by infrastructure deployments (platform/account).
82
+ * The webapp's onboarding timeline and deployment detail page import these
83
+ * directly, replacing the previous fragile string duplication.
84
+ */
85
+ export declare const INFRASTRUCTURE_STEP_NAMES: readonly ["Connect securely", "Prepare environment", "Deploy infrastructure", "Enable monitoring"];
86
+ /** Named access for specific step names (avoids fragile positional indices) */
87
+ export declare const INFRA_STEP_NAME: {
88
+ readonly CONNECT: "Connect securely";
89
+ readonly PREPARE: "Prepare environment";
90
+ readonly DEPLOY: "Deploy infrastructure";
91
+ readonly MONITORING: "Enable monitoring";
92
+ };
93
+ export type InfrastructureStepName = (typeof INFRASTRUCTURE_STEP_NAMES)[number];
94
+ export interface StepDefinition {
95
+ id: StepId;
96
+ name: string;
97
+ conditions?: {
98
+ requiresInfra?: boolean;
99
+ requiresDocker?: boolean;
100
+ requiresECS?: boolean;
101
+ requiresImageTagging?: boolean;
102
+ skipForInfraOnly?: boolean;
103
+ excludeForManagedAccount?: boolean;
104
+ excludeWhenHasDockerfile?: boolean;
105
+ requiresNetwork?: boolean;
106
+ requiresCompute?: boolean;
107
+ requiresDatabase?: boolean;
108
+ requiresStorage?: boolean;
109
+ requiresMessaging?: boolean;
110
+ requiresCdn?: boolean;
111
+ requiresMemberAccounts?: boolean;
112
+ requiresPlatformAccount?: boolean;
113
+ requiresOrgChanges?: boolean;
114
+ requiresPlatformChanges?: boolean;
115
+ requiresAccountChanges?: boolean;
116
+ requiresDomainConfiguration?: boolean;
117
+ requiresDomainChanges?: boolean;
118
+ };
119
+ }
120
+ /**
121
+ * Deployment type for step context.
122
+ *
123
+ * Named StepDeploymentType to avoid collision with the 2-value
124
+ * DeploymentType in params.ts ("application" | "organisation").
125
+ * This 4-value union covers all deployment targets including
126
+ * platform and account sub-deployments.
127
+ */
128
+ export type StepDeploymentType = "application" | "organisation" | "platform" | "account";
129
+ export type Operation = "deploy" | "destroy";
130
+ export interface StepContext {
131
+ deploymentType: StepDeploymentType;
132
+ operation: Operation;
133
+ deployOnly?: boolean;
134
+ infraOnly?: boolean;
135
+ isManagedAccount?: boolean;
136
+ hasDockerfile?: boolean;
137
+ hasDifferences?: boolean;
138
+ pattern?: PatternType | null;
139
+ /** Name of the framework builder that resolved this app (e.g. "opennext", "docker"). */
140
+ builderName?: string;
141
+ openNextOutput?: {
142
+ serverFunction?: string;
143
+ imageOptimisationFunction?: string;
144
+ revalidationFunction?: string;
145
+ warmerFunction?: string;
146
+ assets?: string;
147
+ cache?: string;
148
+ };
149
+ /** Build configuration for pattern apps */
150
+ build?: {
151
+ requiresDatabase: boolean;
152
+ databaseEnvVar: string;
153
+ };
154
+ /** Post-synth resource detection from manifest */
155
+ resources?: AppResourceFlags;
156
+ hasMemberAccounts?: boolean;
157
+ hasPlatformAccount?: boolean;
158
+ hasOrgChanges?: boolean;
159
+ hasPlatformChanges?: boolean;
160
+ hasAccountChanges?: boolean;
161
+ hasDomainConfiguration?: boolean;
162
+ hasDomainChanges?: boolean;
163
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Step IDs used throughout the deployment process.
3
+ * Centralised here to avoid magic strings and enable type safety.
4
+ */
5
+ export const STEP_IDS = {
6
+ // Common steps
7
+ AUTH: "auth",
8
+ DETECT_CONFIG: "detect-config",
9
+ BOOTSTRAP: "bootstrap",
10
+ CFN_CHECK: "cfn-check",
11
+ DIFF: "diff",
12
+ DEPLOY: "deploy",
13
+ DESTROY: "destroy",
14
+ VERIFY: "verify",
15
+ // OpenNext steps
16
+ OPENNEXT_BUILD: "opennext-build",
17
+ CDK_SYNTH: "cdk-synth",
18
+ // Docker/ECS steps
19
+ DOCKER_OPERATIONS: "docker-operations",
20
+ ECR_INIT: "ecr-init",
21
+ DOCKER_DEPLOY: "docker-deploy",
22
+ TAG_ECR_IMAGES: "tag-ecr-images",
23
+ ECS_UPDATE: "ecs-update",
24
+ ECS_MONITOR: "ecs-monitor",
25
+ // Organisation-specific steps
26
+ ORG_SETUP: "org-setup",
27
+ ORG_ENSURE: "org-ensure",
28
+ ORG_POLICY_TYPES: "policy-types",
29
+ ORG_SERVICE_ACCESS: "service-access",
30
+ ORG_CREATE_ACCOUNTS: "create-accounts",
31
+ ORG_ENSURE_OUS: "ensure-ous",
32
+ ORG_PLACE_ACCOUNTS: "place-accounts",
33
+ IDENTITY_CENTRE: "identity-centre",
34
+ ORG_ACCOUNTS: "accounts",
35
+ ORG_COST_TAGS: "cost-tags",
36
+ ORG_PROFILES: "profiles",
37
+ /** Organisation-level prepare (synth + hash-compare). For infra, use PREPARE_ENVIRONMENT. */
38
+ PREPARE: "prepare",
39
+ // Infrastructure-level prepare (platform/account deploy)
40
+ PREPARE_ENVIRONMENT: "prepare-environment",
41
+ // Platform-specific steps
42
+ PLATFORM_ACCOUNT: "platform-account",
43
+ // Account-specific steps
44
+ ACCOUNT_CONTEXT: "account-context",
45
+ // Infrastructure lifecycle steps (platform/account deploy)
46
+ CONNECT: "connect",
47
+ MONITORING: "monitoring",
48
+ // Organisation deploy/destroy steps
49
+ ORG_DEPLOY: "organisation-deploy",
50
+ ORG_DESTROY: "organisation-destroy",
51
+ // Cascade steps
52
+ CASCADE_PLATFORM: "cascade-platform",
53
+ CASCADE_DOMAINS: "cascade-domains",
54
+ CASCADE_ACCOUNTS: "cascade-accounts",
55
+ // Infrastructure stack steps (deploy)
56
+ NETWORK: "network",
57
+ STORAGE: "storage",
58
+ MESSAGING: "messaging",
59
+ DATABASE: "database",
60
+ COMPUTE: "compute",
61
+ CDN: "cdn",
62
+ // Infrastructure stack steps (destroy)
63
+ NETWORK_DESTROY: "network-destroy",
64
+ STORAGE_DESTROY: "storage-destroy",
65
+ MESSAGING_DESTROY: "messaging-destroy",
66
+ DATABASE_DESTROY: "database-destroy",
67
+ COMPUTE_DESTROY: "compute-destroy",
68
+ CDN_DESTROY: "cdn-destroy"
69
+ };
70
+ /**
71
+ * Human-readable step names paired with STEP_IDS.
72
+ * Extracted because these strings are used at 3+ call sites.
73
+ */
74
+ export const STEP_NAMES = {
75
+ AUTH: "Authenticating with AWS",
76
+ PREPARE_DEPLOY: "Preparing deployment",
77
+ PREPARE_DESTROY: "Preparing destruction",
78
+ BOOTSTRAP: "Bootstrapping AWS environment",
79
+ CHECK_INFRA_STATE: "Checking infrastructure state"
80
+ };
81
+ /**
82
+ * Canonical step names emitted by infrastructure deployments (platform/account).
83
+ * The webapp's onboarding timeline and deployment detail page import these
84
+ * directly, replacing the previous fragile string duplication.
85
+ */
86
+ export const INFRASTRUCTURE_STEP_NAMES = [
87
+ "Connect securely",
88
+ "Prepare environment",
89
+ "Deploy infrastructure",
90
+ "Enable monitoring"
91
+ ];
92
+ /** Named access for specific step names (avoids fragile positional indices) */
93
+ export const INFRA_STEP_NAME = {
94
+ CONNECT: INFRASTRUCTURE_STEP_NAMES[0],
95
+ PREPARE: INFRASTRUCTURE_STEP_NAMES[1],
96
+ DEPLOY: INFRASTRUCTURE_STEP_NAMES[2],
97
+ MONITORING: INFRASTRUCTURE_STEP_NAMES[3]
98
+ };
@@ -1 +0,0 @@
1
- export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Check whether a Dockerfile exists in the given directory.
3
+ * Matches any file starting with "Dockerfile" (e.g. Dockerfile, Dockerfile.prod).
4
+ */
5
+ export declare function hasDockerfile(appPath: string): boolean;
@@ -0,0 +1 @@
1
+ import{readdirSync as t}from"fs";import{logger as i}from"@fjall/util/logger";function s(e){try{return t(e).some(o=>o.startsWith("Dockerfile"))}catch(r){return i.debug("dockerfileDetection","Failed to check for Dockerfile",{appPath:e,error:r instanceof Error?r.message:String(r)}),!1}}export{s as hasDockerfile};
@@ -1,3 +1,4 @@
1
- export { DANGEROUS_ENV_VARS, filterDangerousEnvVars, maskSensitiveOutput, parseShellArgs } from "./securityHelpers.js";
2
- export { sleep } from "./sleep.js";
3
- export { singleton } from "./singleton.js";
1
+ export { DANGEROUS_ENV_VARS, filterDangerousEnvVars, maskSensitiveOutput, parseShellArgs, sleep, singleton } from "@fjall/util";
2
+ export { hasDockerfile } from "./dockerfileDetection.js";
3
+ export { createSequencedCallbacks } from "./sequencedCallbacks.js";
4
+ export type { CallbackMetadata, SequencedCallbackEvent, SequencedCallbacksResult } from "./sequencedCallbacks.js";
@@ -1,3 +1 @@
1
- export { DANGEROUS_ENV_VARS, filterDangerousEnvVars, maskSensitiveOutput, parseShellArgs } from "./securityHelpers.js";
2
- export { sleep } from "./sleep.js";
3
- export { singleton } from "./singleton.js";
1
+ import{DANGEROUS_ENV_VARS as s,filterDangerousEnvVars as o,maskSensitiveOutput as t,parseShellArgs as a,sleep as l,singleton as n}from"@fjall/util";import{hasDockerfile as f}from"./dockerfileDetection.js";import{createSequencedCallbacks as S}from"./sequencedCallbacks.js";export{s as DANGEROUS_ENV_VARS,S as createSequencedCallbacks,o as filterDangerousEnvVars,f as hasDockerfile,t as maskSensitiveOutput,a as parseShellArgs,n as singleton,l as sleep};
@@ -0,0 +1,44 @@
1
+ import type { DeployCallbacks } from "../types/callbacks.js";
2
+ /**
3
+ * Metadata attached to each sequenced callback invocation.
4
+ */
5
+ export interface CallbackMetadata {
6
+ /** Monotonically increasing sequence number, starting at 1. */
7
+ sequence: number;
8
+ /** ISO 8601 timestamp of when the callback was invoked. */
9
+ timestamp: string;
10
+ }
11
+ /**
12
+ * A recorded callback event for replay or ordering analysis.
13
+ */
14
+ export interface SequencedCallbackEvent {
15
+ /** Name of the callback that was invoked (e.g. "onLog", "onProgress"). */
16
+ callbackName: string;
17
+ /** Arguments passed to the callback. */
18
+ args: unknown[];
19
+ /** Sequence and timing metadata. */
20
+ metadata: CallbackMetadata;
21
+ }
22
+ /**
23
+ * Result of createSequencedCallbacks — the wrapped callbacks plus
24
+ * accessors for the recorded event log.
25
+ */
26
+ export interface SequencedCallbacksResult {
27
+ /** DeployCallbacks-conforming wrapper that records invocations. */
28
+ callbacks: DeployCallbacks;
29
+ /** Returns a copy of all recorded events in invocation order. */
30
+ getEvents: () => SequencedCallbackEvent[];
31
+ /** Clears the event log without resetting the sequence counter. */
32
+ clearEvents: () => void;
33
+ }
34
+ /**
35
+ * Wraps a DeployCallbacks object so that every callback invocation is
36
+ * recorded with a monotonically increasing sequence number and an ISO
37
+ * timestamp. The original callback is called through with its original
38
+ * arguments, and return values (including Promises) are preserved.
39
+ *
40
+ * Only callbacks that exist on the inner object are wrapped — missing
41
+ * callbacks remain undefined on the wrapper so that optional-chaining
42
+ * call sites behave identically.
43
+ */
44
+ export declare function createSequencedCallbacks(inner: DeployCallbacks): SequencedCallbacksResult;
@@ -0,0 +1 @@
1
+ const l=new Set(["verbose"]);function u(t){let a=0;const n=[],c={};for(const e of Object.keys(t)){if(l.has(e)){c[e]=t[e];continue}const o=t[e];typeof o=="function"&&(c[e]=(...s)=>{a+=1;const r={sequence:a,timestamp:new Date().toISOString()};return n.push({callbackName:e,args:[...s],metadata:r}),o(...s)})}return{callbacks:c,getEvents:()=>[...n],clearEvents:()=>{n.length=0}}}export{u as createSequencedCallbacks};
package/package.json CHANGED
@@ -1,17 +1,56 @@
1
1
  {
2
2
  "name": "@fjall/deploy-core",
3
- "version": "0.89.5",
3
+ "version": "0.89.6",
4
4
  "description": "Shared deployment engine for Fjall — used by CLI and webapp worker",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/src/index.d.ts",
11
+ "default": "./dist/src/index.js"
12
+ },
13
+ "./types": {
14
+ "types": "./dist/src/types/index.d.ts",
15
+ "default": "./dist/src/types/index.js"
16
+ },
17
+ "./events": {
18
+ "types": "./dist/src/events/index.d.ts",
19
+ "default": "./dist/src/events/index.js"
20
+ },
21
+ "./aws": {
22
+ "types": "./dist/src/aws/index.d.ts",
23
+ "default": "./dist/src/aws/index.js"
24
+ },
25
+ "./orchestration": {
26
+ "types": "./dist/src/orchestration/index.d.ts",
27
+ "default": "./dist/src/orchestration/index.js"
28
+ },
29
+ "./services": {
30
+ "types": "./dist/src/services/index.d.ts",
31
+ "default": "./dist/src/services/index.js"
32
+ },
33
+ "./util": {
34
+ "types": "./dist/src/util/index.d.ts",
35
+ "default": "./dist/src/util/index.js"
36
+ },
37
+ "./steps": {
38
+ "types": "./dist/src/steps/index.d.ts",
39
+ "default": "./dist/src/steps/index.js"
40
+ },
41
+ "./__test-utils__": {
42
+ "types": "./dist/src/__test-utils__/index.d.ts",
43
+ "default": "./dist/src/__test-utils__/index.js"
44
+ }
45
+ },
8
46
  "files": [
9
47
  "dist/"
10
48
  ],
11
49
  "scripts": {
12
- "clean": "rm -rf ./dist",
13
- "build": "npm run clean && tsc",
50
+ "clean": "rm -rf ./dist ./sourcemaps",
51
+ "build": "npm run clean && tsc && node ../scripts/minify-dist.mjs dist",
14
52
  "watch": "npm run build && tsc --watch --preserveWatchOutput",
53
+ "watch:only": "tsc --watch --preserveWatchOutput",
15
54
  "typecheck": "tsc --noEmit",
16
55
  "test": "vitest run",
17
56
  "test:watch": "vitest",
@@ -20,9 +59,9 @@
20
59
  "lint": "eslint src/"
21
60
  },
22
61
  "engines": {
23
- "node": ">=18.0.0"
62
+ "node": ">=22.0.0"
24
63
  },
25
- "license": "MIT",
64
+ "license": "SEE LICENSE IN LICENSE",
26
65
  "dependencies": {
27
66
  "@aws-sdk/client-backup": "^3.1009.0",
28
67
  "@aws-sdk/client-cloudformation": "^3.1009.0",
@@ -30,14 +69,16 @@
30
69
  "@aws-sdk/client-ec2": "^3.1009.0",
31
70
  "@aws-sdk/client-organizations": "^3.1009.0",
32
71
  "@aws-sdk/client-ram": "^3.1009.0",
72
+ "@aws-sdk/client-s3": "^3.1009.0",
33
73
  "@aws-sdk/client-sso-admin": "^3.1009.0",
34
74
  "@aws-sdk/client-sts": "^3.1009.0",
35
- "@fjall/generator": "^0.89.5",
36
- "@fjall/util": "^0.89.5",
75
+ "@fjall/generator": "^0.89.6",
76
+ "@fjall/util": "^0.89.6",
77
+ "@smithy/node-http-handler": "^4.5.0",
37
78
  "zod": "^4.3.6"
38
79
  },
39
80
  "devDependencies": {
40
81
  "vitest": "^3.2.3"
41
82
  },
42
- "gitHead": "1680c1a0be16950e9e10e571163ccc42198f6a8e"
83
+ "gitHead": "fb309fa904991ac4f23c49b3bed1be146f738900"
43
84
  }
@@ -1,32 +0,0 @@
1
- import { type ResourceEvent } from "./cloudformationEvents.js";
2
- export interface RootCause {
3
- resource: ResourceEvent;
4
- reason: string;
5
- category: "permissions" | "validation" | "dependency" | "limit" | "network" | "unknown";
6
- isDirectCause: boolean;
7
- }
8
- export interface FailureAnalysis {
9
- rootCause: RootCause;
10
- affectedResources: ResourceEvent[];
11
- dependencyChain: string[];
12
- summary: string;
13
- remediation: string[];
14
- errorPattern?: string;
15
- }
16
- /**
17
- * CloudFormationFailureAnalyser provides intelligent analysis of deployment failures
18
- * It identifies root causes, dependency chains, and provides actionable remediation
19
- */
20
- export declare class CloudFormationFailureAnalyser {
21
- private knownErrorPatterns;
22
- analyseFailure(eventHistory: Map<string, ResourceEvent[]>): FailureAnalysis | null;
23
- private findFailedResources;
24
- private findRootCause;
25
- private categoriseError;
26
- private isDirectCause;
27
- private buildDependencyChain;
28
- private generateRemediation;
29
- private generateSummary;
30
- private simplifyResourceType;
31
- private isFailedStatus;
32
- }