@fjall/util 0.88.3 → 0.89.2
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/LICENSE +21 -0
- package/dist/src/Config.d.ts +68 -147
- package/dist/src/Config.js +157 -350
- package/dist/src/caseConversion.d.ts +33 -0
- package/dist/src/caseConversion.js +59 -0
- package/dist/src/domainExports.d.ts +19 -0
- package/dist/src/domainExports.js +18 -0
- package/dist/src/errorUtils.d.ts +24 -0
- package/dist/src/errorUtils.js +69 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +18 -2
- package/package.json +4 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fjall
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/src/Config.d.ts
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
export type { Account } from "@aws-sdk/client-organizations";
|
|
3
|
-
export type ServiceConfig = {
|
|
4
|
-
id: string;
|
|
5
|
-
type?: string;
|
|
6
|
-
version?: number;
|
|
7
|
-
options?: object;
|
|
8
|
-
dockerConfig?: {
|
|
9
|
-
dockerfilePath: string;
|
|
10
|
-
containerPort: number;
|
|
11
|
-
};
|
|
12
|
-
apiApplicationId?: string;
|
|
13
|
-
};
|
|
1
|
+
import { z } from "zod";
|
|
14
2
|
export type ProviderAccount = {
|
|
15
3
|
id: string;
|
|
16
4
|
name: string;
|
|
17
5
|
environment: string;
|
|
18
6
|
managed?: boolean;
|
|
19
7
|
};
|
|
20
|
-
export type OidcConnection = {
|
|
21
|
-
roleArn: string;
|
|
22
|
-
externalId: string;
|
|
23
|
-
};
|
|
24
8
|
export type Profile = {
|
|
25
|
-
type: "
|
|
9
|
+
type: "sso" | "oidc";
|
|
26
10
|
region: string;
|
|
27
11
|
ssoAccountId?: string;
|
|
28
12
|
ssoRoleName?: string;
|
|
29
13
|
ssoSession?: string;
|
|
30
14
|
oidcRoleArn?: string;
|
|
31
15
|
oidcProviderArn?: string;
|
|
32
|
-
credentialSource?: string;
|
|
33
16
|
roleArn?: string;
|
|
34
17
|
roleSessionName?: string;
|
|
35
18
|
};
|
|
@@ -37,73 +20,69 @@ export type SSOSession = {
|
|
|
37
20
|
ssoRegion: string;
|
|
38
21
|
ssoStartUrl: string;
|
|
39
22
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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>;
|
|
70
57
|
/**
|
|
71
|
-
* Config class for loading and saving fjall-config.json
|
|
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.
|
|
72
62
|
*/
|
|
73
|
-
export type OrgLevelConfig = {
|
|
74
|
-
primaryRegion?: string;
|
|
75
|
-
secondaryRegions?: string[];
|
|
76
|
-
disasterRecoveryRegion?: string;
|
|
77
|
-
providerAccounts?: ProviderAccount[];
|
|
78
|
-
ssoSessions?: {
|
|
79
|
-
[key: string]: SSOSession;
|
|
80
|
-
};
|
|
81
|
-
rootOidcRoleArn?: string;
|
|
82
|
-
};
|
|
83
63
|
export declare class Config {
|
|
84
64
|
rootConfig: RootConfig;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
constructor(rootConfig?: RootConfig, existingAccountsConfig?: Account[], costAllocationTagsConfig?: CostAllocationTags[]);
|
|
88
|
-
isDevelopment(): boolean;
|
|
65
|
+
private configPath;
|
|
66
|
+
constructor(rootConfig?: RootConfig, configPath?: string);
|
|
89
67
|
/**
|
|
90
|
-
* Find the fjall
|
|
91
|
-
|
|
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.
|
|
92
75
|
*/
|
|
93
76
|
private static findConfigDirectory;
|
|
94
77
|
/**
|
|
95
78
|
* Load config file into memory as a raw JSON string
|
|
96
|
-
* @param configFile - Path to the config file
|
|
97
|
-
* @returns Config as JSON string or NULL if no config file accessible
|
|
98
79
|
*/
|
|
99
80
|
private static loadConfigFile;
|
|
100
81
|
/**
|
|
101
|
-
* Load configuration from file
|
|
102
|
-
*
|
|
103
|
-
* @returns Loaded configuration
|
|
104
|
-
* @throws Error if config file cannot be parsed or fails schema validation
|
|
82
|
+
* Load configuration from file.
|
|
83
|
+
* @param appName - Optional app name to load config for a specific app
|
|
105
84
|
*/
|
|
106
|
-
static loadConfig(): Config;
|
|
85
|
+
static loadConfig(appName?: string): Config;
|
|
107
86
|
/**
|
|
108
87
|
* Format a Zod error into a readable error message
|
|
109
88
|
*/
|
|
@@ -111,83 +90,25 @@ export declare class Config {
|
|
|
111
90
|
/**
|
|
112
91
|
* Save configuration to file
|
|
113
92
|
*/
|
|
114
|
-
saveConfig(): void;
|
|
115
|
-
/**
|
|
116
|
-
* Add a new service to the config file
|
|
117
|
-
* @param serviceKey Name/key of the service
|
|
118
|
-
* @param config Service configuration properties
|
|
119
|
-
*/
|
|
120
|
-
addService(serviceKey: string, config: ServiceConfig): void;
|
|
121
|
-
getServiceConfig(serviceKey: string): ServiceConfig | null;
|
|
122
|
-
addProviderAccount(account: ProviderAccount): void;
|
|
123
|
-
getProviderAccount(accountName: string): ProviderAccount | undefined;
|
|
124
|
-
getProviderAccountById(accountId: string): ProviderAccount | undefined;
|
|
125
|
-
/**
|
|
126
|
-
* Get provider account by environment type
|
|
127
|
-
* @param environment The environment type (e.g., 'platform', 'staging', 'production')
|
|
128
|
-
* @returns The provider account with the specified environment or undefined if not found
|
|
129
|
-
*/
|
|
130
|
-
getAccountByEnvironment(environment: string): ProviderAccount | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Sets the existing accounts list. This should be called by AccountService
|
|
133
|
-
* after it fetches the accounts from AWS.
|
|
134
|
-
* @param accounts List of AWS accounts from Organizations API
|
|
135
|
-
*/
|
|
136
|
-
setExistingAccountsList(accounts: Account[]): void;
|
|
137
|
-
getExistingAccounts(): Account[];
|
|
138
|
-
setPrimaryRegion(region: string): void;
|
|
139
|
-
setSecondaryRegions(regions: string[]): void;
|
|
140
|
-
setDisasterRecoveryRegion(region: string): void;
|
|
141
|
-
getPrimaryRegion(): string | undefined;
|
|
142
|
-
getSecondaryRegions(): string[] | undefined;
|
|
143
|
-
getDisasterRecoveryRegion(): string | undefined;
|
|
144
|
-
getAllRegions(): string[];
|
|
145
|
-
/**
|
|
146
|
-
* Sets the cost allocation tags list. This should be called by AccountService
|
|
147
|
-
* after it fetches the tags from AWS Cost Explorer.
|
|
148
|
-
* @param tags List of cost allocation tags
|
|
149
|
-
*/
|
|
150
|
-
setCostAllocationTagsList(tags: CostAllocationTags[]): void;
|
|
151
|
-
getCostAllocationTags(): CostAllocationTags[];
|
|
93
|
+
saveConfig(appName?: string): void;
|
|
152
94
|
/**
|
|
153
95
|
* Get the fjall config directory path
|
|
154
|
-
* @returns The path to the fjall config directory or null if not found
|
|
155
|
-
*/
|
|
156
|
-
static getConfigDirectory(): string | null;
|
|
157
|
-
/**
|
|
158
|
-
* Profile management methods
|
|
159
|
-
*/
|
|
160
|
-
/**
|
|
161
|
-
* Gets the name of the currently active profile.
|
|
162
|
-
* @returns The current profile name, or undefined if no profile is set
|
|
163
|
-
*/
|
|
164
|
-
getCurrentProfile(): string | undefined;
|
|
165
|
-
/**
|
|
166
|
-
* Sets the currently active profile.
|
|
167
|
-
* @param name The name of the profile to set as current
|
|
168
96
|
*/
|
|
169
|
-
|
|
97
|
+
static getConfigDirectory(appName?: string): string | null;
|
|
170
98
|
/**
|
|
171
|
-
*
|
|
172
|
-
* @param name The name of the profile to retrieve
|
|
173
|
-
* @returns The profile configuration, or undefined if not found
|
|
99
|
+
* Discover all app names by scanning fjall/<app>/fjall-config.json
|
|
174
100
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
setOrganisationEmail(email: string): void;
|
|
188
|
-
getOidcIssuerUrl(): string | undefined;
|
|
189
|
-
setOidcIssuerUrl(url: string): void;
|
|
190
|
-
getOidcConnection(accountId: string): OidcConnection | undefined;
|
|
191
|
-
setOidcConnection(accountId: string, connection: OidcConnection): void;
|
|
192
|
-
setOrgLevelConfig(config: OrgLevelConfig): void;
|
|
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;
|
|
193
113
|
}
|
|
114
|
+
export {};
|