sfmc-language-lsp 0.1.0 → 0.2.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 +25 -0
- package/dist/cjs/codeActions/{ampscript.js → ampscript.cjs} +20 -5
- package/dist/cjs/codeActions/ampscript.d.ts +7 -1
- package/dist/cjs/codeActions/ampscript.d.ts.map +1 -1
- package/dist/cjs/codeActions/ampscript.js.map +1 -1
- package/dist/cjs/completions/{ampscript.js → ampscript.cjs} +23 -9
- package/dist/cjs/completions/ampscript.d.ts +11 -2
- package/dist/cjs/completions/ampscript.d.ts.map +1 -1
- package/dist/cjs/completions/ampscript.js.map +1 -1
- package/dist/cjs/completions/ssjs.cjs +305 -0
- package/dist/cjs/completions/ssjs.d.ts +5 -1
- package/dist/cjs/completions/ssjs.d.ts.map +1 -1
- package/dist/cjs/completions/ssjs.js.map +1 -1
- package/dist/cjs/data/{ampscript.js → ampscript.cjs} +6 -1
- package/dist/cjs/data/ampscript.d.ts.map +1 -1
- package/dist/cjs/data/ampscript.js.map +1 -1
- package/dist/cjs/data/{ssjs.js → ssjs.cjs} +14 -4
- package/dist/cjs/data/ssjs.d.ts +7 -1
- package/dist/cjs/data/ssjs.d.ts.map +1 -1
- package/dist/cjs/data/ssjs.js.map +1 -1
- package/dist/cjs/definitions/{ssjs.js → ssjs.cjs} +16 -3
- package/dist/cjs/definitions/ssjs.d.ts +6 -0
- package/dist/cjs/definitions/ssjs.d.ts.map +1 -1
- package/dist/cjs/definitions/ssjs.js.map +1 -1
- package/dist/cjs/hover/{ampscript.js → ampscript.cjs} +18 -7
- package/dist/cjs/hover/ampscript.d.ts +6 -1
- package/dist/cjs/hover/ampscript.d.ts.map +1 -1
- package/dist/cjs/hover/ampscript.js.map +1 -1
- package/dist/cjs/hover/ssjs.cjs +323 -0
- package/dist/cjs/hover/ssjs.d.ts +7 -1
- package/dist/cjs/hover/ssjs.d.ts.map +1 -1
- package/dist/cjs/hover/ssjs.js.map +1 -1
- package/dist/cjs/{index.js → index.cjs} +135 -46
- package/dist/cjs/index.d.ts +77 -16
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/signature/{ampscript.js → ampscript.cjs} +12 -4
- package/dist/cjs/signature/ampscript.d.ts +7 -1
- package/dist/cjs/signature/ampscript.d.ts.map +1 -1
- package/dist/cjs/signature/ampscript.js.map +1 -1
- package/dist/cjs/signature/{ssjs.js → ssjs.cjs} +42 -19
- package/dist/cjs/signature/ssjs.d.ts +8 -1
- package/dist/cjs/signature/ssjs.d.ts.map +1 -1
- package/dist/cjs/signature/ssjs.js.map +1 -1
- package/dist/cjs/utils/{comments.js → comments.cjs} +11 -2
- package/dist/cjs/utils/comments.d.ts +11 -2
- package/dist/cjs/utils/comments.d.ts.map +1 -1
- package/dist/cjs/utils/comments.js.map +1 -1
- package/dist/cjs/utils/{markdown.js → markdown.cjs} +32 -7
- package/dist/cjs/utils/markdown.d.ts +30 -6
- package/dist/cjs/utils/markdown.d.ts.map +1 -1
- package/dist/cjs/utils/markdown.js.map +1 -1
- package/dist/cjs/utils/{positions.js → positions.cjs} +19 -4
- package/dist/cjs/utils/positions.d.ts +18 -3
- package/dist/cjs/utils/positions.d.ts.map +1 -1
- package/dist/cjs/utils/positions.js.map +1 -1
- package/dist/cjs/utils/{regions.js → regions.cjs} +8 -0
- package/dist/cjs/utils/regions.d.ts +8 -0
- package/dist/cjs/utils/regions.d.ts.map +1 -1
- package/dist/cjs/utils/regions.js.map +1 -1
- package/dist/cjs/utils/{text.js → text.cjs} +22 -2
- package/dist/cjs/utils/text.d.ts +22 -2
- package/dist/cjs/utils/text.d.ts.map +1 -1
- package/dist/cjs/utils/text.js.map +1 -1
- package/dist/cjs/validators/{ampscript.js → ampscript.cjs} +112 -31
- package/dist/cjs/validators/ampscript.d.ts +6 -1
- package/dist/cjs/validators/ampscript.d.ts.map +1 -1
- package/dist/cjs/validators/ampscript.js.map +1 -1
- package/dist/cjs/validators/{gtl.js → gtl.cjs} +5 -2
- package/dist/cjs/validators/gtl.d.ts +3 -0
- package/dist/cjs/validators/gtl.d.ts.map +1 -1
- package/dist/cjs/validators/gtl.js.map +1 -1
- package/dist/cjs/validators/{ssjs.js → ssjs.cjs} +70 -16
- package/dist/cjs/validators/ssjs.d.ts +6 -1
- package/dist/cjs/validators/ssjs.d.ts.map +1 -1
- package/dist/cjs/validators/ssjs.js.map +1 -1
- package/dist/esm/codeActions/ampscript.d.ts +7 -1
- package/dist/esm/codeActions/ampscript.d.ts.map +1 -1
- package/dist/esm/codeActions/ampscript.js +17 -2
- package/dist/esm/codeActions/ampscript.js.map +1 -1
- package/dist/esm/completions/ampscript.d.ts +11 -2
- package/dist/esm/completions/ampscript.d.ts.map +1 -1
- package/dist/esm/completions/ampscript.js +18 -4
- package/dist/esm/completions/ampscript.js.map +1 -1
- package/dist/esm/completions/ssjs.d.ts +5 -1
- package/dist/esm/completions/ssjs.d.ts.map +1 -1
- package/dist/esm/completions/ssjs.js +223 -21
- package/dist/esm/completions/ssjs.js.map +1 -1
- package/dist/esm/data/ampscript.d.ts.map +1 -1
- package/dist/esm/data/ampscript.js +6 -1
- package/dist/esm/data/ampscript.js.map +1 -1
- package/dist/esm/data/ssjs.d.ts +7 -1
- package/dist/esm/data/ssjs.d.ts.map +1 -1
- package/dist/esm/data/ssjs.js +14 -4
- package/dist/esm/data/ssjs.js.map +1 -1
- package/dist/esm/definitions/ssjs.d.ts +6 -0
- package/dist/esm/definitions/ssjs.d.ts.map +1 -1
- package/dist/esm/definitions/ssjs.js +15 -2
- package/dist/esm/definitions/ssjs.js.map +1 -1
- package/dist/esm/hover/ampscript.d.ts +6 -1
- package/dist/esm/hover/ampscript.d.ts.map +1 -1
- package/dist/esm/hover/ampscript.js +14 -3
- package/dist/esm/hover/ampscript.js.map +1 -1
- package/dist/esm/hover/ssjs.d.ts +7 -1
- package/dist/esm/hover/ssjs.d.ts.map +1 -1
- package/dist/esm/hover/ssjs.js +199 -37
- package/dist/esm/hover/ssjs.js.map +1 -1
- package/dist/esm/index.d.ts +77 -16
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +118 -29
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/signature/ampscript.d.ts +7 -1
- package/dist/esm/signature/ampscript.d.ts.map +1 -1
- package/dist/esm/signature/ampscript.js +11 -3
- package/dist/esm/signature/ampscript.js.map +1 -1
- package/dist/esm/signature/ssjs.d.ts +8 -1
- package/dist/esm/signature/ssjs.d.ts.map +1 -1
- package/dist/esm/signature/ssjs.js +42 -19
- package/dist/esm/signature/ssjs.js.map +1 -1
- package/dist/esm/utils/comments.d.ts +11 -2
- package/dist/esm/utils/comments.d.ts.map +1 -1
- package/dist/esm/utils/comments.js +11 -2
- package/dist/esm/utils/comments.js.map +1 -1
- package/dist/esm/utils/markdown.d.ts +30 -6
- package/dist/esm/utils/markdown.d.ts.map +1 -1
- package/dist/esm/utils/markdown.js +32 -7
- package/dist/esm/utils/markdown.js.map +1 -1
- package/dist/esm/utils/positions.d.ts +18 -3
- package/dist/esm/utils/positions.d.ts.map +1 -1
- package/dist/esm/utils/positions.js +19 -4
- package/dist/esm/utils/positions.js.map +1 -1
- package/dist/esm/utils/regions.d.ts +8 -0
- package/dist/esm/utils/regions.d.ts.map +1 -1
- package/dist/esm/utils/regions.js +8 -0
- package/dist/esm/utils/regions.js.map +1 -1
- package/dist/esm/utils/text.d.ts +22 -2
- package/dist/esm/utils/text.d.ts.map +1 -1
- package/dist/esm/utils/text.js +22 -2
- package/dist/esm/utils/text.js.map +1 -1
- package/dist/esm/validators/ampscript.d.ts +6 -1
- package/dist/esm/validators/ampscript.d.ts.map +1 -1
- package/dist/esm/validators/ampscript.js +106 -25
- package/dist/esm/validators/ampscript.js.map +1 -1
- package/dist/esm/validators/gtl.d.ts +3 -0
- package/dist/esm/validators/gtl.d.ts.map +1 -1
- package/dist/esm/validators/gtl.js +3 -0
- package/dist/esm/validators/gtl.js.map +1 -1
- package/dist/esm/validators/ssjs.d.ts +6 -1
- package/dist/esm/validators/ssjs.d.ts.map +1 -1
- package/dist/esm/validators/ssjs.js +65 -11
- package/dist/esm/validators/ssjs.js.map +1 -1
- package/dist/types/codeActions/ampscript.d.ts +7 -1
- package/dist/types/codeActions/ampscript.d.ts.map +1 -1
- package/dist/types/completions/ampscript.d.ts +11 -2
- package/dist/types/completions/ampscript.d.ts.map +1 -1
- package/dist/types/completions/ssjs.d.ts +5 -1
- package/dist/types/completions/ssjs.d.ts.map +1 -1
- package/dist/types/data/ampscript.d.ts.map +1 -1
- package/dist/types/data/ssjs.d.ts +7 -1
- package/dist/types/data/ssjs.d.ts.map +1 -1
- package/dist/types/definitions/ssjs.d.ts +6 -0
- package/dist/types/definitions/ssjs.d.ts.map +1 -1
- package/dist/types/hover/ampscript.d.ts +6 -1
- package/dist/types/hover/ampscript.d.ts.map +1 -1
- package/dist/types/hover/ssjs.d.ts +7 -1
- package/dist/types/hover/ssjs.d.ts.map +1 -1
- package/dist/types/index.d.ts +77 -16
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/signature/ampscript.d.ts +7 -1
- package/dist/types/signature/ampscript.d.ts.map +1 -1
- package/dist/types/signature/ssjs.d.ts +8 -1
- package/dist/types/signature/ssjs.d.ts.map +1 -1
- package/dist/types/utils/comments.d.ts +11 -2
- package/dist/types/utils/comments.d.ts.map +1 -1
- package/dist/types/utils/markdown.d.ts +30 -6
- package/dist/types/utils/markdown.d.ts.map +1 -1
- package/dist/types/utils/positions.d.ts +18 -3
- package/dist/types/utils/positions.d.ts.map +1 -1
- package/dist/types/utils/regions.d.ts +8 -0
- package/dist/types/utils/regions.d.ts.map +1 -1
- package/dist/types/utils/text.d.ts +22 -2
- package/dist/types/utils/text.d.ts.map +1 -1
- package/dist/types/validators/ampscript.d.ts +6 -1
- package/dist/types/validators/ampscript.d.ts.map +1 -1
- package/dist/types/validators/gtl.d.ts +3 -0
- package/dist/types/validators/gtl.d.ts.map +1 -1
- package/dist/types/validators/ssjs.d.ts +6 -1
- package/dist/types/validators/ssjs.d.ts.map +1 -1
- package/package.json +28 -9
- package/dist/cjs/completions/ssjs.js +0 -103
- package/dist/cjs/hover/ssjs.js +0 -161
- /package/dist/cjs/{types.js → types.cjs} +0 -0
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.extractLocalSsjsFunctions = exports.validateGtlBlocks = exports.validateSsjs = exports.validateAmpscript = exports.sfmcLanguageService = exports.SfmcLanguageService = exports.DEFAULT_SETTINGS = void 0;
|
|
11
|
-
const types_js_1 = require("./types.
|
|
12
|
-
const ampscript_js_1 = require("./validators/ampscript.
|
|
13
|
-
const ssjs_js_1 = require("./validators/ssjs.
|
|
14
|
-
const ampscript_js_2 = require("./completions/ampscript.
|
|
15
|
-
const ssjs_js_2 = require("./completions/ssjs.
|
|
16
|
-
const ampscript_js_3 = require("./hover/ampscript.
|
|
17
|
-
const ssjs_js_3 = require("./hover/ssjs.
|
|
18
|
-
const ampscript_js_4 = require("./signature/ampscript.
|
|
19
|
-
const ssjs_js_4 = require("./signature/ssjs.
|
|
20
|
-
const ssjs_js_5 = require("./definitions/ssjs.
|
|
21
|
-
const ampscript_js_5 = require("./codeActions/ampscript.
|
|
22
|
-
const ampscript_js_6 = require("./data/ampscript.
|
|
23
|
-
const ssjs_js_6 = require("./data/ssjs.
|
|
24
|
-
const text_js_1 = require("./utils/text.
|
|
25
|
-
var types_js_2 = require("./types.
|
|
11
|
+
const types_js_1 = require("./types.cjs");
|
|
12
|
+
const ampscript_js_1 = require("./validators/ampscript.cjs");
|
|
13
|
+
const ssjs_js_1 = require("./validators/ssjs.cjs");
|
|
14
|
+
const ampscript_js_2 = require("./completions/ampscript.cjs");
|
|
15
|
+
const ssjs_js_2 = require("./completions/ssjs.cjs");
|
|
16
|
+
const ampscript_js_3 = require("./hover/ampscript.cjs");
|
|
17
|
+
const ssjs_js_3 = require("./hover/ssjs.cjs");
|
|
18
|
+
const ampscript_js_4 = require("./signature/ampscript.cjs");
|
|
19
|
+
const ssjs_js_4 = require("./signature/ssjs.cjs");
|
|
20
|
+
const ssjs_js_5 = require("./definitions/ssjs.cjs");
|
|
21
|
+
const ampscript_js_5 = require("./codeActions/ampscript.cjs");
|
|
22
|
+
const ampscript_js_6 = require("./data/ampscript.cjs");
|
|
23
|
+
const ssjs_js_6 = require("./data/ssjs.cjs");
|
|
24
|
+
const text_js_1 = require("./utils/text.cjs");
|
|
25
|
+
var types_js_2 = require("./types.cjs");
|
|
26
26
|
Object.defineProperty(exports, "DEFAULT_SETTINGS", { enumerable: true, get: function () { return types_js_2.DEFAULT_SETTINGS; } });
|
|
27
27
|
/**
|
|
28
28
|
* The main entry point for SFMC language intelligence.
|
|
@@ -30,7 +30,12 @@ Object.defineProperty(exports, "DEFAULT_SETTINGS", { enumerable: true, get: func
|
|
|
30
30
|
*/
|
|
31
31
|
class SfmcLanguageService {
|
|
32
32
|
// ── Validation ────────────────────────────────────────────────────────────
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Validate an AMPscript or SSJS document. Returns LSP Diagnostics.
|
|
35
|
+
* @param doc - Document context with text and language ID.
|
|
36
|
+
* @param settings - Validation settings.
|
|
37
|
+
* @returns Array of LSP Diagnostic objects.
|
|
38
|
+
*/
|
|
34
39
|
validate(doc, settings = types_js_1.DEFAULT_SETTINGS) {
|
|
35
40
|
if (doc.languageId === 'ssjs') {
|
|
36
41
|
return (0, ssjs_js_1.validateSsjs)(doc.text, settings);
|
|
@@ -38,7 +43,12 @@ class SfmcLanguageService {
|
|
|
38
43
|
return (0, ampscript_js_1.validateAmpscript)(doc.text, settings);
|
|
39
44
|
}
|
|
40
45
|
// ── Completions ───────────────────────────────────────────────────────────
|
|
41
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Return completion items at the given cursor position.
|
|
48
|
+
* @param doc - Document context with text and language ID.
|
|
49
|
+
* @param position - Cursor position.
|
|
50
|
+
* @returns Array of LSP CompletionItem objects.
|
|
51
|
+
*/
|
|
42
52
|
getCompletions(doc, position) {
|
|
43
53
|
if (doc.languageId === 'ssjs') {
|
|
44
54
|
const localFns = (0, ssjs_js_5.extractLocalSsjsFunctions)(doc.text);
|
|
@@ -47,12 +57,22 @@ class SfmcLanguageService {
|
|
|
47
57
|
}
|
|
48
58
|
return (0, ampscript_js_2.getAmpscriptCompletions)(doc.text, position);
|
|
49
59
|
}
|
|
50
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Resolve documentation for a completion item (lazy-loaded).
|
|
62
|
+
* @param item - Completion item to resolve.
|
|
63
|
+
* @returns The resolved completion item with documentation attached.
|
|
64
|
+
*/
|
|
51
65
|
resolveCompletion(item) {
|
|
52
66
|
return (0, ampscript_js_2.resolveAmpscriptCompletion)(item);
|
|
53
67
|
}
|
|
54
68
|
// ── Hover ─────────────────────────────────────────────────────────────────
|
|
55
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Return hover documentation at the given line/position.
|
|
71
|
+
* @param doc - Document context with text and language ID.
|
|
72
|
+
* @param line - The current document line text.
|
|
73
|
+
* @param position - The cursor position.
|
|
74
|
+
* @returns Hover object with Markdown documentation, or null.
|
|
75
|
+
*/
|
|
56
76
|
getHover(doc, line, position) {
|
|
57
77
|
if (doc.languageId === 'ssjs') {
|
|
58
78
|
const localFns = (0, ssjs_js_5.extractLocalSsjsFunctions)(doc.text);
|
|
@@ -61,7 +81,12 @@ class SfmcLanguageService {
|
|
|
61
81
|
return (0, ampscript_js_3.getAmpscriptHover)(line, position);
|
|
62
82
|
}
|
|
63
83
|
// ── Signature Help ────────────────────────────────────────────────────────
|
|
64
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Return signature help at the given cursor position.
|
|
86
|
+
* @param doc - Document context with text and language ID.
|
|
87
|
+
* @param textUpToCursor - The document text from the start up to the cursor.
|
|
88
|
+
* @returns SignatureHelp object, or null if outside a function call.
|
|
89
|
+
*/
|
|
65
90
|
getSignatureHelp(doc, textUpToCursor) {
|
|
66
91
|
const context = (0, text_js_1.findFunctionContext)(textUpToCursor);
|
|
67
92
|
if (!context)
|
|
@@ -73,68 +98,132 @@ class SfmcLanguageService {
|
|
|
73
98
|
return (0, ampscript_js_4.getAmpscriptSignatureHelp)(context);
|
|
74
99
|
}
|
|
75
100
|
// ── Go to Definition ──────────────────────────────────────────────────────
|
|
76
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Return the definition location for the word at the given position. Only SSJS is supported.
|
|
103
|
+
* @param doc - Document context with text and language ID.
|
|
104
|
+
* @param word - Identifier name to locate.
|
|
105
|
+
* @returns LSP Location of the definition, or null.
|
|
106
|
+
*/
|
|
77
107
|
getDefinition(doc, word) {
|
|
78
108
|
if (doc.languageId !== 'ssjs')
|
|
79
109
|
return null;
|
|
80
110
|
return (0, ssjs_js_5.getSsjsDefinition)(doc.text, doc.uri ?? '', word);
|
|
81
111
|
}
|
|
82
112
|
// ── Code Actions ──────────────────────────────────────────────────────────
|
|
83
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Return quick-fix code actions for the given diagnostics.
|
|
115
|
+
* @param doc - Document context with text and language ID.
|
|
116
|
+
* @param diagnostics - Diagnostics to generate actions for.
|
|
117
|
+
* @returns Array of code actions.
|
|
118
|
+
*/
|
|
84
119
|
getCodeActions(doc, diagnostics) {
|
|
85
120
|
if (doc.languageId === 'ssjs')
|
|
86
121
|
return [];
|
|
87
122
|
return (0, ampscript_js_5.getAmpscriptCodeActions)(doc.text, doc.uri ?? '', diagnostics);
|
|
88
123
|
}
|
|
89
124
|
// ── Catalog / Lookup (for MCP tools and resources) ────────────────────────
|
|
90
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* Look up an AMPscript function by name. Case-insensitive.
|
|
127
|
+
* @param name - Function name to look up.
|
|
128
|
+
* @returns The AMPscript function descriptor, or null if not found.
|
|
129
|
+
*/
|
|
91
130
|
lookupAmpscriptFunction(name) {
|
|
92
131
|
return ampscript_js_6.functionLookup.get(name.toLowerCase()) ?? null;
|
|
93
132
|
}
|
|
94
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* Look up an SSJS function or method by name. Case-insensitive. Searches all catalogs.
|
|
135
|
+
* @param name - Function or method name to look up.
|
|
136
|
+
* @returns The SSJS function descriptor, or null if not found.
|
|
137
|
+
*/
|
|
95
138
|
lookupSsjsFunction(name) {
|
|
96
139
|
const lower = name.toLowerCase();
|
|
97
140
|
const allFns = [
|
|
98
|
-
...ssjs_js_6.platformMethods,
|
|
99
|
-
...ssjs_js_6.
|
|
100
|
-
...ssjs_js_6.
|
|
101
|
-
...ssjs_js_6.
|
|
141
|
+
...ssjs_js_6.platformMethods,
|
|
142
|
+
...ssjs_js_6.platformFunctions,
|
|
143
|
+
...ssjs_js_6.ssjsGlobals,
|
|
144
|
+
...ssjs_js_6.platformVariableMethods,
|
|
145
|
+
...ssjs_js_6.platformResponseMethods,
|
|
146
|
+
...ssjs_js_6.platformRequestMethods,
|
|
147
|
+
...ssjs_js_6.platformRecipientMethods,
|
|
148
|
+
...ssjs_js_6.wsproxyMethods,
|
|
149
|
+
...ssjs_js_6.httpMethods,
|
|
150
|
+
...ssjs_js_6.httpHeaderMethods,
|
|
151
|
+
...ssjs_js_6.dateTimeTimezoneMethods,
|
|
152
|
+
...ssjs_js_6.errorUtilMethods,
|
|
102
153
|
];
|
|
103
154
|
return allFns.find((f) => f.name.toLowerCase() === lower) ?? null;
|
|
104
155
|
}
|
|
105
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* Return all AMPscript functions in the catalog.
|
|
158
|
+
* @returns Array of all AMPscript function descriptors.
|
|
159
|
+
*/
|
|
106
160
|
getAllAmpscriptFunctions() {
|
|
107
161
|
return ampscript_js_6.ampscriptFunctions;
|
|
108
162
|
}
|
|
109
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* Return all SSJS functions and methods in the catalog.
|
|
165
|
+
* @returns Array of all SSJS function descriptors across all namespaces.
|
|
166
|
+
*/
|
|
110
167
|
getAllSsjsFunctions() {
|
|
111
168
|
return [
|
|
112
|
-
...ssjs_js_6.platformMethods,
|
|
113
|
-
...ssjs_js_6.
|
|
114
|
-
...ssjs_js_6.
|
|
115
|
-
...ssjs_js_6.
|
|
169
|
+
...ssjs_js_6.platformMethods,
|
|
170
|
+
...ssjs_js_6.platformFunctions,
|
|
171
|
+
...ssjs_js_6.ssjsGlobals,
|
|
172
|
+
...ssjs_js_6.platformVariableMethods,
|
|
173
|
+
...ssjs_js_6.platformResponseMethods,
|
|
174
|
+
...ssjs_js_6.platformRequestMethods,
|
|
175
|
+
...ssjs_js_6.platformRecipientMethods,
|
|
176
|
+
...ssjs_js_6.wsproxyMethods,
|
|
177
|
+
...ssjs_js_6.httpMethods,
|
|
178
|
+
...ssjs_js_6.httpHeaderMethods,
|
|
179
|
+
...ssjs_js_6.dateTimeTimezoneMethods,
|
|
180
|
+
...ssjs_js_6.errorUtilMethods,
|
|
116
181
|
];
|
|
117
182
|
}
|
|
118
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* Return all AMPscript keyword names.
|
|
185
|
+
* @returns Array of keyword name strings.
|
|
186
|
+
*/
|
|
119
187
|
getAmpscriptKeywords() {
|
|
120
188
|
return ampscript_js_6.ampscriptKeywords.map((kw) => kw.name);
|
|
121
189
|
}
|
|
122
|
-
/**
|
|
190
|
+
/**
|
|
191
|
+
* Return the ES6+ syntax features that are unsupported in SFMC SSJS.
|
|
192
|
+
* @returns Array of unsupported syntax pattern descriptors.
|
|
193
|
+
*/
|
|
123
194
|
getUnsupportedSsjsSyntax() {
|
|
124
195
|
return [
|
|
125
|
-
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
196
|
+
{
|
|
197
|
+
pattern: 'let/const',
|
|
198
|
+
message: "'let'/'const' declarations are not supported in SFMC SSJS. Use 'var' instead.",
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
pattern: '=>',
|
|
202
|
+
message: 'Arrow functions are not supported in SFMC SSJS. Use a regular function expression.',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
pattern: '`template literals`',
|
|
206
|
+
message: 'Template literals are not supported in SFMC SSJS. Use string concatenation.',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
pattern: 'class',
|
|
210
|
+
message: 'Class declarations are not supported in SFMC SSJS. Use constructor functions.',
|
|
211
|
+
},
|
|
129
212
|
{ pattern: 'async/await', message: 'Async/await is not supported in SFMC SSJS.' },
|
|
130
213
|
];
|
|
131
214
|
}
|
|
132
215
|
// ── Static completion catalog access ──────────────────────────────────────
|
|
133
|
-
/**
|
|
216
|
+
/**
|
|
217
|
+
* Return the pre-built SSJS completion item catalog.
|
|
218
|
+
* @returns Array of pre-built SSJS completion items.
|
|
219
|
+
*/
|
|
134
220
|
getSsjsCompletionCatalog() {
|
|
135
221
|
return ssjs_js_2.ssjsCompletionItems;
|
|
136
222
|
}
|
|
137
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* Return the pre-built AMPscript function completion items.
|
|
225
|
+
* @returns Array of pre-built AMPscript function completion items.
|
|
226
|
+
*/
|
|
138
227
|
getAmpscriptFunctionCompletionItems() {
|
|
139
228
|
return ampscript_js_2.functionCompletionItems;
|
|
140
229
|
}
|
|
@@ -143,12 +232,12 @@ exports.SfmcLanguageService = SfmcLanguageService;
|
|
|
143
232
|
/** Shared singleton instance for callers that don't need separate instances. */
|
|
144
233
|
exports.sfmcLanguageService = new SfmcLanguageService();
|
|
145
234
|
// Re-export validators for direct use
|
|
146
|
-
var ampscript_js_7 = require("./validators/ampscript.
|
|
235
|
+
var ampscript_js_7 = require("./validators/ampscript.cjs");
|
|
147
236
|
Object.defineProperty(exports, "validateAmpscript", { enumerable: true, get: function () { return ampscript_js_7.validateAmpscript; } });
|
|
148
|
-
var ssjs_js_7 = require("./validators/ssjs.
|
|
237
|
+
var ssjs_js_7 = require("./validators/ssjs.cjs");
|
|
149
238
|
Object.defineProperty(exports, "validateSsjs", { enumerable: true, get: function () { return ssjs_js_7.validateSsjs; } });
|
|
150
|
-
var gtl_js_1 = require("./validators/gtl.
|
|
239
|
+
var gtl_js_1 = require("./validators/gtl.cjs");
|
|
151
240
|
Object.defineProperty(exports, "validateGtlBlocks", { enumerable: true, get: function () { return gtl_js_1.validateGtlBlocks; } });
|
|
152
|
-
var ssjs_js_8 = require("./definitions/ssjs.
|
|
241
|
+
var ssjs_js_8 = require("./definitions/ssjs.cjs");
|
|
153
242
|
Object.defineProperty(exports, "extractLocalSsjsFunctions", { enumerable: true, get: function () { return ssjs_js_8.extractLocalSsjsFunctions; } });
|
|
154
243
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { SsjsFunction } from './data/ssjs.js';
|
|
|
11
11
|
export type { DocumentContext, SfmcSettings } from './types.js';
|
|
12
12
|
export { DEFAULT_SETTINGS } from './types.js';
|
|
13
13
|
export type { AmpscriptFunction, AmpscriptFunctionParam } from './data/ampscript.js';
|
|
14
|
-
export type { SsjsFunction, SsjsFunctionParam, EcmascriptBuiltin, SsjsObject } from './data/ssjs.js';
|
|
14
|
+
export type { SsjsFunction, SsjsFunctionParam, EcmascriptBuiltin, SsjsObject, } from './data/ssjs.js';
|
|
15
15
|
export type { LocalSsjsFunction } from './utils/markdown.js';
|
|
16
16
|
/** Import DocumentContext type locally for use in this file */
|
|
17
17
|
import type { DocumentContext } from './types.js';
|
|
@@ -20,38 +20,99 @@ import type { DocumentContext } from './types.js';
|
|
|
20
20
|
* Instantiate once; all methods are stateless and re-entrant.
|
|
21
21
|
*/
|
|
22
22
|
export declare class SfmcLanguageService {
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Validate an AMPscript or SSJS document. Returns LSP Diagnostics.
|
|
25
|
+
* @param doc - Document context with text and language ID.
|
|
26
|
+
* @param settings - Validation settings.
|
|
27
|
+
* @returns Array of LSP Diagnostic objects.
|
|
28
|
+
*/
|
|
24
29
|
validate(doc: DocumentContext, settings?: SfmcSettings): Diagnostic[];
|
|
25
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Return completion items at the given cursor position.
|
|
32
|
+
* @param doc - Document context with text and language ID.
|
|
33
|
+
* @param position - Cursor position.
|
|
34
|
+
* @returns Array of LSP CompletionItem objects.
|
|
35
|
+
*/
|
|
26
36
|
getCompletions(doc: DocumentContext, position: Position): CompletionItem[];
|
|
27
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Resolve documentation for a completion item (lazy-loaded).
|
|
39
|
+
* @param item - Completion item to resolve.
|
|
40
|
+
* @returns The resolved completion item with documentation attached.
|
|
41
|
+
*/
|
|
28
42
|
resolveCompletion(item: CompletionItem): CompletionItem;
|
|
29
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Return hover documentation at the given line/position.
|
|
45
|
+
* @param doc - Document context with text and language ID.
|
|
46
|
+
* @param line - The current document line text.
|
|
47
|
+
* @param position - The cursor position.
|
|
48
|
+
* @returns Hover object with Markdown documentation, or null.
|
|
49
|
+
*/
|
|
30
50
|
getHover(doc: DocumentContext, line: string, position: Position): Hover | null;
|
|
31
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Return signature help at the given cursor position.
|
|
53
|
+
* @param doc - Document context with text and language ID.
|
|
54
|
+
* @param textUpToCursor - The document text from the start up to the cursor.
|
|
55
|
+
* @returns SignatureHelp object, or null if outside a function call.
|
|
56
|
+
*/
|
|
32
57
|
getSignatureHelp(doc: DocumentContext, textUpToCursor: string): SignatureHelp | null;
|
|
33
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Return the definition location for the word at the given position. Only SSJS is supported.
|
|
60
|
+
* @param doc - Document context with text and language ID.
|
|
61
|
+
* @param word - Identifier name to locate.
|
|
62
|
+
* @returns LSP Location of the definition, or null.
|
|
63
|
+
*/
|
|
34
64
|
getDefinition(doc: DocumentContext, word: string): Location | null;
|
|
35
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Return quick-fix code actions for the given diagnostics.
|
|
67
|
+
* @param doc - Document context with text and language ID.
|
|
68
|
+
* @param diagnostics - Diagnostics to generate actions for.
|
|
69
|
+
* @returns Array of code actions.
|
|
70
|
+
*/
|
|
36
71
|
getCodeActions(doc: DocumentContext, diagnostics: Diagnostic[]): CodeAction[];
|
|
37
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Look up an AMPscript function by name. Case-insensitive.
|
|
74
|
+
* @param name - Function name to look up.
|
|
75
|
+
* @returns The AMPscript function descriptor, or null if not found.
|
|
76
|
+
*/
|
|
38
77
|
lookupAmpscriptFunction(name: string): import("./data/ampscript.js").AmpscriptFunction | null;
|
|
39
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Look up an SSJS function or method by name. Case-insensitive. Searches all catalogs.
|
|
80
|
+
* @param name - Function or method name to look up.
|
|
81
|
+
* @returns The SSJS function descriptor, or null if not found.
|
|
82
|
+
*/
|
|
40
83
|
lookupSsjsFunction(name: string): SsjsFunction | null;
|
|
41
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Return all AMPscript functions in the catalog.
|
|
86
|
+
* @returns Array of all AMPscript function descriptors.
|
|
87
|
+
*/
|
|
42
88
|
getAllAmpscriptFunctions(): import("./data/ampscript.js").AmpscriptFunction[];
|
|
43
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Return all SSJS functions and methods in the catalog.
|
|
91
|
+
* @returns Array of all SSJS function descriptors across all namespaces.
|
|
92
|
+
*/
|
|
44
93
|
getAllSsjsFunctions(): SsjsFunction[];
|
|
45
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Return all AMPscript keyword names.
|
|
96
|
+
* @returns Array of keyword name strings.
|
|
97
|
+
*/
|
|
46
98
|
getAmpscriptKeywords(): string[];
|
|
47
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Return the ES6+ syntax features that are unsupported in SFMC SSJS.
|
|
101
|
+
* @returns Array of unsupported syntax pattern descriptors.
|
|
102
|
+
*/
|
|
48
103
|
getUnsupportedSsjsSyntax(): Array<{
|
|
49
104
|
pattern: string;
|
|
50
105
|
message: string;
|
|
51
106
|
}>;
|
|
52
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Return the pre-built SSJS completion item catalog.
|
|
109
|
+
* @returns Array of pre-built SSJS completion items.
|
|
110
|
+
*/
|
|
53
111
|
getSsjsCompletionCatalog(): CompletionItem[];
|
|
54
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Return the pre-built AMPscript function completion items.
|
|
114
|
+
* @returns Array of pre-built AMPscript function completion items.
|
|
115
|
+
*/
|
|
55
116
|
getAmpscriptFunctionCompletionItems(): CompletionItem[];
|
|
56
117
|
}
|
|
57
118
|
/** Shared singleton instance for callers that don't need separate instances. */
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACR,UAAU,EACV,cAAc,EACd,KAAK,EACL,aAAa,EACb,QAAQ,EACR,UAAU,EACV,QAAQ,EACX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAsC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACrF,YAAY,EACR,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,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,EAAE,MAAM,CAAA;KAAE,CAAC;IA4BvE;;;OAGG;IACH,wBAAwB,IAAI,cAAc,EAAE;IAI5C;;;OAGG;IACH,mCAAmC,IAAI,cAAc,EAAE;CAG1D;AAED,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,qBAA4B,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAYH,yCAA8C;AAE9C,4DAA8D;AAC9D,kDAAoD;AAEpD,6DAIoC;AACpC,mDAA+F;AAE/F,uDAAyD;AACzD,6CAA+C;AAE/C,2DAAqE;AACrE,iDAA2D;AAE3D,mDAAqF;AAErF,6DAAqE;AAErE,sDAA4F;AAC5F,4CAawB;AAExB,6CAAsD;AAGtD,uCAA8C;AAArC,4GAAA,gBAAgB,OAAA;AAazB;;;GAGG;AACH,MAAa,mBAAmB;IAC5B,6EAA6E;IAE7E;;;;;OAKG;IACH,QAAQ,CAAC,GAAoB,EAAE,WAAyB,2BAAgB;QACpE,IAAI,GAAG,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;YAC5B,OAAO,IAAA,sBAAY,EAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAA,gCAAiB,EAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED,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D;AAArD,iHAAA,iBAAiB,OAAA;AAC1B,gDAAoD;AAA3C,uGAAA,YAAY,OAAA;AACrB,8CAAwD;AAA/C,2GAAA,iBAAiB,OAAA;AAC1B,iDAAkE;AAAzD,oHAAA,yBAAyB,OAAA"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAmpscriptSignatureHelp = getAmpscriptSignatureHelp;
|
|
4
|
-
const ampscript_js_1 = require("../data/ampscript.
|
|
5
|
-
/**
|
|
4
|
+
const ampscript_js_1 = require("../data/ampscript.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* Return AMPscript signature help for the given function context.
|
|
7
|
+
* @param context - Parsed function call context.
|
|
8
|
+
* @param context.functionName - Name of the function being called.
|
|
9
|
+
* @param context.paramIndex - Zero-based index of the active parameter.
|
|
10
|
+
* @returns SignatureHelp object, or null if the function is unknown.
|
|
11
|
+
*/
|
|
6
12
|
function getAmpscriptSignatureHelp(context) {
|
|
7
13
|
const fn = ampscript_js_1.functionLookup.get(context.functionName.toLowerCase());
|
|
8
14
|
if (!fn || !fn.params || fn.params.length === 0)
|
|
@@ -12,11 +18,13 @@ function getAmpscriptSignatureHelp(context) {
|
|
|
12
18
|
documentation: `${p.description}${p.optional ? ' *(optional)*' : ''}`,
|
|
13
19
|
}));
|
|
14
20
|
return {
|
|
15
|
-
signatures: [
|
|
21
|
+
signatures: [
|
|
22
|
+
{
|
|
16
23
|
label: fn.syntax,
|
|
17
24
|
documentation: fn.description,
|
|
18
25
|
parameters: parameterInfos,
|
|
19
|
-
}
|
|
26
|
+
},
|
|
27
|
+
],
|
|
20
28
|
activeSignature: 0,
|
|
21
29
|
activeParameter: Math.min(context.paramIndex, fn.params.length - 1),
|
|
22
30
|
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { SignatureHelp } from '../types.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Return AMPscript signature help for the given function context.
|
|
4
|
+
* @param context - Parsed function call context.
|
|
5
|
+
* @param context.functionName - Name of the function being called.
|
|
6
|
+
* @param context.paramIndex - Zero-based index of the active parameter.
|
|
7
|
+
* @returns SignatureHelp object, or null if the function is unknown.
|
|
8
|
+
*/
|
|
3
9
|
export declare function getAmpscriptSignatureHelp(context: {
|
|
4
10
|
functionName: string;
|
|
5
11
|
paramIndex: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ampscript.d.ts","sourceRoot":"","sources":["../../../src/signature/ampscript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,aAAa,CAAC;AAGvE
|
|
1
|
+
{"version":3,"file":"ampscript.d.ts","sourceRoot":"","sources":["../../../src/signature/ampscript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,aAAa,CAAC;AAGvE;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACtB,GAAG,aAAa,GAAG,IAAI,CAoBvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ampscript.js","sourceRoot":"","sources":["../../../src/signature/ampscript.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"ampscript.js","sourceRoot":"","sources":["../../../src/signature/ampscript.ts"],"names":[],"mappings":";;AAUA,8DAuBC;AAhCD,uDAAsD;AAEtD;;;;;;GAMG;AACH,SAAgB,yBAAyB,CAAC,OAGzC;IACG,MAAM,EAAE,GAAG,6BAAc,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,IAAI,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE7D,MAAM,cAAc,GAA2B,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjE,KAAK,EAAE,CAAC,CAAC,IAAI;QACb,aAAa,EAAE,GAAG,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE;KACxE,CAAC,CAAC,CAAC;IAEJ,OAAO;QACH,UAAU,EAAE;YACR;gBACI,KAAK,EAAE,EAAE,CAAC,MAAM;gBAChB,aAAa,EAAE,EAAE,CAAC,WAAW;gBAC7B,UAAU,EAAE,cAAc;aAC7B;SACJ;QACD,eAAe,EAAE,CAAC;QAClB,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;KACtE,CAAC;AACN,CAAC"}
|
|
@@ -1,46 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSsjsSignatureHelp = getSsjsSignatureHelp;
|
|
4
|
-
const ssjs_js_1 = require("../data/ssjs.
|
|
4
|
+
const ssjs_js_1 = require("../data/ssjs.cjs");
|
|
5
5
|
const ALL_SSJS_FUNCTIONS = [
|
|
6
|
-
...ssjs_js_1.platformMethods,
|
|
7
|
-
...ssjs_js_1.
|
|
8
|
-
...ssjs_js_1.
|
|
9
|
-
...ssjs_js_1.
|
|
6
|
+
...ssjs_js_1.platformMethods,
|
|
7
|
+
...ssjs_js_1.platformFunctions,
|
|
8
|
+
...ssjs_js_1.ssjsGlobals,
|
|
9
|
+
...ssjs_js_1.platformVariableMethods,
|
|
10
|
+
...ssjs_js_1.platformResponseMethods,
|
|
11
|
+
...ssjs_js_1.platformRequestMethods,
|
|
12
|
+
...ssjs_js_1.platformRecipientMethods,
|
|
13
|
+
...ssjs_js_1.wsproxyMethods,
|
|
14
|
+
...ssjs_js_1.httpMethods,
|
|
15
|
+
...ssjs_js_1.httpHeaderMethods,
|
|
16
|
+
...ssjs_js_1.dateTimeTimezoneMethods,
|
|
17
|
+
...ssjs_js_1.errorUtilMethods,
|
|
10
18
|
];
|
|
11
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Return SSJS signature help for the given function context.
|
|
21
|
+
* @param context - Parsed function call context.
|
|
22
|
+
* @param context.functionName - Name of the function being called.
|
|
23
|
+
* @param context.paramIndex - Zero-based index of the active parameter.
|
|
24
|
+
* @param localFunctions - Local function declarations from the document.
|
|
25
|
+
* @returns SignatureHelp object, or null if the function is unknown.
|
|
26
|
+
*/
|
|
12
27
|
function getSsjsSignatureHelp(context, localFunctions) {
|
|
13
28
|
const fn = ALL_SSJS_FUNCTIONS.find((f) => f.name.toLowerCase() === context.functionName.toLowerCase());
|
|
14
29
|
if (fn) {
|
|
15
30
|
const prefix = fn.prefix ? `${fn.prefix}.` : '';
|
|
16
31
|
if (fn.params && fn.params.length > 0) {
|
|
17
32
|
const parameterInfos = fn.params.map((p) => ({
|
|
18
|
-
label: p.name
|
|
33
|
+
label: `${p.name}${p.optional ? '?' : ''}: ${p.type ?? 'any'}`,
|
|
19
34
|
documentation: `${p.description}${p.optional ? ' *(optional)*' : ''}`,
|
|
20
35
|
}));
|
|
21
36
|
const sigLabel = fn.syntax
|
|
22
37
|
? `${prefix}${fn.syntax}`
|
|
23
|
-
: `${prefix}${fn.name}(${fn.params.map((p) => p.name).join(', ')})`;
|
|
38
|
+
: `${prefix}${fn.name}(${fn.params.map((p) => `${p.name}${p.optional ? '?' : ''}: ${p.type ?? 'any'}`).join(', ')})`;
|
|
24
39
|
return {
|
|
25
|
-
signatures: [
|
|
40
|
+
signatures: [
|
|
41
|
+
{ label: sigLabel, documentation: fn.description, parameters: parameterInfos },
|
|
42
|
+
],
|
|
26
43
|
activeSignature: 0,
|
|
27
44
|
activeParameter: Math.min(context.paramIndex, parameterInfos.length - 1),
|
|
28
45
|
};
|
|
29
46
|
}
|
|
30
|
-
const paramCount = fn.maxArgs === Infinity
|
|
31
|
-
? Math.max(fn.minArgs, context.paramIndex + 1)
|
|
32
|
-
: fn.maxArgs;
|
|
47
|
+
const paramCount = fn.maxArgs === Infinity ? Math.max(fn.minArgs, context.paramIndex + 1) : fn.maxArgs;
|
|
33
48
|
const paramLabels = [];
|
|
34
49
|
for (let i = 0; i < paramCount; i++) {
|
|
35
50
|
paramLabels.push(i < fn.minArgs ? `arg${i + 1}` : `arg${i + 1}?`);
|
|
36
51
|
}
|
|
37
52
|
const parameterInfos = paramLabels.map((label) => ({ label }));
|
|
38
53
|
return {
|
|
39
|
-
signatures: [
|
|
54
|
+
signatures: [
|
|
55
|
+
{
|
|
40
56
|
label: `${prefix}${fn.name}(${paramLabels.join(', ')})`,
|
|
41
57
|
documentation: fn.description,
|
|
42
58
|
parameters: parameterInfos,
|
|
43
|
-
}
|
|
59
|
+
},
|
|
60
|
+
],
|
|
44
61
|
activeSignature: 0,
|
|
45
62
|
activeParameter: Math.min(context.paramIndex, parameterInfos.length - 1),
|
|
46
63
|
};
|
|
@@ -53,19 +70,25 @@ function getSsjsSignatureHelp(context, localFunctions) {
|
|
|
53
70
|
const typeStr = pd?.type ? ` \`${pd.type}\`` : '';
|
|
54
71
|
return {
|
|
55
72
|
label: p,
|
|
56
|
-
documentation: pd
|
|
73
|
+
documentation: pd
|
|
74
|
+
? `${typeStr}${pd.description ? ` — ${pd.description}` : ''}`.trim()
|
|
75
|
+
: undefined,
|
|
57
76
|
};
|
|
58
77
|
});
|
|
59
|
-
const paramList = localFn.params
|
|
78
|
+
const paramList = localFn.params
|
|
79
|
+
.map((p) => {
|
|
60
80
|
const pd = localFn.paramDocs.get(p);
|
|
61
81
|
return pd?.type ? `${p}: ${pd.type}` : p;
|
|
62
|
-
})
|
|
82
|
+
})
|
|
83
|
+
.join(', ');
|
|
63
84
|
return {
|
|
64
|
-
signatures: [
|
|
85
|
+
signatures: [
|
|
86
|
+
{
|
|
65
87
|
label: `${localFn.name}(${paramList})`,
|
|
66
88
|
documentation: localFn.description || undefined,
|
|
67
89
|
parameters: parameterInfos,
|
|
68
|
-
}
|
|
90
|
+
},
|
|
91
|
+
],
|
|
69
92
|
activeSignature: 0,
|
|
70
93
|
activeParameter: Math.min(context.paramIndex, parameterInfos.length - 1),
|
|
71
94
|
};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { SignatureHelp } from '../types.js';
|
|
2
2
|
import type { LocalSsjsFunction } from '../utils/markdown.js';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Return SSJS signature help for the given function context.
|
|
5
|
+
* @param context - Parsed function call context.
|
|
6
|
+
* @param context.functionName - Name of the function being called.
|
|
7
|
+
* @param context.paramIndex - Zero-based index of the active parameter.
|
|
8
|
+
* @param localFunctions - Local function declarations from the document.
|
|
9
|
+
* @returns SignatureHelp object, or null if the function is unknown.
|
|
10
|
+
*/
|
|
4
11
|
export declare function getSsjsSignatureHelp(context: {
|
|
5
12
|
functionName: string;
|
|
6
13
|
paramIndex: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssjs.d.ts","sourceRoot":"","sources":["../../../src/signature/ssjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ssjs.d.ts","sourceRoot":"","sources":["../../../src/signature/ssjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAgC9D;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EACrD,cAAc,EAAE,iBAAiB,EAAE,GACpC,aAAa,GAAG,IAAI,CAoFtB"}
|