@fjall/util 20.0.0 → 21.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/.build-source-hash +25 -14
  2. package/dist/.minified +1 -1
  3. package/dist/atomicTempNaming.d.ts +26 -0
  4. package/dist/atomicTempNaming.js +1 -0
  5. package/dist/aws/costAllocationTags.d.ts +18 -0
  6. package/dist/aws/costAllocationTags.js +1 -1
  7. package/dist/aws/index.d.ts +1 -1
  8. package/dist/aws/index.js +1 -1
  9. package/dist/config.d.ts +28 -14
  10. package/dist/config.js +2 -2
  11. package/dist/configPaths.d.ts +22 -0
  12. package/dist/configPaths.js +1 -0
  13. package/dist/fjallHome.d.ts +78 -0
  14. package/dist/fjallHome.js +1 -0
  15. package/dist/fsHelpers.d.ts +9 -0
  16. package/dist/fsHelpers.js +1 -1
  17. package/dist/index.d.ts +7 -1
  18. package/dist/index.js +1 -1
  19. package/dist/logRotation.d.ts +42 -0
  20. package/dist/logRotation.js +1 -0
  21. package/dist/migration/clickhouseFrameworkUsers.d.ts +80 -0
  22. package/dist/migration/clickhouseFrameworkUsers.js +1 -0
  23. package/dist/migration/clickhouseFrameworkUsers.test.d.ts +1 -0
  24. package/dist/migration/clickhouseFrameworkUsers.test.js +1 -0
  25. package/dist/migration/constants.d.ts +29 -7
  26. package/dist/migration/constants.js +1 -1
  27. package/dist/migration/controlPlaneActivity.d.ts +58 -0
  28. package/dist/migration/controlPlaneActivity.js +2 -0
  29. package/dist/migration/index.d.ts +5 -1
  30. package/dist/migration/index.js +1 -1
  31. package/dist/migration/schemaGateExit.d.ts +63 -0
  32. package/dist/migration/schemaGateExit.js +1 -0
  33. package/dist/migration/sleepAbortable.d.ts +10 -0
  34. package/dist/migration/sleepAbortable.js +1 -0
  35. package/dist/patterns/frameworkPatterns.d.ts +151 -0
  36. package/dist/patterns/frameworkPatterns.js +1 -0
  37. package/dist/patterns/index.d.ts +2 -1
  38. package/dist/patterns/index.js +1 -1
  39. package/dist/patterns/patternTypes.d.ts +29 -0
  40. package/dist/patterns/patternTypes.js +1 -1
  41. package/dist/scaffold/ensureGitignore.d.ts +18 -0
  42. package/dist/scaffold/ensureGitignore.js +9 -0
  43. package/dist/scaffold/gitignore.d.ts +47 -0
  44. package/dist/scaffold/gitignore.js +35 -0
  45. package/dist/securityHelpers.d.ts +1 -1
  46. package/dist/securityHelpers.js +1 -1
  47. package/package.json +9 -1
@@ -0,0 +1,47 @@
1
+ export declare const FJALL_STATE_GITIGNORE_ENTRIES: readonly [".fjall-state*.json", ".deploy-state.json", ...string[]];
2
+ /**
3
+ * Path of the per-checkout local-state file, relative to the project anchor
4
+ * directory, in `.gitignore` spelling. Derived from the constants that define
5
+ * the real write path (`Config.writeLocalConfig`) so the ignore rule cannot
6
+ * drift away from the file it is meant to cover.
7
+ */
8
+ export declare const LOCAL_CONFIG_GITIGNORE_ENTRY = "/.fjall/local.json";
9
+ /**
10
+ * Fjall-managed state DIRECTORIES under `.fjall/` — drift baselines, codemod
11
+ * history, and reserved operator logs. Anchored with a leading slash, so each
12
+ * entry only covers the directory holding the `.gitignore` that carries it.
13
+ */
14
+ export declare const FJALL_MANAGED_STATE_DIR_ENTRIES: readonly ["/.fjall/history/", "/.fjall/baseline/", "/.fjall/logs/"];
15
+ /**
16
+ * `.gitignore` for a scaffolded COMPONENT directory (`fjall/<component>/`):
17
+ * compiled output, CDK synth artefacts, per-machine deploy state, and codemod
18
+ * backups.
19
+ *
20
+ * Deliberately does NOT ignore `fjall-config.json`. Earlier copies of this
21
+ * content did, which is a data-loss hazard rather than a tidiness win: the file
22
+ * is committed project state, and its `capacityIdentity` block is load-bearing
23
+ * deployed state — losing it renames (replaces) every stateful resource in its
24
+ * slot on the next deploy. The entry was harmless only by accident, because it
25
+ * sat in component directories where no `fjall-config.json` exists AND because
26
+ * the packaging defects above meant it never reached a customer machine.
27
+ */
28
+ export declare const FJALL_COMPONENT_GITIGNORE: string;
29
+ /**
30
+ * `.gitignore` for the PROJECT ANCHOR directory — the directory holding
31
+ * `fjall-config.json`, which is where `.fjall/` managed state is written.
32
+ *
33
+ * This is a separate policy from {@link FJALL_COMPONENT_GITIGNORE} because the
34
+ * two cover different directories. A component `.gitignore` at
35
+ * `fjall/<component>/` cannot reach `fjall/.fjall/local.json` one level up, so
36
+ * the local-state entries only do anything when written at the anchor.
37
+ */
38
+ /** Attribution marker for entries appended to a pre-existing `.gitignore`. */
39
+ export declare const LOCAL_STATE_GITIGNORE_MARKER = "# fjall: managed local state (added by the fjall CLI)";
40
+ /**
41
+ * Explanatory preamble written when Fjall CREATES the anchor `.gitignore`.
42
+ * Not appended to an existing file — only the missing entries are, under
43
+ * {@link LOCAL_STATE_GITIGNORE_MARKER}.
44
+ */
45
+ export declare const FJALL_PROJECT_GITIGNORE_HEADER = "# Fjall-managed local state.\n#\n# `fjall-config.json` beside this file is deliberately NOT ignored: it is\n# committed project state, and its `capacityIdentity` block is load-bearing\n# deployed state \u2014 losing it renames (replaces) every stateful resource in its\n# slot on the next deploy.\n\n# Per-checkout active deploy target. Never committed: a committed value\n# silently re-aims a teammate's deploy or a CI pipeline at the wrong target.\n";
46
+ /** Full anchor-directory `.gitignore` (header plus every managed entry). */
47
+ export declare const FJALL_PROJECT_GITIGNORE: string;
@@ -0,0 +1,35 @@
1
+ import{LOCAL_CONFIG_DIRNAME as e,LOCAL_CONFIG_FILENAME as s,ROOT_CONFIG_FILENAME as l}from"../configPaths.js";import{ATOMIC_TMP_SUFFIX as r,atomicTmpGlob as i}from"../atomicTempNaming.js";const t=[".fjall-state*.json",".deploy-state.json"],n=[...t,...t.map(i),...t.map(a=>`${a}${r}`)],c=`/${e}/${s}`,o=[`/${e}/history/`,`/${e}/baseline/`,`/${e}/logs/`],m=`*.js
2
+ *.d.ts
3
+ node_modules
4
+ .cdk.staging
5
+ **/**/cdk.out
6
+
7
+ .DS_Store
8
+
9
+ # Fjall-managed state directories. Kept here as well as at the project anchor
10
+ # because codemod runs resolve them against the working directory.
11
+ ${o.join(`
12
+ `)}
13
+
14
+ # Fjall per-target deploy state \u2014 a per-machine cache, never a deploy oracle.
15
+ ${n.join(`
16
+ `)}
17
+
18
+ # Fjall backup files (sibling \`.bak\` from codemod mutations + domain eject)
19
+ **/backup/
20
+ *.bak
21
+ `,E="# fjall: managed local state (added by the fjall CLI)",d=`# Fjall-managed local state.
22
+ #
23
+ # \`${l}\` beside this file is deliberately NOT ignored: it is
24
+ # committed project state, and its \`capacityIdentity\` block is load-bearing
25
+ # deployed state \u2014 losing it renames (replaces) every stateful resource in its
26
+ # slot on the next deploy.
27
+
28
+ # Per-checkout active deploy target. Never committed: a committed value
29
+ # silently re-aims a teammate's deploy or a CI pipeline at the wrong target.
30
+ `,I=`${d}${c}
31
+
32
+ # Drift baselines, codemod history, and operator logs.
33
+ ${o.join(`
34
+ `)}
35
+ `;export{m as FJALL_COMPONENT_GITIGNORE,o as FJALL_MANAGED_STATE_DIR_ENTRIES,I as FJALL_PROJECT_GITIGNORE,d as FJALL_PROJECT_GITIGNORE_HEADER,n as FJALL_STATE_GITIGNORE_ENTRIES,c as LOCAL_CONFIG_GITIGNORE_ENTRY,E as LOCAL_STATE_GITIGNORE_MARKER};
@@ -50,7 +50,7 @@ export declare const REDACTED_KEY_SENTINEL = "[REDACTED]";
50
50
  * GitHub tokens (ghu_/ghs_/ghp_/gho_/github_pat_), bare AWS access-key IDs
51
51
  * (AKIA-prefixed and ASIA-prefixed), AWS secret keys (env, INI, and JSON key
52
52
  * spellings), session tokens, agent tokens (`fjall_ak_` scoped, `fjall_dk_`
53
- * deploy).
53
+ * deploy), legacy personal API keys (`fj_<8 hex>_<48 hex>`).
54
54
  *
55
55
  * Single source of truth — consumer loggers (CLI, worker, webapp) MUST
56
56
  * NOT re-implement these patterns inline. See
@@ -1 +1 @@
1
- var g=Object.defineProperty;var A=(_,t)=>g(_,"name",{value:t,configurable:!0});const R=new Set(["NODE_OPTIONS","NODE_PATH","NODE_EXTRA_CA_CERTS","NODE_DEBUG","NODE_PRESERVE_SYMLINKS","LD_PRELOAD","LD_LIBRARY_PATH","LD_AUDIT","LD_BIND_NOW","DYLD_INSERT_LIBRARIES","DYLD_LIBRARY_PATH","DYLD_FRAMEWORK_PATH","PYTHONPATH","PYTHONSTARTUP","PERL5LIB","PERL5OPT","RUBYLIB","RUBYOPT","HOME","XDG_CONFIG_HOME","AWS_SHARED_CREDENTIALS_FILE","AWS_CONFIG_FILE","SHELL","BASH_ENV","ENV","ZDOTDIR"]);function T(_){return Object.fromEntries(Object.entries(_).filter(([t])=>!R.has(t.toUpperCase())))}A(T,"filterDangerousEnvVars");const u=/fjall_(?:ak|dk)_[A-Z2-7]{16}\.[A-Z2-7]{40}/,S=/(fjall_(?:ak|dk)_)[A-Z2-7]{16}\.[A-Z2-7]{40}/g,s="***",i="[REDACTED]",o=`-----BEGIN ${i} PRIVATE KEY-----...-----END ${i} PRIVATE KEY-----`,l=String.raw`(?:next|continuation|pagination|page|forward|backward)+token`,p=String.raw`(?!ghu_|ghs_|ghp_|gho_|github_pat_|(?:sk|rk)_(?:live|test)_|whsec_|fjall_(?:ak|dk)_|AKIA|ASIA|%[a-zA-Z])`,D=new RegExp(String.raw`(?<!"${l}":\s*")`+String.raw`(?<="[a-zA-Z0-9_-]*(?:password|passwd|secret|api[_-]?key|token|auth|credential)":\s*")`+p+String.raw`[^"]+`,"gi"),I=new RegExp(String.raw`(?<!${l}\s*[=:]\s*["']?)`+String.raw`(?<=(?<!/)(?:password|passwd|secret|api[_-]?key|token|auth|credential)\s*[=:]\s*["']?)`+p+String.raw`[^\s"']+`,"gi");function w(_){return _.replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[^"\\]|\\[\\nrt"])*?-----END [A-Z ]*PRIVATE KEY-----/g,()=>o).replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,()=>o).replace(/(\w+:\/\/[^:]+:)[^@]+(@)/gi,(t,e,a)=>`${e}${s}${a}`).replace(/(?<![a-zA-Z])(password|passwd|secret|api[_-]?key|token|auth|credential)([=:])["']?[^\s"']+/gi,(t,e,a)=>`${e}${a}${s}`).replace(D,s).replace(I,s).replace(/\b(ghu_|ghs_|ghp_|gho_|github_pat_)[A-Za-z0-9_]+/g,(t,e)=>`${e}${s}`).replace(/\b(sk|rk)_(live|test)_[A-Za-z0-9]{8,}/g,(t,e,a)=>`${e}_${a}_${s}`).replace(/\bwhsec_[A-Za-z0-9]{8,}/g,()=>`whsec_${s}`).replace(/(?<=Authorization:\s*Bearer\s+)[A-Za-z0-9._~+/=-]+/gi,s).replace(/\b(AKIA|ASIA)[A-Z0-9]{12,}\b/g,(t,e)=>`${e}${s}`).replace(/(?<=aws_secret_access_key\s*=\s*["']?|SecretAccessKey[=:]\s*|"(aws)?secretAccessKey":\s*"|"aws_secret_access_key":\s*")[A-Za-z0-9/+=]{40,}/gi,s).replace(/(?<="(aws)?sessionToken":\s*"|"aws_session_token":\s*")[^"]+/gi,s).replace(/(?<=aws_session_token\s*[=:]\s*["']?|SessionToken[=:]\s*["']?)[^\s"']+/gi,s).replace(/(?<="(internal[Aa]piKey|fjallCallbackToken)":\s*")[^"]+/g,s).replace(S,(t,e)=>`${e}${s}`)}A(w,"maskSensitiveOutput");function h(_){const t=[];let e="",a=!1,E=!1,c=!1,n=!1;for(const r of _){if(c){e+=r,c=!1;continue}if(r==="\\"&&!a){c=!0;continue}if(r==="'"&&!E){a=!a,n=!0;continue}if(r==='"'&&!a){E=!E,n=!0;continue}if(r===" "&&!a&&!E){(e||n)&&(t.push(e),e="",n=!1);continue}e+=r}if(a||E)throw new Error(`Unbalanced ${a?"single":"double"} quote in command: ${_.slice(0,80)}`);if(c)throw new Error(`Trailing backslash in command: ${_.slice(0,80)}`);return(e||n)&&t.push(e),t}A(h,"parseShellArgs");export{R as DANGEROUS_ENV_VARS,s as MASKED_VALUE_MARKER,i as REDACTED_KEY_SENTINEL,u as SCOPED_TOKEN_REGEX,T as filterDangerousEnvVars,w as maskSensitiveOutput,h as parseShellArgs};
1
+ var g=Object.defineProperty;var A=(t,a)=>g(t,"name",{value:a,configurable:!0});const R=new Set(["NODE_OPTIONS","NODE_PATH","NODE_EXTRA_CA_CERTS","NODE_DEBUG","NODE_PRESERVE_SYMLINKS","LD_PRELOAD","LD_LIBRARY_PATH","LD_AUDIT","LD_BIND_NOW","DYLD_INSERT_LIBRARIES","DYLD_LIBRARY_PATH","DYLD_FRAMEWORK_PATH","PYTHONPATH","PYTHONSTARTUP","PERL5LIB","PERL5OPT","RUBYLIB","RUBYOPT","HOME","XDG_CONFIG_HOME","AWS_SHARED_CREDENTIALS_FILE","AWS_CONFIG_FILE","SHELL","BASH_ENV","ENV","ZDOTDIR"]);function u(t){return Object.fromEntries(Object.entries(t).filter(([a])=>!R.has(a.toUpperCase())))}A(u,"filterDangerousEnvVars");const L=/fjall_(?:ak|dk)_[A-Z2-7]{16}\.[A-Z2-7]{40}/,S=/(fjall_(?:ak|dk)_)[A-Z2-7]{16}\.[A-Z2-7]{40}/g,D=/\bfj_[0-9a-f]{8}_[0-9a-f]{48}\b/gi,s="***",i="[REDACTED]",o=`-----BEGIN ${i} PRIVATE KEY-----...-----END ${i} PRIVATE KEY-----`,l=String.raw`(?:next|continuation|pagination|page|forward|backward)+token`,p=String.raw`(?!ghu_|ghs_|ghp_|gho_|github_pat_|(?:sk|rk)_(?:live|test)_|whsec_|fjall_(?:ak|dk)_|fj_[0-9a-f]{8}_|AKIA|ASIA|%[a-zA-Z])`,I=new RegExp(String.raw`(?<!"${l}":\s*")`+String.raw`(?<="[a-zA-Z0-9_-]*(?:password|passwd|secret|api[_-]?key|token|auth|credential)":\s*")`+p+String.raw`[^"]+`,"gi"),N=new RegExp(String.raw`(?<!${l}\s*[=:]\s*["']?)`+String.raw`(?<=(?<!/)(?:password|passwd|secret|api[_-]?key|token|auth|credential)\s*[=:]\s*["']?)`+p+String.raw`[^\s"']+`,"gi");function f(t){return t.replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[^"\\]|\\[\\nrt"])*?-----END [A-Z ]*PRIVATE KEY-----/g,()=>o).replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,()=>o).replace(/(\w+:\/\/[^:]+:)[^@]+(@)/gi,(a,e,_)=>`${e}${s}${_}`).replace(/(?<![a-zA-Z])(password|passwd|secret|api[_-]?key|token|auth|credential)([=:])["']?[^\s"']+/gi,(a,e,_)=>`${e}${_}${s}`).replace(I,s).replace(N,s).replace(/\b(ghu_|ghs_|ghp_|gho_|github_pat_)[A-Za-z0-9_]+/g,(a,e)=>`${e}${s}`).replace(/\b(sk|rk)_(live|test)_[A-Za-z0-9]{8,}/g,(a,e,_)=>`${e}_${_}_${s}`).replace(/\bwhsec_[A-Za-z0-9]{8,}/g,()=>`whsec_${s}`).replace(/(?<=Authorization:\s*Bearer\s+)[A-Za-z0-9._~+/=-]+/gi,s).replace(/\b(AKIA|ASIA)[A-Z0-9]{12,}\b/g,(a,e)=>`${e}${s}`).replace(/(?<=aws_secret_access_key\s*=\s*["']?|SecretAccessKey[=:]\s*|"(aws)?secretAccessKey":\s*"|"aws_secret_access_key":\s*")[A-Za-z0-9/+=]{40,}/gi,s).replace(/(?<="(aws)?sessionToken":\s*"|"aws_session_token":\s*")[^"]+/gi,s).replace(/(?<=aws_session_token\s*[=:]\s*["']?|SessionToken[=:]\s*["']?)[^\s"']+/gi,s).replace(/(?<="(internal[Aa]piKey|fjallCallbackToken)":\s*")[^"]+/g,s).replace(S,(a,e)=>`${e}${s}`).replace(D,()=>`fj_${s}`)}A(f,"maskSensitiveOutput");function w(t){const a=[];let e="",_=!1,E=!1,c=!1,n=!1;for(const r of t){if(c){e+=r,c=!1;continue}if(r==="\\"&&!_){c=!0;continue}if(r==="'"&&!E){_=!_,n=!0;continue}if(r==='"'&&!_){E=!E,n=!0;continue}if(r===" "&&!_&&!E){(e||n)&&(a.push(e),e="",n=!1);continue}e+=r}if(_||E)throw new Error(`Unbalanced ${_?"single":"double"} quote in command: ${t.slice(0,80)}`);if(c)throw new Error(`Trailing backslash in command: ${t.slice(0,80)}`);return(e||n)&&a.push(e),a}A(w,"parseShellArgs");export{R as DANGEROUS_ENV_VARS,s as MASKED_VALUE_MARKER,i as REDACTED_KEY_SENTINEL,L as SCOPED_TOKEN_REGEX,u as filterDangerousEnvVars,f as maskSensitiveOutput,w as parseShellArgs};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjall/util",
3
- "version": "20.0.0",
3
+ "version": "21.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/fjall-tech/fjall.git",
@@ -15,6 +15,10 @@
15
15
  "types": "./dist/index.d.ts",
16
16
  "default": "./dist/index.js"
17
17
  },
18
+ "./atomicTempNaming": {
19
+ "types": "./dist/atomicTempNaming.d.ts",
20
+ "default": "./dist/atomicTempNaming.js"
21
+ },
18
22
  "./buildConcurrency": {
19
23
  "types": "./dist/buildConcurrency.d.ts",
20
24
  "default": "./dist/buildConcurrency.js"
@@ -35,6 +39,10 @@
35
39
  "types": "./dist/docker/index.d.ts",
36
40
  "default": "./dist/docker/index.js"
37
41
  },
42
+ "./logRotation": {
43
+ "types": "./dist/logRotation.d.ts",
44
+ "default": "./dist/logRotation.js"
45
+ },
38
46
  "./manifest": {
39
47
  "types": "./dist/manifest/index.d.ts",
40
48
  "default": "./dist/manifest/index.js"