sfmc-sdk 2.1.2 → 2.1.3

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.
@@ -1,26 +1,134 @@
1
1
  [
2
2
  {
3
- "name": "Create PR to develop branch",
4
- "target": "ref",
3
+ "version": 1
4
+ },
5
+ {
6
+ "action": {
7
+ "type": "url",
8
+ "url": "https://github.com/DougMidgley/SFMC-SDK/compare/main...${ref:short}?expand=1&template=pr_template_release.md"
9
+ },
10
+ "name": "Create PR/Release-PR to master branch",
5
11
  "refTargets": [
6
12
  "localbranch",
7
13
  "remotebranch"
8
14
  ],
15
+ "target": "ref"
16
+ },
17
+ {
9
18
  "action": {
10
19
  "type": "url",
11
- "url": "https://github.com/DougMidgley/SFMC-SDK/compare/develop...$shortname?expand=1"
12
- }
20
+ "url": "https://github.com/DougMidgley/SFMC-SDK/compare/develop...${ref:short}?expand=1"
21
+ },
22
+ "name": "Create PR/To develop branch",
23
+ "refTargets": [
24
+ "localbranch",
25
+ "remotebranch"
26
+ ],
27
+ "target": "ref"
13
28
  },
14
29
  {
15
- "name": "Create PR to hotfix branch",
16
- "target": "ref",
30
+ "action": {
31
+ "type": "url",
32
+ "url": "https://github.com/DougMidgley/SFMC-SDK/compare/hotfix...${ref:short}?expand=1"
33
+ },
34
+ "name": "Create PR/To hotfix branch",
17
35
  "refTargets": [
18
36
  "localbranch",
19
37
  "remotebranch"
20
38
  ],
39
+ "target": "ref"
40
+ },
41
+ {
21
42
  "action": {
22
- "type": "url",
23
- "url": "https://github.com/DougMidgley/SFMC-SDK/compare/hotfix...$shortname?expand=1"
43
+ "script": "SKIP_HOOKS=1 git switch ${ref}",
44
+ "showOutput": false,
45
+ "type": "sh",
46
+ "waitForExit": true
47
+ },
48
+ "name": "Skip Hooks/Checkout",
49
+ "refTargets": ["localbranch"],
50
+ "target": "ref"
51
+ },
52
+ {
53
+ "action": {
54
+ "script": "SKIP_HOOKS=1 git switch ${ref:short} && SKIP_HOOKS=2 git pull",
55
+ "showOutput": false,
56
+ "type": "sh",
57
+ "waitForExit": true
58
+ },
59
+ "name": "Skip Hooks/Checkout & Pull",
60
+ "refTargets": ["remotebranch"],
61
+ "target": "ref"
62
+ },
63
+ {
64
+ "name": "Skip Hooks/Commit",
65
+ "refTargets": [
66
+ "localbranch",
67
+ "remotebranch"
68
+ ],
69
+ "target": "ref",
70
+ "ui": {
71
+ "buttons": [
72
+ {
73
+ "action": {
74
+ "args": "commit -n -m \"$1{text}\" -m \" $2{text}\"",
75
+ "path": "${git}",
76
+ "showOutput": false,
77
+ "type": "process",
78
+ "waitForExit": true
79
+ },
80
+ "title": "Commit without Hooks"
81
+ },
82
+ {
83
+ "action": {
84
+ "type": "cancel"
85
+ },
86
+ "title": "Cancel"
87
+ }
88
+ ],
89
+ "controls": [
90
+ {
91
+ "placeholder": "",
92
+ "text": "",
93
+ "textBoxType": "generic",
94
+ "title": "Commit subject",
95
+ "type": "textBox"
96
+ },
97
+ {
98
+ "placeholder": "",
99
+ "text": "",
100
+ "textBoxType": "generic",
101
+ "title": "Description",
102
+ "type": "textBox"
103
+ }
104
+ ],
105
+ "description": "This will create a commit but not run pre-commit hooks",
106
+ "title": "Commit skipping Hooks"
24
107
  }
108
+ },
109
+ {
110
+ "action": {
111
+ "script": "SKIP_HOOKS=4 git merge ${ref:short}",
112
+ "showOutput": false,
113
+ "type": "sh",
114
+ "waitForExit": true
115
+ },
116
+ "name": "Skip Hooks/Merge into current branch",
117
+ "refTargets": ["localbranch"],
118
+ "target": "ref"
119
+ },
120
+ {
121
+ "action": {
122
+ "script": "SKIP_HOOKS=3 git pull",
123
+ "showOutput": false,
124
+ "type": "sh",
125
+ "waitForExit": true
126
+ },
127
+ "name": "Skip Hooks/Pull",
128
+ "refTargets": [
129
+ "localbranch",
130
+ "remotebranch"
131
+ ],
132
+ "target": "ref"
25
133
  }
26
134
  ]
@@ -0,0 +1,19 @@
1
+ name: Close issues related to a merged pull request based on master branch.
2
+
3
+ on:
4
+ pull_request:
5
+ types: [closed]
6
+ branches:
7
+ - develop
8
+ - hotfix
9
+
10
+ jobs:
11
+ closeIssueOnPrMergeTrigger:
12
+
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - name: Closes issues related to a merged pull request.
17
+ uses: ldez/gha-mjolnir@v1.5.0
18
+ env:
19
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,36 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3
+
4
+ name: Publish NPM on Release
5
+
6
+ on:
7
+ release:
8
+ types: [published]
9
+
10
+ permissions:
11
+ id-token: write # Required for OIDC
12
+ contents: read
13
+
14
+ jobs:
15
+ build:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v6
19
+ - uses: actions/setup-node@v6
20
+ with:
21
+ node-version-file: ./package.json
22
+
23
+ - run: npm ci
24
+ - run: npm test
25
+
26
+ publish-npm:
27
+ needs: build
28
+ runs-on: ubuntu-latest
29
+ steps:
30
+ - uses: actions/checkout@v6
31
+ - uses: actions/setup-node@v6
32
+ with:
33
+ node-version-file: ./package.json
34
+ registry-url: https://registry.npmjs.org/
35
+ - run: npm publish
36
+
@@ -17,7 +17,7 @@ jobs:
17
17
  runs-on: ubuntu-latest
18
18
  strategy:
19
19
  matrix:
20
- node: [18, 20, 22]
20
+ node: [20, 22, 24]
21
21
  name: Run Tests with node ${{ matrix.node }}
22
22
  steps:
23
23
  - uses: actions/checkout@v4
@@ -6,11 +6,16 @@ then
6
6
  TICKETID="0"
7
7
  fi
8
8
  TEMPLATE="#$TICKETID: "
9
- echo "[POST_CHECKOUT] Setting template commit to '$TEMPLATE'"
9
+ echo "[POST-CHECKOUT] Setting template commit to '$TEMPLATE'"
10
10
  # wrap $TEMPLATE in quotes or else it is trimmed automatically
11
11
  echo "$TEMPLATE" > ".git/templatemessage"
12
12
 
13
13
 
14
+ if [[ $SKIP_HOOKS>0 ]]; then
15
+ echo "[POST-CHECKOUT] skipping hooks ($SKIP_HOOKS)"
16
+ exit 0
17
+ fi
18
+
14
19
  # ### run npm install ###
15
20
  echo "[POST-CHECKOUT] 📦 Checking for changes to dependencies"
16
21
  # define how to split strings into array elements
@@ -21,7 +26,7 @@ NEWHEAD=$1
21
26
  OLDHEAD=$2
22
27
  # extract all paths to package-lock.json files
23
28
  PACKAGE_LOCK_REGEX="(^package-lock\.json)"
24
- PACKAGES=$(git diff --name-only $NEWHEAD $OLDHEAD | grep -E $PACKAGE_LOCK_REGEX || true)
29
+ PACKAGES=$(git diff --name-only $OLDHEAD $NEWHEAD | grep -E $PACKAGE_LOCK_REGEX || true)
25
30
 
26
31
  if [[ ${PACKAGES[@]} ]]; then
27
32
  for package in $PACKAGES; do
@@ -0,0 +1,24 @@
1
+ if [[ $SKIP_HOOKS>0 ]]; then
2
+ echo "[POST-MERGE] skipping hooks ($SKIP_HOOKS)"
3
+ exit 0
4
+ fi
5
+
6
+ # ### run npm install ###
7
+ echo "[POST-MERGE] 📦 Checking for changes to dependencies"
8
+ # define how to split strings into array elements
9
+ IFS=$'\n'
10
+ # extract all paths to package-lock.json files
11
+ PACKAGE_LOCK_REGEX="(^package-lock\.json)"
12
+ echo "[POST-MERGE] running git diff --name-only HEAD^1 HEAD"
13
+ PACKAGES=$(git diff --name-only HEAD^1 HEAD | grep -E $PACKAGE_LOCK_REGEX || true)
14
+
15
+ if [[ ${PACKAGES[@]} ]]; then
16
+ for package in $PACKAGES; do
17
+ echo "📦 $package was changed."
18
+ done
19
+ echo "📦 Running npm install to update your dependencies..."
20
+ npm install
21
+ npm run lint:fix
22
+ else
23
+ echo "📦 All packages up-to-date. No need to run npm install."
24
+ fi
package/.husky/pre-commit CHANGED
@@ -1,3 +1,4 @@
1
1
  # update typescript type declarations
2
- npx tsc -p tsconfig.precommit.json
2
+ echo "[PRE-COMMIT] Run typescript validation and create/update d.ts files"
3
+ tsc -p tsconfig.precommit.json
3
4
  git add @types
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../lib/util.js"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,iCAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;GAKG;AACH,kCAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;GAKG;AACH,wCAHW,MAAM,GACJ,OAAO,CAOnB;AAED;;;;;;GAMG;AACH;;;;;GAKG;AACH;IACI;;;OAGG;IACH,gBAFW,iBAAiB,EAwB3B;IAlBO,UAAiD;IAWjD,iBAA2B;IAE/B,cAA2B;CAMlC;AACD;;;;;;GAMG;AACH;;;;;GAKG;AACH;IACI;;;;;OAKG;IACH,gBAJW,iBAAiB,YACjB,MAAM,YACN,MAAM,EAwChB;IAlCO,UAAkC;IA4BtC,cAAwB;IACxB,UAAoB;CAM3B;AAED,0DAA4C;;;;;;;;cArG9B,MAAM;;;;UACN,MAAM;;;;cACN,MAAM;;;;;gCACP,KAAK,GAAG,uBAAuB;;;;;;;;cAuC9B,MAAM;;;;UACN,MAAM;;;;cACN,MAAM;;;;;gCACP,KAAK,GAAG,uBAAuB"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../lib/util.js"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,iCAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;GAKG;AACH,kCAHW,MAAM,GACJ,OAAO,CAInB;AAED;;;;;GAKG;AACH,wCAHW,MAAM,GACJ,OAAO,CAOnB;AAED;;;;;;GAMG;AACH;;;;;GAKG;AACH;IACI;;;OAGG;IACH,gBAFW,iBAAiB,EAqB3B;IAfO,UAAiD;IAWjD,iBAA2B;IAE/B,cAA2B;CAGlC;AACD;;;;;;GAMG;AACH;;;;;GAKG;AACH;IACI;;;;;OAKG;IACH,gBAJW,iBAAiB,YACjB,MAAM,YACN,MAAM,EAqChB;IA/BO,UAAkC;IA4BtC,cAAwB;IACxB,UAAoB;CAG3B;AAED,0DAA4C;;;;;;;;cA/F9B,MAAM;;;;UACN,MAAM;;;;cACN,MAAM;;;;;gCACP,KAAK,GAAG,uBAAuB;;;;;;;;cAoC9B,MAAM;;;;UACN,MAAM;;;;cACN,MAAM;;;;;gCACP,KAAK,GAAG,uBAAuB"}
package/eslint.config.js CHANGED
@@ -28,6 +28,12 @@ export default [
28
28
  ignores: ['/node_modules/**'],
29
29
  rules: {
30
30
  'unicorn/prefer-module': 'off',
31
+ 'unicorn/prevent-abbreviations': [
32
+ 'error',
33
+ {
34
+ checkFilenames: false,
35
+ },
36
+ ],
31
37
  'unicorn/numeric-separators-style': 'off',
32
38
  'jsdoc/check-line-alignment': 2,
33
39
  'jsdoc/require-jsdoc': [
package/lib/rest.js CHANGED
@@ -125,13 +125,13 @@ export default class Rest {
125
125
  }
126
126
  // ! the transactional message API returns a value for "count" that represents the currently returned number of records, instead of the total amount. checking for count != pageSize is a workaround for this
127
127
  // * opened Support Case #43988240 for this issue
128
- if (
129
- isTransactionalMessageApi &&
130
- responseBatch[countKey] != responseBatch[pageSizeKey]
131
- ) {
132
- shouldPaginate = false;
133
- }
134
- // if results are less than size, no more requested needed
128
+ if (isTransactionalMessageApi && responseBatch[countKey] == pageSize) {
129
+ page++;
130
+ shouldPaginate = true;
131
+ if (this.options?.eventHandlers?.onLoop) {
132
+ this.options.eventHandlers.onLoop(undefined, collector?.[iteratorField]);
133
+ }
134
+ } // if results are less than size, no more requested needed
135
135
  else if (responseBatch[iteratorField].length < pageSize) {
136
136
  shouldPaginate = false;
137
137
  }
package/lib/util.js CHANGED
@@ -69,9 +69,6 @@ export class RestError extends Error {
69
69
  }
70
70
  this.response = ex.response;
71
71
  this.name = this.constructor.name;
72
- if (Error.captureStackTrace) {
73
- Error.captureStackTrace(this, RestError);
74
- }
75
72
  }
76
73
  }
77
74
  /**
@@ -129,9 +126,6 @@ export class SOAPError extends Error {
129
126
  this.response = response;
130
127
  this.json = soapBody;
131
128
  this.name = this.constructor.name;
132
- if (Error.captureStackTrace) {
133
- Error.captureStackTrace(this, SOAPError);
134
- }
135
129
  }
136
130
  }
137
131
  import axios from 'axios';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfmc-sdk",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Libarary to simplify SFMC requests with updated dependencies and less overhead",
5
5
  "main": "./lib/index.js",
6
6
  "exports": {
@@ -18,7 +18,14 @@
18
18
  "lint": "eslint ./lib ./test",
19
19
  "lint:fix": "eslint ./lib ./test --fix",
20
20
  "lint-ts": "tsc -p tsconfig.precommit.json",
21
- "prepare": "husky || true"
21
+ "lint-ts-prep": "tsc -p tsconfig.npmScripts.json",
22
+ "prepare": "husky || true",
23
+ "prepare-release:audit-fix": "npm audit fix",
24
+ "prepare-release:git": "node prepare-release.js",
25
+ "prepare-release": "run-s prepare-release:audit-fix lint-ts-prep lint:fix prepare-release:git",
26
+ "version:major": "npm version --no-commit-hooks major",
27
+ "version:minor": "npm version --no-commit-hooks minor",
28
+ "version:patch": "npm version --no-commit-hooks patch"
22
29
  },
23
30
  "repository": {
24
31
  "type": "git",
@@ -28,7 +35,7 @@
28
35
  "license": "BSD-3-Clause",
29
36
  "dependencies": {
30
37
  "axios": "^1.7.2",
31
- "fast-xml-parser": "4.4.1",
38
+ "fast-xml-parser": "5.3.4",
32
39
  "p-limit": "5.0.0"
33
40
  },
34
41
  "keywords": [
@@ -43,25 +50,26 @@
43
50
  "sdk"
44
51
  ],
45
52
  "devDependencies": {
46
- "@eslint/js": "9.6.0",
53
+ "@eslint/js": "9.39.2",
47
54
  "@types/mocha": "10.0.7",
48
- "@types/node": "20.14.9",
55
+ "@types/node": "25.2.1",
49
56
  "assert": "2.1.0",
50
57
  "axios-mock-adapter": "1.22.0",
51
58
  "c8": "10.1.2",
52
59
  "chai": "5.1.1",
53
- "eslint": "9.6.0",
60
+ "eslint": "9.39.2",
54
61
  "eslint-config-prettier": "9.1.0",
55
- "eslint-plugin-jsdoc": "48.5.0",
62
+ "eslint-plugin-jsdoc": "62.5.2",
56
63
  "eslint-plugin-mocha": "10.4.3",
57
64
  "eslint-plugin-prettier": "5.1.3",
58
- "eslint-plugin-unicorn": "54.0.0",
59
- "husky": "9.0.11",
60
- "mocha": "10.5.2",
65
+ "eslint-plugin-unicorn": "62.0.0",
66
+ "husky": "9.1.7",
67
+ "mocha": "11.7.5",
68
+ "npm-run-all": "4.1.5",
61
69
  "prettier": "3.3.2",
62
70
  "prettier-eslint": "16.3.0",
63
71
  "sinon": "18.0.0",
64
- "typescript": "5.5.2"
72
+ "typescript": "5.9.3"
65
73
  },
66
74
  "engines": {
67
75
  "npm": ">=9",
@@ -0,0 +1,37 @@
1
+ /* eslint-disable no-console */
2
+ import { exec } from 'node:child_process';
3
+
4
+ console.log('> git status --porcelain');
5
+ exec('git status --porcelain', (err, stdout, stderr) => {
6
+ if (err) {
7
+ console.error(`Error executing git status: ${stderr}`);
8
+ return;
9
+ }
10
+
11
+ if (stdout) {
12
+ console.log(
13
+ ' Found changes:',
14
+ '\n - ' + stdout.split('\n').filter(Boolean).join('\n - ')
15
+ );
16
+ console.log('> git add .');
17
+ exec('git add .', (err, stdout, stderr) => {
18
+ if (err) {
19
+ console.error(`Error executing git add: ${stderr}`);
20
+ return;
21
+ }
22
+
23
+ console.log('> git commit -n -m "prepare-release changes"');
24
+ exec('git commit -n -m "prepare-release changes"', (err, stdout, stderr) => {
25
+ if (err) {
26
+ console.error(`Error executing git commit: ${stderr}`);
27
+ return;
28
+ } else {
29
+ console.log('✅ Changes committed successfully.');
30
+ }
31
+ });
32
+ });
33
+ } else {
34
+ console.log('✅ No untracked files to commit.');
35
+ }
36
+ });
37
+ /* eslint-enable no-console */
@@ -1,39 +0,0 @@
1
- name: Release Package
2
-
3
- on:
4
- push:
5
- # branches to consider in the event; optional, defaults to all
6
- branches:
7
- - main
8
-
9
- jobs:
10
- update_release_draft:
11
- runs-on: ubuntu-latest
12
- steps:
13
- # Drafts your next Release notes as Pull Requests are merged into "main"
14
- - uses: release-drafter/release-drafter@v6
15
- id: create_release
16
- env:
17
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18
- - uses: actions/checkout@v4
19
- - uses: actions/setup-node@v4
20
- with:
21
- node-version: 22
22
- registry-url: https://registry.npmjs.org/
23
- - run: npm i
24
- - run: npm ci
25
- - run: npm publish
26
- env:
27
- NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
28
- - run: |
29
- git config user.name "GitHub Actions Bot"
30
- git config user.email "<>"
31
- git add package.json
32
- git add package-lock.json
33
- git commit -m "Release ${{ steps.create_release.outputs.tag_name }}"
34
- git push origin main
35
- - uses: eregon/publish-release@v1
36
- env:
37
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
- with:
39
- release_id: ${{ steps.create_release.outputs.id }}