ampscript-data 1.1.0 → 2.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.
Files changed (3) hide show
  1. package/README.md +7 -1
  2. package/package.json +1 -1
  3. package/src/index.js +80 -29
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 keywords (`IF`, `FOR`, `SET`, etc.):
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ampscript-data",
3
- "version": "1.1.0",
3
+ "version": "2.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",
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: 4,
108
+ minArgs: 2,
109
109
  maxArgs: 8,
110
110
  category: 'Content',
111
111
  description: 'Includes a file attachment in the outgoing message.',
@@ -2327,25 +2327,48 @@ export const FUNCTIONS = [
2327
2327
  mcnNotes: null,
2328
2328
  docUrl: 'https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-http/mc-ampscript-reference-http-post2.html',
2329
2329
  guideUrl: 'https://ampscript.guide/httppost2/',
2330
- minArgs: 7,
2330
+ minArgs: 3,
2331
2331
  maxArgs: INF,
2332
2332
  category: 'HTTP',
2333
2333
  description:
2334
- 'Performs an HTTP POST with access to response headers. Response body and headers stored in output variables.',
2334
+ 'Performs an HTTP POST with access to response headers. Response body and headers are stored in output variables.',
2335
2335
  params: [
2336
2336
  { name: 'url', description: 'Request URL', type: 'string' },
2337
2337
  { name: 'contentType', description: 'Content-Type header', type: 'string' },
2338
- { name: 'payload', description: 'Request body', type: 'string' },
2339
- { name: 'response', description: 'Output variable for response body', type: 'string' },
2338
+ { name: 'contentToPost', description: 'Request body', type: 'string' },
2339
+ {
2340
+ name: 'exceptionOnError',
2341
+ description:
2342
+ 'If `true`, raise an exception when the request fails; if `false`, continue after an error',
2343
+ type: 'boolean',
2344
+ optional: true,
2345
+ },
2340
2346
  {
2341
- name: 'responseHeaders',
2347
+ name: 'response',
2348
+ description: 'Output variable for the response body',
2349
+ type: 'string',
2350
+ optional: true,
2351
+ },
2352
+ {
2353
+ name: 'responseRowSet',
2342
2354
  mcnSince: null,
2343
2355
  mcnNotes: null,
2344
- description: 'Output variable for response headers',
2356
+ description: 'Output variable for the response headers, returned as a rowset',
2345
2357
  type: 'string',
2358
+ optional: true,
2359
+ },
2360
+ {
2361
+ name: 'headerName1',
2362
+ description: 'First request header name',
2363
+ type: 'string',
2364
+ optional: true,
2365
+ },
2366
+ {
2367
+ name: 'headerValue1',
2368
+ description: 'First request header value',
2369
+ type: 'string',
2370
+ optional: true,
2346
2371
  },
2347
- { name: 'headerName1', description: 'First request header name', type: 'string' },
2348
- { name: 'headerValue1', description: 'First request header value', type: 'string' },
2349
2372
  {
2350
2373
  name: 'headerNameN',
2351
2374
  description: 'Additional request header name',
@@ -2361,10 +2384,10 @@ export const FUNCTIONS = [
2361
2384
  ],
2362
2385
  returnType: 'number',
2363
2386
  returnDescription: 'The HTTP status code of the POST request.',
2364
- repeat: [{ startIndex: 5, groupSize: 2, minGroups: 1 }],
2365
- syntax: 'HTTPPost2(url, contentType, payload, @response, @responseHeaders, headerName1, headerValue1[, headerNameN, headerValueN, ...])',
2387
+ repeat: [{ startIndex: 6, groupSize: 2, minGroups: 0 }],
2388
+ syntax: 'HTTPPost2(url, contentType, contentToPost[, exceptionOnError, @response, @responseRowSet, headerName1, headerValue1, headerNameN, headerValueN, ...])',
2366
2389
  example:
2367
- "%%=HTTPPost2('https://example.com/api', 'application/json', @payload, @response, @responseHeaders)=%%",
2390
+ "%%=HTTPPost2('https://example.com/api', 'application/json', @payload, true, @response, @responseRows)=%%",
2368
2391
  },
2369
2392
  {
2370
2393
  name: 'HTTPPostWithRetry',
@@ -5069,24 +5092,52 @@ export const deprecatedFunctionLookup = new Map(
5069
5092
 
5070
5093
  // ── Keywords ─────────────────────────────────────────────────────────────────
5071
5094
 
5095
+ /**
5096
+ * AMPscript language keyword with completion metadata.
5097
+ * - `name` the keyword as written in source
5098
+ * - `description` short human-readable explanation
5099
+ * - `snippet` completion body with `${n:placeholder}` tab stops
5100
+ *
5101
+ * @type {{name: string, description: string, snippet: string}[]}
5102
+ */
5072
5103
  export const AMPSCRIPT_KEYWORDS = [
5073
- 'var',
5074
- 'set',
5075
- 'if',
5076
- 'then',
5077
- 'elseif',
5078
- 'else',
5079
- 'endif',
5080
- 'for',
5081
- 'to',
5082
- 'downto',
5083
- 'do',
5084
- 'next',
5085
- 'and',
5086
- 'or',
5087
- 'not',
5088
- 'true',
5089
- 'false',
5104
+ {
5105
+ name: 'var',
5106
+ description: 'Declares one or more variables',
5107
+ snippet: 'var @${1:variableName}',
5108
+ },
5109
+ {
5110
+ name: 'set',
5111
+ description: 'Assigns a value to a variable',
5112
+ snippet: 'set @${1:variableName} = ${2:value}',
5113
+ },
5114
+ {
5115
+ name: 'if',
5116
+ description: 'Begins a conditional block',
5117
+ snippet: 'if ${1:condition} then\n\t${2}\nendif',
5118
+ },
5119
+ { name: 'then', description: 'Follows an if/elseif condition', snippet: 'then' },
5120
+ {
5121
+ name: 'elseif',
5122
+ description: 'Additional condition in an if block',
5123
+ snippet: 'elseif ${1:condition} then',
5124
+ },
5125
+ { name: 'else', description: 'Fallback branch in an if block', snippet: 'else' },
5126
+ { name: 'endif', description: 'Closes an if block', snippet: 'endif' },
5127
+ {
5128
+ name: 'for',
5129
+ description: 'Begins a counting loop',
5130
+ snippet: 'for @${1:i} = ${2:1} to ${3:rowCount} do\n\t${4}\nnext @${1:i}',
5131
+ },
5132
+ { name: 'to', description: 'Ascending direction in a for loop', snippet: 'to' },
5133
+ { name: 'downto', description: 'Descending direction in a for loop', snippet: 'downto' },
5134
+ { name: 'do', description: 'Marks the start of a loop body', snippet: 'do' },
5135
+ { name: 'next', description: 'Ends a for loop iteration', snippet: 'next' },
5136
+ { name: 'and', description: 'Logical AND operator', snippet: 'and' },
5137
+ { name: 'or', description: 'Logical OR operator', snippet: 'or' },
5138
+ { name: 'not', description: 'Logical NOT operator', snippet: 'not' },
5139
+ { name: 'true', description: 'Boolean true constant', snippet: 'true' },
5140
+ { name: 'false', description: 'Boolean false constant', snippet: 'false' },
5090
5141
  ];
5091
5142
 
5092
5143
  // ── Personalization strings ──────────────────────────────────────────────────