ampscript-data 3.6.0 → 4.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/package.json +2 -2
- package/src/constants.js +47 -0
- package/src/derived.js +100 -0
- package/src/functions/content.js +1028 -0
- package/src/functions/data-extension.js +1117 -0
- package/src/functions/date-time.js +411 -0
- package/src/functions/einstein-email-recs.js +32 -0
- package/src/functions/encryption-encoding.js +545 -0
- package/src/functions/http.js +338 -0
- package/src/functions/index.js +203 -0
- package/src/functions/marketing-cloud-api.js +378 -0
- package/src/functions/math.js +167 -0
- package/src/functions/microsoft-dynamics.js +400 -0
- package/src/functions/mobileconnect.js +339 -0
- package/src/functions/sales-service-cloud.js +230 -0
- package/src/functions/social.js +151 -0
- package/src/functions/string.js +432 -0
- package/src/functions/utility.js +1118 -0
- package/src/globals.js +9 -0
- package/src/index.js +48 -6865
- package/src/keywords.js +121 -0
- package/src/operators.js +66 -0
- package/src/personalization.js +254 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ampscript-data",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Canonical AMPscript function catalog, keywords, and personalization strings for SFMC tooling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"scripts": {
|
|
32
|
-
"test": "
|
|
32
|
+
"test": "node --test tests/*.test.mjs",
|
|
33
33
|
"lint": "eslint .",
|
|
34
34
|
"lint:fix": "eslint --fix .",
|
|
35
35
|
"prepare": "husky || true",
|
package/src/constants.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// AUTO-SPLIT from the original single-file src/index.js. Data moved verbatim.
|
|
2
|
+
// Shared constants used across the split data files.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Sentinel for variadic functions (maxArgs === Infinity).
|
|
6
|
+
*/
|
|
7
|
+
export const INF = Infinity;
|
|
8
|
+
|
|
9
|
+
// ── Verification-blocked reasons ─────────────────────────────────────────────
|
|
10
|
+
// Fixed enum of concrete technical/environmental reasons why a runtime verification
|
|
11
|
+
// was ATTEMPTED but could not complete. Set on an entry as `verificationBlockedReason`
|
|
12
|
+
// together with `verificationBlocked: true` and `isConfirmed: false`. The specific
|
|
13
|
+
// evidence (error text, invocation shapes tried) belongs in `officialDocsNote`, not here.
|
|
14
|
+
//
|
|
15
|
+
// - no-working-invocation probing found no invocation shape that works; document
|
|
16
|
+
// exactly what was tried in officialDocsNote.
|
|
17
|
+
// - needs-auth-context requires an authenticated / session / subscriber state that
|
|
18
|
+
// the probe context (e.g. a plain CloudPage) cannot supply
|
|
19
|
+
// - no-test-data requires pre-existing data or an integration that is not
|
|
20
|
+
// provisioned on the BU
|
|
21
|
+
// - classic-only-no-assets only works with classic (legacy) assets and none exist
|
|
22
|
+
// on the BU to test against
|
|
23
|
+
// - destructive-unsafe cannot be exercised without unacceptable side effects
|
|
24
|
+
/**
|
|
25
|
+
@type {readonly string[]}
|
|
26
|
+
*/
|
|
27
|
+
export const VERIFICATION_BLOCKED_REASONS = Object.freeze([
|
|
28
|
+
'no-working-invocation',
|
|
29
|
+
'needs-auth-context',
|
|
30
|
+
'no-test-data',
|
|
31
|
+
'classic-only-no-assets',
|
|
32
|
+
'destructive-unsafe',
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
export const EMAIL_EXCLUDED_CATEGORIES = new Set(['Marketing Cloud API']);
|
|
36
|
+
|
|
37
|
+
export const EMAIL_EXCLUDED_FUNCTIONS = new Set([
|
|
38
|
+
'insertdata',
|
|
39
|
+
'updatedata',
|
|
40
|
+
'upsertdata',
|
|
41
|
+
'deletedata',
|
|
42
|
+
'redirect',
|
|
43
|
+
'requestparameter',
|
|
44
|
+
'queryparameter',
|
|
45
|
+
'httprequestheader',
|
|
46
|
+
'isctmlbrowser',
|
|
47
|
+
]);
|
package/src/derived.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// AUTO-SPLIT from the original single-file src/index.js. Logic moved verbatim.
|
|
2
|
+
// Lookups, canonical-casing maps, deprecated/non-functional lookups and the
|
|
3
|
+
// email/MCN helper functions derived from the FUNCTIONS catalog.
|
|
4
|
+
|
|
5
|
+
import { FUNCTIONS } from './functions/index.js';
|
|
6
|
+
import { EMAIL_EXCLUDED_CATEGORIES, EMAIL_EXCLUDED_FUNCTIONS } from './constants.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Case-insensitive lookup: lowercase name -> function entry
|
|
10
|
+
*/
|
|
11
|
+
export const functionLookup = new Map(FUNCTIONS.map((f) => [f.name.toLowerCase(), f]));
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Set of lowercase function names for quick membership checks
|
|
15
|
+
*/
|
|
16
|
+
export const functionNames = new Set(FUNCTIONS.map((f) => f.name.toLowerCase()));
|
|
17
|
+
|
|
18
|
+
// ── Canonical casing map ─────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Ordered list of canonical PascalCase function names
|
|
22
|
+
*/
|
|
23
|
+
export const CANONICAL_FUNCTIONS = FUNCTIONS.map((f) => f.name);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Map from lowercase -> canonical PascalCase name
|
|
27
|
+
*/
|
|
28
|
+
export const FUNCTION_CANONICAL_MAP = new Map(
|
|
29
|
+
CANONICAL_FUNCTIONS.map((name) => [name.toLowerCase(), name]),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// ── Deprecated functions ─────────────────────────────────────────────────────
|
|
33
|
+
// Deprecation metadata lives inline on each FUNCTIONS entry via the
|
|
34
|
+
// `deprecated`, `deprecatedReplacement`, and `deprecatedReason` fields. The
|
|
35
|
+
// lookup below is derived from those flags for consumers that need a quick
|
|
36
|
+
// name -> entry map of deprecated functions.
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Case-insensitive lookup of deprecated functions: lowercase name -> function entry
|
|
40
|
+
*/
|
|
41
|
+
export const deprecatedFunctionLookup = new Map(
|
|
42
|
+
FUNCTIONS.filter((f) => f.deprecated).map((f) => [f.name.toLowerCase(), f]),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Case-insensitive lookup of functions that resolve at runtime but have no known
|
|
47
|
+
* working invocation (`nonFunctionalAtRuntime`): lowercase name -> function entry.
|
|
48
|
+
* Every reached call aborts the page (e.g. a retired Classic feature), so callers
|
|
49
|
+
* can flag the call site. Kept separate from deprecation because these functions
|
|
50
|
+
* were never formally deprecated by Salesforce.
|
|
51
|
+
*/
|
|
52
|
+
export const nonFunctionalFunctionLookup = new Map(
|
|
53
|
+
FUNCTIONS.filter((f) => f.nonFunctionalAtRuntime).map((f) => [f.name.toLowerCase(), f]),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// ── Email-context restrictions ───────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
export function isEmailExcluded(functionName) {
|
|
59
|
+
const lower = functionName.toLowerCase();
|
|
60
|
+
if (EMAIL_EXCLUDED_FUNCTIONS.has(lower)) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const entry = functionLookup.get(lower);
|
|
64
|
+
return entry ? EMAIL_EXCLUDED_CATEGORIES.has(entry.category) : false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ── Marketing Cloud Next (MCN) helpers ───────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns the API version from which this AMPscript function is supported in
|
|
71
|
+
* Marketing Cloud Next, or null if it is not supported in MCN.
|
|
72
|
+
*
|
|
73
|
+
* @param {string} name - AMPscript function name (case-insensitive).
|
|
74
|
+
* @returns {number | null} API version number (e.g. 67) or null.
|
|
75
|
+
*/
|
|
76
|
+
export function getMcnApiVersion(name) {
|
|
77
|
+
return functionLookup.get(name.toLowerCase())?.mcnSince ?? null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Returns true when the given AMPscript function is supported in Marketing
|
|
82
|
+
* Cloud Next (i.e. mcnSince is a non-null API version number).
|
|
83
|
+
*
|
|
84
|
+
* @param {string} name - AMPscript function name (case-insensitive).
|
|
85
|
+
* @returns {boolean} True when the function is supported in Marketing Cloud Next.
|
|
86
|
+
*/
|
|
87
|
+
export function isMcnSupported(name) {
|
|
88
|
+
return getMcnApiVersion(name) !== null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Returns the MCN behavioral difference notes for the given function, or null
|
|
93
|
+
* if there are no differences or the function is not MCN-supported.
|
|
94
|
+
*
|
|
95
|
+
* @param {string} name - AMPscript function name (case-insensitive).
|
|
96
|
+
* @returns {string | null} Behavioral difference notes, or null.
|
|
97
|
+
*/
|
|
98
|
+
export function getMcnNotes(name) {
|
|
99
|
+
return functionLookup.get(name.toLowerCase())?.mcnNotes ?? null;
|
|
100
|
+
}
|