@fjall/generator 0.89.4 → 0.89.6
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 +50 -21
- package/README.md +28 -0
- package/dist/.minified +1 -0
- package/dist/src/ast/astCdnParser.d.ts +5 -0
- package/dist/src/ast/astCdnParser.js +1 -114
- package/dist/src/ast/astCommonParser.d.ts +6 -17
- package/dist/src/ast/astCommonParser.js +1 -351
- package/dist/src/ast/astComputeConnectionParser.d.ts +18 -0
- package/dist/src/ast/astComputeConnectionParser.js +1 -0
- package/dist/src/ast/astComputeParser.d.ts +6 -0
- package/dist/src/ast/astComputeParser.js +1 -473
- package/dist/src/ast/astComputeParserHelpers.d.ts +21 -0
- package/dist/src/ast/astComputeParserHelpers.js +1 -0
- package/dist/src/ast/astDatabaseParser.d.ts +9 -24
- package/dist/src/ast/astDatabaseParser.js +1 -275
- package/dist/src/ast/astDomainParser.d.ts +139 -0
- package/dist/src/ast/astDomainParser.js +1 -0
- package/dist/src/ast/astDynamoDBParser.d.ts +35 -0
- package/dist/src/ast/astDynamoDBParser.js +1 -0
- package/dist/src/ast/astExpressionEvaluator.d.ts +23 -0
- package/dist/src/ast/astExpressionEvaluator.js +1 -0
- package/dist/src/ast/astInfrastructureParser.d.ts +12 -49
- package/dist/src/ast/astInfrastructureParser.js +1 -552
- package/dist/src/ast/astMessagingParser.d.ts +5 -0
- package/dist/src/ast/astMessagingParser.js +1 -78
- package/dist/src/ast/astNetworkParser.d.ts +6 -0
- package/dist/src/ast/astNetworkParser.js +1 -219
- package/dist/src/ast/astPatternParser.d.ts +6 -0
- package/dist/src/ast/astPatternParser.js +1 -155
- package/dist/src/ast/astPlanConverter.d.ts +11 -0
- package/dist/src/ast/astPlanConverter.js +2 -0
- package/dist/src/ast/astStatementClassifier.d.ts +24 -0
- package/dist/src/ast/astStatementClassifier.js +1 -0
- package/dist/src/ast/astStatementQueries.d.ts +21 -0
- package/dist/src/ast/astStatementQueries.js +3 -0
- package/dist/src/ast/astStorageParser.d.ts +5 -0
- package/dist/src/ast/astStorageParser.js +1 -164
- package/dist/src/ast/astSurgicalModification.js +19 -400
- package/dist/src/ast/astTestHelpers.d.ts +635 -0
- package/dist/src/ast/astTestHelpers.js +1 -0
- package/dist/src/ast/index.d.ts +1 -0
- package/dist/src/ast/index.js +1 -6
- package/dist/src/aws/regions.js +1 -254
- package/dist/src/codemod/_internal.d.ts +12 -0
- package/dist/src/codemod/_internal.js +1 -0
- package/dist/src/codemod/edits/addResource/bodyIndex.d.ts +34 -0
- package/dist/src/codemod/edits/addResource/bodyIndex.js +1 -0
- package/dist/src/codemod/edits/addResource/propertyBuilder.d.ts +7 -0
- package/dist/src/codemod/edits/addResource/propertyBuilder.js +1 -0
- package/dist/src/codemod/edits/addResource.d.ts +9 -0
- package/dist/src/codemod/edits/addResource.js +1 -0
- package/dist/src/codemod/edits/ensureImports.d.ts +26 -0
- package/dist/src/codemod/edits/ensureImports.js +1 -0
- package/dist/src/codemod/edits/findInsertionPosition.d.ts +39 -0
- package/dist/src/codemod/edits/findInsertionPosition.js +1 -0
- package/dist/src/codemod/edits/index.d.ts +6 -0
- package/dist/src/codemod/edits/index.js +1 -0
- package/dist/src/codemod/edits/modifyResource/literalConversion.d.ts +37 -0
- package/dist/src/codemod/edits/modifyResource/literalConversion.js +1 -0
- package/dist/src/codemod/edits/modifyResource.d.ts +9 -0
- package/dist/src/codemod/edits/modifyResource.js +1 -0
- package/dist/src/codemod/edits/removeResource/commentHeuristic.d.ts +31 -0
- package/dist/src/codemod/edits/removeResource/commentHeuristic.js +1 -0
- package/dist/src/codemod/edits/removeResource/importPruning.d.ts +8 -0
- package/dist/src/codemod/edits/removeResource/importPruning.js +1 -0
- package/dist/src/codemod/edits/removeResource.d.ts +10 -0
- package/dist/src/codemod/edits/removeResource.js +1 -0
- package/dist/src/codemod/edits/schemaFragments.d.ts +9 -0
- package/dist/src/codemod/edits/schemaFragments.js +1 -0
- package/dist/src/codemod/fileRewriter/builders.d.ts +57 -0
- package/dist/src/codemod/fileRewriter/builders.js +1 -0
- package/dist/src/codemod/fileRewriter/index.d.ts +4 -0
- package/dist/src/codemod/fileRewriter/index.js +1 -0
- package/dist/src/codemod/fileRewriter/locateByRange.d.ts +65 -0
- package/dist/src/codemod/fileRewriter/locateByRange.js +1 -0
- package/dist/src/codemod/fileRewriter/parse.d.ts +18 -0
- package/dist/src/codemod/fileRewriter/parse.js +2 -0
- package/dist/src/codemod/fileRewriter/print.d.ts +46 -0
- package/dist/src/codemod/fileRewriter/print.js +4 -0
- package/dist/src/codemod/historyPaths.d.ts +2 -0
- package/dist/src/codemod/historyPaths.js +1 -0
- package/dist/src/codemod/index.d.ts +7 -0
- package/dist/src/codemod/index.js +1 -0
- package/dist/src/codemod/listResources.d.ts +4 -0
- package/dist/src/codemod/listResources.js +1 -0
- package/dist/src/codemod/semanticIndex/findReferences.d.ts +15 -0
- package/dist/src/codemod/semanticIndex/findReferences.js +2 -0
- package/dist/src/codemod/semanticIndex/index.d.ts +4 -0
- package/dist/src/codemod/semanticIndex/index.js +1 -0
- package/dist/src/codemod/semanticIndex/listImports.d.ts +24 -0
- package/dist/src/codemod/semanticIndex/listImports.js +1 -0
- package/dist/src/codemod/semanticIndex/locateByShape.d.ts +28 -0
- package/dist/src/codemod/semanticIndex/locateByShape.js +1 -0
- package/dist/src/codemod/semanticIndex/projectCache.d.ts +14 -0
- package/dist/src/codemod/semanticIndex/projectCache.js +1 -0
- package/dist/src/codemod/types.d.ts +172 -0
- package/dist/src/codemod/types.js +1 -0
- package/dist/src/dns/bindParser.js +2 -224
- package/dist/src/dns/bindWriter.js +3 -52
- package/dist/src/dns/domainFileGenerator.d.ts +20 -0
- package/dist/src/dns/domainFileGenerator.js +207 -0
- package/dist/src/dns/domainRecords.d.ts +164 -0
- package/dist/src/dns/domainRecords.js +1 -0
- package/dist/src/dns/index.d.ts +2 -1
- package/dist/src/dns/index.js +1 -4
- package/dist/src/dns/types.js +1 -52
- package/dist/src/generation/common.js +6 -161
- package/dist/src/generation/compute.js +82 -590
- package/dist/src/generation/database.js +12 -198
- package/dist/src/generation/generatePatternCode.d.ts +58 -0
- package/dist/src/generation/generatePatternCode.js +33 -0
- package/dist/src/generation/index.js +1 -20
- package/dist/src/generation/infrastructure.d.ts +1 -5
- package/dist/src/generation/infrastructure.js +35 -377
- package/dist/src/generation/messagingConnections.js +1 -73
- package/dist/src/generation/storage.d.ts +0 -15
- package/dist/src/generation/storage.js +35 -168
- package/dist/src/generation/storageConnections.js +1 -75
- package/dist/src/planning/generateResourceChange.d.ts +21 -0
- package/dist/src/planning/generateResourceChange.js +1 -0
- package/dist/src/planning/index.d.ts +3 -0
- package/dist/src/planning/index.js +1 -1
- package/dist/src/planning/resourceAddition.d.ts +154 -0
- package/dist/src/planning/resourceAddition.js +1 -0
- package/dist/src/planning/resourceConnections.d.ts +19 -0
- package/dist/src/planning/resourceConnections.js +1 -0
- package/dist/src/planning/resourcePlanning.js +1 -214
- package/dist/src/presets/index.js +1 -3
- package/dist/src/presets/patternTierPresets.js +1 -131
- package/dist/src/presets/storagePresets.js +1 -36
- package/dist/src/presets/tierPresets.d.ts +5 -8
- package/dist/src/presets/tierPresets.js +1 -384
- package/dist/src/presets/tierTypes.d.ts +1 -1
- package/dist/src/presets/tierTypes.js +0 -7
- package/dist/src/schemas/alarmSchemas.d.ts +19 -0
- package/dist/src/schemas/alarmSchemas.js +1 -0
- package/dist/src/schemas/applicationSchemas.d.ts +22 -6
- package/dist/src/schemas/applicationSchemas.js +1 -80
- package/dist/src/schemas/baseSchemas.d.ts +8 -3
- package/dist/src/schemas/baseSchemas.js +2 -248
- package/dist/src/schemas/cdnSchemas.js +1 -62
- package/dist/src/schemas/computeSchemas.d.ts +25 -3
- package/dist/src/schemas/computeSchemas.js +1 -727
- package/dist/src/schemas/constants.d.ts +5 -7
- package/dist/src/schemas/constants.js +1 -218
- package/dist/src/schemas/databaseSchemas.d.ts +6 -1
- package/dist/src/schemas/databaseSchemas.js +1 -366
- package/dist/src/schemas/index.js +1 -3
- package/dist/src/schemas/instanceTypeArchitecture.js +1 -75
- package/dist/src/schemas/messagingSchemas.js +1 -29
- package/dist/src/schemas/networkSchemas.js +1 -125
- package/dist/src/schemas/patternSchemas.d.ts +1 -1
- package/dist/src/schemas/patternSchemas.js +1 -294
- package/dist/src/schemas/resourceSchemas.d.ts +1 -0
- package/dist/src/schemas/resourceSchemas.js +1 -28
- package/dist/src/schemas/sharedTypes.d.ts +18 -0
- package/dist/src/schemas/sharedTypes.js +1 -0
- package/dist/src/schemas/storageSchemas.d.ts +1 -0
- package/dist/src/schemas/storageSchemas.js +1 -119
- package/dist/src/types/Result.js +1 -31
- package/dist/src/util/errorUtils.js +1 -1
- package/dist/src/validation/patterns.d.ts +9 -0
- package/dist/src/validation/patterns.js +1 -369
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +29 -9
- package/dist/src/dns/infrastructureWriter.d.ts +0 -2
- package/dist/src/dns/infrastructureWriter.js +0 -58
package/dist/src/dns/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./types.js";
|
|
2
|
+
export * from "./domainRecords.js";
|
|
2
3
|
export { parseZoneFile, resolveAlias } from "./bindParser.js";
|
|
3
4
|
export { generateZoneFile } from "./bindWriter.js";
|
|
4
|
-
export {
|
|
5
|
+
export { type GeneratedFile, type DomainGenerationOptions, generateDomainFiles, } from "./domainFileGenerator.js";
|
package/dist/src/dns/index.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { parseZoneFile, resolveAlias } from "./bindParser.js";
|
|
3
|
-
export { generateZoneFile } from "./bindWriter.js";
|
|
4
|
-
export { generateInfrastructureFromZone } from "./infrastructureWriter.js";
|
|
1
|
+
export*from"./types.js";export*from"./domainRecords.js";import{parseZoneFile as m,resolveAlias as p}from"./bindParser.js";import{generateZoneFile as f}from"./bindWriter.js";import{generateDomainFiles as l}from"./domainFileGenerator.js";export{l as generateDomainFiles,f as generateZoneFile,m as parseZoneFile,p as resolveAlias};
|
package/dist/src/dns/types.js
CHANGED
|
@@ -1,52 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { DNS_APEX, getDomainExportNames, } from "@fjall/util";
|
|
3
|
-
export const DnsRecordTypeSchema = z.enum([
|
|
4
|
-
"A",
|
|
5
|
-
"AAAA",
|
|
6
|
-
"CNAME",
|
|
7
|
-
"MX",
|
|
8
|
-
"TXT",
|
|
9
|
-
"NS",
|
|
10
|
-
"SRV",
|
|
11
|
-
"CAA",
|
|
12
|
-
]);
|
|
13
|
-
export const DnsRecordSchema = z
|
|
14
|
-
.object({
|
|
15
|
-
name: z.string(),
|
|
16
|
-
type: DnsRecordTypeSchema,
|
|
17
|
-
ttl: z.number().optional(),
|
|
18
|
-
value: z.string(),
|
|
19
|
-
priority: z.number().optional(),
|
|
20
|
-
weight: z.number().optional(),
|
|
21
|
-
port: z.number().optional(),
|
|
22
|
-
})
|
|
23
|
-
.strict();
|
|
24
|
-
export const DelegationDirectiveSchema = z
|
|
25
|
-
.object({
|
|
26
|
-
subdomain: z.string(),
|
|
27
|
-
targetAccount: z.string(),
|
|
28
|
-
auto: z.boolean(),
|
|
29
|
-
})
|
|
30
|
-
.strict();
|
|
31
|
-
export const CertificateDirectiveSchema = z
|
|
32
|
-
.object({
|
|
33
|
-
domainName: z.string(),
|
|
34
|
-
subjectAlternativeNames: z.array(z.string()),
|
|
35
|
-
})
|
|
36
|
-
.strict();
|
|
37
|
-
export const ParsedZoneFileSchema = z
|
|
38
|
-
.object({
|
|
39
|
-
origin: z.string(),
|
|
40
|
-
ttl: z.number(),
|
|
41
|
-
records: z.array(DnsRecordSchema),
|
|
42
|
-
delegations: z.array(DelegationDirectiveSchema),
|
|
43
|
-
certificates: z.array(CertificateDirectiveSchema),
|
|
44
|
-
})
|
|
45
|
-
.strict();
|
|
46
|
-
export const BIND_DIRECTIVES = Object.freeze({
|
|
47
|
-
ORIGIN: "$ORIGIN",
|
|
48
|
-
TTL: "$TTL",
|
|
49
|
-
FJALL_DELEGATE: "$FJALL-DELEGATE",
|
|
50
|
-
FJALL_CERT: "$FJALL-CERT",
|
|
51
|
-
});
|
|
52
|
-
export const ALIAS_PREFIX = "ALIAS ";
|
|
1
|
+
import{z as t}from"zod";import{DNS_APEX as p,getDomainExportNames as E}from"@fjall/util";const e=t.enum(["A","AAAA","CNAME","MX","TXT","NS","SRV","CAA"]),r=t.object({name:t.string(),type:e,ttl:t.number().optional(),value:t.string(),priority:t.number().optional(),weight:t.number().optional(),port:t.number().optional()}).strict(),o=t.object({subdomain:t.string(),targetAccount:t.string(),auto:t.boolean()}).strict(),n=t.object({domainName:t.string(),subjectAlternativeNames:t.array(t.string())}).strict(),a=t.object({origin:t.string(),ttl:t.number(),records:t.array(r),delegations:t.array(o),certificates:t.array(n)}).strict(),c=Object.freeze({ORIGIN:"$ORIGIN",TTL:"$TTL",FJALL_DELEGATE:"$FJALL-DELEGATE",FJALL_CERT:"$FJALL-CERT"}),s="ALIAS ";export{s as ALIAS_PREFIX,c as BIND_DIRECTIVES,n as CertificateDirectiveSchema,p as DNS_APEX,o as DelegationDirectiveSchema,r as DnsRecordSchema,e as DnsRecordTypeSchema,a as ParsedZoneFileSchema,E as getDomainExportNames};
|
|
@@ -1,161 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { toPascalCase, toKebab, toValidDatabaseName } from "@fjall/util";
|
|
8
|
-
/**
|
|
9
|
-
* Type guard to check if a value is a special code generation value
|
|
10
|
-
*/
|
|
11
|
-
export function isSpecialValue(value) {
|
|
12
|
-
if (typeof value !== "object" || value === null) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
const obj = value;
|
|
16
|
-
return (typeof obj.__identifier === "string" ||
|
|
17
|
-
typeof obj.__expression === "string" ||
|
|
18
|
-
typeof obj.__call === "string");
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Convert resource names to camelCase variable names
|
|
22
|
-
*/
|
|
23
|
-
export function toVariableName(name) {
|
|
24
|
-
return name
|
|
25
|
-
.replace(/[^a-zA-Z0-9]/g, " ")
|
|
26
|
-
.split(" ")
|
|
27
|
-
.map((word, index) => index === 0
|
|
28
|
-
? word.charAt(0).toLowerCase() + word.slice(1)
|
|
29
|
-
: word.charAt(0).toUpperCase() + word.slice(1))
|
|
30
|
-
.join("");
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Get the variable name for a resource, preferring preserved variableName
|
|
34
|
-
* from round-trip parsing over the generated default.
|
|
35
|
-
*/
|
|
36
|
-
export function getVariableName(resource) {
|
|
37
|
-
return resource.variableName ?? toVariableName(resource.name);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Resolve the variable name for a resource by name, looking up across all
|
|
41
|
-
* resource arrays in the plan. Used for cross-resource references (e.g.,
|
|
42
|
-
* compute → database connection variable names).
|
|
43
|
-
*/
|
|
44
|
-
export function resolveResourceVariable(plan, resourceName) {
|
|
45
|
-
for (const db of plan.database) {
|
|
46
|
-
if (db.name === resourceName && db.variableName)
|
|
47
|
-
return db.variableName;
|
|
48
|
-
}
|
|
49
|
-
for (const s3 of plan.s3) {
|
|
50
|
-
if (s3.name === resourceName && s3.variableName)
|
|
51
|
-
return s3.variableName;
|
|
52
|
-
}
|
|
53
|
-
for (const c of plan.compute) {
|
|
54
|
-
if (c.name === resourceName && c.variableName)
|
|
55
|
-
return c.variableName;
|
|
56
|
-
}
|
|
57
|
-
for (const ddb of plan.dynamodb ?? []) {
|
|
58
|
-
if (ddb.name === resourceName && ddb.variableName)
|
|
59
|
-
return ddb.variableName;
|
|
60
|
-
}
|
|
61
|
-
for (const sqs of plan.sqs ?? []) {
|
|
62
|
-
if (sqs.name === resourceName && sqs.variableName)
|
|
63
|
-
return sqs.variableName;
|
|
64
|
-
}
|
|
65
|
-
return toVariableName(resourceName);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Check if an object is simple enough to format inline (single line).
|
|
69
|
-
* Simple = no nested objects/arrays and few primitive values.
|
|
70
|
-
*/
|
|
71
|
-
function isSimpleObject(value) {
|
|
72
|
-
const entries = Object.entries(value);
|
|
73
|
-
if (entries.length === 0)
|
|
74
|
-
return true;
|
|
75
|
-
if (entries.length > 1)
|
|
76
|
-
return false;
|
|
77
|
-
return entries.every(([, v]) => typeof v === "string" ||
|
|
78
|
-
typeof v === "number" ||
|
|
79
|
-
typeof v === "boolean" ||
|
|
80
|
-
v === null);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Format values for code generation, handling complex types.
|
|
84
|
-
* Simple objects (few primitive values) are kept on one line.
|
|
85
|
-
*/
|
|
86
|
-
export function formatValue(value, baseIndent = " ") {
|
|
87
|
-
if (value === undefined || value === null) {
|
|
88
|
-
return "undefined";
|
|
89
|
-
}
|
|
90
|
-
if (typeof value === "string") {
|
|
91
|
-
return JSON.stringify(value);
|
|
92
|
-
}
|
|
93
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
94
|
-
return String(value);
|
|
95
|
-
}
|
|
96
|
-
if (isSpecialValue(value)) {
|
|
97
|
-
if ("__identifier" in value)
|
|
98
|
-
return value.__identifier;
|
|
99
|
-
if ("__expression" in value)
|
|
100
|
-
return value.__expression;
|
|
101
|
-
if ("__call" in value)
|
|
102
|
-
return value.__call;
|
|
103
|
-
}
|
|
104
|
-
if (Array.isArray(value)) {
|
|
105
|
-
return `[${value.map((v) => formatValue(v, baseIndent)).join(", ")}]`;
|
|
106
|
-
}
|
|
107
|
-
if (typeof value === "object") {
|
|
108
|
-
// Filter out undefined values — prevents emitting `key: undefined` in generated code
|
|
109
|
-
const definedEntries = Object.entries(value).filter(([, v]) => v !== undefined);
|
|
110
|
-
// Simple objects stay on one line
|
|
111
|
-
if (isSimpleObject(value)) {
|
|
112
|
-
const formatted = definedEntries
|
|
113
|
-
.map(([k, v]) => `${k}: ${formatValue(v, baseIndent)}`)
|
|
114
|
-
.join(", ");
|
|
115
|
-
return formatted ? `{ ${formatted} }` : "{}";
|
|
116
|
-
}
|
|
117
|
-
// Complex objects get multi-line formatting
|
|
118
|
-
const innerIndent = baseIndent + " ";
|
|
119
|
-
const formatted = definedEntries
|
|
120
|
-
.map(([k, v]) => `${innerIndent}${k}: ${formatValue(v, innerIndent)}`)
|
|
121
|
-
.join(",\n");
|
|
122
|
-
return formatted ? `{\n${formatted}\n${baseIndent}}` : "{}";
|
|
123
|
-
}
|
|
124
|
-
return JSON.stringify(value);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Build a property string for code generation.
|
|
128
|
-
* Handles different value formats: raw (numbers/booleans), string (quoted),
|
|
129
|
-
* object (using formatValue), and boolean-or-object (special false handling).
|
|
130
|
-
*/
|
|
131
|
-
export function buildProperty(condition, name, value, format = "raw") {
|
|
132
|
-
if (!condition)
|
|
133
|
-
return "";
|
|
134
|
-
let formattedValue;
|
|
135
|
-
switch (format) {
|
|
136
|
-
case "string":
|
|
137
|
-
formattedValue = `"${value}"`;
|
|
138
|
-
break;
|
|
139
|
-
case "object":
|
|
140
|
-
formattedValue = formatValue(value);
|
|
141
|
-
break;
|
|
142
|
-
case "boolean-or-object":
|
|
143
|
-
formattedValue = value === false ? "false" : formatValue(value);
|
|
144
|
-
break;
|
|
145
|
-
default:
|
|
146
|
-
formattedValue = String(value);
|
|
147
|
-
}
|
|
148
|
-
return `
|
|
149
|
-
${name}: ${formattedValue},`;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Emit extra properties preserved verbatim during round-trip.
|
|
153
|
-
* Each property is emitted as `key: sourceText,` at the given indentation.
|
|
154
|
-
*/
|
|
155
|
-
export function emitExtraProperties(extraProperties, indent = " ") {
|
|
156
|
-
if (!extraProperties?.length)
|
|
157
|
-
return "";
|
|
158
|
-
return extraProperties
|
|
159
|
-
.map((prop) => `\n${indent}${prop.key}: ${prop.sourceText},`)
|
|
160
|
-
.join("");
|
|
161
|
-
}
|
|
1
|
+
import{toPascalCase as g,toKebab as $,toValidDatabaseName as j}from"@fjall/util";function b(e){if(typeof e!="object"||e===null)return!1;const r=e;return typeof r.__identifier=="string"||typeof r.__expression=="string"||typeof r.__call=="string"}function s(e){return e.replace(/[^a-zA-Z0-9]/g," ").split(" ").map((r,t)=>t===0?r.charAt(0).toLowerCase()+r.slice(1):r.charAt(0).toUpperCase()+r.slice(1)).join("")}function p(e){return e.variableName??s(e.name)}function l(e,r){for(const t of e.database)if(t.name===r&&t.variableName)return t.variableName;for(const t of e.s3)if(t.name===r&&t.variableName)return t.variableName;for(const t of e.compute)if(t.name===r&&t.variableName)return t.variableName;for(const t of e.dynamodb??[])if(t.name===r&&t.variableName)return t.variableName;for(const t of e.sqs??[])if(t.name===r&&t.variableName)return t.variableName;return s(r)}function m(e){const r=Object.entries(e);return r.length===0?!0:r.length>1?!1:r.every(([,t])=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null)}function o(e,r=" "){if(e==null)return"undefined";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean")return String(e);if(b(e)){if("__identifier"in e)return e.__identifier;if("__expression"in e)return e.__expression;if("__call"in e)return e.__call}if(Array.isArray(e))return`[${e.map(t=>o(t,r)).join(", ")}]`;if(typeof e=="object"){const t=Object.entries(e).filter(([,i])=>i!==void 0);if(m(e)){const i=t.map(([a,c])=>`${a}: ${o(c,r)}`).join(", ");return i?`{ ${i} }`:"{}"}const f=r+" ",n=t.map(([i,a])=>`${f}${i}: ${o(a,f)}`).join(`,
|
|
2
|
+
`);return n?`{
|
|
3
|
+
${n}
|
|
4
|
+
${r}}`:"{}"}return JSON.stringify(e)}function u(e,r,t,f="raw"){if(!e)return"";let n;switch(f){case"string":n=`"${t}"`;break;case"object":n=o(t);break;case"boolean-or-object":n=t===!1?"false":o(t);break;default:n=String(t)}return`
|
|
5
|
+
${r}: ${n},`}function y(e,r=" "){return e?.length?e.map(t=>`
|
|
6
|
+
${r}${t.key}: ${t.sourceText},`).join(""):""}export{u as buildProperty,y as emitExtraProperties,o as formatValue,p as getVariableName,b as isSpecialValue,l as resolveResourceVariable,$ as toKebab,g as toPascalCase,j as toValidDatabaseName,s as toVariableName};
|