@fjall/generator 0.95.0 → 0.96.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.
- package/dist/.minified +1 -1
- package/dist/src/ast/astCodeInjection.d.ts +9 -0
- package/dist/src/ast/astCodeInjection.js +8 -0
- package/dist/src/ast/astInfrastructureParser.d.ts +1 -1
- package/dist/src/ast/astStatementClassifier.d.ts +2 -2
- package/dist/src/ast/astStatementClassifier.js +1 -1
- package/dist/src/ast/astStatementQueries.d.ts +4 -4
- package/dist/src/ast/astStatementQueries.js +3 -3
- package/dist/src/ast/astSurgicalModification.d.ts +14 -12
- package/dist/src/ast/astSurgicalModification.js +6 -13
- package/dist/src/ast/astTestHelpers.d.ts +1 -1
- package/dist/src/ast/index.d.ts +3 -2
- package/dist/src/ast/index.js +1 -1
- package/dist/src/codemod/_internal.d.ts +6 -1
- package/dist/src/codemod/_internal.js +1 -1
- package/dist/src/codemod/drift/__tests__/fixtures.d.ts +55 -0
- package/dist/src/codemod/drift/__tests__/fixtures.js +2 -0
- package/dist/src/codemod/drift/detect.d.ts +11 -0
- package/dist/src/codemod/drift/detect.js +1 -0
- package/dist/src/codemod/drift/index.d.ts +4 -0
- package/dist/src/codemod/drift/index.js +1 -0
- package/dist/src/codemod/drift/merge.d.ts +19 -0
- package/dist/src/codemod/drift/merge.js +1 -0
- package/dist/src/codemod/drift/snapshot.d.ts +4 -0
- package/dist/src/codemod/drift/snapshot.js +1 -0
- package/dist/src/codemod/drift/types.d.ts +60 -0
- package/dist/src/codemod/drift/types.js +1 -0
- package/dist/src/codemod/edits/addResource/propertyBuilder.d.ts +1 -1
- package/dist/src/codemod/edits/addResource/propertyBuilder.js +1 -1
- package/dist/src/codemod/edits/addResource.d.ts +8 -3
- package/dist/src/codemod/edits/addResource.js +1 -1
- package/dist/src/codemod/edits/controlFlowPolicy.d.ts +19 -0
- package/dist/src/codemod/edits/controlFlowPolicy.js +1 -0
- package/dist/src/codemod/edits/crossPlanConnection.d.ts +24 -0
- package/dist/src/codemod/edits/crossPlanConnection.js +1 -0
- package/dist/src/codemod/edits/driftPolicy.d.ts +7 -0
- package/dist/src/codemod/edits/driftPolicy.js +1 -0
- package/dist/src/codemod/edits/findInsertionPosition.js +1 -1
- package/dist/src/codemod/edits/index.d.ts +3 -0
- package/dist/src/codemod/edits/index.js +1 -1
- package/dist/src/codemod/edits/modifyResource.d.ts +9 -3
- package/dist/src/codemod/edits/modifyResource.js +1 -1
- package/dist/src/codemod/edits/removeResource.d.ts +2 -2
- package/dist/src/codemod/edits/removeResource.js +1 -1
- package/dist/src/codemod/edits/vpcPeer.d.ts +28 -0
- package/dist/src/codemod/edits/vpcPeer.js +1 -0
- package/dist/src/codemod/edits/vpcPeerAccepter.d.ts +23 -0
- package/dist/src/codemod/edits/vpcPeerAccepter.js +1 -0
- package/dist/src/codemod/index.d.ts +16 -4
- package/dist/src/codemod/index.js +1 -1
- package/dist/src/codemod/llmFallback/__tests__/fixtures.d.ts +5 -0
- package/dist/src/codemod/llmFallback/__tests__/fixtures.js +7 -0
- package/dist/src/codemod/llmFallback/apply.d.ts +10 -0
- package/dist/src/codemod/llmFallback/apply.js +1 -0
- package/dist/src/codemod/llmFallback/claudeTier.d.ts +6 -0
- package/dist/src/codemod/llmFallback/claudeTier.js +1 -0
- package/dist/src/codemod/llmFallback/egressGate.d.ts +5 -0
- package/dist/src/codemod/llmFallback/egressGate.js +1 -0
- package/dist/src/codemod/llmFallback/egressGate.types.d.ts +9 -0
- package/dist/src/codemod/llmFallback/egressGate.types.js +0 -0
- package/dist/src/codemod/llmFallback/index.d.ts +6 -0
- package/dist/src/codemod/llmFallback/index.js +1 -0
- package/dist/src/codemod/llmFallback/morphTier.d.ts +2 -0
- package/dist/src/codemod/llmFallback/morphTier.js +3 -0
- package/dist/src/codemod/llmFallback/prompt.d.ts +12 -0
- package/dist/src/codemod/llmFallback/prompt.js +36 -0
- package/dist/src/codemod/llmFallback/runFallback.d.ts +13 -0
- package/dist/src/codemod/llmFallback/runFallback.js +1 -0
- package/dist/src/codemod/llmFallback/shouldTryFallback.d.ts +13 -0
- package/dist/src/codemod/llmFallback/shouldTryFallback.js +1 -0
- package/dist/src/codemod/llmFallback/signals.d.ts +4 -0
- package/dist/src/codemod/llmFallback/signals.js +1 -0
- package/dist/src/codemod/llmFallback/telemetryEvents.d.ts +141 -0
- package/dist/src/codemod/llmFallback/telemetryEvents.js +1 -0
- package/dist/src/codemod/llmFallback/tierRunner.d.ts +7 -0
- package/dist/src/codemod/llmFallback/tierRunner.js +1 -0
- package/dist/src/codemod/llmFallback/types.d.ts +104 -0
- package/dist/src/codemod/llmFallback/types.js +1 -0
- package/dist/src/codemod/registry.d.ts +4 -1
- package/dist/src/codemod/registry.js +1 -1
- package/dist/src/codemod/semanticIndex/classifyControlFlow.d.ts +2 -0
- package/dist/src/codemod/semanticIndex/classifyControlFlow.js +1 -0
- package/dist/src/codemod/semanticIndex/findReferences.js +2 -2
- package/dist/src/codemod/telemetry/__tests__/errorKinds.fixture.d.ts +1 -0
- package/dist/src/codemod/telemetry/__tests__/errorKinds.fixture.js +1 -0
- package/dist/src/codemod/telemetry/errorKinds.d.ts +2 -0
- package/dist/src/codemod/telemetry/errorKinds.js +1 -0
- package/dist/src/codemod/types.d.ts +105 -1
- package/dist/src/codemod/types.js +1 -1
- package/dist/src/codemod/validationGate/gates/classify.d.ts +2 -0
- package/dist/src/codemod/validationGate/gates/classify.js +1 -0
- package/dist/src/codemod/validationGate/gates/drift.d.ts +2 -0
- package/dist/src/codemod/validationGate/gates/drift.js +1 -0
- package/dist/src/codemod/validationGate/gates/locate.d.ts +7 -0
- package/dist/src/codemod/validationGate/gates/locate.js +1 -0
- package/dist/src/codemod/validationGate/gates/parse.d.ts +2 -0
- package/dist/src/codemod/validationGate/gates/parse.js +1 -0
- package/dist/src/codemod/validationGate/gates/schema.d.ts +2 -0
- package/dist/src/codemod/validationGate/gates/schema.js +1 -0
- package/dist/src/codemod/validationGate/index.d.ts +6 -0
- package/dist/src/codemod/validationGate/index.js +1 -0
- package/dist/src/codemod/validationGate/types.d.ts +35 -0
- package/dist/src/codemod/validationGate/types.js +1 -0
- package/dist/src/planning/index.d.ts +2 -1
- package/dist/src/planning/index.js +1 -1
- package/dist/src/planning/openNextPlanning.d.ts +38 -0
- package/dist/src/planning/openNextPlanning.js +1 -0
- package/dist/src/planning/resourcePlanning.d.ts +0 -46
- package/dist/src/planning/resourcePlanning.js +1 -1
- package/dist/src/schemas/applicationSchemas.d.ts +16 -0
- package/dist/src/schemas/applicationSchemas.js +1 -1
- package/dist/src/schemas/baseSchemas.d.ts +8 -5
- package/dist/src/schemas/baseSchemas.js +2 -2
- package/dist/src/schemas/networkSchemas.d.ts +119 -5
- package/dist/src/schemas/networkSchemas.js +1 -1
- package/dist/src/validation/patterns.d.ts +2 -318
- package/dist/src/validation/patterns.js +1 -1
- package/dist/src/validation/validationMessages.d.ts +314 -0
- package/dist/src/validation/validationMessages.js +1 -0
- package/dist/src/validation/validationPatterns.d.ts +20 -0
- package/dist/src/validation/validationPatterns.js +1 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { StatementType, ResourceName, LlmFallbackTier } from "../types.js";
|
|
2
|
+
import type { GateId } from "../validationGate/types.js";
|
|
3
|
+
import type { EgressRiskReason } from "./egressGate.types.js";
|
|
4
|
+
export declare const PARSE_GATE: GateId;
|
|
5
|
+
export declare const RUNTIME_GATE: GateId;
|
|
6
|
+
export type FallbackOp = "add" | "modify" | "remove" | "resolve-drift-merge";
|
|
7
|
+
export interface FallbackIntent {
|
|
8
|
+
op: FallbackOp;
|
|
9
|
+
type: StatementType;
|
|
10
|
+
name: ResourceName;
|
|
11
|
+
properties: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export interface FallbackInput {
|
|
14
|
+
content: string;
|
|
15
|
+
intent: FallbackIntent;
|
|
16
|
+
tier: LlmFallbackTier;
|
|
17
|
+
orgAllowsFallback: boolean;
|
|
18
|
+
abortSignal?: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
export type FallbackOutput = {
|
|
21
|
+
state: "applied";
|
|
22
|
+
content: string;
|
|
23
|
+
telemetry: FallbackTelemetry;
|
|
24
|
+
} | {
|
|
25
|
+
state: "egress-blocked";
|
|
26
|
+
tier: LlmFallbackTier;
|
|
27
|
+
reason: EgressRiskReason;
|
|
28
|
+
count: number;
|
|
29
|
+
} | {
|
|
30
|
+
state: "timeout";
|
|
31
|
+
tier: LlmFallbackTier;
|
|
32
|
+
elapsedMs: number;
|
|
33
|
+
} | {
|
|
34
|
+
state: "rejected";
|
|
35
|
+
tier: LlmFallbackTier;
|
|
36
|
+
failedGate: GateId;
|
|
37
|
+
diagnostics: string;
|
|
38
|
+
} | {
|
|
39
|
+
state: "cancelled";
|
|
40
|
+
} | {
|
|
41
|
+
state: "disabled";
|
|
42
|
+
reason: "env-flag" | "org-opt-out";
|
|
43
|
+
};
|
|
44
|
+
export interface FallbackTelemetry {
|
|
45
|
+
tier: LlmFallbackTier;
|
|
46
|
+
elapsedMs: number;
|
|
47
|
+
inputTokens: number;
|
|
48
|
+
outputTokens: number;
|
|
49
|
+
opsApplied: number;
|
|
50
|
+
}
|
|
51
|
+
export type TriggerReason = "template-literal-name" | "resource-not-found" | "control-flow-unclassifiable" | "drift-unmergeable";
|
|
52
|
+
export interface StrReplaceOp {
|
|
53
|
+
old_str: string;
|
|
54
|
+
new_str: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ApplyResult {
|
|
57
|
+
content: string;
|
|
58
|
+
appliedCount: number;
|
|
59
|
+
skippedCount: number;
|
|
60
|
+
}
|
|
61
|
+
export interface AnthropicClientProvider {
|
|
62
|
+
create(params: {
|
|
63
|
+
model: string;
|
|
64
|
+
max_tokens: number;
|
|
65
|
+
system: string;
|
|
66
|
+
messages: Array<{
|
|
67
|
+
role: "user";
|
|
68
|
+
content: string;
|
|
69
|
+
}>;
|
|
70
|
+
tools: readonly unknown[];
|
|
71
|
+
signal?: AbortSignal;
|
|
72
|
+
}): Promise<AnthropicResponse>;
|
|
73
|
+
resolveModelId(): string;
|
|
74
|
+
}
|
|
75
|
+
export interface AnthropicResponse {
|
|
76
|
+
content: readonly AnthropicContentBlock[];
|
|
77
|
+
usage?: {
|
|
78
|
+
input_tokens?: number;
|
|
79
|
+
output_tokens?: number;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export type AnthropicContentBlock = {
|
|
83
|
+
type: "text";
|
|
84
|
+
text: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: "tool_use";
|
|
87
|
+
name: string;
|
|
88
|
+
input: Record<string, unknown>;
|
|
89
|
+
};
|
|
90
|
+
export interface MorphClientProvider {
|
|
91
|
+
apply(params: {
|
|
92
|
+
originalFile: string;
|
|
93
|
+
update: string;
|
|
94
|
+
signal?: AbortSignal;
|
|
95
|
+
}): Promise<MorphResponse>;
|
|
96
|
+
isAvailable(): boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface MorphResponse {
|
|
99
|
+
content: string;
|
|
100
|
+
usage?: {
|
|
101
|
+
inputTokens?: number;
|
|
102
|
+
outputTokens?: number;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t="parse",e="runtime";export{t as PARSE_GATE,e as RUNTIME_GATE};
|
|
@@ -25,7 +25,7 @@ export interface StatementTypeEntry {
|
|
|
25
25
|
factoryIdentifier: FactoryIdentifier;
|
|
26
26
|
locator: StatementLocator;
|
|
27
27
|
generator: StatementGenerator;
|
|
28
|
-
schemaFragment: z.ZodObject
|
|
28
|
+
schemaFragment: z.ZodObject<z.ZodRawShape>;
|
|
29
29
|
}
|
|
30
30
|
declare const FACTORY_IDENTIFIERS: {
|
|
31
31
|
readonly database: "DatabaseFactory";
|
|
@@ -35,6 +35,9 @@ declare const FACTORY_IDENTIFIERS: {
|
|
|
35
35
|
readonly cdn: "CdnFactory";
|
|
36
36
|
readonly network: "NetworkFactory";
|
|
37
37
|
readonly pattern: "PatternFactory";
|
|
38
|
+
readonly "vpc-peer": "VpcPeerFactory";
|
|
39
|
+
readonly "vpc-peer-accepter": "VpcPeerAccepterFactory";
|
|
40
|
+
readonly "cross-plan-connection": "CrossPlanConnectionFactory";
|
|
38
41
|
};
|
|
39
42
|
export type FactoryIdentifier = (typeof FACTORY_IDENTIFIERS)[StatementType];
|
|
40
43
|
export declare const STATEMENT_REGISTRY: Record<StatementType, StatementTypeEntry>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as c}from"zod";import{CDNResourcePlanSchema as
|
|
1
|
+
import{z as c}from"zod";import{CDNResourcePlanSchema as i,ComputeResourcePlanSchema as u,CrossPlanConnectionResourcePlanSchema as g,DatabaseResourcePlanSchema as l,NetworkResourcePlanSchema as h,NextJSPatternConfigSchema as d,PayloadPatternConfigSchema as y,S3ResourcePlanSchema as S,SQSResourcePlanSchema as F,VpcPeerAccepterResourcePlanSchema as P,VpcPeerResourcePlanSchema as f}from"../schemas/index.js";import{failure as C}from"../types/Result.js";const r={database:"DatabaseFactory",storage:"StorageFactory",compute:"ComputeFactory",messaging:"MessagingFactory",cdn:"CdnFactory",network:"NetworkFactory",pattern:"PatternFactory","vpc-peer":"VpcPeerFactory","vpc-peer-accepter":"VpcPeerAccepterFactory","cross-plan-connection":"CrossPlanConnectionFactory"};function a(e){const{name:t,...o}=e.shape;return c.object(o).partial().strict()}const b=a(l),R=a(S),v=(()=>{const{name:e,...t}=u.shape;return c.object(t).partial().strict()})(),E=a(F),w=a(i),k=a(h),T=(()=>{const{name:e,type:t,...o}=y.shape,{name:D,type:V,...m}=d.shape;return c.object({...o,...m}).partial().strict()})(),_=a(f),x=a(P),N=a(g);function s(e,t){return C({kind:"SemanticQueryError",reason:`StatementTypeEntry.${e} for ${t} is not wired; existing types dispatch through the shared locator/generator.`})}function j(e){return{factoryIdentifier:e,findByShape:()=>s("locator.findByShape",e),validateContext:()=>s("locator.validateContext",e)}}function A(e){return{build:()=>{const t=s("generator.build",e);throw new Error(t.success?"unreachable":t.error.reason)}}}function n(e,t){return{factoryIdentifier:e,locator:j(e),generator:A(e),schemaFragment:t}}const p={database:n(r.database,b),storage:n(r.storage,R),compute:n(r.compute,v),messaging:n(r.messaging,E),cdn:n(r.cdn,w),network:n(r.network,k),pattern:n(r.pattern,T),"vpc-peer":n(r["vpc-peer"],_),"vpc-peer-accepter":n(r["vpc-peer-accepter"],x),"cross-plan-connection":n(r["cross-plan-connection"],N)};function I(e){const t=Object.keys(p);for(const o of t)if(p[o].factoryIdentifier===e)return o}export{p as STATEMENT_REGISTRY,I as findTypeByIdentifier};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const u=new Set(["IfStatement","ConditionalExpression","SwitchStatement","SwitchCase","CatchClause"]),c=new Set(["ForStatement","ForInStatement","ForOfStatement","WhileStatement","DoWhileStatement"]),a=new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","ObjectMethod","ClassMethod"]);function p(n,t){if(t.length===0)return S(n);let e=n;for(let r=t.length-1;r>=0;r-=1){const o=t[r],i=f(o);if(i===void 0){e=o;continue}if(i==="TryStatement"){if(s(o,e))return"conditional";e=o;continue}if(u.has(i))return"conditional";if(c.has(i))return"loop";if(a.has(i))return"function-body";e=o}const l=f(t[0]);return l==="Program"||l==="File"?"top-level":"unknown"}function f(n){if(typeof n!="object"||n===null)return;const t=n.type;return typeof t=="string"?t:void 0}function s(n,t){if(typeof n!="object"||n===null)return!1;const e=n.finalizer;return e!==void 0&&e===t}function S(n){const t=f(n);return t==="Program"||t==="File"?"top-level":"unknown"}export{p as classifyControlFlow};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Node as
|
|
2
|
-
`)[e-1]??"",
|
|
1
|
+
import{Node as m,SyntaxKind as y}from"ts-morph";import{failure as a,success as u}from"../../types/Result.js";import{DEFAULT_FILE_PATH as S}from"../_internal.js";import{getProject as p}from"./projectCache.js";const f=120;function D(r,n,e=S){let o;try{o=p().createSourceFile(e,r,{overwrite:!0})}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to create source file",cause:t})}let c;try{c=g(o,n.start)}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to resolve declaration at the supplied offset",cause:t})}if(c===void 0)return u([]);let i;try{i=c.getSymbol()}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to resolve symbol for declaration",cause:t})}if(i===void 0)return u([]);let s;try{s=c.findReferencesAsNodes()}catch(t){return a({kind:"SemanticQueryError",reason:"findReferencesAsNodes failed",cause:t})}const d=o.getFullText().split(`
|
|
2
|
+
`),l=[];try{for(const t of s)F(t,i)&&(b(t,c)||l.push(A(t,d)))}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to map references to plain-data locations",cause:t})}return u(l)}function g(r,n){const e=r.getDescendantAtPos(n);return e===void 0?void 0:m.isVariableDeclaration(e)?e:e.getFirstAncestorByKind(y.VariableDeclaration)}function F(r,n){const e=r.getSymbol();return e===void 0?!1:e===n?!0:e.compilerSymbol===n.compilerSymbol}function b(r,n){const e=n.getNameNode();return r===e||r.getStart()===e.getStart()}function A(r,n){const e=r.getStart(),{line:o,column:c}=r.getSourceFile().getLineAndColumnAtPos(e),i=n[o-1]??"",s=i.length>f?i.slice(0,f):i;return{line:o,column:c,context:s}}export{D as findReferences};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=!0;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const CODEMOD_ERROR_KINDS: readonly ["ParseError", "ResourceNotFoundError", "DuplicateResourceError", "ReferencesRemainError", "InvalidPropertyError", "TemplateLiteralNameError", "SemanticQueryError", "ValidationError", "IoError", "DriftConflictError", "DriftUnmergeableError", "PermissionError", "ControlFlowClassifierError", "LlmFallbackRejectedError", "LlmFallbackTimeoutError", "LlmFallbackUnsafeInputError"];
|
|
2
|
+
export type CodemodErrorKind = (typeof CODEMOD_ERROR_KINDS)[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=["ParseError","ResourceNotFoundError","DuplicateResourceError","ReferencesRemainError","InvalidPropertyError","TemplateLiteralNameError","SemanticQueryError","ValidationError","IoError","DriftConflictError","DriftUnmergeableError","PermissionError","ControlFlowClassifierError","LlmFallbackRejectedError","LlmFallbackTimeoutError","LlmFallbackUnsafeInputError"],e=!0;export{r as CODEMOD_ERROR_KINDS};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { GateId } from "./validationGate/types.js";
|
|
3
|
+
import type { EgressRiskReason } from "./llmFallback/egressGate.types.js";
|
|
4
|
+
export declare const DriftPolicySchema: z.ZodObject<{
|
|
5
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
resolutionMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export type DriftPolicy = z.infer<typeof DriftPolicySchema>;
|
|
2
9
|
/**
|
|
3
10
|
* The wider `StatementTypeSchema` in `schemas/baseSchemas.ts` also
|
|
4
11
|
* carries non-factory kinds (import, app-init, tags, custom) that the
|
|
@@ -12,6 +19,9 @@ export declare const StatementTypeSchema: z.ZodEnum<{
|
|
|
12
19
|
network: "network";
|
|
13
20
|
messaging: "messaging";
|
|
14
21
|
cdn: "cdn";
|
|
22
|
+
"vpc-peer": "vpc-peer";
|
|
23
|
+
"vpc-peer-accepter": "vpc-peer-accepter";
|
|
24
|
+
"cross-plan-connection": "cross-plan-connection";
|
|
15
25
|
}>;
|
|
16
26
|
export type StatementType = z.infer<typeof StatementTypeSchema>;
|
|
17
27
|
export declare const ResourceNameSchema: z.ZodString;
|
|
@@ -25,10 +35,18 @@ export declare const AddOptionsSchema: z.ZodObject<{
|
|
|
25
35
|
network: "network";
|
|
26
36
|
messaging: "messaging";
|
|
27
37
|
cdn: "cdn";
|
|
38
|
+
"vpc-peer": "vpc-peer";
|
|
39
|
+
"vpc-peer-accepter": "vpc-peer-accepter";
|
|
40
|
+
"cross-plan-connection": "cross-plan-connection";
|
|
28
41
|
}>;
|
|
29
42
|
name: z.ZodString;
|
|
30
43
|
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
31
44
|
filePath: z.ZodOptional<z.ZodString>;
|
|
45
|
+
driftPolicy: z.ZodOptional<z.ZodObject<{
|
|
46
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
resolutionMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
48
|
+
}, z.core.$strict>>;
|
|
49
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
32
50
|
}, z.core.$strict>;
|
|
33
51
|
export type AddOptions = z.infer<typeof AddOptionsSchema>;
|
|
34
52
|
export declare const RemoveOptionsSchema: z.ZodObject<{
|
|
@@ -40,10 +58,14 @@ export declare const RemoveOptionsSchema: z.ZodObject<{
|
|
|
40
58
|
network: "network";
|
|
41
59
|
messaging: "messaging";
|
|
42
60
|
cdn: "cdn";
|
|
61
|
+
"vpc-peer": "vpc-peer";
|
|
62
|
+
"vpc-peer-accepter": "vpc-peer-accepter";
|
|
63
|
+
"cross-plan-connection": "cross-plan-connection";
|
|
43
64
|
}>;
|
|
44
65
|
name: z.ZodString;
|
|
45
66
|
filePath: z.ZodOptional<z.ZodString>;
|
|
46
67
|
force: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
47
69
|
}, z.core.$strict>;
|
|
48
70
|
export type RemoveOptions = z.infer<typeof RemoveOptionsSchema>;
|
|
49
71
|
export declare const ModifyOptionsSchema: z.ZodObject<{
|
|
@@ -55,10 +77,18 @@ export declare const ModifyOptionsSchema: z.ZodObject<{
|
|
|
55
77
|
network: "network";
|
|
56
78
|
messaging: "messaging";
|
|
57
79
|
cdn: "cdn";
|
|
80
|
+
"vpc-peer": "vpc-peer";
|
|
81
|
+
"vpc-peer-accepter": "vpc-peer-accepter";
|
|
82
|
+
"cross-plan-connection": "cross-plan-connection";
|
|
58
83
|
}>;
|
|
59
84
|
name: z.ZodString;
|
|
60
85
|
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
61
86
|
filePath: z.ZodOptional<z.ZodString>;
|
|
87
|
+
driftPolicy: z.ZodOptional<z.ZodObject<{
|
|
88
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
resolutionMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
90
|
+
}, z.core.$strict>>;
|
|
91
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
62
92
|
}, z.core.$strict>;
|
|
63
93
|
export type ModifyOptions = z.infer<typeof ModifyOptionsSchema>;
|
|
64
94
|
export declare const ReferenceLocationSchema: z.ZodObject<{
|
|
@@ -81,6 +111,9 @@ export declare const ResourceListingEntrySchema: z.ZodObject<{
|
|
|
81
111
|
network: "network";
|
|
82
112
|
messaging: "messaging";
|
|
83
113
|
cdn: "cdn";
|
|
114
|
+
"vpc-peer": "vpc-peer";
|
|
115
|
+
"vpc-peer-accepter": "vpc-peer-accepter";
|
|
116
|
+
"cross-plan-connection": "cross-plan-connection";
|
|
84
117
|
}>;
|
|
85
118
|
name: z.ZodString;
|
|
86
119
|
filePath: z.ZodString;
|
|
@@ -99,6 +132,9 @@ export declare const ResourceListingSchema: z.ZodObject<{
|
|
|
99
132
|
network: "network";
|
|
100
133
|
messaging: "messaging";
|
|
101
134
|
cdn: "cdn";
|
|
135
|
+
"vpc-peer": "vpc-peer";
|
|
136
|
+
"vpc-peer-accepter": "vpc-peer-accepter";
|
|
137
|
+
"cross-plan-connection": "cross-plan-connection";
|
|
102
138
|
}>;
|
|
103
139
|
name: z.ZodString;
|
|
104
140
|
filePath: z.ZodString;
|
|
@@ -169,4 +205,72 @@ export interface SemanticQueryError {
|
|
|
169
205
|
reason: string;
|
|
170
206
|
cause?: unknown;
|
|
171
207
|
}
|
|
172
|
-
export
|
|
208
|
+
export declare const PropertyDeltaSchema: z.ZodObject<{
|
|
209
|
+
property: z.ZodString;
|
|
210
|
+
base: z.ZodOptional<z.ZodUnknown>;
|
|
211
|
+
theirs: z.ZodUnknown;
|
|
212
|
+
ours: z.ZodUnknown;
|
|
213
|
+
verdict: z.ZodEnum<{
|
|
214
|
+
clean: "clean";
|
|
215
|
+
"no-op": "no-op";
|
|
216
|
+
compatible: "compatible";
|
|
217
|
+
conflict: "conflict";
|
|
218
|
+
}>;
|
|
219
|
+
}, z.core.$strict>;
|
|
220
|
+
export type PropertyDelta = z.infer<typeof PropertyDeltaSchema>;
|
|
221
|
+
export interface DriftConflictError {
|
|
222
|
+
kind: "DriftConflictError";
|
|
223
|
+
resource: {
|
|
224
|
+
type: StatementType;
|
|
225
|
+
name: string;
|
|
226
|
+
};
|
|
227
|
+
deltas: PropertyDelta[];
|
|
228
|
+
baselineSource: "pr" | "persistent" | "file" | "unknown";
|
|
229
|
+
remediation?: string;
|
|
230
|
+
}
|
|
231
|
+
export interface DriftUnmergeableError {
|
|
232
|
+
kind: "DriftUnmergeableError";
|
|
233
|
+
resource: {
|
|
234
|
+
type: StatementType;
|
|
235
|
+
name: string;
|
|
236
|
+
};
|
|
237
|
+
reason: string;
|
|
238
|
+
}
|
|
239
|
+
export interface PermissionError {
|
|
240
|
+
kind: "PermissionError";
|
|
241
|
+
reason: "cross-account-peer-requires-trust" | "cross-org-connection-refused" | "unknown-remote-app" | "wildcard-principal-rejected" | "wildcard-resource-rejected";
|
|
242
|
+
details: string;
|
|
243
|
+
remediation?: string;
|
|
244
|
+
}
|
|
245
|
+
export type ControlFlowRefusalReason = "try-catch" | "switch-fall-through" | "nested-ternary" | "loop" | "generator-function" | "async-iterator" | "anonymous-helper" | "decorator-return";
|
|
246
|
+
export interface ControlFlowClassifierError {
|
|
247
|
+
kind: "ControlFlowClassifierError";
|
|
248
|
+
reason: ControlFlowRefusalReason;
|
|
249
|
+
resource: {
|
|
250
|
+
type: StatementType;
|
|
251
|
+
name: string;
|
|
252
|
+
};
|
|
253
|
+
location?: {
|
|
254
|
+
line: number;
|
|
255
|
+
column: number;
|
|
256
|
+
};
|
|
257
|
+
remediation?: string;
|
|
258
|
+
}
|
|
259
|
+
export type LlmFallbackTier = "claude" | "morph";
|
|
260
|
+
export interface LlmFallbackRejectedError {
|
|
261
|
+
kind: "LlmFallbackRejectedError";
|
|
262
|
+
tier: LlmFallbackTier;
|
|
263
|
+
failedGate: GateId;
|
|
264
|
+
diagnostics: string;
|
|
265
|
+
}
|
|
266
|
+
export interface LlmFallbackTimeoutError {
|
|
267
|
+
kind: "LlmFallbackTimeoutError";
|
|
268
|
+
tier: LlmFallbackTier;
|
|
269
|
+
elapsedMs: number;
|
|
270
|
+
}
|
|
271
|
+
export interface LlmFallbackUnsafeInputError {
|
|
272
|
+
kind: "LlmFallbackUnsafeInputError";
|
|
273
|
+
reason: EgressRiskReason;
|
|
274
|
+
count: number;
|
|
275
|
+
}
|
|
276
|
+
export type CodemodError = ParseError | TemplateLiteralNameError | DuplicateResourceError | ResourceNotFoundError | ReferencesRemainError | InvalidPropertyError | SemanticQueryError | DriftConflictError | DriftUnmergeableError | PermissionError | ControlFlowClassifierError | LlmFallbackRejectedError | LlmFallbackTimeoutError | LlmFallbackUnsafeInputError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as
|
|
1
|
+
import{z as t}from"zod";import{VALIDATION_MESSAGES as i,VALIDATION_PATTERNS as c}from"../validation/patterns.js";const o=t.object({force:t.boolean().optional(),resolutionMap:t.record(t.string(),t.unknown()).optional()}).strict(),e=t.enum(["database","storage","compute","messaging","cdn","network","pattern","vpc-peer","vpc-peer-accepter","cross-plan-connection"]),n=t.string().regex(c.PASCAL_CASE,i.PASCAL_CASE),r=t.record(t.string(),t.unknown()),g=t.object({type:e,name:n,properties:r,filePath:t.string().optional(),driftPolicy:o.optional(),branch:t.string().optional()}).strict(),h=t.object({type:e,name:n,filePath:t.string().optional(),force:t.boolean().optional(),branch:t.string().optional()}).strict(),b=t.object({type:e,name:n,properties:r,filePath:t.string().optional(),driftPolicy:o.optional(),branch:t.string().optional()}).strict(),a=t.object({line:t.number().int().positive(),column:t.number().int().positive(),context:t.string()}).strict(),s=t.object({added:t.number().int().nonnegative(),removed:t.number().int().nonnegative()}).strict(),p=t.object({type:e,name:t.string(),filePath:t.string(),start:t.number().int().nonnegative(),length:t.number().int().nonnegative()}).strict(),S=t.object({filePath:t.string(),resources:t.array(p)}).strict(),u=t.object({content:t.string(),linesChanged:s,references:t.array(a).optional(),warnings:t.array(t.string()).optional()}).strict(),d=t.object({property:t.string(),base:t.unknown().optional(),theirs:t.unknown(),ours:t.unknown(),verdict:t.enum(["clean","no-op","compatible","conflict"])}).strict();export{g as AddOptionsSchema,u as CodemodSuccessSchema,o as DriftPolicySchema,s as LinesChangedSchema,b as ModifyOptionsSchema,d as PropertyDeltaSchema,a as ReferenceLocationSchema,h as RemoveOptionsSchema,p as ResourceListingEntrySchema,S as ResourceListingSchema,n as ResourceNameSchema,e as StatementTypeSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{success as p,failure as y}from"../../../types/Result.js";import{parse as m}from"../../fileRewriter/parse.js";import{classifyControlFlow as h}from"../../semanticIndex/classifyControlFlow.js";import{locateAllShapes as A}from"../../semanticIndex/locateByShape.js";const C=new Set(["loc","tokens","comments","original","range"]);function f(o){return typeof o=="object"&&o!==null&&typeof o.type=="string"}function S(o,i){if(!f(o))return;const e=[{node:o,ancestors:[]}];for(;e.length>0;){const t=e.pop();if(t===void 0)continue;const{node:n,ancestors:s}=t;if(n.type==="StringLiteral"&&typeof n.start=="number"&&n.start===i)return{node:n,ancestors:s};const c=[...s,n];for(const u of Object.keys(n)){if(C.has(u))continue;const r=n[u];if(Array.isArray(r))for(let a=r.length-1;a>=0;a-=1){const l=r[a];f(l)&&e.push({node:l,ancestors:c})}else f(r)&&e.push({node:r,ancestors:c})}}}const g={conditional:"try-catch",loop:"loop","function-body":"anonymous-helper",unknown:"anonymous-helper"};function d(o){const i=A(o);if(!i.success)return[];const e=m(o);if(!e.success)return[];const t=[];for(const n of i.data){const s=S(e.data,n.start);if(s===void 0)continue;const c=h(s.node,s.ancestors);t.push({name:n.symbolName,type:n.type,classification:c})}return t}const O={id:"classify",run(o){if(o.inputContent===void 0)return p({action:"proceed"});const i=d(o.inputContent),e=d(o.content);for(const t of e){const n=i.find(s=>s.name===t.name&&s.type===t.type);if(n!==void 0&&n.classification==="top-level"&&t.classification!=="top-level")return y({kind:"ControlFlowClassifierError",reason:g[t.classification],resource:{type:t.type,name:t.name},location:void 0,remediation:"The LLM output moved a resource into a conditional or loop scope."})}return p({action:"proceed"})}};export{O as classifyGate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{failure as i,success as o}from"../../../types/Result.js";import{detectDrift as n}from"../../drift/index.js";import{resolveDriftPolicy as f}from"../../edits/driftPolicy.js";const d={id:"drift",run(r){if(r.baseline===void 0)return o({action:"proceed"});const t=n(r.content,r.plan,r.baseline);if(!t.success)return i(t.error);const e=f(t.data,r.plan.op,r.policy);return e.action==="reject"?i({kind:"DriftConflictError",resource:e.driftState.resource,deltas:e.driftState.deltas,baselineSource:"file"}):o({action:e.action,driftState:e.driftState})}};export{d as driftGate};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Gate } from "../types.js";
|
|
2
|
+
export type LocateMode = "present" | "absent";
|
|
3
|
+
export interface LocateGateOptions {
|
|
4
|
+
mode: LocateMode;
|
|
5
|
+
}
|
|
6
|
+
export declare function createLocateGate(options: LocateGateOptions): Gate;
|
|
7
|
+
export declare const locateGate: Gate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{success as o,failure as r}from"../../../types/Result.js";import{locateByShape as p}from"../../semanticIndex/locateByShape.js";function u(t){return{id:"locate",run(e){const n=p(e.content,{type:e.plan.type,name:e.plan.name});if(!n.success)return r(n.error);const a=n.data!==void 0;return t.mode==="present"&&!a?r({kind:"ResourceNotFoundError",type:e.plan.type,name:e.plan.name,knownNames:[]}):t.mode==="absent"&&a?r({kind:"DuplicateResourceError",type:e.plan.type,name:e.plan.name}):o({action:"proceed"})}}}const c=u({mode:"present"});export{u as createLocateGate,c as locateGate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{success as o,failure as t}from"../../../types/Result.js";import{parse as i}from"../../fileRewriter/parse.js";const d={id:"parse",run(s){const r=i(s.content);if(!r.success){const e=r.error,n=e.line!==void 0&&e.column!==void 0?`${String(e.line)}:${String(e.column)}`:void 0;return t({...e,kind:"ParseError",message:n!==void 0?`${e.message} at ${n}`:e.message})}return o({action:"proceed"})}};export{d as parseGate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{success as c}from"../../../types/Result.js";const t={id:"schema",run(e){return c({action:"proceed"})}};export{t as schemaGate};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { runPipeline, runPipelineAsync, type AsyncGate, type Gate, type GateAction, type GateContext, type GateId, type GateOutcome, type GateResult, } from "./types.js";
|
|
2
|
+
export { driftGate } from "./gates/drift.js";
|
|
3
|
+
export { schemaGate } from "./gates/schema.js";
|
|
4
|
+
export { parseGate } from "./gates/parse.js";
|
|
5
|
+
export { locateGate } from "./gates/locate.js";
|
|
6
|
+
export { classifyGate } from "./gates/classify.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{runPipeline as o,runPipelineAsync as t}from"./types.js";import{driftGate as p}from"./gates/drift.js";import{schemaGate as m}from"./gates/schema.js";import{parseGate as x}from"./gates/parse.js";import{locateGate as s}from"./gates/locate.js";import{classifyGate as c}from"./gates/classify.js";export{c as classifyGate,p as driftGate,s as locateGate,x as parseGate,o as runPipeline,t as runPipelineAsync,m as schemaGate};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Result } from "../../types/Result.js";
|
|
2
|
+
import type { DriftOp, DriftPolicy, DriftState, ResourceSnapshot } from "../drift/index.js";
|
|
3
|
+
import type { CodemodError, ResourceName, StatementType } from "../types.js";
|
|
4
|
+
export type GateId = "parse" | "tsc" | "classify" | "locate" | "schema" | "drift" | "runtime";
|
|
5
|
+
export type GateAction = "proceed" | "skip" | "reject";
|
|
6
|
+
export interface GateContext {
|
|
7
|
+
content: string;
|
|
8
|
+
plan: {
|
|
9
|
+
type: StatementType;
|
|
10
|
+
name: ResourceName;
|
|
11
|
+
properties: Record<string, unknown>;
|
|
12
|
+
op: DriftOp;
|
|
13
|
+
};
|
|
14
|
+
baseline?: ResourceSnapshot;
|
|
15
|
+
policy?: DriftPolicy;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
inputContent?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface GateOutcome {
|
|
20
|
+
action: GateAction;
|
|
21
|
+
driftState?: DriftState;
|
|
22
|
+
failedGate?: GateId;
|
|
23
|
+
diagnostics?: string;
|
|
24
|
+
}
|
|
25
|
+
export type GateResult = Result<GateOutcome, CodemodError>;
|
|
26
|
+
export interface Gate {
|
|
27
|
+
readonly id: GateId;
|
|
28
|
+
run(ctx: GateContext): GateResult;
|
|
29
|
+
}
|
|
30
|
+
export interface AsyncGate {
|
|
31
|
+
readonly id: GateId;
|
|
32
|
+
run(ctx: GateContext): Promise<GateResult>;
|
|
33
|
+
}
|
|
34
|
+
export declare function runPipeline(gates: readonly Gate[], ctx: GateContext): GateResult;
|
|
35
|
+
export declare function runPipelineAsync(gates: ReadonlyArray<Gate | AsyncGate>, ctx: GateContext): Promise<GateResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{success as o}from"../../types/Result.js";function i(n,r){for(const t of n){const e=t.run(r);if(!e.success||e.data.action!=="proceed")return e}return o({action:"proceed"})}async function a(n,r){for(const t of n){if(r.signal?.aborted===!0)return o({action:"reject",failedGate:t.id,diagnostics:"aborted"});const e=await t.run(r);if(!e.success||e.data.action!=="proceed")return e}return o({action:"proceed"})}export{i as runPipeline,a as runPipelineAsync};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { planApplicationResources, type
|
|
1
|
+
export { planApplicationResources, type GenerationOptions, generateInfrastructureFromPlan, } from "./resourcePlanning.js";
|
|
2
|
+
export { type OpenNextResourceOptions, planOpenNextResources, } from "./openNextPlanning.js";
|
|
2
3
|
export { type ConnectionType, applyComputeConnections, applyServiceConnections, } from "./resourceConnections.js";
|
|
3
4
|
export { type AddableResourceType, type AddResourceOptions, type DatabaseAddOptions, type ProxyAddOptions, type S3AddOptions, type NetworkAddOptions, type EcsComputeAddOptions, type LambdaComputeAddOptions, type CdnAddOptions, type TunnelAddOptions, addResourceToPlan, validateResourceAddition, listAvailableResources, } from "./resourceAddition.js";
|
|
4
5
|
export { type ResourceChangeResult, generateResourceChange, } from "./generateResourceChange.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{planApplicationResources as r,
|
|
1
|
+
import{planApplicationResources as r,generateInfrastructureFromPlan as n}from"./resourcePlanning.js";import{planOpenNextResources as a}from"./openNextPlanning.js";import{applyComputeConnections as s,applyServiceConnections as c}from"./resourceConnections.js";import{addResourceToPlan as i,validateResourceAddition as u,listAvailableResources as m}from"./resourceAddition.js";import{generateResourceChange as x}from"./generateResourceChange.js";export{i as addResourceToPlan,s as applyComputeConnections,c as applyServiceConnections,n as generateInfrastructureFromPlan,x as generateResourceChange,m as listAvailableResources,r as planApplicationResources,a as planOpenNextResources,u as validateResourceAddition};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type PatternTypeWithCustom } from "../presets/patternTierPresets.js";
|
|
2
|
+
import type { PatternType } from "../schemas/constants.js";
|
|
3
|
+
import { type Result } from "../types/Result.js";
|
|
4
|
+
import type { ApplicationResourcePlan } from "../schemas/resourceSchemas.js";
|
|
5
|
+
export interface OpenNextResourceOptions {
|
|
6
|
+
/** Pattern tier: lightweight, standard, resilient, or custom */
|
|
7
|
+
tier?: PatternTypeWithCustom;
|
|
8
|
+
/** Custom domain (auto-creates certificate + DNS) */
|
|
9
|
+
domain?: string;
|
|
10
|
+
/** Database configuration (uses tier defaults if not specified) */
|
|
11
|
+
database?: {
|
|
12
|
+
type?: "Instance" | "Aurora";
|
|
13
|
+
instanceType?: string;
|
|
14
|
+
databaseName?: string;
|
|
15
|
+
publiclyAccessible?: boolean;
|
|
16
|
+
allowedIpCidr?: string;
|
|
17
|
+
backupRetention?: number;
|
|
18
|
+
deletionProtection?: boolean;
|
|
19
|
+
encryption?: {
|
|
20
|
+
useCMK: true;
|
|
21
|
+
} | false;
|
|
22
|
+
};
|
|
23
|
+
/** Compute (Lambda) configuration (uses tier defaults if not specified) */
|
|
24
|
+
compute?: {
|
|
25
|
+
memorySize?: number;
|
|
26
|
+
timeout?: number;
|
|
27
|
+
};
|
|
28
|
+
/** CDN configuration (advanced - prefer `domain` for simple setup) */
|
|
29
|
+
cdn?: {
|
|
30
|
+
domainNames?: string[];
|
|
31
|
+
certificateArn?: string;
|
|
32
|
+
};
|
|
33
|
+
/** Additional environment variables */
|
|
34
|
+
environment?: Record<string, string>;
|
|
35
|
+
/** Resource tags */
|
|
36
|
+
tags?: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
export declare function planOpenNextResources(appName: string, pattern: PatternType, options?: OpenNextResourceOptions): Result<ApplicationResourcePlan, Error>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getPatternTierPreset as b,isPatternTierName as C,PATTERN_TIER_NAMES as T}from"../presets/patternTierPresets.js";import{getNetworkPreset as P}from"../presets/tierPresets.js";import{success as l,failure as f}from"../types/Result.js";import{PatternConfigSchema as y}from"../schemas/resourceSchemas.js";const N=P("standard");function w(e){return y.options.some(n=>n.shape?.type?.value===e)}function $(e,n,c){const{tier:r="standard",domain:u,database:d,compute:a,cdn:p,environment:i,tags:m}=c??{},s=C(r);if(!s&&r!=="custom")return f(new Error(`Invalid pattern tier: "${r}". Valid tiers are: ${[...T,"custom"].join(", ")}`));if(!w(n))return f(new Error(`Unsupported pattern type: ${n}`));const t=s?b(r):null,o=R(n,e,{domain:u,database:d,compute:a,cdn:p,environment:i,tierPreset:t});if(!o.success)return o;const g=o.data;return l({appName:e,type:"standard",pattern:n,network:t?t.network:N,backup:t?t.backup:!1,patternConfig:g,database:[],s3:[],compute:[],tags:m??{}})}function k(e,n){return{type:e?.type??n.database.type,instanceType:e?.instanceType??n.database.instanceType,backupRetention:e?.backupRetention??n.database.backupRetention,deletionProtection:e?.deletionProtection??n.database.deletionProtection,...e?.databaseName!==void 0&&{databaseName:e.databaseName},...e?.publiclyAccessible!==void 0&&{publiclyAccessible:e.publiclyAccessible},...e?.allowedIpCidr!==void 0&&{allowedIpCidr:e.allowedIpCidr},...e?.encryption!==void 0&&{encryption:e.encryption}}}function A(e,n){return{memorySize:e?.memorySize??n.compute.memorySize,timeout:e?.timeout??n.compute.timeout}}function E(e){const{encryption:n,...c}=e;return{...c,...n&&{encryption:{storageKey:n}}}}function R(e,n,c){const{domain:r,database:u,compute:d,cdn:a,environment:p,tierPreset:i}=c,m=i?k(u,i):u,s=i?A(d,i):d,t={type:e,name:n,domain:r,database:m?E(m):void 0,compute:s?{server:s}:void 0,cdn:a?{domainNames:a.domainNames,certificateArn:a.certificateArn}:void 0,environment:p},o=y.safeParse(t);return o.success?l(o.data):f(new Error(`Invalid pattern config: ${o.error.message}`))}export{$ as planOpenNextResources};
|
|
@@ -1,56 +1,10 @@
|
|
|
1
1
|
import { type UserServiceConfig, type AppType } from "../presets/tierPresets.js";
|
|
2
|
-
import { type PatternTypeWithCustom } from "../presets/patternTierPresets.js";
|
|
3
|
-
import { type PatternType } from "../schemas/constants.js";
|
|
4
2
|
import { type Result } from "../types/Result.js";
|
|
5
3
|
import type { ApplicationResourcePlan } from "../schemas/resourceSchemas.js";
|
|
6
4
|
export declare function planApplicationResources(appName: string, appType: AppType, includeDatabase?: boolean, services?: UserServiceConfig[], snapshotOptions?: {
|
|
7
5
|
snapshotIdentifier?: string;
|
|
8
6
|
snapshotUsername?: string;
|
|
9
7
|
}): ApplicationResourcePlan;
|
|
10
|
-
export interface OpenNextResourceOptions {
|
|
11
|
-
/** Pattern tier: lightweight, standard, resilient, or custom */
|
|
12
|
-
tier?: PatternTypeWithCustom;
|
|
13
|
-
/** Custom domain (auto-creates certificate + DNS) */
|
|
14
|
-
domain?: string;
|
|
15
|
-
/** Database configuration (uses tier defaults if not specified) */
|
|
16
|
-
database?: {
|
|
17
|
-
type?: "Instance" | "Aurora";
|
|
18
|
-
instanceType?: string;
|
|
19
|
-
databaseName?: string;
|
|
20
|
-
publiclyAccessible?: boolean;
|
|
21
|
-
allowedIpCidr?: string;
|
|
22
|
-
backupRetention?: number;
|
|
23
|
-
deletionProtection?: boolean;
|
|
24
|
-
encryption?: {
|
|
25
|
-
useCMK: true;
|
|
26
|
-
} | false;
|
|
27
|
-
};
|
|
28
|
-
/** Compute (Lambda) configuration (uses tier defaults if not specified) */
|
|
29
|
-
compute?: {
|
|
30
|
-
memorySize?: number;
|
|
31
|
-
timeout?: number;
|
|
32
|
-
};
|
|
33
|
-
/** CDN configuration (advanced - prefer `domain` for simple setup) */
|
|
34
|
-
cdn?: {
|
|
35
|
-
domainNames?: string[];
|
|
36
|
-
certificateArn?: string;
|
|
37
|
-
};
|
|
38
|
-
/** Additional environment variables */
|
|
39
|
-
environment?: Record<string, string>;
|
|
40
|
-
/** Resource tags */
|
|
41
|
-
tags?: Record<string, string>;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Plan resources for OpenNext patterns (Next.js/Payload).
|
|
45
|
-
*
|
|
46
|
-
* All OpenNext patterns use the PatternFactory approach, generating a single
|
|
47
|
-
* `PatternFactory.build()` call. The pattern class internally handles all
|
|
48
|
-
* infrastructure (database, S3, DynamoDB, SQS, Lambdas, CDN).
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* const plan = planOpenNextResources("my-cms", "payload", { tier: "standard" });
|
|
52
|
-
*/
|
|
53
|
-
export declare function planOpenNextResources(appName: string, pattern: PatternType, options?: OpenNextResourceOptions): Result<ApplicationResourcePlan, Error>;
|
|
54
8
|
export interface GenerationOptions {
|
|
55
9
|
/** Resource name mapping from old names to new names (for custom code repositioning) */
|
|
56
10
|
resourceMapping?: Map<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TIER_PRESETS as
|
|
1
|
+
import{TIER_PRESETS as m,getDefaultDatabaseTypeForTier as C,applyTierDefaultsToServices as b}from"../presets/tierPresets.js";import{COMPUTE_TYPE as g}from"../schemas/constants.js";import{success as u,failure as l}from"../types/Result.js";import{injectCustomCodeBlocks as P}from"../ast/astCodeInjection.js";import{toVariableName as d,toValidDatabaseName as k,generateImports as h,generateAppInit as D,generateTags as E,generateNetworkCode as f,generateDatabaseCode as R,generateS3Code as S,generateDynamoDBCode as T,generateSQSCode as I,generateComputeCode as w,generateCDNCode as B,collectCdnReferencedResources as j,usesPatternApproach as y,generatePatternCodeWithComments as U}from"../generation/index.js";function N(e,n,r=!0,o,t){const s={appName:e,type:n,database:[],s3:[],compute:[]};if(n==="custom")return s;const c=n,a=m[c];return{...s,database:$(e,a,c,r,t),compute:A(e,a,c,r,o),network:a.network,backup:a.backup}}function $(e,n,r,o,t){const s=C(r),c=n.database[s];return!o||c===null?[]:[{name:e,type:s,databaseName:k(e),variableName:`${d(e)}Database`,...c,...t?.snapshotIdentifier!==void 0&&{snapshotIdentifier:t.snapshotIdentifier},...t?.snapshotUsername!==void 0&&{snapshotUsername:t.snapshotUsername}}]}function p(e,n){if(!(e===void 0&&n===void 0))return{scaling:{...e!==void 0&&{minCapacity:e},...n!==void 0&&{maxCapacity:n}}}}function v(e,n){const{minCapacity:r,maxCapacity:o,...t}=e,s=n?.containerPort??3e3;return{...t,dockerfilePath:n?.dockerfilePath,needsDatabaseConnection:n?.needsDatabaseConnection,containers:[{port:s}],...p(r,o)}}function A(e,n,r,o,t){const s=n.compute.ecs,c=t&&t.length>0?b(r,t):s.services.map((a,i)=>({...a,name:i===0?"api":`service-${i+1}`}));return[{name:e,type:g.ECS,needsConnection:o,connectedDatabase:o?[e]:void 0,variableName:`${d(e)}Compute`,cluster:s.cluster,services:c.map((a,i)=>v(a,t?.[i]))}]}function Q(e,n){const r=[h(e),D(e),E(e)];if(y(e))r.push(U(e),f(e));else{const t=j(e);r.push(f(e),R(e),S(e),T(e),I(e),w(e,t),B(e))}const o=r.join("");if(e.customCodeBlocks&&e.customCodeBlocks.length>0){const t=P(o,e.customCodeBlocks,n?.resourceMapping);return t.success?u(t.content):l(new Error(`Custom code injection failed: ${t.error??"unknown error"}`))}return u(o)}export{Q as generateInfrastructureFromPlan,N as planApplicationResources};
|