@fjall/util 0.89.5 → 0.94.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 (55) hide show
  1. package/LICENSE +50 -21
  2. package/README.md +22 -0
  3. package/dist/.minified +1 -0
  4. package/dist/Config.d.ts +76 -0
  5. package/dist/Config.js +1 -0
  6. package/dist/aws/CloudFormationFailureAnalyser.d.ts +32 -0
  7. package/dist/aws/CloudFormationFailureAnalyser.js +1 -0
  8. package/dist/aws/cloudformationTypes.d.ts +17 -0
  9. package/dist/aws/cloudformationTypes.js +1 -0
  10. package/dist/aws/errors.d.ts +26 -0
  11. package/dist/aws/errors.js +1 -0
  12. package/dist/aws/index.d.ts +3 -0
  13. package/dist/aws/index.js +1 -0
  14. package/dist/caseConversion.js +1 -0
  15. package/dist/constructMap.d.ts +80 -0
  16. package/dist/constructMap.js +1 -0
  17. package/dist/{src/domainExports.d.ts → domainExports.d.ts} +3 -1
  18. package/dist/domainExports.js +1 -0
  19. package/dist/environments.d.ts +23 -0
  20. package/dist/environments.js +1 -0
  21. package/dist/errorUtils.js +1 -0
  22. package/dist/fsHelpers.d.ts +4 -0
  23. package/dist/fsHelpers.js +1 -0
  24. package/dist/gitRemoteParser.d.ts +8 -0
  25. package/dist/gitRemoteParser.js +1 -0
  26. package/dist/index.d.ts +11 -1
  27. package/dist/index.js +1 -18
  28. package/dist/insights/computePatternFingerprint.d.ts +27 -0
  29. package/dist/insights/computePatternFingerprint.js +1 -0
  30. package/dist/logger.d.ts +32 -0
  31. package/dist/logger.js +2 -0
  32. package/dist/regions.d.ts +8 -0
  33. package/dist/regions.js +1 -0
  34. package/dist/resourceCategorisation.d.ts +28 -0
  35. package/dist/resourceCategorisation.js +1 -0
  36. package/dist/securityHelpers.d.ts +38 -0
  37. package/dist/securityHelpers.js +1 -0
  38. package/dist/singleton.d.ts +2 -0
  39. package/dist/singleton.js +1 -0
  40. package/dist/sleep.d.ts +4 -0
  41. package/dist/sleep.js +1 -0
  42. package/dist/targets.d.ts +57 -0
  43. package/dist/targets.js +1 -0
  44. package/package.json +55 -8
  45. package/dist/src/Config.d.ts +0 -114
  46. package/dist/src/Config.js +0 -276
  47. package/dist/src/caseConversion.js +0 -59
  48. package/dist/src/domainExports.js +0 -18
  49. package/dist/src/errorUtils.js +0 -69
  50. package/dist/src/index.d.ts +0 -5
  51. package/dist/src/index.js +0 -37
  52. package/dist/src/logger.d.ts +0 -12
  53. package/dist/src/logger.js +0 -36
  54. /package/dist/{src/caseConversion.d.ts → caseConversion.d.ts} +0 -0
  55. /package/dist/{src/errorUtils.d.ts → errorUtils.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ const A=["security","network","compute","database","storage","monitoring","dns","identity","bootstrap","events","registry","backup"],o=Object.freeze({"AWS::IAM::Role":"security","AWS::IAM::Policy":"security","AWS::IAM::OIDCProvider":"security","AWS::EC2::SecurityGroup":"security","AWS::KMS::Key":"security","AWS::KMS::Alias":"security","AWS::EC2::VPC":"network","AWS::EC2::Subnet":"network","AWS::EC2::InternetGateway":"network","AWS::EC2::NatGateway":"network","AWS::EC2::RouteTable":"network","AWS::EC2::Route":"network","AWS::EC2::VPCGatewayAttachment":"network","AWS::EC2::SubnetRouteTableAssociation":"network","AWS::EC2::EIP":"network","AWS::ECS::Cluster":"compute","AWS::ECS::Service":"compute","AWS::ECS::TaskDefinition":"compute","AWS::Lambda::Function":"compute","AWS::ElasticLoadBalancingV2::LoadBalancer":"compute","AWS::ElasticLoadBalancingV2::TargetGroup":"compute","AWS::ElasticLoadBalancingV2::Listener":"compute","AWS::ElasticLoadBalancingV2::ListenerRule":"compute","AWS::RDS::DBInstance":"database","AWS::RDS::DBCluster":"database","AWS::SecretsManager::Secret":"database","AWS::S3::Bucket":"storage","AWS::S3::BucketPolicy":"storage","AWS::CloudTrail::Trail":"monitoring","AWS::CloudWatch::Alarm":"monitoring","AWS::Logs::LogGroup":"monitoring","AWS::Events::EventBus":"events","AWS::Events::Rule":"events","AWS::ECR::Repository":"registry","AWS::CodeBuild::Project":"registry","AWS::Route53::RecordSet":"dns","AWS::CertificateManager::Certificate":"dns","AWS::CloudFront::Distribution":"dns","AWS::Backup::BackupVault":"backup","AWS::Backup::BackupPlan":"backup","AWS::Backup::BackupSelection":"backup","AWS::SSO::PermissionSet":"identity","AWS::SSO::Assignment":"identity","AWS::Organizations::Account":"identity","AWS::CDK::Metadata":"compute","AWS::CloudFormation::CustomResource":"compute","AWS::CloudFormation::WaitCondition":"compute","AWS::CloudFormation::WaitConditionHandle":"compute"}),e=new Set;function c(t){if(!t)return"compute";if(t.startsWith("Custom::"))return o[t]??"compute";const a=o[t];return a||e.add(t),a??"compute"}function r(){return new Set(e)}function u(){e.clear()}const S=Object.freeze({"AWS::EC2::NatGateway":120,"AWS::RDS::DBInstance":300,"AWS::RDS::DBCluster":300,"AWS::CloudFront::Distribution":300,"AWS::ECS::Service":180,"AWS::ElasticLoadBalancingV2::LoadBalancer":60,"AWS::EC2::SecurityGroup":10,"AWS::IAM::Role":15,"AWS::IAM::Policy":15,"AWS::IAM::OIDCProvider":10,"AWS::S3::Bucket":10,"AWS::S3::BucketPolicy":5,"AWS::Lambda::Function":30,"AWS::EC2::VPC":15,"AWS::EC2::Subnet":15,"AWS::EC2::InternetGateway":10,"AWS::EC2::RouteTable":5,"AWS::EC2::Route":5,"AWS::EC2::VPCGatewayAttachment":10,"AWS::EC2::SubnetRouteTableAssociation":5,"AWS::EC2::EIP":10,"AWS::ECS::Cluster":15,"AWS::ECS::TaskDefinition":10,"AWS::ElasticLoadBalancingV2::TargetGroup":10,"AWS::ElasticLoadBalancingV2::Listener":10,"AWS::ElasticLoadBalancingV2::ListenerRule":5,"AWS::SecretsManager::Secret":10,"AWS::Logs::LogGroup":5,"AWS::CloudWatch::Alarm":10,"AWS::CloudTrail::Trail":15,"AWS::Events::EventBus":5,"AWS::Events::Rule":5,"AWS::ECR::Repository":10,"AWS::Route53::RecordSet":30,"AWS::CertificateManager::Certificate":60,"AWS::KMS::Key":15,"AWS::KMS::Alias":5,"AWS::Backup::BackupVault":10,"AWS::Backup::BackupPlan":10,"AWS::Backup::BackupSelection":10,"AWS::SSO::PermissionSet":15,"AWS::SSO::Assignment":10,"AWS::Organizations::Account":60}),n=30;function s(t){return S[t]??n}const i=Object.freeze({"AWS::Lambda::Function":"Lambda Function","AWS::IAM::Role":"IAM Role","AWS::IAM::Policy":"IAM Policy","AWS::S3::Bucket":"S3 Bucket","AWS::DynamoDB::Table":"DynamoDB Table","AWS::EC2::Instance":"EC2 Instance","AWS::EC2::SecurityGroup":"Security Group","AWS::EC2::VPC":"VPC","AWS::EC2::Subnet":"Subnet","AWS::EC2::InternetGateway":"Internet Gateway","AWS::EC2::RouteTable":"Route Table","AWS::EC2::Route":"Route","AWS::ECS::Cluster":"ECS Cluster","AWS::ECS::Service":"ECS Service","AWS::ECS::TaskDefinition":"Task Definition","AWS::ElasticLoadBalancingV2::LoadBalancer":"Load Balancer","AWS::ElasticLoadBalancingV2::TargetGroup":"Target Group","AWS::ElasticLoadBalancingV2::Listener":"Listener","AWS::CloudFormation::Stack":"CloudFormation Stack","AWS::CDK::Metadata":"CDK Metadata","Custom::CDKBucketDeployment":"Bucket Deployment","AWS::SSM::Parameter":"SSM Parameter","AWS::CloudWatch::Alarm":"CloudWatch Alarm","AWS::Logs::LogGroup":"Log Group","AWS::ApiGateway::RestApi":"API Gateway","AWS::ApiGateway::Deployment":"API Deployment","AWS::ApiGateway::Stage":"API Stage","AWS::ApiGateway::Method":"API Method","AWS::ApiGateway::Resource":"API Resource","AWS::CloudFront::Distribution":"CloudFront Distribution","AWS::Route53::RecordSet":"Route53 Record","AWS::RDS::DBInstance":"RDS Instance","AWS::RDS::DBCluster":"RDS Cluster","AWS::SQS::Queue":"SQS Queue","AWS::SNS::Topic":"SNS Topic","AWS::Events::Rule":"EventBridge Rule","AWS::StepFunctions::StateMachine":"Step Function","AWS::EC2::NatGateway":"NAT Gateway","AWS::EC2::EIP":"Elastic IP","AWS::EC2::VPCGatewayAttachment":"Gateway Attachment","AWS::EC2::SubnetRouteTableAssociation":"Route Association","AWS::CloudTrail::Trail":"CloudTrail","AWS::IAM::OIDCProvider":"OIDC Provider","AWS::Events::EventBus":"Event Bus","AWS::Backup::BackupVault":"Backup Vault","AWS::Backup::BackupPlan":"Backup Plan","AWS::Backup::BackupSelection":"Backup Selection","AWS::SecretsManager::Secret":"Secret","AWS::KMS::Key":"KMS Key","AWS::KMS::Alias":"KMS Alias","AWS::ECR::Repository":"ECR Repository","AWS::CertificateManager::Certificate":"Certificate","AWS::ElasticLoadBalancingV2::ListenerRule":"Listener Rule","AWS::EC2::IPAM":"IPAM","AWS::EC2::IPAMPool":"IPAM Pool","AWS::EC2::IPAMPoolCidr":"IPAM Pool CIDR","Custom::ram":"RAM","Custom::ipamDelegateAdmin":"IPAM Delegate Admin","Custom::CostAllocationTags":"Cost Allocation Tags","Custom::ActivateOrganisationsAccess":"Activate Organisations Access","Custom::Organizations_TagResource":"Organisations Tag Resource","AWS::CloudFormation::CustomResource":"Custom Resource","AWS::CloudFormation::WaitCondition":"Wait Condition","AWS::CloudFormation::WaitConditionHandle":"Wait Condition Handle","AWS::SSO::PermissionSet":"SSO Permission Set","AWS::SSO::Assignment":"SSO Assignment","AWS::Organizations::Account":"Organisations Account","AWS::S3::BucketPolicy":"S3 Bucket Policy","AWS::CodeBuild::Project":"CodeBuild Project"});function W(t){return i[t]||t.split("::").pop()||t}export{A as RESOURCE_CATEGORIES,c as categoriseResource,u as clearUnmappedResourceTypes,s as getExpectedDuration,W as getFriendlyResourceType,r as getUnmappedResourceTypes};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Security helpers for spawn operations
3
+ *
4
+ * Provides environment variable filtering and credential masking
5
+ * to prevent command injection and credential leakage.
6
+ */
7
+ /**
8
+ * Environment variables that MUST NOT be passed from user input to spawned processes.
9
+ * These can be exploited for:
10
+ * - Code execution hijacking (PATH, NODE_OPTIONS)
11
+ * - Dynamic linker injection (LD_PRELOAD, DYLD_INSERT_LIBRARIES)
12
+ * - Interpreter code injection (PYTHONPATH, RUBYLIB)
13
+ * - Credential/identity hijacking (HOME, AWS_CONFIG_FILE)
14
+ * - Shell injection (BASH_ENV, ENV)
15
+ */
16
+ export declare const DANGEROUS_ENV_VARS: Set<string>;
17
+ /**
18
+ * Filter dangerous environment variables from a record.
19
+ * Returns a new object with only safe environment variables.
20
+ */
21
+ export declare function filterDangerousEnvVars(env: Record<string, string | undefined>): Record<string, string | undefined>;
22
+ /**
23
+ * Matches the FULL scoped agent token: prefix (16 base32) + separator (.) + secret (40 base32).
24
+ * Base32 alphabet: A-Z2-7. The `.` separator MUST be included or the secret leaks unmasked.
25
+ * Single source of truth — all masking call sites import this.
26
+ */
27
+ export declare const SCOPED_TOKEN_REGEX: RegExp;
28
+ /**
29
+ * Mask sensitive information in output strings to prevent credential leakage.
30
+ * Patterns: postgres://user:pass@host, password=xxx, secret=xxx, apikey=xxx
31
+ */
32
+ export declare function maskSensitiveOutput(output: string): string;
33
+ /**
34
+ * Parse a shell command string into an array of arguments.
35
+ * Handles single quotes, double quotes, and escaped characters.
36
+ * Throws on unbalanced quotes to prevent unexpected argument splitting.
37
+ */
38
+ export declare function parseShellArgs(command: string): string[];
@@ -0,0 +1 @@
1
+ const i=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 c(e){return Object.fromEntries(Object.entries(e).filter(([s])=>!i.has(s.toUpperCase())))}const o=/fjall_ak_[A-Z2-7]{16}\.[A-Z2-7]{40}/;function l(e){return e.replace(/(\w+:\/\/[^:]+:)[^@]+(@)/gi,"$1***$2").replace(/(?<![a-zA-Z])(password|passwd|secret|api[_-]?key|token|auth|credential)([=:])["']?[^\s"']+/gi,"$1$2***").replace(/\b(ghu_|ghs_|ghp_|github_pat_)[A-Za-z0-9_]+/g,"***").replace(/(?<=Authorization:\s*Bearer\s+)[A-Za-z0-9._~+/=-]+/gi,"***").replace(/(?<=AWS_SECRET_ACCESS_KEY=|SecretAccessKey[=:]\s*|"secretAccessKey":\s*")[A-Za-z0-9/+=]{40,}/g,"***").replace(new RegExp(o.source,"g"),"fjall_ak_***")}function A(e){const s=[];let t="",r=!1,n=!1,E=!1,a=!1;for(const _ of e){if(E){t+=_,E=!1;continue}if(_==="\\"&&!r){E=!0;continue}if(_==="'"&&!n){r=!r,a=!0;continue}if(_==='"'&&!r){n=!n,a=!0;continue}if(_===" "&&!r&&!n){(t||a)&&(s.push(t),t="",a=!1);continue}t+=_}if(r||n)throw new Error(`Unbalanced ${r?"single":"double"} quote in command: ${e.slice(0,80)}`);if(E)throw new Error(`Trailing backslash in command: ${e.slice(0,80)}`);return(t||a)&&s.push(t),s}export{i as DANGEROUS_ENV_VARS,o as SCOPED_TOKEN_REGEX,c as filterDangerousEnvVars,l as maskSensitiveOutput,A as parseShellArgs};
@@ -0,0 +1,2 @@
1
+ /** Lazily creates one instance per factory — shared singleton helper. */
2
+ export declare function singleton<T>(factory: () => T): () => T;
@@ -0,0 +1 @@
1
+ function r(t){let e,n=!1;return()=>(n||(e=t(),n=!0),e)}export{r as singleton};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Delay execution for the given number of milliseconds.
3
+ */
4
+ export declare const sleep: (ms: number) => Promise<void>;
package/dist/sleep.js ADDED
@@ -0,0 +1 @@
1
+ const s=e=>new Promise(o=>setTimeout(o,e));export{s as sleep};
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Target derivation — shared across CLI, webapp, and deploy-core.
3
+ *
4
+ * A "target" is a deployment destination: an account + region combination
5
+ * with a canonical name derived from org config at runtime.
6
+ */
7
+ /** Structural interface for the region fields on OrgConfig. */
8
+ export interface OrgConfigRegions {
9
+ primaryRegion?: string;
10
+ secondaryRegions?: string[];
11
+ disasterRecoveryRegion?: string;
12
+ }
13
+ /**
14
+ * Collect all configured regions from an org config into a flat array.
15
+ * Includes primary, secondary, and disaster recovery regions.
16
+ */
17
+ export declare function deriveRegionsFromOrgConfig(config: OrgConfigRegions): string[];
18
+ export interface TargetAccount {
19
+ name: string;
20
+ id: string;
21
+ environment: string;
22
+ }
23
+ export interface DerivedTarget {
24
+ name: string;
25
+ accountName: string;
26
+ accountId: string;
27
+ environment: string;
28
+ region: string;
29
+ }
30
+ /**
31
+ * Generate a canonical target name from account name and region.
32
+ * e.g. ("Production-US", "us-east-1") → "production-us-use1"
33
+ */
34
+ export declare function generateTargetName(accountName: string, region: string): string;
35
+ /**
36
+ * Derive all deployment targets from org config accounts and regions.
37
+ * Excludes root accounts (organisation management accounts).
38
+ * Sorted by environment, then account name, then region.
39
+ */
40
+ export declare function deriveTargets(accounts: TargetAccount[], regions: string[]): DerivedTarget[];
41
+ /**
42
+ * Derive all deployment targets from an org config object.
43
+ * Convenience wrapper combining deriveRegionsFromOrgConfig + deriveTargets.
44
+ */
45
+ export declare function deriveAllTargets(orgConfig: OrgConfigRegions & {
46
+ providerAccounts: TargetAccount[];
47
+ }): DerivedTarget[];
48
+ /**
49
+ * Merge secondaryRegions from the local config file into an API-sourced OrgConfig.
50
+ * Local config is the source of truth for secondaryRegions; the API provides
51
+ * primaryRegion and disasterRecoveryRegion. Deduplicates to avoid overlap.
52
+ */
53
+ export declare function mergeSecondaryRegions<T extends OrgConfigRegions>(orgConfig: T, localSecondaryRegions: string[]): T;
54
+ /**
55
+ * Find a target by its canonical name.
56
+ */
57
+ export declare function findTarget(targets: DerivedTarget[], targetName: string): DerivedTarget | undefined;
@@ -0,0 +1 @@
1
+ import{abbreviateRegion as c}from"./regions.js";function s(e){const r=[e.primaryRegion,...e.secondaryRegions??[],e.disasterRecoveryRegion].filter(t=>t!==void 0);return[...new Set(r)]}function m(e,r){return`${e.toLowerCase()}-${c(r)}`}function u(e,r){const t=[];for(const n of e)if(n.environment!=="root")for(const o of r)t.push({name:m(n.name,o),accountName:n.name,accountId:n.id,environment:n.environment,region:o});return t.sort((n,o)=>{const i=n.environment.localeCompare(o.environment);if(i!==0)return i;const a=n.accountName.localeCompare(o.accountName);return a!==0?a:n.region.localeCompare(o.region)})}function f(e){return u(e.providerAccounts,s(e))}function p(e,r){if(r.length===0)return e;const t=new Set([e.primaryRegion,e.disasterRecoveryRegion].filter(Boolean)),n=r.filter(o=>!t.has(o));return{...e,secondaryRegions:n.length>0?n:void 0}}function g(e,r){return e.find(t=>t.name===r)}export{f as deriveAllTargets,s as deriveRegionsFromOrgConfig,u as deriveTargets,g as findTarget,m as generateTargetName,p as mergeSecondaryRegions};
package/package.json CHANGED
@@ -1,27 +1,74 @@
1
1
  {
2
2
  "name": "@fjall/util",
3
- "version": "0.89.5",
3
+ "version": "0.94.0",
4
4
  "description": "Common utility methods",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./config": {
14
+ "types": "./dist/Config.d.ts",
15
+ "default": "./dist/Config.js"
16
+ },
17
+ "./constructMap": {
18
+ "types": "./dist/constructMap.d.ts",
19
+ "default": "./dist/constructMap.js"
20
+ },
21
+ "./environments": {
22
+ "types": "./dist/environments.d.ts",
23
+ "default": "./dist/environments.js"
24
+ },
25
+ "./fsHelpers": {
26
+ "types": "./dist/fsHelpers.d.ts",
27
+ "default": "./dist/fsHelpers.js"
28
+ },
29
+ "./targets": {
30
+ "types": "./dist/targets.d.ts",
31
+ "default": "./dist/targets.js"
32
+ },
33
+ "./resourceCategorisation": {
34
+ "types": "./dist/resourceCategorisation.d.ts",
35
+ "default": "./dist/resourceCategorisation.js"
36
+ },
37
+ "./logger": {
38
+ "types": "./dist/logger.d.ts",
39
+ "default": "./dist/logger.js"
40
+ },
41
+ "./aws": {
42
+ "types": "./dist/aws/index.d.ts",
43
+ "default": "./dist/aws/index.js"
44
+ },
45
+ "./insights/computePatternFingerprint": {
46
+ "types": "./dist/insights/computePatternFingerprint.d.ts",
47
+ "default": "./dist/insights/computePatternFingerprint.js"
48
+ }
49
+ },
7
50
  "files": [
8
51
  "dist/"
9
52
  ],
10
53
  "scripts": {
11
- "clean": "rm -rf ./dist",
54
+ "clean": "rm -rf ./dist ./sourcemaps",
12
55
  "clean:node": "rm -rf ./node_modules",
13
- "build": "npm run clean && npx tsc",
56
+ "build": "npm run clean && npx tsc && node ../scripts/minify-dist.mjs dist",
14
57
  "watch": "npm run build && npx tsc-watch",
58
+ "watch:only": "npx tsc-watch",
15
59
  "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json}\"",
16
- "format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json}\""
60
+ "format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json}\"",
61
+ "test": "vitest run",
62
+ "typecheck": "npx tsc --noEmit"
17
63
  },
18
64
  "author": "",
19
- "license": "MIT",
65
+ "license": "SEE LICENSE IN LICENSE",
20
66
  "devDependencies": {
21
67
  "@types/node": "^22.13.10",
22
68
  "prettier": "^3.2.5",
23
69
  "tsc-watch": "^7.0.0",
24
- "typescript": "^5.8.2"
70
+ "typescript": "^5.8.2",
71
+ "vitest": "^4.1.0"
25
72
  },
26
73
  "dependencies": {
27
74
  "@aws-sdk/client-organizations": "^3.997.0",
@@ -31,7 +78,7 @@
31
78
  "@smithy/core": "2.5.5"
32
79
  },
33
80
  "engines": {
34
- "node": ">=18.0.0"
81
+ "node": ">=22.0.0"
35
82
  },
36
- "gitHead": "1680c1a0be16950e9e10e571163ccc42198f6a8e"
83
+ "gitHead": "97f6b382405bb3068e841d30866222fd76bc3b15"
37
84
  }
@@ -1,114 +0,0 @@
1
- import { z } from "zod";
2
- export type ProviderAccount = {
3
- id: string;
4
- name: string;
5
- environment: string;
6
- managed?: boolean;
7
- };
8
- export type Profile = {
9
- type: "sso" | "oidc";
10
- region: string;
11
- ssoAccountId?: string;
12
- ssoRoleName?: string;
13
- ssoSession?: string;
14
- oidcRoleArn?: string;
15
- oidcProviderArn?: string;
16
- roleArn?: string;
17
- roleSessionName?: string;
18
- };
19
- export type SSOSession = {
20
- ssoRegion: string;
21
- ssoStartUrl: string;
22
- };
23
- declare const DeployStageSchema: z.ZodObject<{
24
- account: z.ZodString;
25
- regions: z.ZodArray<z.ZodString>;
26
- }, z.core.$strict>;
27
- export type DeployStage = z.infer<typeof DeployStageSchema>;
28
- declare const DomainConfigSchema: z.ZodObject<{
29
- name: z.ZodString;
30
- type: z.ZodEnum<{
31
- apex: "apex";
32
- delegated: "delegated";
33
- }>;
34
- parentDomain: z.ZodOptional<z.ZodString>;
35
- account: z.ZodOptional<z.ZodString>;
36
- }, z.core.$strict>;
37
- export type DomainConfig = z.infer<typeof DomainConfigSchema>;
38
- declare const RootConfigSchema: z.ZodObject<{
39
- version: z.ZodOptional<z.ZodNumber>;
40
- generatorVersion: z.ZodOptional<z.ZodString>;
41
- deploy: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
42
- account: z.ZodString;
43
- regions: z.ZodArray<z.ZodString>;
44
- }, z.core.$strict>>>;
45
- activeStage: z.ZodOptional<z.ZodString>;
46
- domains: z.ZodOptional<z.ZodArray<z.ZodObject<{
47
- name: z.ZodString;
48
- type: z.ZodEnum<{
49
- apex: "apex";
50
- delegated: "delegated";
51
- }>;
52
- parentDomain: z.ZodOptional<z.ZodString>;
53
- account: z.ZodOptional<z.ZodString>;
54
- }, z.core.$strict>>>;
55
- }, z.core.$strict>;
56
- type RootConfig = z.infer<typeof RootConfigSchema>;
57
- /**
58
- * Config class for loading and saving per-app fjall-config.json files.
59
- * Each app has its own config at fjall/<app>/fjall-config.json.
60
- * Stores deploy mapping, active stage, domains, and generator version.
61
- * Org-level config (accounts, regions, OIDC) is served by OrgConfigClient from the API.
62
- */
63
- export declare class Config {
64
- rootConfig: RootConfig;
65
- private configPath;
66
- constructor(rootConfig?: RootConfig, configPath?: string);
67
- /**
68
- * Find the fjall directory by walking up the directory tree
69
- */
70
- private static findFjallDirectory;
71
- /**
72
- * Find the config directory for a specific app or the legacy root config.
73
- * When appName is provided, looks for fjall/<appName>/fjall-config.json.
74
- * When omitted, falls back to legacy fjall/fjall-config.json or direct fjall-config.json.
75
- */
76
- private static findConfigDirectory;
77
- /**
78
- * Load config file into memory as a raw JSON string
79
- */
80
- private static loadConfigFile;
81
- /**
82
- * Load configuration from file.
83
- * @param appName - Optional app name to load config for a specific app
84
- */
85
- static loadConfig(appName?: string): Config;
86
- /**
87
- * Format a Zod error into a readable error message
88
- */
89
- private static formatZodError;
90
- /**
91
- * Save configuration to file
92
- */
93
- saveConfig(appName?: string): void;
94
- /**
95
- * Get the fjall config directory path
96
- */
97
- static getConfigDirectory(appName?: string): string | null;
98
- /**
99
- * Discover all app names by scanning fjall/<app>/fjall-config.json
100
- */
101
- static discoverApps(): string[];
102
- getDeployStages(): Record<string, DeployStage>;
103
- getDeployStage(name: string): DeployStage | undefined;
104
- setDeployStage(name: string, stage: DeployStage): void;
105
- removeDeployStage(name: string): boolean;
106
- getActiveStage(): string | undefined;
107
- setActiveStage(name: string): void;
108
- getDomains(): DomainConfig[];
109
- setDomains(domains: DomainConfig[]): void;
110
- addDomain(domain: DomainConfig): void;
111
- getDomain(name: string): DomainConfig | undefined;
112
- removeDomain(name: string): boolean;
113
- }
114
- export {};