ampscript-data 1.1.0 → 2.0.1
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 +7 -1
- package/package.json +1 -1
- package/src/index.js +103 -38
package/README.md
CHANGED
|
@@ -169,10 +169,16 @@ getMcnNotes('ProperCase'); // null
|
|
|
169
169
|
|
|
170
170
|
### `AMPSCRIPT_KEYWORDS`
|
|
171
171
|
|
|
172
|
-
An array of AMPscript language
|
|
172
|
+
An array of AMPscript language keyword descriptors (`if`, `for`, `set`, etc.). Each entry carries a short description and a completion snippet with `${n:placeholder}` tab stops:
|
|
173
173
|
|
|
174
174
|
```js
|
|
175
175
|
import { AMPSCRIPT_KEYWORDS } from 'ampscript-data';
|
|
176
|
+
|
|
177
|
+
for (const kw of AMPSCRIPT_KEYWORDS) {
|
|
178
|
+
console.log(kw.name); // e.g. 'if'
|
|
179
|
+
console.log(kw.description); // human-readable description
|
|
180
|
+
console.log(kw.snippet); // completion body, e.g. 'if ${1:condition} then\n\t${2}\nendif'
|
|
181
|
+
}
|
|
176
182
|
```
|
|
177
183
|
|
|
178
184
|
### `PERSONALIZATION_STRINGS`
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -105,7 +105,7 @@ export const FUNCTIONS = [
|
|
|
105
105
|
mcnNotes: null,
|
|
106
106
|
docUrl: 'https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-content/mc-ampscript-reference-content-attach-file.html',
|
|
107
107
|
guideUrl: 'https://ampscript.guide/attachfile/',
|
|
108
|
-
minArgs:
|
|
108
|
+
minArgs: 2,
|
|
109
109
|
maxArgs: 8,
|
|
110
110
|
category: 'Content',
|
|
111
111
|
description: 'Includes a file attachment in the outgoing message.',
|
|
@@ -365,7 +365,7 @@ export const FUNCTIONS = [
|
|
|
365
365
|
],
|
|
366
366
|
returnType: 'string',
|
|
367
367
|
returnDescription: 'A URL that renders the requested barcode image.',
|
|
368
|
-
syntax: 'BarcodeURL(valueToConvert, barcodeType, width, height, checksumValue,
|
|
368
|
+
syntax: 'BarcodeURL(valueToConvert, barcodeType, width, height, checksumValue, showText, altText, rotation, transparentBG)',
|
|
369
369
|
example: "%%=BarcodeURL('12345', 'qr', 150, 150, 0, 0, '', 0, 0)=%%",
|
|
370
370
|
},
|
|
371
371
|
{
|
|
@@ -857,7 +857,7 @@ export const FUNCTIONS = [
|
|
|
857
857
|
syntax: 'ContentArea(contentAreaId[, impressionRegionName, errorOnMissingContentArea, errorMessage, statusCode])',
|
|
858
858
|
example: '%%=ContentArea(12345)=%%',
|
|
859
859
|
deprecated: true,
|
|
860
|
-
deprecatedReplacement: '
|
|
860
|
+
deprecatedReplacement: 'ContentBlockByID',
|
|
861
861
|
deprecatedReason:
|
|
862
862
|
'ContentArea references classic content areas, which are no longer supported. Use Content Builder content blocks instead.',
|
|
863
863
|
},
|
|
@@ -1103,7 +1103,7 @@ export const FUNCTIONS = [
|
|
|
1103
1103
|
mcnNotes: null,
|
|
1104
1104
|
docUrl: 'https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-content/mc-ampscript-reference-content-image-by-id.html',
|
|
1105
1105
|
guideUrl: 'https://ampscript.guide/contentimagebyid/',
|
|
1106
|
-
minArgs:
|
|
1106
|
+
minArgs: 2,
|
|
1107
1107
|
maxArgs: 2,
|
|
1108
1108
|
category: 'Content',
|
|
1109
1109
|
description: 'Returns the URL of a Content Builder image asset by its numeric ID.',
|
|
@@ -1423,12 +1423,24 @@ export const FUNCTIONS = [
|
|
|
1423
1423
|
mcnNotes: null,
|
|
1424
1424
|
description: 'The date part to extract from the string',
|
|
1425
1425
|
type: 'string',
|
|
1426
|
-
enum: [
|
|
1426
|
+
enum: [
|
|
1427
|
+
'year',
|
|
1428
|
+
'Y',
|
|
1429
|
+
'month',
|
|
1430
|
+
'M',
|
|
1431
|
+
'monthName',
|
|
1432
|
+
'day',
|
|
1433
|
+
'D',
|
|
1434
|
+
'hour',
|
|
1435
|
+
'H',
|
|
1436
|
+
'minute',
|
|
1437
|
+
'MI',
|
|
1438
|
+
],
|
|
1427
1439
|
},
|
|
1428
1440
|
],
|
|
1429
|
-
returnType: '
|
|
1441
|
+
returnType: 'string',
|
|
1430
1442
|
returnDescription:
|
|
1431
|
-
'The requested component of the date as a
|
|
1443
|
+
'The requested component of the date. Most parts return a numeric value as a string; `monthName` returns the full month name as text.',
|
|
1432
1444
|
syntax: 'DatePart(dateString, datePart)',
|
|
1433
1445
|
example: "%%=DatePart('2026-01-15', 'Y')=%%",
|
|
1434
1446
|
},
|
|
@@ -2053,7 +2065,9 @@ export const FUNCTIONS = [
|
|
|
2053
2065
|
maxArgs: 1,
|
|
2054
2066
|
category: 'Social',
|
|
2055
2067
|
description: 'Retrieves published social media content by its identifier.',
|
|
2056
|
-
params: [
|
|
2068
|
+
params: [
|
|
2069
|
+
{ name: 'socialContentId', description: 'Social content ID', type: 'string|number' },
|
|
2070
|
+
],
|
|
2057
2071
|
returnType: 'string',
|
|
2058
2072
|
returnDescription: 'The published social content for the supplied identifier.',
|
|
2059
2073
|
syntax: 'GetPublishedSocialContent(socialContentId)',
|
|
@@ -2100,7 +2114,7 @@ export const FUNCTIONS = [
|
|
|
2100
2114
|
{
|
|
2101
2115
|
name: 'socialNetworkCode',
|
|
2102
2116
|
description: 'The number code of the social network to share to',
|
|
2103
|
-
type: '
|
|
2117
|
+
type: 'number',
|
|
2104
2118
|
},
|
|
2105
2119
|
{
|
|
2106
2120
|
name: 'contentRegion',
|
|
@@ -2136,7 +2150,7 @@ export const FUNCTIONS = [
|
|
|
2136
2150
|
returnDescription: 'HTML that publishes the social-forward content for the region.',
|
|
2137
2151
|
repeat: [{ startIndex: 2, groupSize: 2, minGroups: 0 }],
|
|
2138
2152
|
syntax: 'GetSocialPublishURL(socialNetworkCode, contentRegion[, socialNetworkParamKey1, socialNetworkParamValue1, ...])',
|
|
2139
|
-
example: "%%=GetSocialPublishURL(
|
|
2153
|
+
example: "%%=GetSocialPublishURL(1, 'Shared content region 1')=%%",
|
|
2140
2154
|
},
|
|
2141
2155
|
{
|
|
2142
2156
|
name: 'GetSocialPublishURLByName',
|
|
@@ -2327,25 +2341,48 @@ export const FUNCTIONS = [
|
|
|
2327
2341
|
mcnNotes: null,
|
|
2328
2342
|
docUrl: 'https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-http/mc-ampscript-reference-http-post2.html',
|
|
2329
2343
|
guideUrl: 'https://ampscript.guide/httppost2/',
|
|
2330
|
-
minArgs:
|
|
2344
|
+
minArgs: 3,
|
|
2331
2345
|
maxArgs: INF,
|
|
2332
2346
|
category: 'HTTP',
|
|
2333
2347
|
description:
|
|
2334
|
-
'Performs an HTTP POST with access to response headers. Response body and headers stored in output variables.',
|
|
2348
|
+
'Performs an HTTP POST with access to response headers. Response body and headers are stored in output variables.',
|
|
2335
2349
|
params: [
|
|
2336
2350
|
{ name: 'url', description: 'Request URL', type: 'string' },
|
|
2337
2351
|
{ name: 'contentType', description: 'Content-Type header', type: 'string' },
|
|
2338
|
-
{ name: '
|
|
2339
|
-
{
|
|
2352
|
+
{ name: 'contentToPost', description: 'Request body', type: 'string' },
|
|
2353
|
+
{
|
|
2354
|
+
name: 'exceptionOnError',
|
|
2355
|
+
description:
|
|
2356
|
+
'If `true`, raise an exception when the request fails; if `false`, continue after an error',
|
|
2357
|
+
type: 'boolean',
|
|
2358
|
+
optional: true,
|
|
2359
|
+
},
|
|
2360
|
+
{
|
|
2361
|
+
name: 'response',
|
|
2362
|
+
description: 'Output variable for the response body',
|
|
2363
|
+
type: 'string',
|
|
2364
|
+
optional: true,
|
|
2365
|
+
},
|
|
2340
2366
|
{
|
|
2341
|
-
name: '
|
|
2367
|
+
name: 'responseRowSet',
|
|
2342
2368
|
mcnSince: null,
|
|
2343
2369
|
mcnNotes: null,
|
|
2344
|
-
description: 'Output variable for response headers',
|
|
2370
|
+
description: 'Output variable for the response headers, returned as a rowset',
|
|
2345
2371
|
type: 'string',
|
|
2372
|
+
optional: true,
|
|
2373
|
+
},
|
|
2374
|
+
{
|
|
2375
|
+
name: 'headerName1',
|
|
2376
|
+
description: 'First request header name',
|
|
2377
|
+
type: 'string',
|
|
2378
|
+
optional: true,
|
|
2379
|
+
},
|
|
2380
|
+
{
|
|
2381
|
+
name: 'headerValue1',
|
|
2382
|
+
description: 'First request header value',
|
|
2383
|
+
type: 'string',
|
|
2384
|
+
optional: true,
|
|
2346
2385
|
},
|
|
2347
|
-
{ name: 'headerName1', description: 'First request header name', type: 'string' },
|
|
2348
|
-
{ name: 'headerValue1', description: 'First request header value', type: 'string' },
|
|
2349
2386
|
{
|
|
2350
2387
|
name: 'headerNameN',
|
|
2351
2388
|
description: 'Additional request header name',
|
|
@@ -2361,10 +2398,10 @@ export const FUNCTIONS = [
|
|
|
2361
2398
|
],
|
|
2362
2399
|
returnType: 'number',
|
|
2363
2400
|
returnDescription: 'The HTTP status code of the POST request.',
|
|
2364
|
-
repeat: [{ startIndex:
|
|
2365
|
-
syntax: 'HTTPPost2(url, contentType,
|
|
2401
|
+
repeat: [{ startIndex: 6, groupSize: 2, minGroups: 0 }],
|
|
2402
|
+
syntax: 'HTTPPost2(url, contentType, contentToPost[, exceptionOnError, @response, @responseRowSet, headerName1, headerValue1, headerNameN, headerValueN, ...])',
|
|
2366
2403
|
example:
|
|
2367
|
-
"%%=HTTPPost2('https://example.com/api', 'application/json', @payload, @response, @
|
|
2404
|
+
"%%=HTTPPost2('https://example.com/api', 'application/json', @payload, true, @response, @responseRows)=%%",
|
|
2368
2405
|
},
|
|
2369
2406
|
{
|
|
2370
2407
|
name: 'HTTPPostWithRetry',
|
|
@@ -5069,24 +5106,52 @@ export const deprecatedFunctionLookup = new Map(
|
|
|
5069
5106
|
|
|
5070
5107
|
// ── Keywords ─────────────────────────────────────────────────────────────────
|
|
5071
5108
|
|
|
5109
|
+
/**
|
|
5110
|
+
* AMPscript language keyword with completion metadata.
|
|
5111
|
+
* - `name` the keyword as written in source
|
|
5112
|
+
* - `description` short human-readable explanation
|
|
5113
|
+
* - `snippet` completion body with `${n:placeholder}` tab stops
|
|
5114
|
+
*
|
|
5115
|
+
* @type {{name: string, description: string, snippet: string}[]}
|
|
5116
|
+
*/
|
|
5072
5117
|
export const AMPSCRIPT_KEYWORDS = [
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
'
|
|
5089
|
-
|
|
5118
|
+
{
|
|
5119
|
+
name: 'var',
|
|
5120
|
+
description: 'Declares one or more variables',
|
|
5121
|
+
snippet: 'var @${1:variableName}',
|
|
5122
|
+
},
|
|
5123
|
+
{
|
|
5124
|
+
name: 'set',
|
|
5125
|
+
description: 'Assigns a value to a variable',
|
|
5126
|
+
snippet: 'set @${1:variableName} = ${2:value}',
|
|
5127
|
+
},
|
|
5128
|
+
{
|
|
5129
|
+
name: 'if',
|
|
5130
|
+
description: 'Begins a conditional block',
|
|
5131
|
+
snippet: 'if ${1:condition} then\n\t${2}\nendif',
|
|
5132
|
+
},
|
|
5133
|
+
{ name: 'then', description: 'Follows an if/elseif condition', snippet: 'then' },
|
|
5134
|
+
{
|
|
5135
|
+
name: 'elseif',
|
|
5136
|
+
description: 'Additional condition in an if block',
|
|
5137
|
+
snippet: 'elseif ${1:condition} then',
|
|
5138
|
+
},
|
|
5139
|
+
{ name: 'else', description: 'Fallback branch in an if block', snippet: 'else' },
|
|
5140
|
+
{ name: 'endif', description: 'Closes an if block', snippet: 'endif' },
|
|
5141
|
+
{
|
|
5142
|
+
name: 'for',
|
|
5143
|
+
description: 'Begins a counting loop',
|
|
5144
|
+
snippet: 'for @${1:i} = ${2:1} to ${3:rowCount} do\n\t${4}\nnext @${1:i}',
|
|
5145
|
+
},
|
|
5146
|
+
{ name: 'to', description: 'Ascending direction in a for loop', snippet: 'to' },
|
|
5147
|
+
{ name: 'downto', description: 'Descending direction in a for loop', snippet: 'downto' },
|
|
5148
|
+
{ name: 'do', description: 'Marks the start of a loop body', snippet: 'do' },
|
|
5149
|
+
{ name: 'next', description: 'Ends a for loop iteration', snippet: 'next' },
|
|
5150
|
+
{ name: 'and', description: 'Logical AND operator', snippet: 'and' },
|
|
5151
|
+
{ name: 'or', description: 'Logical OR operator', snippet: 'or' },
|
|
5152
|
+
{ name: 'not', description: 'Logical NOT operator', snippet: 'not' },
|
|
5153
|
+
{ name: 'true', description: 'Boolean true constant', snippet: 'true' },
|
|
5154
|
+
{ name: 'false', description: 'Boolean false constant', snippet: 'false' },
|
|
5090
5155
|
];
|
|
5091
5156
|
|
|
5092
5157
|
// ── Personalization strings ──────────────────────────────────────────────────
|