@fjall/util 2.27.0 → 2.30.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.
- package/dist/.minified +1 -1
- package/dist/aws/CloudFormationFailureAnalyser.d.ts +27 -1
- package/dist/aws/CloudFormationFailureAnalyser.js +1 -1
- package/dist/aws/cloudformationTypes.d.ts +6 -0
- package/dist/aws/driftSuspects.d.ts +54 -0
- package/dist/aws/driftSuspects.js +1 -0
- package/dist/aws/index.d.ts +1 -0
- package/dist/aws/index.js +1 -1
- package/dist/aws/maskFailureAnalysis.js +1 -1
- package/dist/cfn/physicalNameProperties.d.ts +13 -0
- package/dist/cfn/physicalNameProperties.js +1 -0
- package/dist/docker/bakeGuard.d.ts +11 -0
- package/dist/docker/bakeGuard.js +1 -1
- package/dist/docker/index.d.ts +1 -1
- package/dist/docker/index.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/manifest/schemas.d.ts +4 -0
- package/dist/manifest/schemas.js +1 -1
- package/dist/migration/compareSchemaVersion.d.ts +50 -0
- package/dist/migration/compareSchemaVersion.js +1 -0
- package/dist/migration/compareSchemaVersion.test.d.ts +1 -0
- package/dist/migration/compareSchemaVersion.test.js +1 -0
- package/dist/migration/constants.d.ts +9 -0
- package/dist/migration/constants.js +1 -1
- package/dist/migration/index.d.ts +1 -0
- package/dist/migration/index.js +1 -1
- package/dist/migration/verifyExpectedSchemaVersion.d.ts +5 -0
- package/dist/migration/verifyExpectedSchemaVersion.js +1 -1
- package/dist/migration/verifyExpectedSchemaVersion.test.js +1 -1
- package/dist/patterns/index.d.ts +11 -0
- package/dist/patterns/index.js +1 -0
- package/dist/patterns/patternTypes.d.ts +91 -0
- package/dist/patterns/patternTypes.js +1 -0
- package/dist/patterns/staticSiteForms.d.ts +24 -0
- package/dist/patterns/staticSiteForms.js +1 -0
- package/package.json +7 -2
package/dist/.minified
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
84 files minified at 2026-07-15T07:08:25.279Z
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ResourceEvent } from "./cloudformationTypes.js";
|
|
2
|
+
import { type DriftSuspectEvent } from "./driftSuspects.js";
|
|
2
3
|
export interface RootCause {
|
|
3
4
|
resource: ResourceEvent;
|
|
4
5
|
reason: string;
|
|
@@ -12,6 +13,13 @@ export interface FailureAnalysis {
|
|
|
12
13
|
summary: string;
|
|
13
14
|
remediation: string[];
|
|
14
15
|
errorPattern?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Resources whose failure carries the out-of-band-deletion shape (Class 1
|
|
18
|
+
* drift): CloudFormation still tracks them but the service reported
|
|
19
|
+
* NotFound. Suspects only — confirmation requires the deploy-core drift
|
|
20
|
+
* probe. Absent when no failure event matches the NotFound anchors.
|
|
21
|
+
*/
|
|
22
|
+
driftSuspects?: DriftSuspectEvent[];
|
|
15
23
|
}
|
|
16
24
|
/**
|
|
17
25
|
* CloudFormationFailureAnalyser provides intelligent analysis of deployment failures
|
|
@@ -19,7 +27,25 @@ export interface FailureAnalysis {
|
|
|
19
27
|
*/
|
|
20
28
|
export declare class CloudFormationFailureAnalyser {
|
|
21
29
|
private knownErrorPatterns;
|
|
22
|
-
|
|
30
|
+
/**
|
|
31
|
+
* `stackName` opts the drift scan into current-operation bounding: the
|
|
32
|
+
* monitor's event history is seeded with the stack's FULL retained event
|
|
33
|
+
* history (~90 days), so an unbounded scan would resurrect suspects from
|
|
34
|
+
* long-past operations that were since cured. Callers whose history is
|
|
35
|
+
* already operation-scoped (callback-fed collections) omit it.
|
|
36
|
+
*/
|
|
37
|
+
analyseFailure(eventHistory: Map<string, ResourceEvent[]>, stackName?: string): FailureAnalysis | null;
|
|
38
|
+
/**
|
|
39
|
+
* Scans EVERY failed event, not failedResources: a wedged resource's
|
|
40
|
+
* UPDATE_FAILED is superseded by its rollback event, so latest-per-resource
|
|
41
|
+
* semantics would drop exactly the wedge. When `stackName` is given, the
|
|
42
|
+
* scan is bounded to events at/after the current operation's opening event;
|
|
43
|
+
* if no opening event is visible the scan yields nothing rather than risk
|
|
44
|
+
* classifying a stale prior-operation failure (fail-safe: a missed hint is
|
|
45
|
+
* recoverable via `fjall drift detect`, a stale suspect self-reinforces
|
|
46
|
+
* through the journal).
|
|
47
|
+
*/
|
|
48
|
+
private classifyDriftSuspects;
|
|
23
49
|
private findFailedResources;
|
|
24
50
|
private findRootCause;
|
|
25
51
|
private categoriseError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
import{classifyDriftSuspectEvents as c,findCurrentOperationStart as d}from"./driftSuspects.js";class f{knownErrorPatterns=[{pattern:/AccessDenied|UnauthorizedOperation|Forbidden/i,category:"permissions",remediation:["Check IAM permissions for the deployment role","Ensure the role has necessary CloudFormation permissions","Verify service-linked roles are created if needed"]},{pattern:/Invalid.*Parameter|ValidationError|Invalid.*Value/i,category:"validation",remediation:["Review parameter values in your CDK code","Check for typos in resource names or ARNs","Ensure all required parameters are provided"]},{pattern:/Limit.*Exceeded|Quota.*Exceeded|Maximum.*reached/i,category:"limit",remediation:["Check AWS service quotas in the Service Quotas console","Request a quota increase if needed","Consider using a different region with available capacity"]},{pattern:/Timeout|Connection.*refused|Network.*unreachable/i,category:"network",remediation:["Check network connectivity and VPC settings","Verify security groups and NACLs","Ensure endpoints are accessible"]},{pattern:/already exists|Duplicate|ConflictException/i,category:"validation",remediation:["Resource with this name already exists","Consider using a different name or deleting the existing resource","Check if you are deploying to the correct account/region"]},{pattern:/Role.*not.*found|Role.*does.*not.*exist/i,category:"dependency",remediation:["Ensure IAM roles are created before dependent resources","Check role names and ARNs are correct","Verify cross-stack references are properly configured"]}];analyseFailure(e,t){const r=this.findFailedResources(e);if(r.length===0)return null;const s=this.findRootCause(r,e),n=this.buildDependencyChain(s.resource,r),i=this.classifyDriftSuspects(e,t),o=this.generateRemediation(s);i.length>0&&o.unshift("One or more resources CloudFormation still tracks appear to have been deleted outside CloudFormation","Run 'fjall drift detect' to confirm the deletion; confirmed deletions are remediated with 'fjall drift repair'");const a=this.generateSummary(s,r);return{rootCause:s,affectedResources:r,dependencyChain:n,summary:a,remediation:o,errorPattern:s.category,...i.length>0?{driftSuspects:i}:{}}}classifyDriftSuspects(e,t){const r=t!==void 0?d(e.get(t)??[],t):null;if(t!==void 0&&r===null)return[];const s=[];for(const n of e.values())for(const i of n)this.isFailedStatus(i.status)&&(r!==null&&i.timestamp.getTime()<r.getTime()||s.push(i));return c(s)}findFailedResources(e){const t=[];for(const[r,s]of e){const n=s[s.length-1];n&&this.isFailedStatus(n.status)&&t.push(n)}return t.sort((r,s)=>r.timestamp.getTime()-s.timestamp.getTime())}findRootCause(e,t){if(e.length===0)return{resource:{logicalId:"Unknown",resourceType:"Unknown",status:"FAILED",timestamp:new Date},reason:"No failed resources found",category:"unknown",isDirectCause:!1};const r=e[0],s=this.categoriseError(r.statusReason||""),n=this.isDirectCause(r,t);return{resource:r,reason:r.statusReason||"Unknown error",category:s,isDirectCause:n}}categoriseError(e){for(const t of this.knownErrorPatterns)if(t.pattern.test(e))return t.category;return"unknown"}isDirectCause(e,t){const r=e.statusReason||"";return r.includes("depends on")||r.includes("referenced by")||r.includes("required by")?!1:!(t.get(e.logicalId)||[]).some(i=>i.status.includes("COMPLETE")&&!i.status.includes("ROLLBACK"))}buildDependencyChain(e,t){const r=[];r.push(`${e.logicalId} (${e.resourceType}) - ROOT CAUSE`);for(const s of t)s.logicalId!==e.logicalId&&((s.statusReason||"").toLowerCase().includes(e.logicalId.toLowerCase())?r.push(` \u2192 ${s.logicalId} (${s.resourceType}) - Failed due to ${e.logicalId}`):r.push(` \u2192 ${s.logicalId} (${s.resourceType})`));return r}generateRemediation(e){const t=[];for(const r of this.knownErrorPatterns)if(r.category===e.category){t.push(...r.remediation);break}return e.resource.resourceType.includes("IAM")?t.push("Review IAM policies and trust relationships"):e.resource.resourceType.includes("Lambda")?t.push("Check Lambda function configuration and runtime"):e.resource.resourceType.includes("ECS")&&t.push("Verify ECS task definition and container configuration"),t.length===0&&t.push("Review the CloudFormation console for detailed error messages","Check the resource configuration in your CDK code","Ensure all dependencies are properly defined"),t}generateSummary(e,t){const r=this.simplifyResourceType(e.resource.resourceType),s=t.length;let n=`Deployment failed: ${r} "${e.resource.logicalId}" `;switch(e.category){case"permissions":n+="failed due to insufficient permissions";break;case"validation":n+="failed validation";break;case"dependency":n+="has missing or invalid dependencies";break;case"limit":n+="exceeded AWS service limits";break;case"network":n+="encountered network issues";break;default:n+="failed to create"}return s>1&&(n+=` (${s-1} dependent resources also failed)`),n}simplifyResourceType(e){return e.replace("AWS::","").replace("::"," ")}isFailedStatus(e){return e.includes("FAILED")}}export{f as CloudFormationFailureAnalyser};
|
|
@@ -13,5 +13,11 @@ export interface ResourceEvent {
|
|
|
13
13
|
group?: string;
|
|
14
14
|
/** CDK construct path (e.g., "/Account/CloudTrail/trail/Resource"). */
|
|
15
15
|
constructPath?: string;
|
|
16
|
+
/**
|
|
17
|
+
* CloudFormation ClientRequestToken for the operation that emitted this event
|
|
18
|
+
* (§5.9 capture-not-stamp). Lets a reconciler correlate an orphaned CFN
|
|
19
|
+
* operation back to its deployment row. Absent on synthetic/initial events.
|
|
20
|
+
*/
|
|
21
|
+
clientRequestToken?: string;
|
|
16
22
|
}
|
|
17
23
|
export declare function isResourceEvent(event: unknown): event is ResourceEvent;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class 1 drift classification — out-of-band deletion suspects.
|
|
3
|
+
*
|
|
4
|
+
* A resource CloudFormation still tracks but which was deleted outside
|
|
5
|
+
* CloudFormation wedges every subsequent update: the service handler returns
|
|
6
|
+
* NotFound and the stack rolls back (the BusinessContinuity CMK incident,
|
|
7
|
+
* account 913524923178). The patterns here are derived from the Phase 0
|
|
8
|
+
* empirical fixtures (`fjall/deploy-core/src/orchestration/drift/__tests__/
|
|
9
|
+
* fixtures/bc-stack-events.json`, captured 2026-07-07): the stable anchors are
|
|
10
|
+
* the registry handler contract marker `HandlerErrorCode: NotFound` and the
|
|
11
|
+
* service message shape `does not exist (Service: …`.
|
|
12
|
+
*
|
|
13
|
+
* Classification is SUSPECTS ONLY — never a confirmed verdict. Confirmation
|
|
14
|
+
* requires a direct per-type probe (deploy-core `driftProbe.ts`); a suspect
|
|
15
|
+
* that cannot be probed stays UNCONFIRMED and remediation is refused
|
|
16
|
+
* (fail-closed: never surgery on a resource not proven dead).
|
|
17
|
+
*/
|
|
18
|
+
import type { ResourceEvent } from "./cloudformationTypes.js";
|
|
19
|
+
/**
|
|
20
|
+
* A resource whose failure event carries the out-of-band-deletion shape.
|
|
21
|
+
* `statusReason` is raw here — the analyser's `maskFailureAnalysis` boundary
|
|
22
|
+
* (or the sink) masks before display/persistence.
|
|
23
|
+
*/
|
|
24
|
+
export interface DriftSuspectEvent {
|
|
25
|
+
logicalId: string;
|
|
26
|
+
resourceType: string;
|
|
27
|
+
physicalId?: string;
|
|
28
|
+
/** The failed status that carried the NotFound shape (e.g. UPDATE_FAILED). */
|
|
29
|
+
failedStatus: string;
|
|
30
|
+
statusReason: string;
|
|
31
|
+
}
|
|
32
|
+
/** True when a failure reason carries the out-of-band-deletion shape. */
|
|
33
|
+
export declare function isDriftSuspectReason(statusReason: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* True for the stack-level event that opens a CloudFormation operation —
|
|
36
|
+
* the shared boundary for "current operation only" scans (the deploy-core
|
|
37
|
+
* last-operation event walk and the failure analyser's drift scan).
|
|
38
|
+
*/
|
|
39
|
+
export declare function isOperationOpeningEvent(event: ResourceEvent, stackName: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Timestamp of the most recent operation-opening event for `stackName`, or
|
|
42
|
+
* null when none is visible. Server-clock consistent with event timestamps,
|
|
43
|
+
* so callers can bound scans without local-clock skew.
|
|
44
|
+
*/
|
|
45
|
+
export declare function findCurrentOperationStart(events: readonly ResourceEvent[], stackName: string): Date | null;
|
|
46
|
+
/**
|
|
47
|
+
* Extract out-of-band-deletion suspects from failure events. Callers pass
|
|
48
|
+
* EVERY failed event in the operation, not just each resource's latest — a
|
|
49
|
+
* wedged resource's UPDATE_FAILED is typically superseded by a later
|
|
50
|
+
* UPDATE_ROLLBACK_* event, so latest-event-per-resource semantics would drop
|
|
51
|
+
* exactly the suspects this classifier exists to find. Deduplicated by
|
|
52
|
+
* logicalId (first match wins).
|
|
53
|
+
*/
|
|
54
|
+
export declare function classifyDriftSuspectEvents(events: readonly ResourceEvent[]): DriftSuspectEvent[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=new Set(["UPDATE_FAILED","DELETE_FAILED"]),i=[/HandlerErrorCode:\s*NotFound\b/,/does not exist \(Service:/i,/\b(?:ResourceNotFoundException|NotFoundException|NoSuchBucket|NoSuchEntity)\b/],c=/Resource (?:creation|update) cancelled/i;function u(e){return c.test(e)?!1:i.some(s=>s.test(e))}const a="AWS::CloudFormation::Stack",r=new Set(["CREATE_IN_PROGRESS","UPDATE_IN_PROGRESS","DELETE_IN_PROGRESS","IMPORT_IN_PROGRESS"]),E="User Initiated";function S(e,s){return e.resourceType===a&&e.logicalId===s&&r.has(e.status)&&e.statusReason!==void 0&&e.statusReason.includes(E)}function d(e,s){let n=null;for(const t of e)S(t,s)&&(n===null||t.timestamp.getTime()>n.getTime())&&(n=t.timestamp);return n}function R(e){const s=[],n=new Set;for(const t of e)n.has(t.logicalId)||o.has(t.status)&&(t.statusReason===void 0||t.statusReason===""||u(t.statusReason)&&(n.add(t.logicalId),s.push({logicalId:t.logicalId,resourceType:t.resourceType,...t.physicalId!==void 0&&t.physicalId!==""?{physicalId:t.physicalId}:{},failedStatus:t.status,statusReason:t.statusReason})));return s}export{R as classifyDriftSuspectEvents,d as findCurrentOperationStart,u as isDriftSuspectReason,S as isOperationOpeningEvent};
|
package/dist/aws/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { STACK_NOT_FOUND_PATTERN, CDK_NO_STACKS_MATCH, type ResourceEvent, isRes
|
|
|
3
3
|
export { type ResourceProgressCounts, countResourceProgress, formatElapsed } from "./deployProgress.js";
|
|
4
4
|
export { CloudFormationFailureAnalyser, type RootCause, type FailureAnalysis } from "./CloudFormationFailureAnalyser.js";
|
|
5
5
|
export { maskFailureAnalysis } from "./maskFailureAnalysis.js";
|
|
6
|
+
export { classifyDriftSuspectEvents, findCurrentOperationStart, isDriftSuspectReason, isOperationOpeningEvent, type DriftSuspectEvent } from "./driftSuspects.js";
|
|
6
7
|
export { IPAM_OPERATIONS_POOL_TAG_KEY, formatIpamPairTagValue } from "./ipamTags.js";
|
|
7
8
|
export { SDK_PRE_EMPTY_TAG_KEY } from "./infraTags.js";
|
|
8
9
|
export { ACCOUNT_MONITORING_ROLE_NAME } from "./monitoringRole.js";
|
package/dist/aws/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AWSError as e,NoRolesFoundError as
|
|
1
|
+
import{AWSError as e,NoRolesFoundError as t,InvalidCredentialsError as i,SSOTokenExpiredError as s,MissingRegionError as n,ProfileNotFoundError as E,CommandError as a,isAWSError as p,isNoRolesFoundError as _,isSSOUnauthorizedError as f}from"./errors.js";import{STACK_NOT_FOUND_PATTERN as O,CDK_NO_STACKS_MATCH as u,isResourceEvent as A}from"./cloudformationTypes.js";import{countResourceProgress as T,formatElapsed as l}from"./deployProgress.js";import{CloudFormationFailureAnalyser as d}from"./CloudFormationFailureAnalyser.js";import{maskFailureAnalysis as x}from"./maskFailureAnalysis.js";import{classifyDriftSuspectEvents as P,findCurrentOperationStart as F,isDriftSuspectReason as c,isOperationOpeningEvent as I}from"./driftSuspects.js";import{IPAM_OPERATIONS_POOL_TAG_KEY as M,formatIpamPairTagValue as g}from"./ipamTags.js";import{SDK_PRE_EMPTY_TAG_KEY as v}from"./infraTags.js";import{ACCOUNT_MONITORING_ROLE_NAME as G}from"./monitoringRole.js";export{G as ACCOUNT_MONITORING_ROLE_NAME,e as AWSError,u as CDK_NO_STACKS_MATCH,d as CloudFormationFailureAnalyser,a as CommandError,M as IPAM_OPERATIONS_POOL_TAG_KEY,i as InvalidCredentialsError,n as MissingRegionError,t as NoRolesFoundError,E as ProfileNotFoundError,v as SDK_PRE_EMPTY_TAG_KEY,s as SSOTokenExpiredError,O as STACK_NOT_FOUND_PATTERN,P as classifyDriftSuspectEvents,T as countResourceProgress,F as findCurrentOperationStart,l as formatElapsed,g as formatIpamPairTagValue,p as isAWSError,c as isDriftSuspectReason,_ as isNoRolesFoundError,I as isOperationOpeningEvent,A as isResourceEvent,f as isSSOUnauthorizedError,x as maskFailureAnalysis};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{maskSensitiveOutput as
|
|
1
|
+
import{maskSensitiveOutput as t}from"../securityHelpers.js";function r(e){return e.statusReason===void 0?e:{...e,statusReason:t(e.statusReason)}}function u(e){return{...e,statusReason:t(e.statusReason)}}function n(e){const s={...e.rootCause,reason:t(e.rootCause.reason),resource:r(e.rootCause.resource)};return{...e,rootCause:s,affectedResources:e.affectedResources.map(r),...e.driftSuspects!==void 0?{driftSuspects:e.driftSuspects.map(u)}:{}}}export{n as maskFailureAnalysis};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fallback map for pinned-name detection: CloudFormation resource types whose
|
|
3
|
+
* user-settable NAMING property cannot be derived from the registry schema's
|
|
4
|
+
* `primaryIdentifier` — the identifier is a generated attribute (ARN, URL, ID)
|
|
5
|
+
* that never appears in a template's Properties.
|
|
6
|
+
*
|
|
7
|
+
* Consulted by @fjall/deploy-core's pinned-name detector AFTER the
|
|
8
|
+
* primaryIdentifier derivation fails to yield a template property. Keep this
|
|
9
|
+
* map small: types whose primaryIdentifier IS the naming property
|
|
10
|
+
* (DBInstanceIdentifier, TableName, BucketName, RepositoryName, …) must NOT be
|
|
11
|
+
* added here.
|
|
12
|
+
*/
|
|
13
|
+
export declare const PHYSICAL_NAME_FALLBACK_PROPERTIES: Readonly<Record<string, string>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={"AWS::SecretsManager::Secret":"Name","AWS::SQS::Queue":"QueueName","AWS::SNS::Topic":"TopicName"};export{e as PHYSICAL_NAME_FALLBACK_PROPERTIES};
|
|
@@ -29,6 +29,17 @@ import type { DockerBuildArgValue } from "../manifest/schemas.js";
|
|
|
29
29
|
* finding/warning message states the same blast radius (design R4).
|
|
30
30
|
*/
|
|
31
31
|
export declare const BAKE_GUARD_EXPOSURE_CLAUSE: string;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a per-deploy de-duplicator for bake-exposure warnings.
|
|
34
|
+
*
|
|
35
|
+
* A buildArg baked into more than one service image of the same app (an app +
|
|
36
|
+
* its workers, built as separate groups) produces byte-identical exposure
|
|
37
|
+
* warnings — the exposure is a property of the KEY, not of each image, so the
|
|
38
|
+
* operator only needs to see each warning once per deploy. Returns a predicate
|
|
39
|
+
* that is `true` the first time it sees a message and `false` thereafter; share
|
|
40
|
+
* one instance across a deploy's build groups.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createBakeWarningDeduper(): (message: string) => boolean;
|
|
32
43
|
export type BakeGuardFindingReason = "sourced-ref" | "credential-shape";
|
|
33
44
|
export interface BakeGuardFinding {
|
|
34
45
|
/** The offending `buildArgs` key. */
|
package/dist/docker/bakeGuard.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{maskSensitiveOutput as
|
|
1
|
+
import{maskSensitiveOutput as o}from"../securityHelpers.js";import{PUBLIC_BUILD_ARG_PREFIXES as l,isPublicBuildVarName as s}from"./buildArgInference.js";const u="baked values are world-readable in `docker history`, image provenance/SBOM, and the `<app>-cache` mode=max ECR cache repo";function p(){const e=new Set;return n=>e.has(n)?!1:(e.add(n),!0)}function g(e,n){const a=[],i=[];if(e===void 0)return{findings:a,warnings:i};for(const[t,r]of Object.entries(e)){if(typeof r=="object"){if(r.acknowledgePublic===!0)continue;if(r.ssm!==void 0||r.secretsManager!==void 0){a.push({key:t,reason:"sourced-ref",message:`buildArg "${t}" (app "${n}") is sourced from a secret store (SSM/Secrets Manager) but baked via --build-arg \u2014 ${u}. Move it to docker.buildSecrets (BuildKit --secret mount, never baked), or, if the value is genuinely public-but-sensitive and must ship in the client bundle, set acknowledgePublic: true to bake it deliberately.`});continue}s(t)||i.push({key:t,message:d(t)});continue}if(o(r)!==r){a.push({key:t,reason:"credential-shape",message:c(t,n)});continue}s(t)||i.push({key:t,message:d(t)})}return{findings:a,warnings:i}}function d(e){return`buildArg "${e}" does not start with a public prefix (${l.join(", ")}) and is frozen into the image at build time \u2014 ${u}. If this value should vary per deploy, use a runtime env var (ECS task environment) instead of baking it.`}function c(e,n){return`buildArg "${e}" (app "${n}") has a value that looks like a credential but would be baked via --build-arg \u2014 ${u}. Move it to docker.buildSecrets (BuildKit --secret mount, never baked). If it is a genuinely public-but-sensitive value, use the object form { ssm/secretsManager/env, acknowledgePublic: true } to bake it deliberately.`}function k(e){const n=new Set;if(e===void 0)return n;for(const[a,i]of Object.entries(e))typeof i=="object"&&i.acknowledgePublic===!0&&n.add(a);return n}function v(e,n,a){const i=[];for(const[t,r]of Object.entries(e))a.has(t)||o(r)!==r&&i.push({key:t,reason:"credential-shape",message:c(t,n)});return i}export{u as BAKE_GUARD_EXPOSURE_CLAUSE,k as acknowledgedBuildArgKeys,p as createBakeWarningDeduper,g as evaluateBakeGuard,v as evaluateResolvedBuildArgValues};
|
package/dist/docker/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { type Result, isSuccess, isFailure, success, failure } from "./result.js
|
|
|
2
2
|
export { DOCKER_CLI_LOG_CATEGORY, DOCKER_CLI_BUILDX_LOG_CATEGORY, BUILDX_VERSION_FLOOR, ENGINE_VERSION_FLOOR, PrerequisiteMissingExitCode, DEFAULT_BUILDER_NAME, DEFAULT_DOCKER_BIN, SIGTERM_GRACE_MS, STDERR_TAIL_LINES, DEFAULT_BUILD_TIMEOUT_MS, DEFAULT_PUSH_TIMEOUT_MS, DEFAULT_PULL_TIMEOUT_MS, DEFAULT_INSPECT_TIMEOUT_MS, DEFAULT_DAEMON_PROBE_TIMEOUT_MS } from "./dockerCliConstants.js";
|
|
3
3
|
export { BuildxBuildArgsSchema, BuildxBuildResultSchema, DockerCliErrorKindSchema, DockerCliErrorSchema, isDockerCliErrorKind, type BuildxBuildArgs, type BuildxBuildResult, type DockerCliError, type DockerCliErrorKind } from "./dockerCliSchemas.js";
|
|
4
4
|
export { buildxArgvBuilder } from "./buildxArgvBuilder.js";
|
|
5
|
-
export { evaluateBakeGuard, evaluateResolvedBuildArgValues, acknowledgedBuildArgKeys, BAKE_GUARD_EXPOSURE_CLAUSE, type BakeGuardFinding, type BakeGuardFindingReason, type BakeGuardWarning, type BakeGuardResult } from "./bakeGuard.js";
|
|
5
|
+
export { evaluateBakeGuard, evaluateResolvedBuildArgValues, acknowledgedBuildArgKeys, createBakeWarningDeduper, BAKE_GUARD_EXPOSURE_CLAUSE, type BakeGuardFinding, type BakeGuardFindingReason, type BakeGuardWarning, type BakeGuardResult } from "./bakeGuard.js";
|
|
6
6
|
export { PUBLIC_BUILD_ARG_PREFIXES, isPublicBuildVarName, inferPublicBuildArgKeys, type InferPublicBuildArgKeysInput } from "./buildArgInference.js";
|
|
7
7
|
export { parseRawjsonLine, type RawjsonEnvelope, type RawjsonVertex, type RawjsonStatus, type RawjsonLog, type RawjsonWarning } from "./rawjsonParser.js";
|
|
8
8
|
export { rawjsonToVertexEvent, type RawjsonVertexEvent, type NormalisedVertex, type NormalisedStatus, type NormalisedLog, type NormalisedWarning } from "./rawjsonToVertexEvent.js";
|
package/dist/docker/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isSuccess as o,isFailure as E,success as _,failure as i}from"./result.js";import{DOCKER_CLI_LOG_CATEGORY as
|
|
1
|
+
import{isSuccess as o,isFailure as E,success as _,failure as i}from"./result.js";import{DOCKER_CLI_LOG_CATEGORY as a,DOCKER_CLI_BUILDX_LOG_CATEGORY as l,BUILDX_VERSION_FLOOR as s,ENGINE_VERSION_FLOOR as u,PrerequisiteMissingExitCode as T,DEFAULT_BUILDER_NAME as A,DEFAULT_DOCKER_BIN as L,SIGTERM_GRACE_MS as R,STDERR_TAIL_LINES as D,DEFAULT_BUILD_TIMEOUT_MS as c,DEFAULT_PUSH_TIMEOUT_MS as U,DEFAULT_PULL_TIMEOUT_MS as d,DEFAULT_INSPECT_TIMEOUT_MS as I,DEFAULT_DAEMON_PROBE_TIMEOUT_MS as O}from"./dockerCliConstants.js";import{BuildxBuildArgsSchema as x,BuildxBuildResultSchema as B,DockerCliErrorKindSchema as m,DockerCliErrorSchema as C,isDockerCliErrorKind as p}from"./dockerCliSchemas.js";import{buildxArgvBuilder as M}from"./buildxArgvBuilder.js";import{evaluateBakeGuard as n,evaluateResolvedBuildArgValues as P,acknowledgedBuildArgKeys as F,createBakeWarningDeduper as G,BAKE_GUARD_EXPOSURE_CLAUSE as g}from"./bakeGuard.js";import{PUBLIC_BUILD_ARG_PREFIXES as h,isPublicBuildVarName as k,inferPublicBuildArgKeys as b}from"./buildArgInference.js";import{parseRawjsonLine as y}from"./rawjsonParser.js";import{rawjsonToVertexEvent as X}from"./rawjsonToVertexEvent.js";import{parseMetadataFile as w}from"./metadataFileParser.js";import{projectBuildxResult as H}from"./projectBuildxResult.js";import{abortChildProcess as W}from"./abortHelpers.js";import{DockerCli as J}from"./DockerCli.js";import{createEcrAuthSession as Z}from"./ecrCredentialStore.js";import{buildCacheRepositoryName as ee,untaggedLifecyclePolicyText as re,CACHE_REPO_UNTAGGED_RETENTION_DAYS as oe}from"./cacheRepository.js";export{g as BAKE_GUARD_EXPOSURE_CLAUSE,s as BUILDX_VERSION_FLOOR,x as BuildxBuildArgsSchema,B as BuildxBuildResultSchema,oe as CACHE_REPO_UNTAGGED_RETENTION_DAYS,A as DEFAULT_BUILDER_NAME,c as DEFAULT_BUILD_TIMEOUT_MS,O as DEFAULT_DAEMON_PROBE_TIMEOUT_MS,L as DEFAULT_DOCKER_BIN,I as DEFAULT_INSPECT_TIMEOUT_MS,d as DEFAULT_PULL_TIMEOUT_MS,U as DEFAULT_PUSH_TIMEOUT_MS,l as DOCKER_CLI_BUILDX_LOG_CATEGORY,a as DOCKER_CLI_LOG_CATEGORY,J as DockerCli,m as DockerCliErrorKindSchema,C as DockerCliErrorSchema,u as ENGINE_VERSION_FLOOR,h as PUBLIC_BUILD_ARG_PREFIXES,T as PrerequisiteMissingExitCode,R as SIGTERM_GRACE_MS,D as STDERR_TAIL_LINES,W as abortChildProcess,F as acknowledgedBuildArgKeys,ee as buildCacheRepositoryName,M as buildxArgvBuilder,G as createBakeWarningDeduper,Z as createEcrAuthSession,n as evaluateBakeGuard,P as evaluateResolvedBuildArgValues,i as failure,b as inferPublicBuildArgKeys,p as isDockerCliErrorKind,E as isFailure,k as isPublicBuildVarName,o as isSuccess,w as parseMetadataFile,y as parseRawjsonLine,H as projectBuildxResult,X as rawjsonToVertexEvent,_ as success,re as untaggedLifecyclePolicyText};
|
package/dist/index.d.ts
CHANGED
|
@@ -26,3 +26,6 @@ export { RESERVED_APP_NAMES, type ReservedAppName, RESERVED_APP_NAME_MESSAGE, is
|
|
|
26
26
|
export { deriveContentHashTag, CONTENT_HASH_TAG_PATTERN } from "./infra/deriveContentHashTag.js";
|
|
27
27
|
export { DEPLOY_MODES, DeployModeSchema, type DeployMode, IMAGE_TAG_PATTERN, ImageTagSchema, type ImageTag, ServiceArtefactSchema, type ServiceArtefact, ServiceArtefactsSchema, type ServiceArtefacts, ARTEFACT_OUTPUT_FIELDS, type ArtefactOutputField, artefactOutputKey } from "./infra/deployArtefacts.js";
|
|
28
28
|
export { MIGRATION_SNAPSHOT_NAME_PREFIX, EXPECTED_SCHEMA_VERSION_ENV, EXPECTED_SCHEMA_VERSION_TOOL_ENV, EXPECTED_CH_SCHEMA_VERSION_ENV, SCHEMA_ADMIN_USER_ENV, SCHEMA_ADMIN_PASSWORD_ENV, PRISMA_MIGRATION_DIR_RE, CLICKHOUSE_MIGRATION_SKIP_RE } from "./migration/constants.js";
|
|
29
|
+
export { PHYSICAL_NAME_FALLBACK_PROPERTIES } from "./cfn/physicalNameProperties.js";
|
|
30
|
+
export { PATTERN_TYPE_VALUES, type PatternType, PATTERN_TYPES, isPatternType, type PatternArtefact, type PatternStackPlacement, type PatternDescriptor, PATTERN_REGISTRY, type OpenNextPatternType, OPENNEXT_PATTERN_TYPES, isOpenNextPatternType, STATIC_SITE_ROUTING_VALUES, type StaticSiteRouting } from "./patterns/patternTypes.js";
|
|
31
|
+
export { DEFAULT_FORMS_FROM_LOCAL_PART, defaultFormsFromAddress, defaultFormsCorsOrigin, isAddressAtDomain } from "./patterns/staticSiteForms.js";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DNS_APEX as
|
|
1
|
+
import{DNS_APEX as E,getDomainExportNames as o}from"./infra/domainExports.js";import{BACKUP_VAULT_NAME as _}from"./infra/backupVault.js";import{APPROVAL_TOKEN_OUTPUT_PREFIX as S,TOKEN_STDERR_PREFIX as A}from"./deploy/approvalTokenOutput.js";import{imageTagParameterName as n}from"./infra/imageTags.js";import{toPascalCase as i,toKebab as N,toValidDatabaseName as m,toScreamingSnake as s,capitalise as O,getSafeZoneName as P,accountConstructKey as C,hasAsciiStableConstructKey as p}from"./naming/caseConversion.js";import{findAccountNameCollision as c}from"./naming/accountNameCollision.js";import{defaultConnectedAccountName as I,suffixedAccountName as M,REGION_SHORT_CODES as x,findTrailingRegionShortCode as u,regionSuffixRejectionMessage as d}from"./naming/connectedAccountName.js";import{normaliseError as l,getErrorMessage as U,hasErrorCode as L,getErrorCode as V,getErrorStack as F,formatErrorString as G}from"./errorUtils.js";import{singleton as v}from"./async/singleton.js";import{DANGEROUS_ENV_VARS as X,filterDangerousEnvVars as b,maskSensitiveOutput as K,parseShellArgs as y,SCOPED_TOKEN_REGEX as Y}from"./securityHelpers.js";import{sleep as B}from"./async/sleep.js";import{mapSettledWithConcurrency as j}from"./async/concurrency.js";import{ACCOUNT_STAGES_WITH_ROOT as Z,STRUCTURAL_ENVIRONMENTS as q,ACCOUNT_STAGES as w,ACCOUNT_STAGE_LABELS as J,isAccountStage as Q,ACCOUNT_TIERS as $,AccountTierSchema as ee,isAccountTier as re,environmentToTier as Ee,stageFromWireEnvironment as oe,accountTier as te,getEnvironmentLabel as _e,ACCOUNT_ROLES as ae}from"./environments.js";import{RESOURCE_CATEGORIES as Ae,categoriseResource as Te,getExpectedDuration as ne,getFriendlyResourceType as Re}from"./resourceCategorisation.js";import{parseGitRemoteUrl as Ne}from"./repo/gitRemoteParser.js";import{abbreviateRegion as se,AWS_REGIONS_METADATA as Oe,DEFAULT_REGION as Pe,getRegionInfo as Ce,MAX_SECONDARY_REGIONS as pe,OPT_IN_REGION_CODES as fe,optInRegionWarning as ce,regions as ge,suggestRegionForTimezone as Ie}from"./infra/regions.js";import{SCOPE_VALUES as xe,MACHINE_ONLY_SCOPES as ue,USER_GRANTABLE_SCOPES as de}from"./infra/tokenScopes.js";import{SECRET_NAME_PATTERN as le,SECRET_NAME_ERROR as Ue,SSM_COMPONENT_PATTERN as Le,SSM_COMPONENT_ERROR as Ve,SSM_STANDARD_MAX_VALUE_BYTES as Fe,SecretNamespaceSchema as Ge,buildNamespaceParts as he,buildParameterPath as ve,parseParameterPath as He,isManageablePath as Xe,parseDotEnv as be,escapeDotEnvValue as Ke}from"./secrets.js";import{ConnectionWireSchema as Ye,ConnectionsListResponseSchema as We}from"./infra/connectionsWire.js";import{deriveRegionsFromOrgConfig as ke,deriveTargets as je,deriveAllTargets as ze,environmentOrTier as Ze,findTarget as qe,generateTargetName as we}from"./targets.js";import{buildAppConfigPath as Qe}from"./repo/appPath.js";import{findInfrastructurePaths as er,findBoundaryPath as rr,isInfrastructureFile as Er}from"./repo/findInfrastructurePaths.js";import{inferContainerFromCandidates as tr}from"./repo/inferContainerFromCandidates.js";import{RESERVED_APP_NAMES as ar,RESERVED_APP_NAME_MESSAGE as Sr,isReservedAppName as Ar,RESERVED_APP_NAME_SUFFIX as Tr,RESERVED_APP_NAME_SUFFIX_MESSAGE as nr,hasReservedAppNameSuffix as Rr}from"./naming/reservedAppNames.js";import{deriveContentHashTag as Nr,CONTENT_HASH_TAG_PATTERN as mr}from"./infra/deriveContentHashTag.js";import{DEPLOY_MODES as Or,DeployModeSchema as Pr,IMAGE_TAG_PATTERN as Cr,ImageTagSchema as pr,ServiceArtefactSchema as fr,ServiceArtefactsSchema as cr,ARTEFACT_OUTPUT_FIELDS as gr,artefactOutputKey as Ir}from"./infra/deployArtefacts.js";import{MIGRATION_SNAPSHOT_NAME_PREFIX as xr,EXPECTED_SCHEMA_VERSION_ENV as ur,EXPECTED_SCHEMA_VERSION_TOOL_ENV as dr,EXPECTED_CH_SCHEMA_VERSION_ENV as Dr,SCHEMA_ADMIN_USER_ENV as lr,SCHEMA_ADMIN_PASSWORD_ENV as Ur,PRISMA_MIGRATION_DIR_RE as Lr,CLICKHOUSE_MIGRATION_SKIP_RE as Vr}from"./migration/constants.js";import{PHYSICAL_NAME_FALLBACK_PROPERTIES as Gr}from"./cfn/physicalNameProperties.js";import{PATTERN_TYPE_VALUES as vr,PATTERN_TYPES as Hr,isPatternType as Xr,PATTERN_REGISTRY as br,OPENNEXT_PATTERN_TYPES as Kr,isOpenNextPatternType as yr,STATIC_SITE_ROUTING_VALUES as Yr}from"./patterns/patternTypes.js";import{DEFAULT_FORMS_FROM_LOCAL_PART as Br,defaultFormsFromAddress as kr,defaultFormsCorsOrigin as jr,isAddressAtDomain as zr}from"./patterns/staticSiteForms.js";export{ae as ACCOUNT_ROLES,w as ACCOUNT_STAGES,Z as ACCOUNT_STAGES_WITH_ROOT,J as ACCOUNT_STAGE_LABELS,$ as ACCOUNT_TIERS,S as APPROVAL_TOKEN_OUTPUT_PREFIX,gr as ARTEFACT_OUTPUT_FIELDS,Oe as AWS_REGIONS_METADATA,ee as AccountTierSchema,_ as BACKUP_VAULT_NAME,Vr as CLICKHOUSE_MIGRATION_SKIP_RE,mr as CONTENT_HASH_TAG_PATTERN,Ye as ConnectionWireSchema,We as ConnectionsListResponseSchema,X as DANGEROUS_ENV_VARS,Br as DEFAULT_FORMS_FROM_LOCAL_PART,Pe as DEFAULT_REGION,Or as DEPLOY_MODES,E as DNS_APEX,Pr as DeployModeSchema,Dr as EXPECTED_CH_SCHEMA_VERSION_ENV,ur as EXPECTED_SCHEMA_VERSION_ENV,dr as EXPECTED_SCHEMA_VERSION_TOOL_ENV,Cr as IMAGE_TAG_PATTERN,pr as ImageTagSchema,ue as MACHINE_ONLY_SCOPES,pe as MAX_SECONDARY_REGIONS,xr as MIGRATION_SNAPSHOT_NAME_PREFIX,Kr as OPENNEXT_PATTERN_TYPES,fe as OPT_IN_REGION_CODES,br as PATTERN_REGISTRY,Hr as PATTERN_TYPES,vr as PATTERN_TYPE_VALUES,Gr as PHYSICAL_NAME_FALLBACK_PROPERTIES,Lr as PRISMA_MIGRATION_DIR_RE,x as REGION_SHORT_CODES,ar as RESERVED_APP_NAMES,Sr as RESERVED_APP_NAME_MESSAGE,Tr as RESERVED_APP_NAME_SUFFIX,nr as RESERVED_APP_NAME_SUFFIX_MESSAGE,Ae as RESOURCE_CATEGORIES,Ur as SCHEMA_ADMIN_PASSWORD_ENV,lr as SCHEMA_ADMIN_USER_ENV,Y as SCOPED_TOKEN_REGEX,xe as SCOPE_VALUES,Ue as SECRET_NAME_ERROR,le as SECRET_NAME_PATTERN,Ve as SSM_COMPONENT_ERROR,Le as SSM_COMPONENT_PATTERN,Fe as SSM_STANDARD_MAX_VALUE_BYTES,Yr as STATIC_SITE_ROUTING_VALUES,q as STRUCTURAL_ENVIRONMENTS,Ge as SecretNamespaceSchema,fr as ServiceArtefactSchema,cr as ServiceArtefactsSchema,A as TOKEN_STDERR_PREFIX,de as USER_GRANTABLE_SCOPES,se as abbreviateRegion,C as accountConstructKey,te as accountTier,Ir as artefactOutputKey,Qe as buildAppConfigPath,he as buildNamespaceParts,ve as buildParameterPath,O as capitalise,Te as categoriseResource,I as defaultConnectedAccountName,jr as defaultFormsCorsOrigin,kr as defaultFormsFromAddress,ze as deriveAllTargets,Nr as deriveContentHashTag,ke as deriveRegionsFromOrgConfig,je as deriveTargets,Ze as environmentOrTier,Ee as environmentToTier,Ke as escapeDotEnvValue,b as filterDangerousEnvVars,c as findAccountNameCollision,rr as findBoundaryPath,er as findInfrastructurePaths,qe as findTarget,u as findTrailingRegionShortCode,G as formatErrorString,we as generateTargetName,o as getDomainExportNames,_e as getEnvironmentLabel,V as getErrorCode,U as getErrorMessage,F as getErrorStack,ne as getExpectedDuration,Re as getFriendlyResourceType,Ce as getRegionInfo,P as getSafeZoneName,p as hasAsciiStableConstructKey,L as hasErrorCode,Rr as hasReservedAppNameSuffix,n as imageTagParameterName,tr as inferContainerFromCandidates,Q as isAccountStage,re as isAccountTier,zr as isAddressAtDomain,Er as isInfrastructureFile,Xe as isManageablePath,yr as isOpenNextPatternType,Xr as isPatternType,Ar as isReservedAppName,j as mapSettledWithConcurrency,K as maskSensitiveOutput,l as normaliseError,ce as optInRegionWarning,be as parseDotEnv,Ne as parseGitRemoteUrl,He as parseParameterPath,y as parseShellArgs,d as regionSuffixRejectionMessage,ge as regions,v as singleton,B as sleep,oe as stageFromWireEnvironment,M as suffixedAccountName,Ie as suggestRegionForTimezone,N as toKebab,i as toPascalCase,s as toScreamingSnake,m as toValidDatabaseName};
|
|
@@ -213,6 +213,8 @@ export type ManifestService = z.infer<typeof ManifestServiceSchema>;
|
|
|
213
213
|
declare const ManifestPatternSchema: z.ZodObject<{
|
|
214
214
|
type: z.ZodEnum<{
|
|
215
215
|
payload: "payload";
|
|
216
|
+
nextjs: "nextjs";
|
|
217
|
+
staticsite: "staticsite";
|
|
216
218
|
}>;
|
|
217
219
|
name: z.ZodString;
|
|
218
220
|
source: z.ZodString;
|
|
@@ -296,6 +298,8 @@ export declare const FjallManifestSchema: z.ZodObject<{
|
|
|
296
298
|
pattern: z.ZodOptional<z.ZodObject<{
|
|
297
299
|
type: z.ZodEnum<{
|
|
298
300
|
payload: "payload";
|
|
301
|
+
nextjs: "nextjs";
|
|
302
|
+
staticsite: "staticsite";
|
|
299
303
|
}>;
|
|
300
304
|
name: z.ZodString;
|
|
301
305
|
source: z.ZodString;
|
package/dist/manifest/schemas.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";const
|
|
1
|
+
import{z as e}from"zod";import{PATTERN_TYPE_VALUES as u}from"../patterns/patternTypes.js";const M="fjall-manifest.json",b=1,f=/^[A-Za-z0-9_.-]+$/,S=e.object({id:e.string().min(1,"buildSecret id cannot be empty").regex(f,"buildSecret id may contain only letters, digits, '_', '.', and '-' (no comma, '=', or whitespace, which would break the buildx --secret argv)"),ssm:e.string().min(1,"ssm parameter name cannot be empty").optional(),secretsManager:e.object({name:e.string().min(1,"secret name cannot be empty").optional(),arn:e.string().min(1,"secret arn cannot be empty").optional(),field:e.string().min(1,"secret field cannot be empty").optional()}).strict().refine(t=>t.name===void 0!=(t.arn===void 0),"secretsManager requires exactly one of name or arn").optional(),env:e.string().min(1,"env variable name cannot be empty").optional()}).strict().superRefine((t,n)=>{[t.ssm,t.secretsManager,t.env].filter(r=>r!==void 0).length!==1&&n.addIssue({code:e.ZodIssueCode.custom,message:"buildSecret requires exactly one source (ssm, secretsManager, or env)"})}),y=e.union([e.string(),e.object({ssm:e.string().min(1,"ssm parameter name cannot be empty").optional(),secretsManager:e.object({name:e.string().min(1,"secret name cannot be empty").optional(),arn:e.string().min(1,"secret arn cannot be empty").optional(),field:e.string().min(1,"secret field cannot be empty").optional()}).strict().refine(t=>t.name===void 0!=(t.arn===void 0),"secretsManager requires exactly one of name or arn").optional(),env:e.string().min(1,"env variable name cannot be empty").optional(),acknowledgePublic:e.boolean().optional()}).strict().superRefine((t,n)=>{[t.ssm,t.secretsManager,t.env].filter(r=>r!==void 0).length!==1&&n.addIssue({code:e.ZodIssueCode.custom,message:"buildArg value requires exactly one source (ssm, secretsManager, or env)"})})]),i=e.object({path:e.string(),context:e.string().min(1,"context cannot be empty").optional(),target:e.string().min(1,"target cannot be empty").optional(),buildArgs:e.record(e.string(),y).optional(),buildSecrets:e.array(S).optional()}).strict(),A=i.partial();function j(t,n){if(n===void 0)return t;const a=n.context??t.context,r=n.target??t.target,o=n.buildArgs??t.buildArgs,s=n.buildSecrets??t.buildSecrets;return{path:n.path??t.path,...a!==void 0&&{context:a},...r!==void 0&&{target:r},...o!==void 0&&{buildArgs:o},...s!==void 0&&{buildSecrets:s}}}const c=e.object({name:e.string(),clusterName:e.string().optional(),docker:i.optional(),containerPort:e.number().optional(),secrets:e.array(e.string()).optional(),ssmSecretsPath:e.string().optional(),importedSecretNames:e.array(e.string()).optional()}).strict(),m=e.object({type:e.enum(u),name:e.string(),source:e.string()}).strict(),l=e.object({repositoryName:e.string()}).strict(),p=e.object({name:e.string(),secrets:e.array(e.string()).optional(),ssmSecretsPath:e.string().optional(),importedSecretNames:e.array(e.string()).optional()}).strict(),d=e.object({templateHash:e.string(),synthTimestamp:e.string()}).strict(),g=e.object({constructPath:e.string().max(512),group:e.string().max(128),resourceType:e.string().max(256)}).strict(),E=e.object({version:e.literal(b),generatedAt:e.string(),appName:e.string(),services:e.array(c),lambdas:e.array(p),pattern:m.optional(),ecr:l.optional(),stacks:e.record(e.string(),d),resourceMap:e.record(e.string(),g).optional()}).strict();export{f as BUILDKIT_SECRET_ID_PATTERN,y as DockerBuildArgValueSchema,A as DockerBuildPartialSchema,i as DockerBuildSchema,S as DockerBuildSecretRefSchema,M as FJALL_MANIFEST_FILENAME,E as FjallManifestSchema,b as MANIFEST_SCHEMA_VERSION,l as ManifestEcrSchema,p as ManifestLambdaSchema,m as ManifestPatternSchema,c as ManifestServiceSchema,d as ManifestStackHashSchema,g as ResourceMapEntrySchema,j as mergeDockerBuild};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boot-gate version comparison with expand-only rollback tolerance.
|
|
3
|
+
*
|
|
4
|
+
* The schema-version gates (`verifyExpectedSchemaVersion` for Postgres,
|
|
5
|
+
* `verifyExpectedClickHouseSchemaVersion` for ClickHouse) both decide whether a
|
|
6
|
+
* booting image's EXPECTED schema version is SATISFIED by what the database has
|
|
7
|
+
* APPLIED. Both route their `matches` verdict through here so the two gates can
|
|
8
|
+
* never drift (Code Quality § "Coupled values: shared source at 2 occurrences").
|
|
9
|
+
*
|
|
10
|
+
* The tolerance exists because expand/contract migrations make an old image safe
|
|
11
|
+
* against a newer schema: rolling the image back without rolling the DB back is
|
|
12
|
+
* the intended expand-only rollback, and a strict-equality gate defeated it by
|
|
13
|
+
* refusing to boot. See `aiDocs/patterns/migration-safety-pattern.md`.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* True when `version` is a monotonically-ordered migration identifier whose
|
|
17
|
+
* lexicographic order equals its chronological/sequence order — a Prisma
|
|
18
|
+
* migration name (`20260706120000_add_users`, fixed-width timestamp) or a
|
|
19
|
+
* ClickHouse migration filename (`011-issue-brief-citations.sql`, zero-padded
|
|
20
|
+
* numeric prefix). Both are selected as "latest" by `.sort()` at synth time
|
|
21
|
+
* (`pickLatest*Migration`) and apply time (the runner), so lexicographic
|
|
22
|
+
* comparison here mirrors that selection exactly.
|
|
23
|
+
*
|
|
24
|
+
* Returns false for the non-orderable audit fields — `_schema_migrations.version`
|
|
25
|
+
* (sha256 content hash) and `prisma_version` (the constant marker `"applied"`) —
|
|
26
|
+
* so the caller fails closed on exact identity for those.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isOrderableSchemaVersion(version: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the `expected` schema version baked into the image is satisfied by the
|
|
31
|
+
* `actual` version applied to the database.
|
|
32
|
+
*
|
|
33
|
+
* When BOTH are orderable migration identifiers, the DB may sit AT or AHEAD of
|
|
34
|
+
* the image's expectation — an old image booting against a newer expand-only
|
|
35
|
+
* schema is safe, so `actual >= expected` passes. The forward direction
|
|
36
|
+
* (`actual < expected`, new code against an older schema) still fails: the
|
|
37
|
+
* columns/tables the image needs may not exist yet.
|
|
38
|
+
*
|
|
39
|
+
* When EITHER is non-orderable (content hash, constant marker), there is no
|
|
40
|
+
* defined newer/older, so it falls back to strict identity — fail-closed,
|
|
41
|
+
* byte-identical to the pre-tolerance behaviour.
|
|
42
|
+
*
|
|
43
|
+
* The `>=` is lexicographic, which equals sequence order only when both
|
|
44
|
+
* versions share an equal-width numeric prefix (Prisma's fixed 14-digit
|
|
45
|
+
* timestamp always does; a ClickHouse `NNN-…` filename only if authored
|
|
46
|
+
* zero-padded). If the widths differ — or a `.sql` name carries no numeric
|
|
47
|
+
* prefix at all — lexicographic order cannot be trusted, so it also falls back
|
|
48
|
+
* to strict identity (fail-closed) rather than return a possibly-inverted `>=`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isSchemaVersionSatisfied(expected: string, actual: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PRISMA_MIGRATION_DIR_RE as u,CLICKHOUSE_MIGRATION_FILE_RE as s}from"./constants.js";function e(n){return u.test(n)||s.test(n)}function o(n){const r=/^(\d+)/.exec(n);return r===null?null:r[1].length}function I(n,r){if(e(n)&&e(r)){const t=o(n),i=o(r);return t!==null&&i!==null&&t===i?r>=n:r===n}return r===n}export{e as isOrderableSchemaVersion,I as isSchemaVersionSatisfied};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{describe as i,expect as e,it as s}from"vitest";import{isOrderableSchemaVersion as t,isSchemaVersionSatisfied as a}from"./compareSchemaVersion.js";i("isOrderableSchemaVersion",()=>{s("recognises a Prisma migration name",()=>{e(t("20260706120000_add_log_events")).toBe(!0)}),s("recognises a ClickHouse migration filename",()=>{e(t("011-issue-brief-citations.sql")).toBe(!0)}),s("rejects a sha256 content hash (the audit `version` field)",()=>{e(t("3f2b1c9d8e7a6f5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b")).toBe(!1)}),s("rejects the constant `prisma_version` marker",()=>{e(t("applied")).toBe(!1)}),s("rejects a digit-leading string with no migration shape",()=>{e(t("19bc2fdeadbeef")).toBe(!1)})}),i("isSchemaVersionSatisfied",()=>{i("orderable versions (expand-only tolerance)",()=>{s("passes when actual equals expected (Prisma)",()=>{e(a("20260520000000_add_widgets","20260520000000_add_widgets")).toBe(!0)}),s("passes when actual is AHEAD of expected (Prisma rollback)",()=>{e(a("20260520000000_add_widgets","20260521000000_more")).toBe(!0)}),s("fails when actual TRAILS expected (Prisma \u2014 new code, old schema)",()=>{e(a("20260520000000_add_widgets","20260519000000_old")).toBe(!1)}),s("passes when actual is AHEAD of expected (ClickHouse rollback)",()=>{e(a("010-issue-briefs.sql","011-citations.sql")).toBe(!0)}),s("fails when actual TRAILS expected (ClickHouse)",()=>{e(a("010-issue-briefs.sql","009-old.sql")).toBe(!1)}),s("respects zero-padded numeric ordering, not naive digit count",()=>{e(a("010-a.sql","002-b.sql")).toBe(!1),e(a("002-b.sql","010-a.sql")).toBe(!0)})}),i("mismatched-width prefixes (fail-closed, no lexicographic trust)",()=>{s("refuses `>=` when CH numeric-prefix widths differ",()=>{e(a("010-x.sql","9-hotfix.sql")).toBe(!1),e(a("9-hotfix.sql","010-x.sql")).toBe(!1)}),s("still passes on exact identity even at a mismatched-width name",()=>{e(a("9-hotfix.sql","9-hotfix.sql")).toBe(!0)}),s("fails closed for a `.sql` name with no numeric prefix",()=>{e(a("010-x.sql","hotfix.sql")).toBe(!1),e(a("hotfix.sql","hotfix.sql")).toBe(!0)})}),i("non-orderable versions (fail-closed strict identity)",()=>{s("passes only on exact hash identity",()=>{const o="3f2b1c9d8e7a6f5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b";e(a(o,o)).toBe(!0)}),s("fails for a different hash even when it sorts later",()=>{e(a("00000000","ffffffff")).toBe(!1)}),s("fails when only one side is orderable",()=>{e(a("20260520000000_add_widgets","applied")).toBe(!1),e(a("applied","20260521000000_more")).toBe(!1)})})});
|
|
@@ -59,3 +59,12 @@ export declare const PRISMA_MIGRATION_DIR_RE: RegExp;
|
|
|
59
59
|
* record, hard-failing every boot.
|
|
60
60
|
*/
|
|
61
61
|
export declare const CLICKHOUSE_MIGRATION_SKIP_RE: RegExp;
|
|
62
|
+
/**
|
|
63
|
+
* A ClickHouse migration filename — the `.sql` suffix by which
|
|
64
|
+
* `pickLatestClickHouseMigration` / `runSqlMigrations` select the "latest"
|
|
65
|
+
* migration (both `.endsWith(".sql")` then `.sort()`). The boot gate's
|
|
66
|
+
* order-tolerant comparison uses it to tell a monotonically-ordered CH version
|
|
67
|
+
* (`ch_version` = the latest `.sql` filename) from the non-orderable audit
|
|
68
|
+
* fields (`version` = sha256 hash, `prisma_version` = the constant `"applied"`).
|
|
69
|
+
*/
|
|
70
|
+
export declare const CLICKHOUSE_MIGRATION_FILE_RE: RegExp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const E="fjall-premigrate",_="EXPECTED_SCHEMA_VERSION",S="EXPECTED_SCHEMA_VERSION_TOOL",
|
|
1
|
+
const E="fjall-premigrate",_="EXPECTED_SCHEMA_VERSION",S="EXPECTED_SCHEMA_VERSION_TOOL",I="EXPECTED_CH_SCHEMA_VERSION",A="SCHEMA_ADMIN_USER",C="SCHEMA_ADMIN_PASSWORD",N=/^\d{14}_/,M=/\.dev\.sql$/,R=/\.sql$/;export{R as CLICKHOUSE_MIGRATION_FILE_RE,M as CLICKHOUSE_MIGRATION_SKIP_RE,I as EXPECTED_CH_SCHEMA_VERSION_ENV,_ as EXPECTED_SCHEMA_VERSION_ENV,S as EXPECTED_SCHEMA_VERSION_TOOL_ENV,E as MIGRATION_SNAPSHOT_NAME_PREFIX,N as PRISMA_MIGRATION_DIR_RE,C as SCHEMA_ADMIN_PASSWORD_ENV,A as SCHEMA_ADMIN_USER_ENV};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { MIGRATION_SNAPSHOT_NAME_PREFIX, EXPECTED_SCHEMA_VERSION_ENV, EXPECTED_SCHEMA_VERSION_TOOL_ENV, EXPECTED_CH_SCHEMA_VERSION_ENV, SCHEMA_ADMIN_USER_ENV, SCHEMA_ADMIN_PASSWORD_ENV, PRISMA_MIGRATION_DIR_RE, CLICKHOUSE_MIGRATION_SKIP_RE } from "./constants.js";
|
|
2
2
|
export { pickLatestPrismaMigration } from "./pickLatestPrismaMigration.js";
|
|
3
3
|
export { pickLatestClickHouseMigration } from "./pickLatestClickHouseMigration.js";
|
|
4
|
+
export { isOrderableSchemaVersion, isSchemaVersionSatisfied } from "./compareSchemaVersion.js";
|
|
4
5
|
export { type MigrationsSqlClient, type VerifyExpectedSchemaVersionOpts, type VerifyExpectedSchemaVersionResult, verifyExpectedSchemaVersion } from "./verifyExpectedSchemaVersion.js";
|
|
5
6
|
export { CLICKHOUSE_MANAGED_USERS_ENV, MANAGED_USER_NAME_PATTERN, userPasswordEnvName, ManagedUserNameSchema, ManagedUserNamesSchema, type ManagedUserName, type ManagedUserNames } from "./clickhouseSqlUsers.js";
|
package/dist/migration/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MIGRATION_SNAPSHOT_NAME_PREFIX as e,EXPECTED_SCHEMA_VERSION_ENV as
|
|
1
|
+
import{MIGRATION_SNAPSHOT_NAME_PREFIX as e,EXPECTED_SCHEMA_VERSION_ENV as S,EXPECTED_SCHEMA_VERSION_TOOL_ENV as r,EXPECTED_CH_SCHEMA_VERSION_ENV as N,SCHEMA_ADMIN_USER_ENV as a,SCHEMA_ADMIN_PASSWORD_ENV as A,PRISMA_MIGRATION_DIR_RE as o,CLICKHOUSE_MIGRATION_SKIP_RE as M}from"./constants.js";import{pickLatestPrismaMigration as i}from"./pickLatestPrismaMigration.js";import{pickLatestClickHouseMigration as R}from"./pickLatestClickHouseMigration.js";import{isOrderableSchemaVersion as t,isSchemaVersionSatisfied as C}from"./compareSchemaVersion.js";import{verifyExpectedSchemaVersion as V}from"./verifyExpectedSchemaVersion.js";import{CLICKHOUSE_MANAGED_USERS_ENV as H,MANAGED_USER_NAME_PATTERN as T,userPasswordEnvName as c,ManagedUserNameSchema as p,ManagedUserNamesSchema as D}from"./clickhouseSqlUsers.js";export{H as CLICKHOUSE_MANAGED_USERS_ENV,M as CLICKHOUSE_MIGRATION_SKIP_RE,N as EXPECTED_CH_SCHEMA_VERSION_ENV,S as EXPECTED_SCHEMA_VERSION_ENV,r as EXPECTED_SCHEMA_VERSION_TOOL_ENV,T as MANAGED_USER_NAME_PATTERN,e as MIGRATION_SNAPSHOT_NAME_PREFIX,p as ManagedUserNameSchema,D as ManagedUserNamesSchema,o as PRISMA_MIGRATION_DIR_RE,A as SCHEMA_ADMIN_PASSWORD_ENV,a as SCHEMA_ADMIN_USER_ENV,t as isOrderableSchemaVersion,C as isSchemaVersionSatisfied,R as pickLatestClickHouseMigration,i as pickLatestPrismaMigration,c as userPasswordEnvName,V as verifyExpectedSchemaVersion};
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
* Returns `{ matches, expected, actual }` rather than throwing on mismatch:
|
|
21
21
|
* the boot gate's caller owns the exit-code / log shape so the helper can
|
|
22
22
|
* be reused by integration tests, dashboards, and CLI checks alike.
|
|
23
|
+
*
|
|
24
|
+
* `matches` tolerates expand-only rollback: an old image booting against a
|
|
25
|
+
* NEWER applied schema passes (`actual >= expected`), while the forward
|
|
26
|
+
* direction (new code against an older schema) still fails. The comparison is
|
|
27
|
+
* delegated to `isSchemaVersionSatisfied` — see it for the orderability rules.
|
|
23
28
|
*/
|
|
24
29
|
/**
|
|
25
30
|
* Minimal SQL-driver shim. Compatible with `pg.Client.query`, `mysql2.query`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{isSchemaVersionSatisfied as c}from"./compareSchemaVersion.js";const s="SELECT migration_name FROM _prisma_migrations WHERE finished_at IS NOT NULL ORDER BY finished_at DESC LIMIT 1",a="migration_name";async function m(e){if(e.signal?.aborted)throw new Error("verifyExpectedSchemaVersion: aborted by signal before query");let r,n;if(e.tool==="prisma")r=s,n=a;else if(e.tool==="custom"){if(e.customQuery===void 0)throw new Error('verifyExpectedSchemaVersion: tool="custom" requires customQuery');r=e.customQuery.sql,n=e.customQuery.column}else throw new Error(`verifyExpectedSchemaVersion: unknown tool ${String(e.tool)}`);const i=(await e.client.query(r)).rows[0],o=i!==void 0?i[n]:void 0,t=typeof o=="string"?o:null;return{matches:t!==null&&c(e.expected,t),expected:e.expected,actual:t}}export{m as verifyExpectedSchemaVersion};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{describe as
|
|
1
|
+
import{describe as c,expect as a,it as s,vi as l}from"vitest";import{verifyExpectedSchemaVersion as o}from"./verifyExpectedSchemaVersion.js";function n(t){const e=[];return{client:{query:l.fn(async i=>(e.push(i),{rows:t}))},queries:e}}c("verifyExpectedSchemaVersion",()=>{c('tool: "prisma"',()=>{s("returns matches=true when actual === expected",async()=>{const{client:t,queries:e}=n([{migration_name:"20260520000000_add_widgets"}]),r=await o({tool:"prisma",expected:"20260520000000_add_widgets",client:t});a(r).toEqual({matches:!0,expected:"20260520000000_add_widgets",actual:"20260520000000_add_widgets"}),a(e).toHaveLength(1),a(e[0]).toContain("_prisma_migrations"),a(e[0]).toContain("finished_at IS NOT NULL"),a(e[0]).toContain("ORDER BY finished_at DESC LIMIT 1")}),s("returns matches=false with actual when DB trails image",async()=>{const{client:t}=n([{migration_name:"20260519000000_old"}]),e=await o({tool:"prisma",expected:"20260520000000_add_widgets",client:t});a(e).toEqual({matches:!1,expected:"20260520000000_add_widgets",actual:"20260519000000_old"})}),s("returns matches=true when DB is AHEAD (expand-only rollback)",async()=>{const{client:t}=n([{migration_name:"20260521000000_add_more_widgets"}]),e=await o({tool:"prisma",expected:"20260520000000_add_widgets",client:t});a(e).toEqual({matches:!0,expected:"20260520000000_add_widgets",actual:"20260521000000_add_more_widgets"})}),s("returns actual=null on empty result set",async()=>{const{client:t}=n([]),e=await o({tool:"prisma",expected:"20260520000000_add_widgets",client:t});a(e).toEqual({matches:!1,expected:"20260520000000_add_widgets",actual:null})}),s("returns actual=null when row's migration_name is not a string",async()=>{const{client:t}=n([{migration_name:12345}]),e=await o({tool:"prisma",expected:"x",client:t});a(e.actual).toBeNull(),a(e.matches).toBe(!1)})}),c('tool: "custom"',()=>{s("uses customQuery sql and column",async()=>{const{client:t,queries:e}=n([{hash:"deadbeef"}]),r=await o({tool:"custom",expected:"deadbeef",client:t,customQuery:{sql:"SELECT hash FROM __drizzle_migrations ORDER BY created_at DESC LIMIT 1",column:"hash"}});a(r.matches).toBe(!0),a(r.actual).toBe("deadbeef"),a(e[0]).toBe("SELECT hash FROM __drizzle_migrations ORDER BY created_at DESC LIMIT 1")}),s("stays strict for non-orderable versions even when actual sorts later",async()=>{const{client:t}=n([{hash:"ffffffff"}]),e=await o({tool:"custom",expected:"00000000",client:t,customQuery:{sql:"SELECT hash FROM __drizzle_migrations ORDER BY created_at DESC LIMIT 1",column:"hash"}});a(e.matches).toBe(!1),a(e.actual).toBe("ffffffff")}),s("throws when customQuery is omitted",async()=>{const{client:t}=n([]);await a(o({tool:"custom",expected:"x",client:t})).rejects.toThrow(/tool="custom" requires customQuery/)})}),c("abort signal",()=>{s("short-circuits before query when signal is already aborted",async()=>{const{client:t,queries:e}=n([{migration_name:"irrelevant"}]),r=new AbortController;r.abort(),await a(o({tool:"prisma",expected:"x",client:t,signal:r.signal})).rejects.toThrow(/aborted by signal before query/),a(e).toEqual([])})})});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pattern vocabulary, its dispatch registry and the static-site forms
|
|
3
|
+
* address rules.
|
|
4
|
+
*
|
|
5
|
+
* Available as the `@fjall/util/patterns` subpath so consumers that must stay
|
|
6
|
+
* free of `node:*` imports (deploy-core's browser-safe `types/` barrel, which
|
|
7
|
+
* the webapp bundles) can take the vocabulary without depending on the root
|
|
8
|
+
* barrel's contents staying pure.
|
|
9
|
+
*/
|
|
10
|
+
export { PATTERN_TYPE_VALUES, type PatternType, PATTERN_TYPES, isPatternType, type PatternArtefact, type PatternStackPlacement, type PatternDescriptor, PATTERN_REGISTRY, type OpenNextPatternType, OPENNEXT_PATTERN_TYPES, isOpenNextPatternType, STATIC_SITE_ROUTING_VALUES, type StaticSiteRouting } from "./patternTypes.js";
|
|
11
|
+
export { DEFAULT_FORMS_FROM_LOCAL_PART, defaultFormsFromAddress, defaultFormsCorsOrigin, isAddressAtDomain } from "./staticSiteForms.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PATTERN_TYPE_VALUES as r,PATTERN_TYPES as A,isPatternType as _,PATTERN_REGISTRY as e,OPENNEXT_PATTERN_TYPES as P,isOpenNextPatternType as s,STATIC_SITE_ROUTING_VALUES as t}from"./patternTypes.js";import{DEFAULT_FORMS_FROM_LOCAL_PART as o,defaultFormsFromAddress as N,defaultFormsCorsOrigin as S,isAddressAtDomain as O}from"./staticSiteForms.js";export{o as DEFAULT_FORMS_FROM_LOCAL_PART,P as OPENNEXT_PATTERN_TYPES,e as PATTERN_REGISTRY,A as PATTERN_TYPES,r as PATTERN_TYPE_VALUES,t as STATIC_SITE_ROUTING_VALUES,S as defaultFormsCorsOrigin,N as defaultFormsFromAddress,O as isAddressAtDomain,s as isOpenNextPatternType,_ as isPatternType};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pattern vocabulary — single source of truth.
|
|
3
|
+
*
|
|
4
|
+
* A "pattern" is a whole-application shape (Payload CMS, a Next.js app, a
|
|
5
|
+
* pre-built static site) that the generator emits, the CDK synthesises,
|
|
6
|
+
* deploy-core builds and the CLI offers. Before this module the vocabulary was
|
|
7
|
+
* declared four times — generator schemas, CDK interfaces, the deploy manifest
|
|
8
|
+
* and the CLI create flow — each with a different membership, so adding a
|
|
9
|
+
* pattern to one left the others silently wrong.
|
|
10
|
+
*
|
|
11
|
+
* `PATTERN_REGISTRY` is the compiler's checklist. It is a `Record<PatternType,
|
|
12
|
+
* PatternDescriptor>`, so a new member of `PATTERN_TYPE_VALUES` fails to
|
|
13
|
+
* compile until every dispatch decision — which stack, which builder, which
|
|
14
|
+
* construct id — is stated. Dispatch sites read the descriptor instead of
|
|
15
|
+
* re-deriving the answer from a ternary chain whose `else` branch would
|
|
16
|
+
* otherwise absorb the new pattern.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Every pattern the toolchain knows about.
|
|
20
|
+
*
|
|
21
|
+
* - `payload` — Payload CMS on OpenNext (always has a database + migrations).
|
|
22
|
+
* - `nextjs` — a plain Next.js app on OpenNext (optional database). No CDK
|
|
23
|
+
* construct exists yet: `IPatternProps` (components/infrastructure) omits it,
|
|
24
|
+
* so a generated `nextjs` app fails to synthesise. Add the props + a
|
|
25
|
+
* `PatternFactory.build` case to close the gap.
|
|
26
|
+
* - `staticsite` — pre-built static assets on private S3 + CloudFront/OAC.
|
|
27
|
+
*/
|
|
28
|
+
export declare const PATTERN_TYPE_VALUES: readonly ["payload", "nextjs", "staticsite"];
|
|
29
|
+
export type PatternType = (typeof PATTERN_TYPE_VALUES)[number];
|
|
30
|
+
export declare const PATTERN_TYPES: ReadonlySet<string>;
|
|
31
|
+
export declare function isPatternType(value: unknown): value is PatternType;
|
|
32
|
+
/**
|
|
33
|
+
* What a pattern's build step produces. Selects the deploy-core builder:
|
|
34
|
+
* `opennext-lambda` runs the OpenNext build and uploads a Lambda bundle;
|
|
35
|
+
* `static-assets` runs the site's own build command and syncs a directory to S3.
|
|
36
|
+
*/
|
|
37
|
+
export type PatternArtefact = "opennext-lambda" | "static-assets";
|
|
38
|
+
/**
|
|
39
|
+
* Which stack the pattern's constructs are placed into. A static site has no
|
|
40
|
+
* VPC or compute, so it co-locates in the CDN stack; OpenNext patterns carry a
|
|
41
|
+
* Lambda (and usually a database) and belong in the compute stack.
|
|
42
|
+
*/
|
|
43
|
+
export type PatternStackPlacement = "compute" | "cdn";
|
|
44
|
+
export interface PatternDescriptor {
|
|
45
|
+
/** Human-facing name, used by the CLI picker and progress output. */
|
|
46
|
+
readonly label: string;
|
|
47
|
+
/** Suffix the generator appends to the PascalCase app name for the construct id. */
|
|
48
|
+
readonly constructIdSuffix: string;
|
|
49
|
+
/** What the build produces — selects the deploy-core framework builder. */
|
|
50
|
+
readonly artefact: PatternArtefact;
|
|
51
|
+
/** Stack the pattern's constructs are placed into. */
|
|
52
|
+
readonly stackPlacement: PatternStackPlacement;
|
|
53
|
+
}
|
|
54
|
+
export declare const PATTERN_REGISTRY: {
|
|
55
|
+
readonly payload: {
|
|
56
|
+
readonly label: "Payload CMS";
|
|
57
|
+
readonly constructIdSuffix: "Payload";
|
|
58
|
+
readonly artefact: "opennext-lambda";
|
|
59
|
+
readonly stackPlacement: "compute";
|
|
60
|
+
};
|
|
61
|
+
readonly nextjs: {
|
|
62
|
+
readonly label: "Next.js";
|
|
63
|
+
readonly constructIdSuffix: "Nextjs";
|
|
64
|
+
readonly artefact: "opennext-lambda";
|
|
65
|
+
readonly stackPlacement: "compute";
|
|
66
|
+
};
|
|
67
|
+
readonly staticsite: {
|
|
68
|
+
readonly label: "Static site";
|
|
69
|
+
readonly constructIdSuffix: "StaticSite";
|
|
70
|
+
readonly artefact: "static-assets";
|
|
71
|
+
readonly stackPlacement: "cdn";
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* The OpenNext-shaped patterns, derived from the registry at both the type and
|
|
76
|
+
* the value level — a new OpenNext pattern joins this accept-set by declaring
|
|
77
|
+
* its artefact, not by being remembered in a second list. (`as const satisfies`
|
|
78
|
+
* above is what keeps the literal `artefact` types the mapped type reads.)
|
|
79
|
+
*/
|
|
80
|
+
export type OpenNextPatternType = {
|
|
81
|
+
[K in PatternType]: (typeof PATTERN_REGISTRY)[K]["artefact"] extends "opennext-lambda" ? K : never;
|
|
82
|
+
}[PatternType];
|
|
83
|
+
export declare const OPENNEXT_PATTERN_TYPES: readonly OpenNextPatternType[];
|
|
84
|
+
export declare function isOpenNextPatternType(value: string | undefined | null): value is OpenNextPatternType;
|
|
85
|
+
/**
|
|
86
|
+
* Routing mode for a static site. Shared with the CDN construct and the
|
|
87
|
+
* generator's `StaticSiteRoutingSchema`, both of which derive from this tuple —
|
|
88
|
+
* a third mode must not be addable to one without the other.
|
|
89
|
+
*/
|
|
90
|
+
export declare const STATIC_SITE_ROUTING_VALUES: readonly ["multipage", "spa"];
|
|
91
|
+
export type StaticSiteRouting = (typeof STATIC_SITE_ROUTING_VALUES)[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=["payload","nextjs","staticsite"],a=new Set(e);function o(t){return typeof t=="string"&&a.has(t)}const n={payload:{label:"Payload CMS",constructIdSuffix:"Payload",artefact:"opennext-lambda",stackPlacement:"compute"},nextjs:{label:"Next.js",constructIdSuffix:"Nextjs",artefact:"opennext-lambda",stackPlacement:"compute"},staticsite:{label:"Static site",constructIdSuffix:"StaticSite",artefact:"static-assets",stackPlacement:"cdn"}},c=e.filter(t=>n[t].artefact==="opennext-lambda"),s=new Set(c);function T(t){return t!=null&&s.has(t)}const r=["multipage","spa"];export{c as OPENNEXT_PATTERN_TYPES,n as PATTERN_REGISTRY,a as PATTERN_TYPES,e as PATTERN_TYPE_VALUES,r as STATIC_SITE_ROUTING_VALUES,T as isOpenNextPatternType,o as isPatternType};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Address derivation for the static-site contact form.
|
|
3
|
+
*
|
|
4
|
+
* The generator validates `forms.from` against these rules and the CDK
|
|
5
|
+
* construct derives the defaults from them, so they are a coupled pair: a
|
|
6
|
+
* change to the default sender that landed on one side only would deploy an
|
|
7
|
+
* endpoint whose IAM `ses:FromAddress` condition denies its own send.
|
|
8
|
+
*/
|
|
9
|
+
/** Local part of the default envelope sender: `noreply@<domain>`. */
|
|
10
|
+
export declare const DEFAULT_FORMS_FROM_LOCAL_PART = "noreply";
|
|
11
|
+
/**
|
|
12
|
+
* The envelope sender used when `forms.from` is absent. Sits at the site's
|
|
13
|
+
* domain because SES sends only from a verified identity.
|
|
14
|
+
*/
|
|
15
|
+
export declare function defaultFormsFromAddress(domain: string): string;
|
|
16
|
+
/** The origin allowed to POST the form when `forms.corsOrigin` is absent. */
|
|
17
|
+
export declare function defaultFormsCorsOrigin(domain: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether `address` sits at exactly `domain`. Subdomains are rejected: the
|
|
20
|
+
* pattern grants `ses:SendEmail` under a `ses:FromAddress` condition pinned to
|
|
21
|
+
* the address, so an address SES would accept but the policy would not is a
|
|
22
|
+
* deploy-green/runtime-500 trap.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isAddressAtDomain(address: string, domain: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s="noreply";function f(r){return`${s}@${r}`}function i(r){return`https://${r}`}function u(r,o){const t=r.split("@");if(t.length!==2)return!1;const[e,n]=t;return e===void 0||e===""||n===void 0?!1:n.toLowerCase()===o.toLowerCase()}export{s as DEFAULT_FORMS_FROM_LOCAL_PART,i as defaultFormsCorsOrigin,f as defaultFormsFromAddress,u as isAddressAtDomain};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjall/util",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.0",
|
|
4
4
|
"description": "Common utility methods",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"types": "./dist/manifest/index.d.ts",
|
|
31
31
|
"default": "./dist/manifest/index.js"
|
|
32
32
|
},
|
|
33
|
+
"./patterns": {
|
|
34
|
+
"types": "./dist/patterns/index.d.ts",
|
|
35
|
+
"default": "./dist/patterns/index.js"
|
|
36
|
+
},
|
|
33
37
|
"./manifest/schemas": {
|
|
34
38
|
"types": "./dist/manifest/schemas.d.ts",
|
|
35
39
|
"default": "./dist/manifest/schemas.js"
|
|
@@ -101,6 +105,7 @@
|
|
|
101
105
|
"clean": "rm -rf ./dist ./sourcemaps",
|
|
102
106
|
"clean:node": "rm -rf ./node_modules",
|
|
103
107
|
"build": "npm run clean && npx tsc && node ../scripts/minify-dist.mjs dist",
|
|
108
|
+
"prepack": "node ../scripts/check-dist-freshness.mjs",
|
|
104
109
|
"watch": "npm run build && npx tsc-watch",
|
|
105
110
|
"watch:only": "npx tsc-watch",
|
|
106
111
|
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json}\"",
|
|
@@ -129,5 +134,5 @@
|
|
|
129
134
|
"engines": {
|
|
130
135
|
"node": ">=22.0.0"
|
|
131
136
|
},
|
|
132
|
-
"gitHead": "
|
|
137
|
+
"gitHead": "ec35b16db566dfa5feb714c16f132c55b4663c86"
|
|
133
138
|
}
|