sfmc-language-lsp 3.9.0 → 3.11.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 +9 -0
- package/dist/cjs/data/ssjs.cjs +12 -7
- package/dist/cjs/data/ssjs.d.ts +32 -0
- package/dist/cjs/data/ssjs.d.ts.map +1 -1
- package/dist/cjs/data/ssjs.js.map +1 -1
- package/dist/cjs/validators/ssjs.cjs +173 -4
- package/dist/cjs/validators/ssjs.d.ts +2 -0
- package/dist/cjs/validators/ssjs.d.ts.map +1 -1
- package/dist/cjs/validators/ssjs.js.map +1 -1
- package/dist/esm/data/ssjs.d.ts +32 -0
- package/dist/esm/data/ssjs.d.ts.map +1 -1
- package/dist/esm/data/ssjs.js +12 -7
- package/dist/esm/data/ssjs.js.map +1 -1
- package/dist/esm/validators/ssjs.d.ts +2 -0
- package/dist/esm/validators/ssjs.d.ts.map +1 -1
- package/dist/esm/validators/ssjs.js +173 -4
- package/dist/esm/validators/ssjs.js.map +1 -1
- package/dist/types/data/ssjs.d.ts +32 -0
- package/dist/types/data/ssjs.d.ts.map +1 -1
- package/dist/types/validators/ssjs.d.ts +2 -0
- package/dist/types/validators/ssjs.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,6 +47,15 @@ import type {
|
|
|
47
47
|
} from 'sfmc-language-lsp';
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
## Core-version-aware SSJS diagnostics
|
|
51
|
+
|
|
52
|
+
Some Core library members only exist up to a maximum `Platform.Load("Core", <version>)` and are `undefined` beyond it. The SSJS validator reads the `maxCoreVersion` metadata from `ssjs-data`, compares it against the Core version the document actually loads, and escalates the diagnostic accordingly:
|
|
53
|
+
|
|
54
|
+
- No `Platform.Load("Core", …)`, or a version within range → **Warning** ("deprecated")
|
|
55
|
+
- A version above `maxCoreVersion` → **Error** (the member is `undefined`, so the call throws a `TypeError` at runtime)
|
|
56
|
+
|
|
57
|
+
`ErrorUtil` and `ErrorUtil.ThrowWSProxyError` are the first members covered — both are limited to Core version `"1"`.
|
|
58
|
+
|
|
50
59
|
## Install
|
|
51
60
|
|
|
52
61
|
```bash
|
package/dist/cjs/data/ssjs.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* propagate automatically.
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.httpPropertyConstraintLookup = exports.replaceableStaticLookup = exports.polyfillablePrototypeLookup = exports.polyfillableStaticLookup = exports.polyfillableMethods = exports.ecmascriptBuiltins = exports.deprecatedGlobals = exports.nonexistentGlobals = exports.requiresCoreLoadGlobals = exports.scriptUtilRequestMethods = exports.scriptUtilConstructors = exports.platformRecipientMethods = exports.errorUtilMethods = exports.dateTimeTimezoneMethods = exports.dateTimeMethods = exports.httpHeaderMethods = exports.httpMethods = exports.wsproxyMethods = exports.coreDeprecatedMethodLookup = exports.coreNonFunctionalMethodLookup = exports.coreObjectNameSet = exports.coreLibraryObjects = exports.coreRequestMethods = exports.platformRequestMethods = exports.platformResponseMethods = exports.platformVariableMethods = exports.ssjsGlobals = exports.platformFunctionLookup = exports.platformFunctions = exports.platformMethods = void 0;
|
|
11
|
+
exports.httpPropertyConstraintLookup = exports.propertyAccessLookup = exports.replaceableStaticLookup = exports.polyfillablePrototypeLookup = exports.polyfillableStaticLookup = exports.polyfillableMethods = exports.ecmascriptBuiltins = exports.deprecatedGlobals = exports.nonexistentGlobals = exports.requiresCoreLoadGlobals = exports.scriptUtilRequestMethods = exports.scriptUtilConstructors = exports.platformRecipientMethods = exports.errorUtilMethods = exports.dateTimeTimezoneMethods = exports.dateTimeMethods = exports.httpHeaderMethods = exports.httpMethods = exports.wsproxyMethods = exports.maxCoreVersionLookup = exports.coreDeprecatedMethodLookup = exports.coreNonFunctionalMethodLookup = exports.coreObjectNameSet = exports.coreLibraryObjects = exports.coreRequestMethods = exports.platformRequestMethods = exports.platformResponseMethods = exports.platformVariableMethods = exports.ssjsGlobals = exports.platformFunctionLookup = exports.platformFunctions = exports.platformMethods = void 0;
|
|
12
12
|
const ssjs_data_1 = require("ssjs-data");
|
|
13
13
|
const urls_1 = require("ssjs-data/urls");
|
|
14
14
|
// ── Top-level Platform methods ───────────────────────────────────────────────
|
|
@@ -95,6 +95,12 @@ exports.coreNonFunctionalMethodLookup = ssjs_data_1.coreNonFunctionalMethodLooku
|
|
|
95
95
|
* validators/hover/completions can surface deprecation warnings and notes.
|
|
96
96
|
*/
|
|
97
97
|
exports.coreDeprecatedMethodLookup = ssjs_data_1.coreDeprecatedMethodLookup;
|
|
98
|
+
/**
|
|
99
|
+
* Members that exist only up to a maximum `Platform.Load("Core", <version>)`.
|
|
100
|
+
* Map<qualifiedNameLower, { name, maxCoreVersion }> re-exposed from ssjs-data so
|
|
101
|
+
* validators can tell "deprecated but callable" from "undefined at runtime".
|
|
102
|
+
*/
|
|
103
|
+
exports.maxCoreVersionLookup = ssjs_data_1.maxCoreVersionLookup;
|
|
98
104
|
// ── WSProxy methods ──────────────────────────────────────────────────────────
|
|
99
105
|
exports.wsproxyMethods = ssjs_data_1.WSPROXY_METHODS.map((m) => ({
|
|
100
106
|
...m,
|
|
@@ -255,13 +261,12 @@ exports.replaceableStaticLookup = new Map(ssjs_data_1.KNOWN_UNSUPPORTED
|
|
|
255
261
|
},
|
|
256
262
|
]));
|
|
257
263
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
* the validator can flag
|
|
261
|
-
*
|
|
262
|
-
* and HttpGet define the same property, the constraints are identical, so a
|
|
263
|
-
* single map keyed by name is sufficient.
|
|
264
|
+
* Properties whose access direction is restricted at runtime, keyed by the
|
|
265
|
+
* lowercase qualified name (e.g. `platform.request.method`). Re-exposed from
|
|
266
|
+
* ssjs-data so the validator can flag reads of write-only properties and
|
|
267
|
+
* writes to read-only ones.
|
|
264
268
|
*/
|
|
269
|
+
exports.propertyAccessLookup = ssjs_data_1.propertyAccessLookup;
|
|
265
270
|
exports.httpPropertyConstraintLookup = new Map([
|
|
266
271
|
...ssjs_data_1.SCRIPT_UTIL_REQUEST_PROPERTIES,
|
|
267
272
|
...ssjs_data_1.SCRIPT_UTIL_HTTPGET_PROPERTIES,
|
package/dist/cjs/data/ssjs.d.ts
CHANGED
|
@@ -33,6 +33,11 @@ export interface SsjsFunction {
|
|
|
33
33
|
nonFunctionalAtRuntime?: boolean;
|
|
34
34
|
officialDocsNote?: string;
|
|
35
35
|
requiresCoreLoad?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Highest `Platform.Load("Core", <version>)` that still provides this member.
|
|
38
|
+
* Loading a newer Core version leaves it `undefined` at runtime.
|
|
39
|
+
*/
|
|
40
|
+
maxCoreVersion?: string;
|
|
36
41
|
aliasOf?: string;
|
|
37
42
|
/**
|
|
38
43
|
* Exact set of permitted argument counts for a discontinuous overload where a
|
|
@@ -98,6 +103,15 @@ export declare const coreNonFunctionalMethodLookup: Map<string, Map<string, Ssjs
|
|
|
98
103
|
* validators/hover/completions can surface deprecation warnings and notes.
|
|
99
104
|
*/
|
|
100
105
|
export declare const coreDeprecatedMethodLookup: Map<string, Map<string, SsjsFunction>>;
|
|
106
|
+
/**
|
|
107
|
+
* Members that exist only up to a maximum `Platform.Load("Core", <version>)`.
|
|
108
|
+
* Map<qualifiedNameLower, { name, maxCoreVersion }> re-exposed from ssjs-data so
|
|
109
|
+
* validators can tell "deprecated but callable" from "undefined at runtime".
|
|
110
|
+
*/
|
|
111
|
+
export declare const maxCoreVersionLookup: Map<string, {
|
|
112
|
+
name: string;
|
|
113
|
+
maxCoreVersion: string;
|
|
114
|
+
}>;
|
|
101
115
|
export declare const wsproxyMethods: SsjsFunction[];
|
|
102
116
|
export declare const httpMethods: SsjsFunction[];
|
|
103
117
|
export declare const httpHeaderMethods: SsjsFunction[];
|
|
@@ -189,5 +203,23 @@ export interface HttpPropertyValueConstraint {
|
|
|
189
203
|
* and HttpGet define the same property, the constraints are identical, so a
|
|
190
204
|
* single map keyed by name is sufficient.
|
|
191
205
|
*/
|
|
206
|
+
/**
|
|
207
|
+
* Restricted access direction of a property at runtime:
|
|
208
|
+
* `write-only` — assignment works, reading throws;
|
|
209
|
+
* `write-only-opaque` — assignment works, reading returns an opaque CLR value;
|
|
210
|
+
* `read-only` — reading works, assignment is silently ineffective.
|
|
211
|
+
*/
|
|
212
|
+
export type PropertyAccess = 'write-only' | 'write-only-opaque' | 'read-only';
|
|
213
|
+
/**
|
|
214
|
+
* Properties whose access direction is restricted at runtime, keyed by the
|
|
215
|
+
* lowercase qualified name (e.g. `platform.request.method`). Re-exposed from
|
|
216
|
+
* ssjs-data so the validator can flag reads of write-only properties and
|
|
217
|
+
* writes to read-only ones.
|
|
218
|
+
*/
|
|
219
|
+
export declare const propertyAccessLookup: Map<string, {
|
|
220
|
+
name: string;
|
|
221
|
+
owner: string;
|
|
222
|
+
access: PropertyAccess;
|
|
223
|
+
}>;
|
|
192
224
|
export declare const httpPropertyConstraintLookup: Map<string, HttpPropertyValueConstraint>;
|
|
193
225
|
//# sourceMappingURL=ssjs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssjs.d.ts","sourceRoot":"","sources":["../../../src/data/ssjs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"ssjs.d.ts","sourceRoot":"","sources":["../../../src/data/ssjs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiCH,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MA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Q,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,mBAAmB,GAAG,WAAW,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,GAAG,CAClC,MAAM,EACN;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CAC/B,CAAC;AAE7B,eAAO,MAAM,4BAA4B,0CAaxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssjs.js","sourceRoot":"","sources":["../../../src/data/ssjs.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"ssjs.js","sourceRoot":"","sources":["../../../src/data/ssjs.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,yCA4BmB;AACnB,yCAAgF;AA6EhF,gFAAgF;AAEnE,QAAA,eAAe,GAAmB,4BAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACxE,GAAG,CAAC;IACJ,MAAM,EAAE,UAAU;CACrB,CAAC,CAAC,CAAC;AAEJ,gFAAgF;AAEnE,QAAA,iBAAiB,GAAmB,8BAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5E,GAAG,CAAC;IACJ,MAAM,EAAE,mBAAmB;CAC9B,CAAC,CAAC,CAAC;AAES,QAAA,sBAAsB,GAAG,IAAI,GAAG,CACzC,yBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAC1D,CAAC;AAEF,gFAAgF;AAEhF,gFAAgF;AAChF,2EAA2E;AAC3E,uEAAuE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AC,CAAC,CAAC,CAC/C,CAAC;AAWF;;;;;;GAMG;AACU,QAAA,uBAAuB,GAAG,IAAI,GAAG,CACzC,6BAA0F;KACtF,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC;KAC9D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACR,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;IACtC;QACI,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,WAAW,EAAE,CAAC,CAAC,WAAqB;QACpC,UAAU,EAAE,CAAC,CAAC,UAAU;KAC3B;CACJ,CAAC,CACT,CAAC;AAiCF;;;;;GAKG;AACU,QAAA,oBAAoB,GAG7B,gCAAwB,CAAC;AAEhB,QAAA,4BAA4B,GAAG,IAAI,GAAG,CAC/C;IACI,GAAI,0CAGD;IACH,GAAI,0CAGD;CACN;KACI,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC;KAChC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,eAA8C,CAAC,CAAC,CAC9E,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SSJS_ESLINT_DUPLICATE_DIAG_CODES = exports.DIAG_CODE_SSJS_NONFUNCTIONAL_METHOD = exports.DIAG_CODE_SSJS_INVALID_ARITY = exports.DIAG_CODE_SSJS_DEPRECATED = exports.DIAG_CODE_SSJS_NONEXISTENT_GLOBAL = exports.DIAG_CODE_SSJS_INVALID_HTTP_PROPERTY = exports.DIAG_CODE_SSJS_CLR_CONTENT_ACCESS = exports.DIAG_CODE_SSJS_CLR_HEADER_ACCESS = exports.DIAG_CODE_SSJS_UNSUPPORTED_SYNTAX = exports.DIAG_CODE_SSJS_PLATFORM_LOAD_VERSION = exports.DIAG_CODE_SSJS_REQUIRE_PLATFORM_LOAD = exports.DIAG_CODE_SSJS_REPLACE_WITH_PLATFORM_FUNCTION = exports.DIAG_CODE_SSJS_MCN_NOT_SUPPORTED = exports.DIAG_CODE_SSJS_POLYFILL_REQUIRED = void 0;
|
|
3
|
+
exports.SSJS_ESLINT_DUPLICATE_DIAG_CODES = exports.DIAG_CODE_SSJS_NONFUNCTIONAL_METHOD = exports.DIAG_CODE_SSJS_INVALID_ARITY = exports.DIAG_CODE_SSJS_DEPRECATED = exports.DIAG_CODE_SSJS_NONEXISTENT_GLOBAL = exports.DIAG_CODE_SSJS_INVALID_PROPERTY_ACCESS = exports.DIAG_CODE_SSJS_INVALID_HTTP_PROPERTY = exports.DIAG_CODE_SSJS_CLR_CONTENT_ACCESS = exports.DIAG_CODE_SSJS_CLR_HEADER_ACCESS = exports.DIAG_CODE_SSJS_UNSUPPORTED_SYNTAX = exports.DIAG_CODE_SSJS_PLATFORM_LOAD_VERSION = exports.DIAG_CODE_SSJS_REQUIRE_PLATFORM_LOAD = exports.DIAG_CODE_SSJS_REPLACE_WITH_PLATFORM_FUNCTION = exports.DIAG_CODE_SSJS_MCN_NOT_SUPPORTED = exports.DIAG_CODE_SSJS_POLYFILL_REQUIRED = void 0;
|
|
4
4
|
exports.validateSsjs = validateSsjs;
|
|
5
5
|
const types_js_1 = require("../types.cjs");
|
|
6
6
|
const types_js_2 = require("../types.cjs");
|
|
@@ -49,6 +49,12 @@ exports.DIAG_CODE_SSJS_CLR_CONTENT_ACCESS = 'ssjs/clr-content-access';
|
|
|
49
49
|
// `req.emptyContentHandling = 5`, `req.retries = -2.45`, `req.method = 'POT'`).
|
|
50
50
|
// Constraints live in ssjs-data. Mirrors the `ssjs-http-property-value` rule.
|
|
51
51
|
exports.DIAG_CODE_SSJS_INVALID_HTTP_PROPERTY = 'ssjs/invalid-http-property-value';
|
|
52
|
+
// Property access that goes against the direction the runtime supports: reading
|
|
53
|
+
// a write-only property (`req.postData` — throws), reading a write-only-opaque
|
|
54
|
+
// one (`Platform.Response.ContentType` — returns an opaque CLR value), or
|
|
55
|
+
// assigning to a read-only one (`Platform.Request.Method` — no effect). Driven
|
|
56
|
+
// by ssjs-data's `access` field. Mirrors the `ssjs-no-invalid-property-access` rule.
|
|
57
|
+
exports.DIAG_CODE_SSJS_INVALID_PROPERTY_ACCESS = 'ssjs/invalid-property-access';
|
|
52
58
|
// Bare-name global that is officially documented but does NOT exist at runtime
|
|
53
59
|
// (calling it throws a ReferenceError), e.g. `Redirect`. Driven by ssjs-data's
|
|
54
60
|
// `notDefinedAtRuntime` flag. Mirrors the `ssjs-no-nonexistent-global` rule.
|
|
@@ -80,6 +86,7 @@ exports.DIAG_CODE_SSJS_NONFUNCTIONAL_METHOD = 'ssjs/nonfunctional-method';
|
|
|
80
86
|
* - clr-header-access → `ssjs-no-clr-header-access`
|
|
81
87
|
* - clr-content-access → `ssjs-require-string-clr-content`
|
|
82
88
|
* - invalid-http-property-value → `ssjs-http-property-value`
|
|
89
|
+
* - invalid-property-access → `ssjs-no-invalid-property-access`
|
|
83
90
|
* - nonexistent-global → `ssjs-no-nonexistent-global`
|
|
84
91
|
* - deprecated → `ssjs-no-deprecated-function`
|
|
85
92
|
* - invalid-arity → `ssjs-platform-function-arity`
|
|
@@ -95,6 +102,7 @@ exports.SSJS_ESLINT_DUPLICATE_DIAG_CODES = new Set([
|
|
|
95
102
|
exports.DIAG_CODE_SSJS_CLR_HEADER_ACCESS,
|
|
96
103
|
exports.DIAG_CODE_SSJS_CLR_CONTENT_ACCESS,
|
|
97
104
|
exports.DIAG_CODE_SSJS_INVALID_HTTP_PROPERTY,
|
|
105
|
+
exports.DIAG_CODE_SSJS_INVALID_PROPERTY_ACCESS,
|
|
98
106
|
exports.DIAG_CODE_SSJS_NONEXISTENT_GLOBAL,
|
|
99
107
|
exports.DIAG_CODE_SSJS_DEPRECATED,
|
|
100
108
|
exports.DIAG_CODE_SSJS_INVALID_ARITY,
|
|
@@ -492,6 +500,103 @@ function collectInvalidHttpPropertyDiagnostics(text, commentRanges, budget) {
|
|
|
492
500
|
}
|
|
493
501
|
return diagnostics;
|
|
494
502
|
}
|
|
503
|
+
/**
|
|
504
|
+
* Builds the diagnostic message for a restricted-access violation.
|
|
505
|
+
* @param owner - Qualified owner name (e.g. `Platform.Request`).
|
|
506
|
+
* @param name - Property name as declared in ssjs-data.
|
|
507
|
+
* @param access - The restriction that was violated.
|
|
508
|
+
* @returns The human-readable diagnostic message.
|
|
509
|
+
*/
|
|
510
|
+
function propertyAccessMessage(owner, name, access) {
|
|
511
|
+
if (access === 'write-only') {
|
|
512
|
+
return (`'${owner}.${name}' is write-only. Reading it throws "Property Get method was not ` +
|
|
513
|
+
`found." at runtime — outside a try/catch that throw aborts the whole page. Keep the ` +
|
|
514
|
+
`value in your own variable instead.`);
|
|
515
|
+
}
|
|
516
|
+
if (access === 'write-only-opaque') {
|
|
517
|
+
return (`'${owner}.${name}' does not read back the value you assigned — the runtime returns ` +
|
|
518
|
+
`an opaque CLR value. Keep the value in your own variable instead.`);
|
|
519
|
+
}
|
|
520
|
+
return `'${owner}.${name}' is read-only. Assigning to it has no effect.`;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Scan the document for property accesses that go against the direction the
|
|
524
|
+
* runtime supports: reading a `write-only` / `write-only-opaque` property, or
|
|
525
|
+
* assigning to a `read-only` one. The restrictions come from ssjs-data's
|
|
526
|
+
* `access` field, so this pass and the `ssjs-no-invalid-property-access` rule
|
|
527
|
+
* share one source of truth.
|
|
528
|
+
*
|
|
529
|
+
* Accesses on a bare identifier only count when that identifier holds a
|
|
530
|
+
* `Script.Util.HttpRequest` / `HttpGet` instance (same tracking as the other
|
|
531
|
+
* HTTP passes); `Platform.Request.*` / `Platform.Response.*` are matched on the
|
|
532
|
+
* literal member path.
|
|
533
|
+
* @param text - Full document text.
|
|
534
|
+
* @param commentRanges - Comment ranges to skip.
|
|
535
|
+
* @param budget - Maximum number of diagnostics still allowed.
|
|
536
|
+
* @returns Diagnostics for invalid property accesses (length ≤ budget).
|
|
537
|
+
*/
|
|
538
|
+
function collectInvalidPropertyAccessDiagnostics(text, commentRanges, budget) {
|
|
539
|
+
const diagnostics = [];
|
|
540
|
+
if (budget <= 0 || ssjs_js_1.propertyAccessLookup.size === 0)
|
|
541
|
+
return diagnostics;
|
|
542
|
+
// 1. Collect request variables (same shape as the other HTTP passes).
|
|
543
|
+
const requestVars = new Set();
|
|
544
|
+
const reqPattern = /\b(?:var\s+)?([A-Za-z_$][\w$]*)\s*=\s*(?:new\s+)?Script\s*\.\s*Util\s*\.\s*(?:HttpRequest|HttpGet)\s*\(/g;
|
|
545
|
+
let rm;
|
|
546
|
+
while ((rm = reqPattern.exec(text)) !== null) {
|
|
547
|
+
if ((0, comments_js_1.isInCommentRange)(rm.index, commentRanges))
|
|
548
|
+
continue;
|
|
549
|
+
requestVars.add(rm[1]);
|
|
550
|
+
}
|
|
551
|
+
// 2. Every `Platform.Request|Response.<prop>` or `<identifier>.<prop>` access.
|
|
552
|
+
// The Platform branch is listed first so it wins over the bare-identifier one.
|
|
553
|
+
const accessPattern = /\bPlatform\s*\.\s*(Request|Response)\s*\.\s*([A-Za-z_$][\w$]*)|\b([A-Za-z_$][\w$]*)\s*\.\s*([A-Za-z_$][\w$]*)/g;
|
|
554
|
+
let am;
|
|
555
|
+
while ((am = accessPattern.exec(text)) !== null && diagnostics.length < budget) {
|
|
556
|
+
if ((0, comments_js_1.isInCommentRange)(am.index, commentRanges))
|
|
557
|
+
continue;
|
|
558
|
+
const [match, platformNs, platformProp, identifier, identifierProp] = am;
|
|
559
|
+
let owner;
|
|
560
|
+
let propName;
|
|
561
|
+
if (platformNs) {
|
|
562
|
+
owner = `Platform.${platformNs}`;
|
|
563
|
+
propName = platformProp;
|
|
564
|
+
}
|
|
565
|
+
else if (requestVars.has(identifier)) {
|
|
566
|
+
owner = 'Script.Util.HttpRequest';
|
|
567
|
+
propName = identifierProp;
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
const entry = ssjs_js_1.propertyAccessLookup.get(`${owner}.${propName}`.toLowerCase());
|
|
573
|
+
if (!entry)
|
|
574
|
+
continue;
|
|
575
|
+
// A plain `=` right after the member expression makes this a write;
|
|
576
|
+
// `==` / `===` / `=>` are comparisons or arrows, i.e. still reads.
|
|
577
|
+
const after = text.slice(am.index + match.length);
|
|
578
|
+
const isWrite = /^\s*=(?![=>])/.test(after);
|
|
579
|
+
if (isWrite !== (entry.access === 'read-only'))
|
|
580
|
+
continue;
|
|
581
|
+
// The call form (`Platform.Response.ContentType()`) is already reported
|
|
582
|
+
// by the property-call diagnostics — skip it here to avoid duplicates.
|
|
583
|
+
if (!isWrite && /^\s*\(/.test(after))
|
|
584
|
+
continue;
|
|
585
|
+
diagnostics.push({
|
|
586
|
+
severity: entry.access === 'write-only-opaque'
|
|
587
|
+
? types_js_1.DiagnosticSeverity.Warning
|
|
588
|
+
: types_js_1.DiagnosticSeverity.Error,
|
|
589
|
+
range: {
|
|
590
|
+
start: (0, positions_js_1.offsetToPosition)(text, am.index),
|
|
591
|
+
end: (0, positions_js_1.offsetToPosition)(text, am.index + match.length),
|
|
592
|
+
},
|
|
593
|
+
message: propertyAccessMessage(entry.owner, entry.name, entry.access),
|
|
594
|
+
source: 'ssjs',
|
|
595
|
+
code: exports.DIAG_CODE_SSJS_INVALID_PROPERTY_ACCESS,
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
return diagnostics;
|
|
599
|
+
}
|
|
495
600
|
/**
|
|
496
601
|
* Renders a `validArities` set as a human phrase, e.g. `[1, 6]` → "1 or 6",
|
|
497
602
|
* `[1, 2, 4]` → "1, 2 or 4".
|
|
@@ -775,6 +880,53 @@ function deprecationNote(entry) {
|
|
|
775
880
|
const match = /deprecated\s*—\s*(.+)$/i.exec(entry.description ?? '');
|
|
776
881
|
return match ? `Deprecated — ${match[1]}` : 'This API is deprecated.';
|
|
777
882
|
}
|
|
883
|
+
// Matches `Platform.Load("core", "<version>")`. Kept as a source string because the
|
|
884
|
+
// pattern is used with the global flag in two places and would otherwise share
|
|
885
|
+
// lastIndex state between scans.
|
|
886
|
+
const PLATFORM_LOAD_VERSION_SOURCE = String.raw `Platform\s*\.\s*Load\s*\(\s*["']core["']\s*,\s*["']([^"']*)["']\s*\)`;
|
|
887
|
+
/**
|
|
888
|
+
* Find the Core version a document loads via `Platform.Load("core", "<version>")`.
|
|
889
|
+
* @param text - Full document text.
|
|
890
|
+
* @param commentRanges - Precomputed comment ranges to skip.
|
|
891
|
+
* @returns The first non-commented version string, or undefined when none is found.
|
|
892
|
+
*/
|
|
893
|
+
function findLoadedCoreVersion(text, commentRanges) {
|
|
894
|
+
const pattern = new RegExp(PLATFORM_LOAD_VERSION_SOURCE, 'gi');
|
|
895
|
+
let match;
|
|
896
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
897
|
+
if ((0, comments_js_1.isInCommentRange)(match.index, commentRanges))
|
|
898
|
+
continue;
|
|
899
|
+
return match[1];
|
|
900
|
+
}
|
|
901
|
+
return undefined;
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Split a Core version string into three numeric segments, padding missing ones
|
|
905
|
+
* with 0 so "1" and "1.0.0" are equivalent.
|
|
906
|
+
* @param version - Version string, e.g. "1" or "1.1.5".
|
|
907
|
+
* @returns Three numeric segments.
|
|
908
|
+
*/
|
|
909
|
+
function parseCoreVersion(version) {
|
|
910
|
+
const parts = version.split('.').map((p) => Number(p) || 0);
|
|
911
|
+
while (parts.length < 3)
|
|
912
|
+
parts.push(0);
|
|
913
|
+
return parts;
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Compare two Core version strings ("1", "1.1.5", …) numerically.
|
|
917
|
+
* @param a - Left version.
|
|
918
|
+
* @param b - Right version.
|
|
919
|
+
* @returns Negative when a < b, 0 when equal, positive when a > b.
|
|
920
|
+
*/
|
|
921
|
+
function compareCoreVersions(a, b) {
|
|
922
|
+
const left = parseCoreVersion(a);
|
|
923
|
+
const right = parseCoreVersion(b);
|
|
924
|
+
for (const [index, element] of left.entries()) {
|
|
925
|
+
if (element !== right[index])
|
|
926
|
+
return element - right[index];
|
|
927
|
+
}
|
|
928
|
+
return 0;
|
|
929
|
+
}
|
|
778
930
|
/**
|
|
779
931
|
* Collect diagnostics for Core Library method calls flagged `deprecated` in
|
|
780
932
|
* ssjs-data (e.g. `ContentAreaObj.Init`, `Send.Definition.Add`, `Portfolio.Update`).
|
|
@@ -1048,6 +1200,13 @@ function validateSsjs(text, settings = types_js_2.DEFAULT_SETTINGS) {
|
|
|
1048
1200
|
if (deprecatedErrorUtil.length > 0) {
|
|
1049
1201
|
const methodNames = deprecatedErrorUtil.map((m) => m.name).join('|');
|
|
1050
1202
|
const errorUtilPattern = new RegExp(String.raw `\bErrorUtil\s*\.\s*(${methodNames})\s*\(`, 'g');
|
|
1203
|
+
// The wording depends on which Core version the file loads: under a version
|
|
1204
|
+
// above maxCoreVersion, ErrorUtil is undefined and the call throws.
|
|
1205
|
+
const maxCoreVersion = ssjs_js_1.maxCoreVersionLookup.get('errorutil')?.maxCoreVersion;
|
|
1206
|
+
const loadedCoreVersion = findLoadedCoreVersion(text, commentRanges);
|
|
1207
|
+
const isUnavailable = maxCoreVersion !== undefined &&
|
|
1208
|
+
loadedCoreVersion !== undefined &&
|
|
1209
|
+
compareCoreVersions(loadedCoreVersion, maxCoreVersion) > 0;
|
|
1051
1210
|
let euMatch;
|
|
1052
1211
|
while ((euMatch = errorUtilPattern.exec(text)) !== null && problems < max) {
|
|
1053
1212
|
if ((0, comments_js_1.isInCommentRange)(euMatch.index, commentRanges))
|
|
@@ -1056,12 +1215,14 @@ function validateSsjs(text, settings = types_js_2.DEFAULT_SETTINGS) {
|
|
|
1056
1215
|
const name = euMatch[1];
|
|
1057
1216
|
const nameStart = euMatch.index + euMatch[0].indexOf(name);
|
|
1058
1217
|
diagnostics.push({
|
|
1059
|
-
severity: types_js_1.DiagnosticSeverity.Warning,
|
|
1218
|
+
severity: isUnavailable ? types_js_1.DiagnosticSeverity.Error : types_js_1.DiagnosticSeverity.Warning,
|
|
1060
1219
|
range: {
|
|
1061
1220
|
start: (0, positions_js_1.offsetToPosition)(text, nameStart),
|
|
1062
1221
|
end: (0, positions_js_1.offsetToPosition)(text, nameStart + name.length),
|
|
1063
1222
|
},
|
|
1064
|
-
message:
|
|
1223
|
+
message: isUnavailable
|
|
1224
|
+
? `'ErrorUtil.${name}' is undefined under Platform.Load("Core", "${loadedCoreVersion}") — it only exists in Core version "${maxCoreVersion}", so this call throws a TypeError at runtime. Check 'result.Status' and 'throw new Error(...)' instead.`
|
|
1225
|
+
: `'ErrorUtil.${name}' is deprecated — it only exists under Platform.Load("Core", "1") and is undefined in newer Core versions. Check 'result.Status' and 'throw new Error(...)' instead.`,
|
|
1065
1226
|
source: 'ssjs',
|
|
1066
1227
|
code: exports.DIAG_CODE_SSJS_DEPRECATED,
|
|
1067
1228
|
});
|
|
@@ -1077,7 +1238,7 @@ function validateSsjs(text, settings = types_js_2.DEFAULT_SETTINGS) {
|
|
|
1077
1238
|
diagnostics.push(...deprecatedMethodDiagnostics);
|
|
1078
1239
|
}
|
|
1079
1240
|
// 2. Wrong Platform.Load version
|
|
1080
|
-
const platformLoadVersionPattern =
|
|
1241
|
+
const platformLoadVersionPattern = new RegExp(PLATFORM_LOAD_VERSION_SOURCE, 'gi');
|
|
1081
1242
|
let versionMatch;
|
|
1082
1243
|
while ((versionMatch = platformLoadVersionPattern.exec(text)) !== null && problems < max) {
|
|
1083
1244
|
if ((0, comments_js_1.isInCommentRange)(versionMatch.index, commentRanges))
|
|
@@ -1284,6 +1445,14 @@ function validateSsjs(text, settings = types_js_2.DEFAULT_SETTINGS) {
|
|
|
1284
1445
|
problems += invalidPropDiagnostics.length;
|
|
1285
1446
|
diagnostics.push(...invalidPropDiagnostics);
|
|
1286
1447
|
}
|
|
1448
|
+
// 4e-2. Property accesses against the runtime-supported direction: reads of
|
|
1449
|
+
// write-only properties (`req.postData`, `Platform.Response.ContentType`) and
|
|
1450
|
+
// assignments to read-only ones (`Platform.Request.Method = …`).
|
|
1451
|
+
if (problems < max) {
|
|
1452
|
+
const accessDiagnostics = collectInvalidPropertyAccessDiagnostics(text, commentRanges, max - problems);
|
|
1453
|
+
problems += accessDiagnostics.length;
|
|
1454
|
+
diagnostics.push(...accessDiagnostics);
|
|
1455
|
+
}
|
|
1287
1456
|
// 4f. Platform.Function calls with a discontinuous-overload arity violation
|
|
1288
1457
|
// (argument count in [minArgs, maxArgs] but not in validArities, e.g. HTTPGet
|
|
1289
1458
|
// called with 2-5 args). Only functions declaring validArities participate.
|
|
@@ -9,6 +9,7 @@ export declare const DIAG_CODE_SSJS_UNSUPPORTED_SYNTAX = "ssjs/unsupported-synta
|
|
|
9
9
|
export declare const DIAG_CODE_SSJS_CLR_HEADER_ACCESS = "ssjs/clr-header-access";
|
|
10
10
|
export declare const DIAG_CODE_SSJS_CLR_CONTENT_ACCESS = "ssjs/clr-content-access";
|
|
11
11
|
export declare const DIAG_CODE_SSJS_INVALID_HTTP_PROPERTY = "ssjs/invalid-http-property-value";
|
|
12
|
+
export declare const DIAG_CODE_SSJS_INVALID_PROPERTY_ACCESS = "ssjs/invalid-property-access";
|
|
12
13
|
export declare const DIAG_CODE_SSJS_NONEXISTENT_GLOBAL = "ssjs/nonexistent-global";
|
|
13
14
|
export declare const DIAG_CODE_SSJS_DEPRECATED = "ssjs/deprecated";
|
|
14
15
|
export declare const DIAG_CODE_SSJS_INVALID_ARITY = "ssjs/invalid-arity";
|
|
@@ -24,6 +25,7 @@ export declare const DIAG_CODE_SSJS_NONFUNCTIONAL_METHOD = "ssjs/nonfunctional-m
|
|
|
24
25
|
* - clr-header-access → `ssjs-no-clr-header-access`
|
|
25
26
|
* - clr-content-access → `ssjs-require-string-clr-content`
|
|
26
27
|
* - invalid-http-property-value → `ssjs-http-property-value`
|
|
28
|
+
* - invalid-property-access → `ssjs-no-invalid-property-access`
|
|
27
29
|
* - nonexistent-global → `ssjs-no-nonexistent-global`
|
|
28
30
|
* - deprecated → `ssjs-no-deprecated-function`
|
|
29
31
|
* - invalid-arity → `ssjs-platform-function-arity`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssjs.d.ts","sourceRoot":"","sources":["../../../src/validators/ssjs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ssjs.d.ts","sourceRoot":"","sources":["../../../src/validators/ssjs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAkChD,eAAO,MAAM,gCAAgC,2BAA2B,CAAC;AACzE,eAAO,MAAM,gCAAgC,2BAA2B,CAAC;AAIzE,eAAO,MAAM,6CAA6C,wCAAwC,CAAC;AAGnG,eAAO,MAAM,oCAAoC,+BAA+B,CAAC;AAGjF,eAAO,MAAM,oCAAoC,+BAA+B,CAAC;AAIjF,eAAO,MAAM,iCAAiC,4BAA4B,CAAC;AAK3E,eAAO,MAAM,gCAAgC,2BAA2B,CAAC;AAMzE,eAAO,MAAM,iCAAiC,4BAA4B,CAAC;AAK3E,eAAO,MAAM,oCAAoC,qCAAqC,CAAC;AAMvF,eAAO,MAAM,sCAAsC,iCAAiC,CAAC;AAIrF,eAAO,MAAM,iCAAiC,4BAA4B,CAAC;AAI3E,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AAM3D,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AAMjE,eAAO,MAA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