@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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type namedTypes as n } from "ast-types";
|
|
2
|
+
/** Quote styles recognised by the builders — mirrors T4b's detectQuoteStyle. */
|
|
3
|
+
export type QuoteStyle = "double" | "single";
|
|
4
|
+
/**
|
|
5
|
+
* Key/value pair for {@link buildFactoryStatement}. Keys are identifier
|
|
6
|
+
* names (already validated upstream — no quoting logic here).
|
|
7
|
+
*/
|
|
8
|
+
export interface ObjectPropertyInput {
|
|
9
|
+
key: string;
|
|
10
|
+
value: n.Property["value"];
|
|
11
|
+
}
|
|
12
|
+
export interface BuildFactoryStatementParams {
|
|
13
|
+
/** Factory identifier, e.g. `"DatabaseFactory"`. */
|
|
14
|
+
factory: string;
|
|
15
|
+
/** Resource name, used as the first argument literal. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Configuration object properties. */
|
|
18
|
+
properties: ObjectPropertyInput[];
|
|
19
|
+
/** Quote style for NEW string literals the builder synthesises. */
|
|
20
|
+
quoteStyle: QuoteStyle;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Build an `ExpressionStatement` wrapping `XFactory.build("Name", { … })`.
|
|
24
|
+
*
|
|
25
|
+
* The factory identifier is emitted as a bare `Identifier` so the caller
|
|
26
|
+
* controls whether to add an `ImportDeclaration` separately (via
|
|
27
|
+
* {@link buildImportDeclaration} / {@link appendSpecifier}). The resource
|
|
28
|
+
* name literal honours `quoteStyle` via `extra.raw` on the literal.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildFactoryStatement(params: BuildFactoryStatementParams): n.ExpressionStatement;
|
|
31
|
+
/**
|
|
32
|
+
* Build an object `Property` with a bare-identifier key. If `key` is
|
|
33
|
+
* not a valid JS identifier (e.g. contains a hyphen), the key is
|
|
34
|
+
* emitted as a quoted StringLiteral instead, honouring `quoteStyle`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildObjectProperty(key: string, value: n.Property["value"], quoteStyle: QuoteStyle): n.Property;
|
|
37
|
+
/**
|
|
38
|
+
* Build an `ImportDeclaration` for `import { a, b } from "module"` with
|
|
39
|
+
* the supplied specifier names. The module source literal honours
|
|
40
|
+
* `quoteStyle`. Specifiers are emitted as `ImportSpecifier` (named
|
|
41
|
+
* imports only) — namespace or default imports are out of scope for
|
|
42
|
+
* the Phase 1 codemod surface.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildImportDeclaration(specifiers: string[], module: string, quoteStyle?: QuoteStyle): n.ImportDeclaration;
|
|
45
|
+
/**
|
|
46
|
+
* Build a `MemberExpression` for `object.property` shapes such as
|
|
47
|
+
* `app.addStorage(...)`. Both arguments are bare identifiers — the
|
|
48
|
+
* engine never emits computed member access.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildMemberExpression(object: string, property: string): n.MemberExpression;
|
|
51
|
+
/**
|
|
52
|
+
* Mutate `importDecl` to add a named `ImportSpecifier` for `name`.
|
|
53
|
+
* Dedupes by the imported (NOT local) identifier — re-adding an
|
|
54
|
+
* existing specifier is a no-op. Preserves specifier order so the
|
|
55
|
+
* printed output stays stable across repeated invocations.
|
|
56
|
+
*/
|
|
57
|
+
export declare function appendSpecifier(importDecl: n.ImportDeclaration, name: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{builders as i}from"ast-types";function d(e){const t=i.memberExpression(i.identifier(e.factory),i.identifier("build"),!1),r=c(e.name,e.quoteStyle),n=i.objectExpression(e.properties.map(o=>f(o.key,o.value,e.quoteStyle))),s=i.callExpression(t,[r,n]);return i.expressionStatement(s)}function f(e,t,r){const n=u(e)?i.identifier(e):c(e,r);return i.property("init",n,t)}function b(e,t,r="double"){const n=e.map(o=>i.importSpecifier(i.identifier(o))),s=c(t,r);return i.importDeclaration(n,s)}function m(e,t){return i.memberExpression(i.identifier(e),i.identifier(t),!1)}function x(e,t){Array.isArray(e.specifiers)||(e.specifiers=[]);for(const r of e.specifiers)if(a(r)&&r.imported.name===t)return;e.specifiers.push(i.importSpecifier(i.identifier(t)))}function c(e,t){const r=t==="single"?"'":'"',n=`${r}${p(e,t)}${r}`;return i.stringLiteral.from({value:e,extra:{rawValue:e,raw:n}})}function p(e,t){const r=e.replace(/\\/g,"\\\\");return t==="single"?r.replace(/'/g,"\\'"):r.replace(/"/g,'\\"')}function u(e){return/^[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}]*$/u.test(e)}function a(e){return e!==null&&typeof e=="object"&&"type"in e&&e.type==="ImportSpecifier"}export{x as appendSpecifier,d as buildFactoryStatement,b as buildImportDeclaration,m as buildMemberExpression,f as buildObjectProperty};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { parse, type ParsedFile, type ParseError } from "./parse.js";
|
|
2
|
+
export { detectLineTerminator, detectQuoteStyle, printFile } from "./print.js";
|
|
3
|
+
export { appendSpecifier, buildFactoryStatement, buildImportDeclaration, buildMemberExpression, buildObjectProperty, type BuildFactoryStatementParams, type ObjectPropertyInput, type QuoteStyle, } from "./builders.js";
|
|
4
|
+
export { locateByLineColumn, locateByRange, type LineColumnHint, type NodeLocation, } from "./locateByRange.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parse as r}from"./parse.js";import{detectLineTerminator as i,detectQuoteStyle as p,printFile as a}from"./print.js";import{appendSpecifier as n,buildFactoryStatement as m,buildImportDeclaration as c,buildMemberExpression as d,buildObjectProperty as b}from"./builders.js";import{locateByLineColumn as f,locateByRange as x}from"./locateByRange.js";export{n as appendSpecifier,m as buildFactoryStatement,c as buildImportDeclaration,d as buildMemberExpression,b as buildObjectProperty,i as detectLineTerminator,p as detectQuoteStyle,f as locateByLineColumn,x as locateByRange,r as parse,a as printFile};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type * as recast from "recast";
|
|
2
|
+
import type { NodeLocation } from "../types.js";
|
|
3
|
+
export type { NodeLocation } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Optional line/column coordinates used by the fallback path. Line is
|
|
6
|
+
* 1-based (matching recast's `loc.start.line`); column is 0-based
|
|
7
|
+
* (matching recast's `loc.start.column`).
|
|
8
|
+
*/
|
|
9
|
+
export interface LineColumnHint {
|
|
10
|
+
line?: number;
|
|
11
|
+
column?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Minimal AST-node shape the walkers read. Mirrors the shallow record
|
|
15
|
+
* used by `lineColumnFallback.test.ts` and `print.ts` — keeps this file
|
|
16
|
+
* free of `@babel/types` as a runtime dependency.
|
|
17
|
+
*/
|
|
18
|
+
interface NodeShape {
|
|
19
|
+
type?: string;
|
|
20
|
+
start?: number | null;
|
|
21
|
+
end?: number | null;
|
|
22
|
+
value?: unknown;
|
|
23
|
+
loc?: {
|
|
24
|
+
start?: {
|
|
25
|
+
line?: number;
|
|
26
|
+
column?: number;
|
|
27
|
+
};
|
|
28
|
+
end?: {
|
|
29
|
+
line?: number;
|
|
30
|
+
column?: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
/** Parsed file shape, mirroring `parse.ts`'s `ParsedFile` without importing it. */
|
|
36
|
+
type ParsedFile = ReturnType<typeof recast.parse>;
|
|
37
|
+
/**
|
|
38
|
+
* Locate an `ast-types` node whose byte range matches `loc` exactly.
|
|
39
|
+
* On miss, invoke the line/column fallback if `hint` carries coords.
|
|
40
|
+
*
|
|
41
|
+
* Returns `undefined` on total miss (neither exact nor fallback found a
|
|
42
|
+
* candidate) — the caller decides whether that is an error or a skip.
|
|
43
|
+
*
|
|
44
|
+
* Semantic contract: the `length` field MUST equal `node.end - node.start`
|
|
45
|
+
* for the matching node. For `StringLiteral` nodes this span INCLUDES the
|
|
46
|
+
* enclosing quote characters, matching `locateByShape`'s use of
|
|
47
|
+
* `firstArg.getWidth()` (ts-morph) — so a `StringLiteral` carrying
|
|
48
|
+
* `"PrimaryDb"` has `length === 11` (9 letters + 2 quotes).
|
|
49
|
+
*/
|
|
50
|
+
export declare function locateByRange(file: ParsedFile, loc: NodeLocation, hint?: LineColumnHint): NodeShape | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Fallback locator ported verbatim from Phase 0
|
|
53
|
+
* `__tests__/lineColumnFallback.test.ts`'s `findLocationByLineColumn`.
|
|
54
|
+
*
|
|
55
|
+
* Walks the AST for `StringLiteral` nodes whose `value` equals
|
|
56
|
+
* `loc.symbolName` and whose `loc.start.line` is within ±2 lines of
|
|
57
|
+
* `loc.line`. Disambiguates same-line candidates by column proximity,
|
|
58
|
+
* then by earliest `start` offset for determinism.
|
|
59
|
+
*
|
|
60
|
+
* Adaptation from Phase 0: return type becomes the `ast-types` node
|
|
61
|
+
* itself (the production contract) rather than `{ start, length }` (the
|
|
62
|
+
* Phase 0 test shape). The parity test in `locateByRange.test.ts`
|
|
63
|
+
* asserts the adapted result shape still round-trips byte-for-byte.
|
|
64
|
+
*/
|
|
65
|
+
export declare function locateByLineColumn(file: ParsedFile, loc: NodeLocation & LineColumnHint): NodeShape | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function b(u,r,i){const n=m(u,r);if(n!==void 0)return n;if(i?.line!==void 0)return p(u,{...r,...i})}function p(u,r){if(r.line===void 0)return;const i=r.line,n=r.column??0,e=[];if(y(u,t=>{if(t.type!=="StringLiteral"||typeof t.value!="string"||t.value!==r.symbolName||typeof t.start!="number"||typeof t.end!="number")return;const s=t.loc?.start?.line,f=t.loc?.start?.column;typeof s!="number"||typeof f!="number"||Math.abs(s-i)>2||e.push({node:t,line:s,column:f,start:t.start})}),e.length!==0)return e.sort((t,s)=>{const f=Math.abs(t.line-i),o=Math.abs(s.line-i);if(f!==o)return f-o;const c=Math.abs(t.column-n),l=Math.abs(s.column-n);return c!==l?c-l:t.start-s.start}),e[0]?.node}function m(u,r){const i=r.start+r.length;let n;return y(u,e=>{n===void 0&&(typeof e.start!="number"||typeof e.end!="number"||e.start===r.start&&e.end===i&&(n=e))}),n}function y(u,r){const i=[u];for(;i.length>0;){const n=i.pop();if(!(!a(n)||typeof n.type!="string")){r(n);for(const e of Object.keys(n)){if(e==="loc"||e==="comments"||e==="tokens")continue;const t=n[e];if(Array.isArray(t))for(const s of t)a(s)&&typeof s.type=="string"&&i.push(s);else a(t)&&typeof t.type=="string"&&i.push(t)}}}}function a(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)}export{p as locateByLineColumn,b as locateByRange};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as recast from "recast";
|
|
2
|
+
import { type Result } from "../../types/Result.js";
|
|
3
|
+
import type { ParseError } from "../types.js";
|
|
4
|
+
export type { ParseError } from "../types.js";
|
|
5
|
+
export type ParsedFile = ReturnType<typeof recast.parse>;
|
|
6
|
+
/**
|
|
7
|
+
* Parse `content` with the correct recast parser for the file shape.
|
|
8
|
+
*
|
|
9
|
+
* Dispatch rules (Phase 0 carry-over #1):
|
|
10
|
+
* - `filePath` ends in `.tsx` OR `content` matches the JSX heuristic
|
|
11
|
+
* → `recast/parsers/babel-ts`.
|
|
12
|
+
* - Otherwise → try `recast/parsers/typescript`; on failure fall back
|
|
13
|
+
* to `recast/parsers/babel-ts` ONCE. If both fail, surface the
|
|
14
|
+
* original typescript-parser error via `ParseError`.
|
|
15
|
+
*
|
|
16
|
+
* Never throws — every failure path returns `failure(ParseError)`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parse(content: string, filePath?: string): Result<ParsedFile, ParseError>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as d from"recast";import x from"recast/parsers/typescript.js";import a from"recast/parsers/babel-ts.js";import{failure as E,success as y}from"../../types/Result.js";const m=1,l=120;function I(n,t){if((t?.endsWith(".tsx")??!1)||b(n))return f(n,a,t);const e=f(n,x,t);if(e.success)return e;const s=f(n,a,t);return s.success?s:e}function b(n){return/<[A-Z][A-Za-z0-9]*[\s/>]|<>/.test(n)}function f(n,t,r){try{const e=d.parse(n,{parser:t});return y(e)}catch(e){return E(g(e,n,r))}}function g(n,t,r){const e=n instanceof Error?n.message:String(n),s=S(n),o=s?.line,c=s?.column;return{kind:"ParseError",file:r,line:o,column:c,message:e,sourceSnippet:h(t,o)}}function S(n){if(typeof n!="object"||n===null)return;const t=n.loc;if(typeof t!="object"||t===null)return;const r=t.line,e=t.column;return{line:typeof r=="number"?r:void 0,column:typeof e=="number"?e:void 0}}function h(n,t){const r=n.split(/\r?\n/);if(r.length===0)return"";const e=t!==void 0&&t>=1&&t<=r.length?t-1:0,s=Math.max(0,e-m),o=Math.min(r.length-1,e+m),c=[];for(let u=s;u<=o;u+=1){const i=r[u]??"",p=i.length>l?`${i.slice(0,l)}\u2026`:i;c.push(p)}return c.join(`
|
|
2
|
+
`)}export{I as parse};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as recast from "recast";
|
|
2
|
+
/**
|
|
3
|
+
* Print `ast` back to source, preserving the original line terminator
|
|
4
|
+
* and a leading UTF-8 BOM when the caller passes them via `source`.
|
|
5
|
+
*
|
|
6
|
+
* `source` is the ORIGINAL file text (pre-parse). We inspect it twice:
|
|
7
|
+
* 1. BOM detection via `charCodeAt(0)`. Recast's reprint normally
|
|
8
|
+
* carries the BOM through via its reuse-original-whitespace cache,
|
|
9
|
+
* so we only re-prepend `\uFEFF` when the printed output has lost
|
|
10
|
+
* it. The idempotent check avoids doubling the BOM on the common
|
|
11
|
+
* pure-round-trip path.
|
|
12
|
+
* 2. Line-terminator detection via `detectLineTerminator(source)` —
|
|
13
|
+
* the first `\r\n` sighting wins. Passed through to
|
|
14
|
+
* `recast.print`'s `lineTerminator` option so CRLF fixtures survive
|
|
15
|
+
* on non-Windows hosts.
|
|
16
|
+
*
|
|
17
|
+
* The printer consults the AST's dominant quote style via
|
|
18
|
+
* `detectQuoteStyle` and threads it through `recast.print`'s `quote`
|
|
19
|
+
* option. Unchanged nodes reprint from recast's whitespace cache (so
|
|
20
|
+
* byte-equality round-trip is preserved regardless of the option),
|
|
21
|
+
* while newly-synthesised nodes without a cached print inherit the
|
|
22
|
+
* dominant style — honouring extra.raw on builder-emitted literals.
|
|
23
|
+
*/
|
|
24
|
+
export declare function printFile(ast: recast.types.ASTNode, source: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Detect the dominant line terminator in `source`. The first `\r\n`
|
|
27
|
+
* sighting wins; otherwise returns `\n`. Defaults to `\n` for empty or
|
|
28
|
+
* single-line input so recast's printer has a deterministic answer.
|
|
29
|
+
*
|
|
30
|
+
* This MUST NOT consult `os.EOL` — Phase 0 proved that relying on
|
|
31
|
+
* `os.EOL` silently rewrites CRLF fixtures to LF on Linux CI and LF
|
|
32
|
+
* fixtures to CRLF on Windows CI.
|
|
33
|
+
*/
|
|
34
|
+
export declare function detectLineTerminator(source: string): "\n" | "\r\n";
|
|
35
|
+
/**
|
|
36
|
+
* Count `StringLiteral` nodes in `ast` by quote style (read from
|
|
37
|
+
* `extra.raw`'s first character) and return the majority. Ties break
|
|
38
|
+
* to `"double"`; a source with zero string literals also returns
|
|
39
|
+
* `"double"` as a neutral default.
|
|
40
|
+
*
|
|
41
|
+
* Consumed by T7 builders when they emit new literals. We deliberately
|
|
42
|
+
* do NOT pass the result back into `recast.print({ quote })` — recast's
|
|
43
|
+
* reprint mechanics keep each original literal's quotes verbatim, and
|
|
44
|
+
* forcing a global style would violate byte-equality round-trip.
|
|
45
|
+
*/
|
|
46
|
+
export declare function detectQuoteStyle(ast: recast.types.ASTNode): "double" | "single";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import*as u from"recast";const p="\uFEFF",f=65279;function m(t,c){const o=a(c),e=l(t),r=u.print(t,{quote:e,lineTerminator:o,trailingComma:!0}).code,n=c.charCodeAt(0)===f,i=r.charCodeAt(0)===f;return n&&!i?`${p}${r}`:r}function a(t){return t.includes(`\r
|
|
2
|
+
`)?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`}function l(t){let c=0,o=0;return y(t,e=>{if(e.type!=="StringLiteral"&&e.type!=="Literal")return;const r=e.extra;if(!s(r))return;const n=r.raw;if(typeof n!="string"||n.length===0)return;const i=n.charAt(0);i==="'"?c+=1:i==='"'&&(o+=1)}),c>o?"single":"double"}function y(t,c){const o=[t];for(;o.length>0;){const e=o.pop();if(!(!s(e)||typeof e.type!="string")){c(e);for(const r of Object.keys(e)){if(r==="loc"||r==="comments"||r==="tokens")continue;const n=e[r];if(Array.isArray(n))for(const i of n)s(i)&&typeof i.type=="string"&&o.push(i);else s(n)&&typeof n.type=="string"&&o.push(n)}}}}function s(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}export{a as detectLineTerminator,l as detectQuoteStyle,m as printFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(t){return`${t}.bak`}function a(t,r){const n=r.toISOString().replaceAll(":","");return`${t}/${n}.ts`}export{o as backupPath,a as historyEntryPath};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { addResource, type AddResourceError, type AddResourceSuccess, } from "./edits/addResource.js";
|
|
2
|
+
export { removeResource, type RemoveResourceError, type RemoveResourceSuccess, } from "./edits/removeResource.js";
|
|
3
|
+
export { modifyResource, type ModifyResourceError, type ModifyResourceSuccess, } from "./edits/modifyResource.js";
|
|
4
|
+
export { listResources, type ListResourcesError } from "./listResources.js";
|
|
5
|
+
export { parse } from "./fileRewriter/parse.js";
|
|
6
|
+
export { StatementTypeSchema } from "./types.js";
|
|
7
|
+
export type { AddOptions, CodemodError, CodemodSuccess, DuplicateResourceError, InvalidPropertyError, LinesChanged, ModifyOptions, NodeLocation, ParseError, ReferenceLocation, ReferencesRemainError, RemoveOptions, ResourceListing, ResourceListingEntry, ResourceName, ResourceNotFoundError, SemanticQueryError, StatementType, TemplateLiteralNameError, } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{addResource as r}from"./edits/addResource.js";import{removeResource as t}from"./edits/removeResource.js";import{modifyResource as f}from"./edits/modifyResource.js";import{listResources as x}from"./listResources.js";import{parse as a}from"./fileRewriter/parse.js";import{StatementTypeSchema as R}from"./types.js";export{R as StatementTypeSchema,r as addResource,x as listResources,f as modifyResource,a as parse,t as removeResource};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Result } from "../types/Result.js";
|
|
2
|
+
import type { ResourceListing, SemanticQueryError, TemplateLiteralNameError } from "./types.js";
|
|
3
|
+
export type ListResourcesError = TemplateLiteralNameError | SemanticQueryError;
|
|
4
|
+
export declare function listResources(content: string, filePath?: string): Result<ResourceListing, ListResourcesError>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{failure as a,success as c}from"../types/Result.js";import{DEFAULT_FILE_PATH as m}from"./_internal.js";import{locateAllShapes as l}from"./semanticIndex/index.js";function f(t,s=m){const r=l(t,s);if(!r.success)return a(r.error);const o=r.data.map(e=>({type:e.type,name:e.symbolName,filePath:e.filePath,start:e.start,length:e.length}));return c({filePath:s,resources:o})}export{f as listResources};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Result } from "../../types/Result.js";
|
|
2
|
+
import type { NodeLocation, ReferenceLocation, SemanticQueryError } from "../types.js";
|
|
3
|
+
export type { ReferenceLocation } from "../types.js";
|
|
4
|
+
export type FindReferencesError = SemanticQueryError;
|
|
5
|
+
/**
|
|
6
|
+
* Resolves every reference to the variable declaration identified by
|
|
7
|
+
* `declaration.start` within `content`. Uses ts-morph's language-service
|
|
8
|
+
* reference finder and filters the results by symbol identity so shadowed
|
|
9
|
+
* bindings with the same text never cross-pollinate.
|
|
10
|
+
*
|
|
11
|
+
* Returns `success([])` when the declaration has no symbol (e.g. destructuring
|
|
12
|
+
* initialiser) or no live references. Returns `failure(...)` only when
|
|
13
|
+
* ts-morph throws during traversal or the content cannot be loaded.
|
|
14
|
+
*/
|
|
15
|
+
export declare function findReferences(content: string, declaration: NodeLocation, filePath?: string): Result<ReferenceLocation[], FindReferencesError>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Node as d,SyntaxKind as m}from"ts-morph";import{failure as a,success as l}from"../../types/Result.js";import{DEFAULT_FILE_PATH as y}from"../_internal.js";import{getProject as S}from"./projectCache.js";const f=120;function T(r,n,e=y){let i;try{i=S().createSourceFile(e,r,{overwrite:!0})}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to create source file",cause:t})}let o;try{o=p(i,n.start)}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to resolve declaration at the supplied offset",cause:t})}if(o===void 0)return l([]);let s;try{s=o.getSymbol()}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to resolve symbol for declaration",cause:t})}if(s===void 0)return l([]);let c;try{c=o.findReferencesAsNodes()}catch(t){return a({kind:"SemanticQueryError",reason:"findReferencesAsNodes failed",cause:t})}const u=[];try{for(const t of c)g(t,s)&&(F(t,o)||u.push(b(t)))}catch(t){return a({kind:"SemanticQueryError",reason:"Failed to map references to plain-data locations",cause:t})}return l(u)}function p(r,n){const e=r.getDescendantAtPos(n);return e===void 0?void 0:d.isVariableDeclaration(e)?e:e.getFirstAncestorByKind(m.VariableDeclaration)}function g(r,n){const e=r.getSymbol();return e===void 0?!1:e===n?!0:e.compilerSymbol===n.compilerSymbol}function F(r,n){const e=n.getNameNode();return r===e||r.getStart()===e.getStart()}function b(r){const n=r.getStart(),{line:e,column:i}=r.getSourceFile().getLineAndColumnAtPos(n),c=r.getSourceFile().getFullText().split(`
|
|
2
|
+
`)[e-1]??"",u=c.length>f?c.slice(0,f):c;return{line:e,column:i,context:u}}export{T as findReferences};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { locateByShape, locateAllShapes, type NodeLocation, type StatementType, type LocateByShapeError, } from "./locateByShape.js";
|
|
2
|
+
export { findReferences, type ReferenceLocation, type FindReferencesError, } from "./findReferences.js";
|
|
3
|
+
export { getProject, resetProjectForTest } from "./projectCache.js";
|
|
4
|
+
export { listImports, type ImportInfo, type ListImportsError, } from "./listImports.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{locateByShape as r,locateAllShapes as t}from"./locateByShape.js";import{findReferences as f}from"./findReferences.js";import{getProject as c,resetProjectForTest as l}from"./projectCache.js";import{listImports as a}from"./listImports.js";export{f as findReferences,c as getProject,a as listImports,t as locateAllShapes,r as locateByShape,l as resetProjectForTest};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Result } from "../../types/Result.js";
|
|
2
|
+
import type { NodeLocation, SemanticQueryError } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* `specifiers` contains the IMPORTED names (the original identifier on
|
|
5
|
+
* the module), not the local alias — matching the dedupe contract in
|
|
6
|
+
* `fileRewriter.appendSpecifier`.
|
|
7
|
+
*/
|
|
8
|
+
export interface ImportInfo {
|
|
9
|
+
module: string;
|
|
10
|
+
specifiers: string[];
|
|
11
|
+
location: NodeLocation;
|
|
12
|
+
}
|
|
13
|
+
export type ListImportsError = SemanticQueryError;
|
|
14
|
+
/**
|
|
15
|
+
* Walk every top-level `ImportDeclaration` in `content` and return a
|
|
16
|
+
* plain-data `ImportInfo[]` in source order. Declarations with a
|
|
17
|
+
* non-literal module specifier are skipped; declarations with no named
|
|
18
|
+
* bindings (side-effect `import "x"`, default-only, namespace-only) are
|
|
19
|
+
* included with an empty `specifiers` array so callers can still detect
|
|
20
|
+
* their presence.
|
|
21
|
+
*
|
|
22
|
+
* Never throws — every failure path returns `failure(ListImportsError)`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function listImports(content: string, filePath?: string): Result<ImportInfo[], ListImportsError>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as s}from"ts-morph";import{failure as c,success as a}from"../../types/Result.js";import{DEFAULT_FILE_PATH as u}from"../_internal.js";import{getProject as m}from"./projectCache.js";function S(t,i=u){let r;try{r=m().createSourceFile(i,t,{overwrite:!0})}catch(e){return c({kind:"SemanticQueryError",reason:"Failed to create source file",cause:e})}const o=[];try{for(const e of r.getImportDeclarations()){const n=f(e,i);n!==void 0&&o.push(n)}}catch(e){return c({kind:"SemanticQueryError",reason:"Failed to enumerate import declarations",cause:e})}return a(o)}function f(t,i){const r=t.getModuleSpecifier();if(!s.isStringLiteral(r))return;const o=r.getLiteralValue(),e=t.getNamedImports().map(n=>n.getNameNode().getText());return{module:o,specifiers:e,location:{filePath:i,start:t.getStart(),length:t.getWidth(),symbolName:o}}}export{S as listImports};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Result } from "../../types/Result.js";
|
|
2
|
+
import type { NodeLocation, StatementType, TemplateLiteralNameError, SemanticQueryError } from "../types.js";
|
|
3
|
+
export type { NodeLocation, StatementType } from "../types.js";
|
|
4
|
+
export type LocateByShapeError = TemplateLiteralNameError | SemanticQueryError;
|
|
5
|
+
/**
|
|
6
|
+
* Locates a single `XFactory.build("Name", ...)` call matching the
|
|
7
|
+
* supplied `{ type, name }` query. Returns `success(undefined)` when
|
|
8
|
+
* the file contains no matching call; returns `failure(...)` only for
|
|
9
|
+
* template-literal factory names (Joint 1 rejection) or a genuine
|
|
10
|
+
* semantic-query error from ts-morph.
|
|
11
|
+
*/
|
|
12
|
+
export declare function locateByShape(content: string, query: {
|
|
13
|
+
type: StatementType;
|
|
14
|
+
name: string;
|
|
15
|
+
}, filePath?: string): Result<NodeLocation | undefined, LocateByShapeError>;
|
|
16
|
+
/**
|
|
17
|
+
* Walks every call expression in the source and returns a
|
|
18
|
+
* `NodeLocation & { type }` for each `XFactory.build("Name", ...)`
|
|
19
|
+
* shape. The traversal descends into `IfStatement`, `Block`,
|
|
20
|
+
* `ForStatement`, and function bodies via `forEachDescendant`.
|
|
21
|
+
*
|
|
22
|
+
* Emits `TemplateLiteralNameError` for the first non-plain-string
|
|
23
|
+
* factory name encountered — the engine cannot safely locate a
|
|
24
|
+
* template-literal name by shape.
|
|
25
|
+
*/
|
|
26
|
+
export declare function locateAllShapes(content: string, filePath?: string): Result<Array<NodeLocation & {
|
|
27
|
+
type: StatementType;
|
|
28
|
+
}>, LocateByShapeError>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as s,SyntaxKind as a}from"ts-morph";import{failure as c,success as l}from"../../types/Result.js";import{DEFAULT_FILE_PATH as u}from"../_internal.js";import{getProject as m}from"./projectCache.js";const f={DatabaseFactory:"database",StorageFactory:"storage",ComputeFactory:"compute",MessagingFactory:"messaging",CdnFactory:"cdn",NetworkFactory:"network",PatternFactory:"pattern"};function g(n){return Object.prototype.hasOwnProperty.call(f,n)}function b(n,t,e=u){const o=y(n,e);if(!o.success)return o;const r=o.data.find(i=>i.type===t.type&&i.symbolName===t.name);return l(r)}function y(n,t=u){let e;try{e=m().createSourceFile(t,n,{overwrite:!0})}catch(r){return c({kind:"SemanticQueryError",reason:"Failed to create source file",cause:r})}const o=[];try{e.forEachDescendant(r=>{if(!s.isCallExpression(r))return;const i=h(r);if(i!=="not-factory-call"&&i.kind!=="binding-pattern-declared"){if(i.kind==="template-literal-name")throw new d(r,i.type);o.push({filePath:t,start:i.nameStart,length:i.nameLength,symbolName:i.name,type:i.type})}})}catch(r){return r instanceof d?c(r.toError(t)):c({kind:"SemanticQueryError",reason:"forEachDescendant traversal failed",cause:r})}return l(o)}function h(n){const t=n.getExpression();if(!s.isPropertyAccessExpression(t))return"not-factory-call";const e=E(t);if(e===void 0||F(n))return"not-factory-call";if(S(n))return{kind:"binding-pattern-declared"};const r=n.getArguments()[0];return r===void 0?"not-factory-call":s.isTemplateExpression(r)||s.isNoSubstitutionTemplateLiteral(r)?{kind:"template-literal-name",type:e}:s.isStringLiteral(r)?{kind:"match",type:e,name:r.getLiteralValue(),nameStart:r.getStart(),nameLength:r.getWidth()}:"not-factory-call"}function E(n){const t=n.getExpression();if(!s.isIdentifier(t)||n.getName()!=="build")return;const e=t.getText();if(g(e))return f[e]}function F(n){let t=n.getParent();for(;t!==void 0;){const e=t.getKind();if(e===a.TypeReference||e===a.TypeQuery||e===a.TypeLiteral||e===a.TypeAliasDeclaration||e===a.InterfaceDeclaration||e===a.TypeParameter||e===a.PropertySignature||e===a.MethodSignature||e===a.JsxOpeningElement||e===a.JsxClosingElement||e===a.JsxSelfClosingElement||e===a.JsxAttribute)return!0;t=t.getParent()}return!1}function S(n){const t=n.getFirstAncestorByKind(a.VariableDeclaration);if(t===void 0)return!1;const o=t.getNameNode().getKind();return o===a.ObjectBindingPattern||o===a.ArrayBindingPattern}class d extends Error{call;type;constructor(t,e){super("Template-literal factory name detected"),this.call=t,this.type=e,this.name="TemplateLiteralMarker"}toError(t){const o=this.call.getArguments()[0]?.getStart()??this.call.getStart(),r=this.call.getSourceFile(),{line:i,column:p}=r.getLineAndColumnAtPos(o);return{kind:"TemplateLiteralNameError",file:t,line:i,column:p,suggestion:"Replace the template literal with a plain string literal so the resource name can be resolved statically."}}}export{y as locateAllShapes,b as locateByShape};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Project } from "ts-morph";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the shared ts-morph `Project`, creating it lazily on first call.
|
|
4
|
+
* Subsequent calls reuse the same instance.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getProject(): Project;
|
|
7
|
+
/**
|
|
8
|
+
* Clears the cached `Project`. Tests call this in `beforeEach` to
|
|
9
|
+
* guarantee isolation across describe blocks that exercise different
|
|
10
|
+
* source shapes.
|
|
11
|
+
*
|
|
12
|
+
* @internal — production code must not depend on this.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resetProjectForTest(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Project as t,ScriptTarget as r}from"ts-morph";let e;function i(){return e===void 0&&(e=new t({useInMemoryFileSystem:!0,skipAddingFilesFromTsConfig:!0,compilerOptions:{target:r.ES2022}})),e}function n(){e=void 0}export{i as getProject,n as resetProjectForTest};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The wider `StatementTypeSchema` in `schemas/baseSchemas.ts` also
|
|
4
|
+
* carries non-factory kinds (import, app-init, tags, custom) that the
|
|
5
|
+
* codemod never locates by factory shape.
|
|
6
|
+
*/
|
|
7
|
+
export declare const StatementTypeSchema: z.ZodEnum<{
|
|
8
|
+
storage: "storage";
|
|
9
|
+
database: "database";
|
|
10
|
+
compute: "compute";
|
|
11
|
+
pattern: "pattern";
|
|
12
|
+
network: "network";
|
|
13
|
+
messaging: "messaging";
|
|
14
|
+
cdn: "cdn";
|
|
15
|
+
}>;
|
|
16
|
+
export type StatementType = z.infer<typeof StatementTypeSchema>;
|
|
17
|
+
export declare const ResourceNameSchema: z.ZodString;
|
|
18
|
+
export type ResourceName = z.infer<typeof ResourceNameSchema>;
|
|
19
|
+
export declare const AddOptionsSchema: z.ZodObject<{
|
|
20
|
+
type: z.ZodEnum<{
|
|
21
|
+
storage: "storage";
|
|
22
|
+
database: "database";
|
|
23
|
+
compute: "compute";
|
|
24
|
+
pattern: "pattern";
|
|
25
|
+
network: "network";
|
|
26
|
+
messaging: "messaging";
|
|
27
|
+
cdn: "cdn";
|
|
28
|
+
}>;
|
|
29
|
+
name: z.ZodString;
|
|
30
|
+
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
31
|
+
filePath: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
export type AddOptions = z.infer<typeof AddOptionsSchema>;
|
|
34
|
+
export declare const RemoveOptionsSchema: z.ZodObject<{
|
|
35
|
+
type: z.ZodEnum<{
|
|
36
|
+
storage: "storage";
|
|
37
|
+
database: "database";
|
|
38
|
+
compute: "compute";
|
|
39
|
+
pattern: "pattern";
|
|
40
|
+
network: "network";
|
|
41
|
+
messaging: "messaging";
|
|
42
|
+
cdn: "cdn";
|
|
43
|
+
}>;
|
|
44
|
+
name: z.ZodString;
|
|
45
|
+
filePath: z.ZodOptional<z.ZodString>;
|
|
46
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export type RemoveOptions = z.infer<typeof RemoveOptionsSchema>;
|
|
49
|
+
export declare const ModifyOptionsSchema: z.ZodObject<{
|
|
50
|
+
type: z.ZodEnum<{
|
|
51
|
+
storage: "storage";
|
|
52
|
+
database: "database";
|
|
53
|
+
compute: "compute";
|
|
54
|
+
pattern: "pattern";
|
|
55
|
+
network: "network";
|
|
56
|
+
messaging: "messaging";
|
|
57
|
+
cdn: "cdn";
|
|
58
|
+
}>;
|
|
59
|
+
name: z.ZodString;
|
|
60
|
+
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
61
|
+
filePath: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
export type ModifyOptions = z.infer<typeof ModifyOptionsSchema>;
|
|
64
|
+
export declare const ReferenceLocationSchema: z.ZodObject<{
|
|
65
|
+
line: z.ZodNumber;
|
|
66
|
+
column: z.ZodNumber;
|
|
67
|
+
context: z.ZodString;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
export type ReferenceLocation = z.infer<typeof ReferenceLocationSchema>;
|
|
70
|
+
export declare const LinesChangedSchema: z.ZodObject<{
|
|
71
|
+
added: z.ZodNumber;
|
|
72
|
+
removed: z.ZodNumber;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
export type LinesChanged = z.infer<typeof LinesChangedSchema>;
|
|
75
|
+
export declare const ResourceListingEntrySchema: z.ZodObject<{
|
|
76
|
+
type: z.ZodEnum<{
|
|
77
|
+
storage: "storage";
|
|
78
|
+
database: "database";
|
|
79
|
+
compute: "compute";
|
|
80
|
+
pattern: "pattern";
|
|
81
|
+
network: "network";
|
|
82
|
+
messaging: "messaging";
|
|
83
|
+
cdn: "cdn";
|
|
84
|
+
}>;
|
|
85
|
+
name: z.ZodString;
|
|
86
|
+
filePath: z.ZodString;
|
|
87
|
+
start: z.ZodNumber;
|
|
88
|
+
length: z.ZodNumber;
|
|
89
|
+
}, z.core.$strict>;
|
|
90
|
+
export type ResourceListingEntry = z.infer<typeof ResourceListingEntrySchema>;
|
|
91
|
+
export declare const ResourceListingSchema: z.ZodObject<{
|
|
92
|
+
filePath: z.ZodString;
|
|
93
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
94
|
+
type: z.ZodEnum<{
|
|
95
|
+
storage: "storage";
|
|
96
|
+
database: "database";
|
|
97
|
+
compute: "compute";
|
|
98
|
+
pattern: "pattern";
|
|
99
|
+
network: "network";
|
|
100
|
+
messaging: "messaging";
|
|
101
|
+
cdn: "cdn";
|
|
102
|
+
}>;
|
|
103
|
+
name: z.ZodString;
|
|
104
|
+
filePath: z.ZodString;
|
|
105
|
+
start: z.ZodNumber;
|
|
106
|
+
length: z.ZodNumber;
|
|
107
|
+
}, z.core.$strict>>;
|
|
108
|
+
}, z.core.$strict>;
|
|
109
|
+
export type ResourceListing = z.infer<typeof ResourceListingSchema>;
|
|
110
|
+
export declare const CodemodSuccessSchema: z.ZodObject<{
|
|
111
|
+
content: z.ZodString;
|
|
112
|
+
linesChanged: z.ZodObject<{
|
|
113
|
+
added: z.ZodNumber;
|
|
114
|
+
removed: z.ZodNumber;
|
|
115
|
+
}, z.core.$strict>;
|
|
116
|
+
references: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
117
|
+
line: z.ZodNumber;
|
|
118
|
+
column: z.ZodNumber;
|
|
119
|
+
context: z.ZodString;
|
|
120
|
+
}, z.core.$strict>>>;
|
|
121
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
122
|
+
}, z.core.$strict>;
|
|
123
|
+
export type CodemodSuccess = z.infer<typeof CodemodSuccessSchema>;
|
|
124
|
+
/** @internal Bridging tuple across the ts-morph / recast boundary (ADR §1). */
|
|
125
|
+
export interface NodeLocation {
|
|
126
|
+
filePath: string;
|
|
127
|
+
start: number;
|
|
128
|
+
length: number;
|
|
129
|
+
symbolName: string;
|
|
130
|
+
}
|
|
131
|
+
export interface ParseError {
|
|
132
|
+
kind: "ParseError";
|
|
133
|
+
file: string | undefined;
|
|
134
|
+
line: number | undefined;
|
|
135
|
+
column: number | undefined;
|
|
136
|
+
message: string;
|
|
137
|
+
sourceSnippet: string;
|
|
138
|
+
}
|
|
139
|
+
export interface TemplateLiteralNameError {
|
|
140
|
+
kind: "TemplateLiteralNameError";
|
|
141
|
+
file: string;
|
|
142
|
+
line: number;
|
|
143
|
+
column: number;
|
|
144
|
+
suggestion: string;
|
|
145
|
+
}
|
|
146
|
+
export interface DuplicateResourceError {
|
|
147
|
+
kind: "DuplicateResourceError";
|
|
148
|
+
type: StatementType;
|
|
149
|
+
name: string;
|
|
150
|
+
}
|
|
151
|
+
export interface ResourceNotFoundError {
|
|
152
|
+
kind: "ResourceNotFoundError";
|
|
153
|
+
type: StatementType;
|
|
154
|
+
name: string;
|
|
155
|
+
knownNames: string[];
|
|
156
|
+
}
|
|
157
|
+
export interface ReferencesRemainError {
|
|
158
|
+
kind: "ReferencesRemainError";
|
|
159
|
+
variable: string;
|
|
160
|
+
references: ReferenceLocation[];
|
|
161
|
+
}
|
|
162
|
+
export interface InvalidPropertyError {
|
|
163
|
+
kind: "InvalidPropertyError";
|
|
164
|
+
property: string;
|
|
165
|
+
reason: string;
|
|
166
|
+
}
|
|
167
|
+
export interface SemanticQueryError {
|
|
168
|
+
kind: "SemanticQueryError";
|
|
169
|
+
reason: string;
|
|
170
|
+
cause?: unknown;
|
|
171
|
+
}
|
|
172
|
+
export type CodemodError = ParseError | TemplateLiteralNameError | DuplicateResourceError | ResourceNotFoundError | ReferencesRemainError | InvalidPropertyError | SemanticQueryError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";const t=e.enum(["database","storage","compute","messaging","cdn","network","pattern"]),n=e.string().regex(/^[A-Z][A-Za-z0-9]*$/,"Resource name must start with an uppercase letter and contain only alphanumerics (PascalCase)."),o=e.record(e.string(),e.unknown()),c=e.object({type:t,name:n,properties:o,filePath:e.string().optional()}).strict(),m=e.object({type:t,name:n,filePath:e.string().optional(),force:e.boolean().optional()}).strict(),p=e.object({type:t,name:n,properties:o,filePath:e.string().optional()}).strict(),r=e.object({line:e.number().int().nonnegative(),column:e.number().int().nonnegative(),context:e.string()}).strict(),a=e.object({added:e.number().int().nonnegative(),removed:e.number().int().nonnegative()}).strict(),i=e.object({type:t,name:e.string(),filePath:e.string(),start:e.number().int().nonnegative(),length:e.number().int().nonnegative()}).strict(),g=e.object({filePath:e.string(),resources:e.array(i)}).strict(),h=e.object({content:e.string(),linesChanged:a,references:e.array(r).optional(),warnings:e.array(e.string()).optional()}).strict();export{c as AddOptionsSchema,h as CodemodSuccessSchema,a as LinesChangedSchema,p as ModifyOptionsSchema,r as ReferenceLocationSchema,m as RemoveOptionsSchema,i as ResourceListingEntrySchema,g as ResourceListingSchema,n as ResourceNameSchema,t as StatementTypeSchema};
|