@fjall/util 2.30.3 → 2.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.minified +1 -1
- package/dist/infra/deployArtefacts.d.ts +6 -4
- package/dist/manifest/index.d.ts +1 -1
- package/dist/manifest/index.js +1 -1
- package/dist/manifest/io.d.ts +41 -0
- package/dist/manifest/io.js +1 -1
- package/dist/manifest/schemas.d.ts +29 -0
- package/dist/manifest/schemas.js +1 -1
- package/package.json +2 -2
package/dist/.minified
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
84 files minified at 2026-07-
|
|
1
|
+
84 files minified at 2026-07-16T20:42:02.563Z
|
|
@@ -44,10 +44,12 @@ export type ImageTag = z.infer<typeof ImageTagSchema>;
|
|
|
44
44
|
* `ecrRepositoryArn` is absent for non-ECR registries.
|
|
45
45
|
*
|
|
46
46
|
* `functionArn`/`publishedVersion` are the Lambda analogue of
|
|
47
|
-
* `taskDefinitionArn`: present
|
|
48
|
-
*
|
|
49
|
-
* `lambda:PublishVersion`
|
|
50
|
-
*
|
|
47
|
+
* `taskDefinitionArn`: present whenever a fresh version was published for a
|
|
48
|
+
* container-image Lambda — on a full deploy via the best-effort post-deploy
|
|
49
|
+
* `lambda:PublishVersion` step (a publish failure degrades the artefact, it
|
|
50
|
+
* never fails an already-succeeded deploy), and on code-only rollouts AND
|
|
51
|
+
* rollbacks via `UpdateFunctionCode`'s `Publish: true`, which publishes
|
|
52
|
+
* alongside the update itself.
|
|
51
53
|
*/
|
|
52
54
|
export declare const ServiceArtefactSchema: z.ZodObject<{
|
|
53
55
|
serviceName: z.ZodString;
|
package/dist/manifest/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* the barrel — the package.json `exports` map exposes both subpaths.
|
|
8
8
|
*/
|
|
9
9
|
export { DockerBuildSchema, DockerBuildArgValueSchema, DockerBuildSecretRefSchema, DockerBuildPartialSchema, mergeDockerBuild, ManifestServiceSchema, ManifestPatternSchema, ManifestEcrSchema, ManifestLambdaSchema, ManifestStackHashSchema, ResourceMapEntrySchema, FjallManifestSchema, FJALL_MANIFEST_FILENAME, MANIFEST_SCHEMA_VERSION, BUILDKIT_SECRET_ID_PATTERN, type DockerBuild, type DockerBuildArgValue, type DockerBuildSecretRef, type DockerBuildPartial, type ManifestService, type ManifestPattern, type ManifestEcr, type ManifestLambda, type ManifestStackHash, type ResourceMapEntry, type FjallManifest } from "./schemas.js";
|
|
10
|
-
export { getManifestFilePath, readManifestFile, writeManifestFile, createEmptyManifest, readConstructMap, parseDockerServicesFromManifest, parseLambdaDockerServicesFromManifest, parseLambdaDockerEntriesFromManifest, type ManifestDockerService, type ManifestLambdaDockerEntry } from "./io.js";
|
|
10
|
+
export { getManifestFilePath, readManifestFile, writeManifestFile, createEmptyManifest, readConstructMap, parseDockerServicesFromManifest, parseLambdaDockerServicesFromManifest, parseLambdaDockerEntriesFromManifest, parseDockerDeclarationsFromManifest, type ManifestDockerService, type ManifestLambdaDockerEntry, type ManifestDockerDeclarations } from "./io.js";
|
package/dist/manifest/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DockerBuildSchema as r,DockerBuildArgValueSchema as t,DockerBuildSecretRefSchema as c,DockerBuildPartialSchema as i,mergeDockerBuild as s,ManifestServiceSchema as m,ManifestPatternSchema as S,ManifestEcrSchema as
|
|
1
|
+
import{DockerBuildSchema as r,DockerBuildArgValueSchema as t,DockerBuildSecretRefSchema as c,DockerBuildPartialSchema as i,mergeDockerBuild as s,ManifestServiceSchema as m,ManifestPatternSchema as S,ManifestEcrSchema as o,ManifestLambdaSchema as M,ManifestStackHashSchema as n,ResourceMapEntrySchema as f,FjallManifestSchema as h,FJALL_MANIFEST_FILENAME as l,MANIFEST_SCHEMA_VERSION as E,BUILDKIT_SECRET_ID_PATTERN as D}from"./schemas.js";import{getManifestFilePath as d,readManifestFile as k,writeManifestFile as p,createEmptyManifest as u,readConstructMap as A,parseDockerServicesFromManifest as I,parseLambdaDockerServicesFromManifest as L,parseLambdaDockerEntriesFromManifest as _,parseDockerDeclarationsFromManifest as B}from"./io.js";export{D as BUILDKIT_SECRET_ID_PATTERN,t as DockerBuildArgValueSchema,i as DockerBuildPartialSchema,r as DockerBuildSchema,c as DockerBuildSecretRefSchema,l as FJALL_MANIFEST_FILENAME,h as FjallManifestSchema,E as MANIFEST_SCHEMA_VERSION,o as ManifestEcrSchema,M as ManifestLambdaSchema,S as ManifestPatternSchema,m as ManifestServiceSchema,n as ManifestStackHashSchema,f as ResourceMapEntrySchema,u as createEmptyManifest,d as getManifestFilePath,s as mergeDockerBuild,B as parseDockerDeclarationsFromManifest,I as parseDockerServicesFromManifest,_ as parseLambdaDockerEntriesFromManifest,L as parseLambdaDockerServicesFromManifest,A as readConstructMap,k as readManifestFile,p as writeManifestFile};
|
package/dist/manifest/io.d.ts
CHANGED
|
@@ -75,6 +75,14 @@ export declare function parseDockerServicesFromManifest(cdkOutPath: string): Man
|
|
|
75
75
|
* Returns an empty array if the manifest does not exist, cannot be parsed, or
|
|
76
76
|
* contains no Lambda Docker entries. Lambdas without a `docker` block
|
|
77
77
|
* (bring-your-own-image) are skipped, not an error.
|
|
78
|
+
*
|
|
79
|
+
* Throws deliberately (not a `Result`) on divergent shared-`imageKey` docker
|
|
80
|
+
* configs even though `Result`-returning callers sit above it: the throw is a
|
|
81
|
+
* config error surfaced before any build starts, and both production
|
|
82
|
+
* boundaries convert it — the CLI's `catch` in `runApplicationDeployment`
|
|
83
|
+
* (`cli/src/services/deployment/applicationDeployment.ts`) and the webapp
|
|
84
|
+
* worker's job-level `catch` in `deploymentJobHandler`. Sanctioned per the
|
|
85
|
+
* 2026-07-16 docker-lambda review; do not re-litigate as a Pitfall-4 escape.
|
|
78
86
|
*/
|
|
79
87
|
export declare function parseLambdaDockerServicesFromManifest(cdkOutPath: string): ManifestDockerService[];
|
|
80
88
|
/** A single container-Lambda manifest entry that declared a `docker` block. */
|
|
@@ -94,3 +102,36 @@ export interface ManifestLambdaDockerEntry {
|
|
|
94
102
|
* (`lambda:PublishVersion` takes a function name, not an image key).
|
|
95
103
|
*/
|
|
96
104
|
export declare function parseLambdaDockerEntriesFromManifest(cdkOutPath: string): ManifestLambdaDockerEntry[];
|
|
105
|
+
/**
|
|
106
|
+
* Every Docker build the post-synth manifest declares, across BOTH
|
|
107
|
+
* independent namespaces: ECS service `docker` configs (`manifest.services`)
|
|
108
|
+
* and container-Lambda `docker` blocks (`manifest.lambdas`).
|
|
109
|
+
*/
|
|
110
|
+
export interface ManifestDockerDeclarations {
|
|
111
|
+
readonly ecsServices: ManifestDockerService[];
|
|
112
|
+
readonly lambdaEntries: ManifestLambdaDockerEntry[];
|
|
113
|
+
/**
|
|
114
|
+
* True when either namespace declares at least one build. This is the
|
|
115
|
+
* canonical "does this app need a Docker build?" presence gate — see
|
|
116
|
+
* `parseDockerDeclarationsFromManifest`.
|
|
117
|
+
*/
|
|
118
|
+
readonly declaresBuild: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Aggregate view of every Docker build declared in the manifest. Presence
|
|
122
|
+
* gates ("should a Docker build run for this app?") MUST consume
|
|
123
|
+
* `declaresBuild` from here rather than composing the namespace parsers
|
|
124
|
+
* themselves: the namespaces are independent, and a gate that checks only one
|
|
125
|
+
* silently misses apps whose builds live entirely in the other — detection
|
|
126
|
+
* once checked only `manifest.services`, so a container-Lambda-only app never
|
|
127
|
+
* built and fell back to welcome-image seeding.
|
|
128
|
+
*
|
|
129
|
+
* When adding a new docker-carrying manifest namespace, extend this aggregate
|
|
130
|
+
* (fields + `declaresBuild`) in the same change as the build-group
|
|
131
|
+
* composition in deploy-core's `dockerBuildHelper` — the two must agree on
|
|
132
|
+
* emptiness, or presence and execution drift apart again.
|
|
133
|
+
*
|
|
134
|
+
* Never throws: both underlying parsers return `[]` on a missing or
|
|
135
|
+
* malformed manifest.
|
|
136
|
+
*/
|
|
137
|
+
export declare function parseDockerDeclarationsFromManifest(cdkOutPath: string): ManifestDockerDeclarations;
|
package/dist/manifest/io.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile as g,writeFile as y,unlink as
|
|
1
|
+
import{readFile as g,writeFile as y,unlink as M,rename as h,mkdir as F}from"fs/promises";import{readFileSync as b}from"fs";import{dirname as k,join as c}from"path";import{logger as o}from"../logger.js";import{fileExists as w}from"../fsHelpers.js";import{getErrorMessage as f}from"../errorUtils.js";import{recordToConstructMap as S}from"../constructMap.js";import{FjallManifestSchema as A,FJALL_MANIFEST_FILENAME as u,MANIFEST_SCHEMA_VERSION as x,normaliseDockerBuild as d}from"./schemas.js";function m(t){return c(t,u)}async function E(t){const r=m(t);if(!await w(r))return null;try{const n=await g(r,"utf-8"),e=JSON.parse(n),a=A.safeParse(e);return a.success||o.debug("FjallManifest","Manifest validation failed",{path:r,errors:a.error.issues.map(i=>`${i.path.join(".")}: ${i.message}`)}),a.success?a.data:null}catch(n){return o.debug("FjallManifest","Failed to read manifest file",{path:r,error:f(n)}),null}}async function K(t,r){const n=m(t),e=`${n}.${Date.now()}.tmp`;await F(k(n),{recursive:!0});try{await y(e,JSON.stringify(r,null,2),"utf-8"),await h(e,n)}catch(a){try{await M(e)}catch(i){o.debug("FjallManifest","Temp file cleanup failed (non-fatal)",{path:e,error:f(i)})}throw a}}function P(t){return{version:x,generatedAt:new Date().toISOString(),appName:t,services:[],lambdas:[],stacks:{}}}async function T(t){const r=await E(t);return r?.resourceMap?S(r.resourceMap):new Map}function s(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function l(t,r){const n=c(t,u);let e;try{e=b(n,"utf-8")}catch{o.debug("FjallManifest",`Manifest file not readable \u2014 no ${r} extracted`,{path:n});return}let a;try{a=JSON.parse(e)}catch{o.debug("FjallManifest",`Manifest is not valid JSON \u2014 no ${r} extracted`,{path:n});return}return s(a)?a:void 0}function v(t){const r=l(t,"Docker services");if(r===void 0||!Array.isArray(r.services))return[];const n=[];for(const e of r.services){if(!s(e)||typeof e.name!="string")continue;const a=d(e.docker);a!==void 0&&n.push({name:e.name,docker:a})}return n}function _(t){const r=new Map;for(const{name:n,imageKey:e,docker:a}of p(t)){const i=r.get(e);if(i===void 0){r.set(e,{name:e,docker:a});continue}if(JSON.stringify(i.docker)!==JSON.stringify(a))throw new Error(`Lambda functions sharing image key "${e}" declare different \`docker\` configs \u2014 every Lambda function sharing an \`image\` must build from the identical Dockerfile/context/target/buildArgs (offending function: "${n}").`)}return Array.from(r.values())}function p(t){const r=l(t,"Lambda Docker entries");if(r===void 0||!Array.isArray(r.lambdas))return[];const n=[];for(const e of r.lambdas){if(!s(e)||typeof e.name!="string")continue;const a=d(e.docker);if(a===void 0)continue;const i=typeof e.imageKey=="string"&&e.imageKey.length>0?e.imageKey:e.name;n.push({name:e.name,imageKey:i,docker:a})}return n}function C(t){const r=v(t),n=p(t);return{ecsServices:r,lambdaEntries:n,declaresBuild:r.length>0||n.length>0}}export{P as createEmptyManifest,m as getManifestFilePath,C as parseDockerDeclarationsFromManifest,v as parseDockerServicesFromManifest,p as parseLambdaDockerEntriesFromManifest,_ as parseLambdaDockerServicesFromManifest,T as readConstructMap,E as readManifestFile,K as writeManifestFile};
|
|
@@ -176,6 +176,35 @@ export type DockerBuildPartial = z.infer<typeof DockerBuildPartialSchema>;
|
|
|
176
176
|
* invoke this when they have a service-side `docker` to merge against.
|
|
177
177
|
*/
|
|
178
178
|
export declare function mergeDockerBuild(service: DockerBuild, migrationsOverride: DockerBuildPartial | undefined): DockerBuild;
|
|
179
|
+
/**
|
|
180
|
+
* Normalise a candidate `docker` sub-object: empty-string fields are coerced
|
|
181
|
+
* to undefined at the parser boundary so downstream consumers never have to
|
|
182
|
+
* distinguish `target: ""` from `target: undefined` (AC17).
|
|
183
|
+
*
|
|
184
|
+
* `buildArgs` is carried through verbatim — it is the only channel by which
|
|
185
|
+
* Vite-style `VITE_*` values reach the production client bundle, so dropping it
|
|
186
|
+
* here ships a bundle built with no `--build-arg` flags. A value may be a plain
|
|
187
|
+
* string (the common case) OR the public-but-sensitive object form
|
|
188
|
+
* (`DockerBuildArgValue`); both are validated by the final `DockerBuildSchema`
|
|
189
|
+
* safeParse below (a malformed value makes the whole docker candidate invalid,
|
|
190
|
+
* never throwing — safeParse returns undefined). An empty map is coerced to
|
|
191
|
+
* undefined for parity with the empty-string scalar handling.
|
|
192
|
+
*
|
|
193
|
+
* `buildSecrets` is carried through verbatim too — an empty array is coerced to
|
|
194
|
+
* undefined for parity. Each ref is validated by the final `DockerBuildSchema`
|
|
195
|
+
* safeParse below.
|
|
196
|
+
*/
|
|
197
|
+
export declare function normaliseDockerBuild(value: unknown): DockerBuild | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* Canonical comparator for "identical docker configs". Both deploy-time
|
|
200
|
+
* guards (assertNoCrossEntityBuildKeyDivergence in deploy-core's
|
|
201
|
+
* dockerBuildHelper; parseLambdaDockerServicesFromManifest in ./io.ts) and
|
|
202
|
+
* the synth-time guard (getOrCreateImageTagParameter in
|
|
203
|
+
* @fjall/components-infrastructure) must agree byte-for-byte — the
|
|
204
|
+
* fingerprint routes through normaliseDockerBuild so the empty-value
|
|
205
|
+
* coercions and field order match on every side.
|
|
206
|
+
*/
|
|
207
|
+
export declare function dockerBuildFingerprint(docker: DockerBuild | undefined): string | undefined;
|
|
179
208
|
declare const ManifestServiceSchema: z.ZodObject<{
|
|
180
209
|
name: z.ZodString;
|
|
181
210
|
clusterName: z.ZodOptional<z.ZodString>;
|
package/dist/manifest/schemas.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";import{PATTERN_TYPE_VALUES as
|
|
1
|
+
import{z as e}from"zod";import{PATTERN_TYPE_VALUES as b}from"../patterns/patternTypes.js";const E="fjall-manifest.json",y=1,S=/^[A-Za-z0-9_.-]+$/,h=e.object({id:e.string().min(1,"buildSecret id cannot be empty").regex(S,"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)"})}),x=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)"})})]),a=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(),x).optional(),buildSecrets:e.array(h).optional()}).strict(),k=a.partial();function N(t,n){if(n===void 0)return t;const s=n.context??t.context,r=n.target??t.target,o=n.buildArgs??t.buildArgs,i=n.buildSecrets??t.buildSecrets;return{path:n.path??t.path,...s!==void 0&&{context:s},...r!==void 0&&{target:r},...o!==void 0&&{buildArgs:o},...i!==void 0&&{buildSecrets:i}}}function d(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function A(t){if(!d(t)||typeof t.path!="string"||t.path.length===0)return;const n=typeof t.context=="string"&&t.context.length>0?t.context:void 0,s=typeof t.target=="string"&&t.target.length>0?t.target:void 0,r=d(t.buildArgs)&&Object.keys(t.buildArgs).length>0?t.buildArgs:void 0,o=Array.isArray(t.buildSecrets)&&t.buildSecrets.length>0?t.buildSecrets:void 0,i={path:t.path,...n!==void 0&&{context:n},...s!==void 0&&{target:s},...r!==void 0&&{buildArgs:r},...o!==void 0&&{buildSecrets:o}},c=a.safeParse(i);return c.success?c.data:void 0}function T(t){if(t===void 0)return;const n=A(t);return n===void 0?void 0:JSON.stringify(n)}const m=e.object({name:e.string(),clusterName:e.string().optional(),docker:a.optional(),containerPort:e.number().optional(),secrets:e.array(e.string()).optional(),ssmSecretsPath:e.string().optional(),importedSecretNames:e.array(e.string()).optional()}).strict(),p=e.object({type:e.enum(b),name:e.string(),source:e.string()}).strict(),g=e.object({repositoryName:e.string()}).strict(),l=e.object({name:e.string(),secrets:e.array(e.string()).optional(),ssmSecretsPath:e.string().optional(),importedSecretNames:e.array(e.string()).optional(),docker:a.optional(),imageKey:e.string().optional()}).strict(),u=e.object({templateHash:e.string(),synthTimestamp:e.string()}).strict(),f=e.object({constructPath:e.string().max(512),group:e.string().max(128),resourceType:e.string().max(256)}).strict(),I=e.object({version:e.literal(y),generatedAt:e.string(),appName:e.string(),services:e.array(m),lambdas:e.array(l),pattern:p.optional(),ecr:g.optional(),stacks:e.record(e.string(),u),resourceMap:e.record(e.string(),f).optional()}).strict();export{S as BUILDKIT_SECRET_ID_PATTERN,x as DockerBuildArgValueSchema,k as DockerBuildPartialSchema,a as DockerBuildSchema,h as DockerBuildSecretRefSchema,E as FJALL_MANIFEST_FILENAME,I as FjallManifestSchema,y as MANIFEST_SCHEMA_VERSION,g as ManifestEcrSchema,l as ManifestLambdaSchema,p as ManifestPatternSchema,m as ManifestServiceSchema,u as ManifestStackHashSchema,f as ResourceMapEntrySchema,T as dockerBuildFingerprint,N as mergeDockerBuild,A as normaliseDockerBuild};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjall/util",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.31.1",
|
|
4
4
|
"description": "Common utility methods",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -134,5 +134,5 @@
|
|
|
134
134
|
"engines": {
|
|
135
135
|
"node": ">=22.0.0"
|
|
136
136
|
},
|
|
137
|
-
"gitHead": "
|
|
137
|
+
"gitHead": "a48cfaf6e050ce1736837802dfcaf517ba39f199"
|
|
138
138
|
}
|