mcp-server-sfmc 0.4.3 → 1.0.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/README.md +140 -31
- package/bundled/mcn-help/chunks.json +1 -0
- package/ci-templates/github-copilot-review-instructions.md +1 -1
- package/dist/conversion-rules.d.ts +149 -0
- package/dist/conversion-rules.d.ts.map +1 -0
- package/dist/conversion-rules.js +845 -0
- package/dist/conversion-rules.js.map +1 -0
- package/dist/index.js +832 -64
- package/dist/index.js.map +1 -1
- package/dist/mcn-help-search.d.ts +39 -0
- package/dist/mcn-help-search.d.ts.map +1 -0
- package/dist/mcn-help-search.js +88 -0
- package/dist/mcn-help-search.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared conversion rules for SSJS ↔ AMPscript and MCN rewriting.
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for mapping tables and deterministic transformation
|
|
5
|
+
* logic used by:
|
|
6
|
+
* - rewrite_for_mcn tool
|
|
7
|
+
* - convertSsjsToAmpscript tool
|
|
8
|
+
* - convertAmpscriptToSsjs tool
|
|
9
|
+
*/
|
|
10
|
+
export interface ChangeEntry {
|
|
11
|
+
line: number;
|
|
12
|
+
description: string;
|
|
13
|
+
}
|
|
14
|
+
export interface FlaggedSection {
|
|
15
|
+
line: number;
|
|
16
|
+
code: string;
|
|
17
|
+
reason: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ConversionResult {
|
|
20
|
+
convertedCode: string;
|
|
21
|
+
changes: ChangeEntry[];
|
|
22
|
+
flaggedSections: FlaggedSection[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Maps a Platform.Function.X name (lowercase) to the equivalent AMPscript
|
|
26
|
+
* canonical function name. Only functions with a direct 1:1 equivalent are
|
|
27
|
+
* included.
|
|
28
|
+
*/
|
|
29
|
+
export declare const PLATFORM_FUNCTION_TO_AMP: Readonly<Record<string, string>>;
|
|
30
|
+
/**
|
|
31
|
+
* Maps an AMPscript function name (lowercase) to its SSJS Platform.Function
|
|
32
|
+
* equivalent name (the part after "Platform.Function.").
|
|
33
|
+
*/
|
|
34
|
+
export declare const AMP_TO_PLATFORM_FUNCTION: Readonly<Record<string, string>>;
|
|
35
|
+
/**
|
|
36
|
+
* Ordered list of [RegExp, replacement] pairs to convert .NET format specifiers
|
|
37
|
+
* in FormatDate() calls to Java SimpleDateFormat equivalents.
|
|
38
|
+
* Applied sequentially so more specific patterns match before general ones.
|
|
39
|
+
*/
|
|
40
|
+
export declare const DOTNET_TO_JAVA_FORMAT_REPLACEMENTS: ReadonlyArray<[RegExp, string]>;
|
|
41
|
+
/**
|
|
42
|
+
* Set of .NET standard format shorthands that have no direct Java equivalent
|
|
43
|
+
* and must be replaced with an explicit pattern.
|
|
44
|
+
*/
|
|
45
|
+
export declare const DOTNET_STANDARD_SHORTHANDS: ReadonlySet<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Set of AMPscript function names (lowercase) that are available only in
|
|
48
|
+
* CloudPages / web content context and are not supported in Marketing Cloud Next.
|
|
49
|
+
*/
|
|
50
|
+
export declare const CLOUDPAGES_ONLY_FUNCTIONS: ReadonlySet<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Patterns in SSJS code that indicate constructs with no AMPscript equivalent.
|
|
53
|
+
* Any SSJS block containing these patterns is classified as "Not migratable"
|
|
54
|
+
* in check_mcn_compatibility and marked MANUAL_REWRITE_REQUIRED in rewriting tools.
|
|
55
|
+
*/
|
|
56
|
+
export declare const NON_MIGRATABLE_SSJS_PATTERNS: ReadonlyArray<{
|
|
57
|
+
pattern: RegExp;
|
|
58
|
+
reason: string;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Convert a SSJS code block to equivalent AMPscript using deterministic rules.
|
|
62
|
+
*
|
|
63
|
+
* Handles:
|
|
64
|
+
* - `Platform.Function.X(args)` → `X(args)`
|
|
65
|
+
* - `Platform.Variable.GetValue("name")` → `\@name`
|
|
66
|
+
* - `Platform.Variable.SetValue("name", val)` → `SET \@name = val`
|
|
67
|
+
* - `Platform.Response.Write(expr)` → `OutputLine(expr)`
|
|
68
|
+
* - `var x = expr;` → `SET \@x = expr`
|
|
69
|
+
* - `var x;` → `VAR \@x`
|
|
70
|
+
* - Control flow: if/else if/else/} → IF/ELSEIF/ELSE/ENDIF
|
|
71
|
+
* - `for (var i = start; i <= end; i++) {` → `FOR \@i = start TO end DO`
|
|
72
|
+
*
|
|
73
|
+
* Flags non-migratable constructs as MANUAL_REWRITE_REQUIRED.
|
|
74
|
+
* @param code - SSJS source code (may include `<script runat="server">` tags).
|
|
75
|
+
* @returns {ConversionResult} Conversion result with converted code, change log, and flagged sections.
|
|
76
|
+
*/
|
|
77
|
+
export declare function ssjsToAmpscript(code: string): ConversionResult;
|
|
78
|
+
/**
|
|
79
|
+
* Convert AMPscript code to equivalent SSJS using deterministic rules.
|
|
80
|
+
*
|
|
81
|
+
* Handles:
|
|
82
|
+
* - `%%[ SET \@x = expr ]%%` → `var x = expr;`
|
|
83
|
+
* - `%%[ VAR \@x, \@y ]%%` → `var x, y;`
|
|
84
|
+
* - `%%[ IF cond THEN / ELSEIF / ELSE / ENDIF ]%%` → JS control flow
|
|
85
|
+
* - `%%[ FOR \@i = start TO end DO / NEXT \@i ]%%` → for loop
|
|
86
|
+
* - `%%=Output(\@x)=%%` / `%%=OutputLine(\@x)=%%` → `Platform.Response.Write(x)`
|
|
87
|
+
* - `%%=FunctionName(args)=%%` → `Platform.Response.Write(Platform.Function.FunctionName(args))`
|
|
88
|
+
* - Known AMPscript functions → Platform.Function.X equivalents
|
|
89
|
+
* - `\@variable` references → bare variable names
|
|
90
|
+
* @param code - AMPscript source code.
|
|
91
|
+
* @returns {ConversionResult} Conversion result with converted SSJS, change log, and flagged sections.
|
|
92
|
+
*/
|
|
93
|
+
export declare function ampscriptToSsjs(code: string): ConversionResult;
|
|
94
|
+
/**
|
|
95
|
+
* Strip `@` prefix from AMPscript variable references in an expression.
|
|
96
|
+
* @param expr - Expression possibly containing `@varName` references.
|
|
97
|
+
* @returns {string} Expression with `@` prefixes removed.
|
|
98
|
+
*/
|
|
99
|
+
export declare function stripAmpVars(expr: string): string;
|
|
100
|
+
export interface McnRewriteOptions {
|
|
101
|
+
/** Function to check if an AMPscript function is MCN-supported */
|
|
102
|
+
isMcnSupportedFn: (name: string) => boolean;
|
|
103
|
+
/** Function to get MCN behavioral notes for a function */
|
|
104
|
+
getMcnNotesFn: (name: string) => string | null;
|
|
105
|
+
}
|
|
106
|
+
export interface McnRewriteResult {
|
|
107
|
+
rewrittenCode: string;
|
|
108
|
+
changes: Array<{
|
|
109
|
+
line: number;
|
|
110
|
+
type: string;
|
|
111
|
+
description: string;
|
|
112
|
+
}>;
|
|
113
|
+
nonMigratableItems: Array<{
|
|
114
|
+
line: number;
|
|
115
|
+
code: string;
|
|
116
|
+
reason: string;
|
|
117
|
+
}>;
|
|
118
|
+
difficulty: 'ready' | 'minor' | 'significant' | 'not-migratable';
|
|
119
|
+
summary: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Rewrite AMPscript code to be compatible with Marketing Cloud Next.
|
|
123
|
+
*
|
|
124
|
+
* Performs deterministic rewrites:
|
|
125
|
+
* - FormatDate(StringToDate(x), fmt) → FormatDate(x, fmt)
|
|
126
|
+
* - .NET → Java SimpleDateFormat format string conversions in FormatDate()
|
|
127
|
+
* - Lookup with odd arg count → annotated with comment
|
|
128
|
+
* - MCE-only functions → marked with %%-- NOT SUPPORTED IN MCN --%% annotation
|
|
129
|
+
* @param code - AMPscript source code to rewrite.
|
|
130
|
+
* @param options - Functions for MCN support checking and note retrieval.
|
|
131
|
+
* @returns {McnRewriteResult} Rewrite result with rewritten code, change log, and difficulty assessment.
|
|
132
|
+
*/
|
|
133
|
+
export declare function rewriteAmpForMcn(code: string, options: McnRewriteOptions): McnRewriteResult;
|
|
134
|
+
/**
|
|
135
|
+
* Count the number of top-level comma-separated arguments in a function
|
|
136
|
+
* argument string (respects nested parentheses).
|
|
137
|
+
* @param argsStr - The argument string (contents between outer parens).
|
|
138
|
+
* @returns {number} Number of top-level arguments.
|
|
139
|
+
*/
|
|
140
|
+
export declare function countArgs(argsStr: string): number;
|
|
141
|
+
/**
|
|
142
|
+
* Determine whether a SSJS code block contains only patterns that can be
|
|
143
|
+
* automatically converted to AMPscript. Returns true when no non-migratable
|
|
144
|
+
* patterns are found.
|
|
145
|
+
* @param blockCode - SSJS block code (without `<script>` tags).
|
|
146
|
+
* @returns {boolean} True when the block is likely convertible.
|
|
147
|
+
*/
|
|
148
|
+
export declare function isSsjsBlockConvertible(blockCode: string): boolean;
|
|
149
|
+
//# sourceMappingURL=conversion-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversion-rules.d.ts","sourceRoot":"","sources":["../src/conversion-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,eAAe,EAAE,cAAc,EAAE,CAAC;CACrC;AAMD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiDrE,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0CrE,CAAC;AAMF;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,EAAE,aAAa,CAAC,CAAC,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