ampscript-data 0.1.2 → 0.1.4

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 (2) hide show
  1. package/package.json +24 -2
  2. package/src/index.js +29 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ampscript-data",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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,9 +29,31 @@
29
29
  ],
30
30
  "license": "MIT",
31
31
  "scripts": {
32
- "test": "echo No tests defined"
32
+ "test": "echo No tests defined",
33
+ "lint": "eslint .",
34
+ "lint:fix": "eslint --fix .",
35
+ "prepare": "husky || true",
36
+ "format": "prettier --write .",
37
+ "format:check": "prettier --check ."
33
38
  },
34
39
  "engines": {
35
40
  "node": ">=18.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@eslint/js": "^10.0.1",
44
+ "eslint": "^10.1.0",
45
+ "eslint-config-prettier": "^10.1.8",
46
+ "eslint-plugin-jsdoc": "^62.0.0",
47
+ "eslint-plugin-prettier": "^5.5.0",
48
+ "eslint-plugin-unicorn": "^64.0.0",
49
+ "globals": "^17.4.0",
50
+ "husky": "^9.1.7",
51
+ "lint-staged": "^17.0.5",
52
+ "prettier": "^3.8.1"
53
+ },
54
+ "lint-staged": {
55
+ "*.{js,mjs,cjs}": [
56
+ "eslint --fix"
57
+ ]
36
58
  }
37
59
  }
package/src/index.js CHANGED
@@ -11,7 +11,7 @@ const INF = Infinity;
11
11
 
12
12
  // ── Function catalog ─────────────────────────────────────────────────────────
13
13
 
14
- /** @type {Array<{name:string, minArgs:number, maxArgs:number, category:string, description:string, params:Array<{name:string, description:string, type?:string, optional?:boolean}>, returnType?:string, syntax?:string, example?:string}>} */
14
+ /** @type {{name: string, minArgs: number, maxArgs: number, category: string, description: string, params: {name: string, description: string, type?: string, optional?: boolean}[], returnType?: string, syntax?: string, example?: string}[]} */
15
15
  export const FUNCTIONS = [
16
16
  {
17
17
  name: 'Add',
@@ -1212,22 +1212,6 @@ export const FUNCTIONS = [
1212
1212
  returnType: 'string',
1213
1213
  syntax: 'GetSocialPublishURLByName(regionName, socialAccount[, ...])',
1214
1214
  },
1215
- {
1216
- name: 'GetValue',
1217
- minArgs: 1,
1218
- maxArgs: 1,
1219
- category: 'Utility',
1220
- description: 'Returns the value of a variable by name at runtime.',
1221
- params: [
1222
- {
1223
- name: 'variableName',
1224
- description: 'Name of the variable (without @)',
1225
- type: 'string',
1226
- },
1227
- ],
1228
- returnType: 'string',
1229
- syntax: 'GetValue(variableName)',
1230
- },
1231
1215
  {
1232
1216
  name: 'GUID',
1233
1217
  minArgs: 0,
@@ -1384,10 +1368,20 @@ export const FUNCTIONS = [
1384
1368
  minArgs: 2,
1385
1369
  maxArgs: 2,
1386
1370
  category: 'Content',
1387
- description: 'Returns an HTML img tag for the Portfolio image matching the specified customer key.',
1371
+ description:
1372
+ 'Returns an HTML img tag for the Portfolio image matching the specified customer key.',
1388
1373
  params: [
1389
- { name: 'customerKey', description: 'Customer/external key of the image', type: 'string' },
1390
- { name: 'fallbackKey', description: 'Customer/external key of the fallback image if the primary is not found', type: 'string' },
1374
+ {
1375
+ name: 'customerKey',
1376
+ description: 'Customer/external key of the image',
1377
+ type: 'string',
1378
+ },
1379
+ {
1380
+ name: 'fallbackKey',
1381
+ description:
1382
+ 'Customer/external key of the fallback image if the primary is not found',
1383
+ type: 'string',
1384
+ },
1391
1385
  ],
1392
1386
  returnType: 'string',
1393
1387
  syntax: 'Image(customerKey, fallbackKey)',
@@ -1461,7 +1455,11 @@ export const FUNCTIONS = [
1461
1455
  description: 'Output variable for the resulting status message',
1462
1456
  type: 'string',
1463
1457
  },
1464
- { name: 'errorCode', description: 'Output variable for the resulting error code', type: 'string' },
1458
+ {
1459
+ name: 'errorCode',
1460
+ description: 'Output variable for the resulting error code',
1461
+ type: 'string',
1462
+ },
1465
1463
  {
1466
1464
  name: 'createOptions',
1467
1465
  description: 'Optional CreateOptions API object',
@@ -1484,7 +1482,11 @@ export const FUNCTIONS = [
1484
1482
  description: 'Output variable for the resulting status message',
1485
1483
  type: 'string',
1486
1484
  },
1487
- { name: 'errorCode', description: 'Output variable for the resulting error code', type: 'string' },
1485
+ {
1486
+ name: 'errorCode',
1487
+ description: 'Output variable for the resulting error code',
1488
+ type: 'string',
1489
+ },
1488
1490
  {
1489
1491
  name: 'deleteOptions',
1490
1492
  description: 'Optional DeleteOptions API object',
@@ -2246,19 +2248,6 @@ export const FUNCTIONS = [
2246
2248
  returnType: 'void',
2247
2249
  syntax: 'SetStateMSCRMRecord(entityType, entityId, state, status)',
2248
2250
  },
2249
- {
2250
- name: 'SetValue',
2251
- minArgs: 2,
2252
- maxArgs: 2,
2253
- category: 'Utility',
2254
- description: 'Sets the value of a subscriber or send-context attribute by name.',
2255
- params: [
2256
- { name: 'attributeName', description: 'Attribute name to set', type: 'string' },
2257
- { name: 'value', description: 'Value to assign' },
2258
- ],
2259
- returnType: 'void',
2260
- syntax: 'SetValue(attributeName, value)',
2261
- },
2262
2251
  {
2263
2252
  name: 'SHA1',
2264
2253
  minArgs: 1,
@@ -2352,7 +2341,8 @@ export const FUNCTIONS = [
2352
2341
  { name: 'startIndex', description: '1-based start position', type: 'number' },
2353
2342
  {
2354
2343
  name: 'length',
2355
- description: 'Number of characters to extract. If omitted, returns the remainder of the string.',
2344
+ description:
2345
+ 'Number of characters to extract. If omitted, returns the remainder of the string.',
2356
2346
  type: 'number',
2357
2347
  optional: true,
2358
2348
  },
@@ -2713,7 +2703,9 @@ const EMAIL_EXCLUDED_FUNCTIONS = new Set([
2713
2703
 
2714
2704
  export function isEmailExcluded(functionName) {
2715
2705
  const lower = functionName.toLowerCase();
2716
- if (EMAIL_EXCLUDED_FUNCTIONS.has(lower)) return true;
2706
+ if (EMAIL_EXCLUDED_FUNCTIONS.has(lower)) {
2707
+ return true;
2708
+ }
2717
2709
  const entry = functionLookup.get(lower);
2718
2710
  return entry ? EMAIL_EXCLUDED_CATEGORIES.has(entry.category) : false;
2719
2711
  }