sfmc-sdk 0.0.7 → 0.1.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.
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "npm" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "daily"
@@ -0,0 +1,4 @@
1
+ enhancement: feature/*
2
+ bug: bug/*
3
+ chore: chore/*
4
+ release: develop
@@ -0,0 +1,31 @@
1
+ name-template: '$RESOLVED_VERSION'
2
+ tag-template: '$RESOLVED_VERSION'
3
+ exclude-labels:
4
+ - 'release'
5
+ categories:
6
+ - title: '🚀 Features'
7
+ labels:
8
+ - 'enhancement'
9
+ - title: '🐛 Bug Fixes'
10
+ labels:
11
+ - 'bug'
12
+ - title: '🧰 Maintenance'
13
+ label: 'chore'
14
+ version-resolver:
15
+ major:
16
+ labels:
17
+ - 'major'
18
+ minor:
19
+ labels:
20
+ - 'minor'
21
+ - 'enhancement'
22
+ patch:
23
+ labels:
24
+ - 'patch'
25
+ - 'bug'
26
+ - 'chore'
27
+ default: patch
28
+ template: |
29
+ ## Release Notes
30
+
31
+ $CHANGES
@@ -13,12 +13,10 @@ name: "CodeQL"
13
13
 
14
14
  on:
15
15
  push:
16
- branches: [ master ]
16
+ branches: [ main, develop ]
17
17
  pull_request:
18
18
  # The branches below must be a subset of the branches above
19
- branches: [ master ]
20
- schedule:
21
- - cron: '27 5 * * 4'
19
+ branches: [ main, develop ]
22
20
 
23
21
  jobs:
24
22
  analyze:
@@ -42,26 +40,6 @@ jobs:
42
40
  uses: github/codeql-action/init@v1
43
41
  with:
44
42
  languages: ${{ matrix.language }}
45
- # If you wish to specify custom queries, you can do so here or in a config file.
46
- # By default, queries listed here will override any specified in a config file.
47
- # Prefix the list here with "+" to use these queries and those in the config file.
48
- # queries: ./path/to/local/query, your-org/your-repo/queries@main
49
-
50
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51
- # If this step fails, then you should remove it and run the build manually (see below)
52
- - name: Autobuild
53
- uses: github/codeql-action/autobuild@v1
54
-
55
- # â„šī¸ Command-line programs to run using the OS shell.
56
- # 📚 https://git.io/JvXDl
57
-
58
- # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines
59
- # and modify them (or add more) to build your code if your project
60
- # uses a compiled language
61
-
62
- #- run: |
63
- # make bootstrap
64
- # make release
65
43
 
66
44
  - name: Perform CodeQL Analysis
67
45
  uses: github/codeql-action/analyze@v1
@@ -0,0 +1,24 @@
1
+ name: PR Validation
2
+ on:
3
+ pull_request:
4
+ types: [opened, reopened, synchronize]
5
+
6
+ jobs:
7
+ pr-labeler:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: TimonVS/pr-labeler-action@v3
11
+ with:
12
+ configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value
13
+ env:
14
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15
+ test:
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - uses: actions/setup-node@v2
21
+ with:
22
+ node-version: 16
23
+ registry-url: https://registry.npmjs.org/
24
+ - run: npm run test
@@ -0,0 +1,39 @@
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@v5
15
+ id: create_release
16
+ env:
17
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18
+ - uses: actions/checkout@v2
19
+ - uses: actions/setup-node@v2
20
+ with:
21
+ node-version: 16
22
+ registry-url: https://registry.npmjs.org/
23
+ - uses: HarmvZ/set-package-json-version-action@v0.1.2
24
+ with:
25
+ version: ${{ steps.create_release.outputs.tag_name }}
26
+ - run: npm i
27
+ - run: npm ci
28
+ - run: npm publish
29
+ env:
30
+ NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
31
+ - run: |
32
+ git add package.json
33
+ git add package-lock.json
34
+ git commit -m "Release ${{ steps.create_release.outputs.tag_name }}"
35
+ - uses: eregon/publish-release@v1
36
+ env:
37
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
+ with:
39
+ release_id: ${{ steps.create_release.outputs.id }}
@@ -2,15 +2,12 @@
2
2
 
3
3
  ## What is the purpose of this pull request? (put an "X" next to an item)
4
4
 
5
- - [ ] Documentation update
6
- - [ ] Bug fix
7
- - [ ] Extend features
5
+ - [ ] Fix
6
+ - [ ] Improvements
7
+ - [ ] New Feature
8
+ - [ ] Documentation updates
8
9
  - [ ] Other, please explain:
9
10
 
10
11
  ## What changes did you make? (Give an overview)
11
12
 
12
13
  ...
13
-
14
- ## Is there anything you'd like reviewers to focus on?
15
-
16
- ...
package/README.md CHANGED
@@ -16,8 +16,8 @@ This library attempts to overcomes some of the complexity/shortcomings of the or
16
16
  - Is opinionated about how Auth should be managed (only accepts a standard Auth method)
17
17
  - Only uses Promises/Async-Await, no callbacks
18
18
  - Maintainers of the semi-official lib from Salesforce are not responsive
19
- - Allows for using a persisting credentials in an external app, then passing
20
- - We expect parsing of SOAP to
19
+ - Allows for using a persisting credentials in an external app, then passing in
20
+ - We expect parsing of SOAP payloads to be done outside of the SDK (not helper methods)
21
21
 
22
22
  ## Usage
23
23
 
package/lib/index.js CHANGED
@@ -6,7 +6,7 @@ module.exports = class SDK {
6
6
  /**
7
7
  * Creates an instance of SDK.
8
8
  * @param {Object} options Auth Object for making requests
9
- * @param {Object} eventHandlers collection of handler functions (for example for logging)
9
+ * @param {Object} eventHandlers collection of handler functions (for examplef or logging)
10
10
  */
11
11
  constructor(options, eventHandlers) {
12
12
  this.auth = new Auth(options, eventHandlers);
package/lib/soap.js CHANGED
@@ -24,272 +24,262 @@ module.exports = class Soap {
24
24
  * @returns {Promise<Object>} SOAP object converted from XML
25
25
  */
26
26
  retrieve(type, props, requestParams) {
27
- const body = {
28
- RetrieveRequestMsg: {
29
- '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
30
- RetrieveRequest: {
31
- ObjectType: type,
32
- Properties: props,
27
+ const body = {
28
+ RetrieveRequestMsg: {
29
+ '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
30
+ RetrieveRequest: {
31
+ ObjectType: type,
32
+ Properties: props,
33
+ },
33
34
  },
34
- },
35
- };
35
+ };
36
36
 
37
- if (requestParams) {
38
- validateOptions(requestParams.options, [
39
- 'BatchSize',
40
- 'IncludeObjects',
41
- 'OnlyIncludeBase',
42
- ]);
43
- if (requestParams.options) {
44
- body.RetrieveRequestMsg.RetrieveRequest.Options = requestParams.options;
45
- }
46
- if (requestParams.ClientIDs) {
47
- body.RetrieveRequestMsg.RetrieveRequest.ClientIDs = requestParams.clientIDs;
48
- }
49
- // filter can be simple or complex and has three properties leftOperand, rightOperand, and operator
50
- if (requestParams.filter) {
51
- body.RetrieveRequestMsg.RetrieveRequest.Filter = _parseFilter(requestParams.filter);
52
- }
53
- if (requestParams.QueryAllAccounts) {
54
- body.RetrieveRequestMsg.RetrieveRequest.QueryAllAccounts = true;
55
- }
56
- if (requestParams.continueRequest) {
57
- body.RetrieveRequestMsg.RetrieveRequest.ContinueRequest =
58
- requestParams.continueRequest;
37
+ if (requestParams) {
38
+ validateOptions(requestParams.options, [
39
+ 'BatchSize',
40
+ 'IncludeObjects',
41
+ 'OnlyIncludeBase',
42
+ ]);
43
+ if (requestParams.options) {
44
+ body.RetrieveRequestMsg.RetrieveRequest.Options = requestParams.options;
45
+ }
46
+ if (requestParams.ClientIDs) {
47
+ body.RetrieveRequestMsg.RetrieveRequest.ClientIDs = requestParams.clientIDs;
48
+ }
49
+ // filter can be simple or complex and has three properties leftOperand, rightOperand, and operator
50
+ if (requestParams.filter) {
51
+ body.RetrieveRequestMsg.RetrieveRequest.Filter = _parseFilter(requestParams.filter);
52
+ }
53
+ if (requestParams.QueryAllAccounts) {
54
+ body.RetrieveRequestMsg.RetrieveRequest.QueryAllAccounts = true;
55
+ }
56
+ if (requestParams.continueRequest) {
57
+ body.RetrieveRequestMsg.RetrieveRequest.ContinueRequest =
58
+ requestParams.continueRequest;
59
+ }
59
60
  }
60
- }
61
61
 
62
- return _apiRequest(
63
- this.auth,
64
- {
65
- action: 'Retrieve',
66
- req: body,
67
- key: 'RetrieveResponseMsg',
68
- },
69
- 1
70
- );
71
- }
72
- /**
73
- * Method used to retrieve all data via SOAP API
74
- * @param {string} type -SOAP Object type
75
- * @param {Array<String>} props - Properties which should be retrieved
76
- * @param {Object} [requestParams] - additional RetrieveRequest parameters, for example filter or options
77
- * @returns {Promise<Object>} SOAP object converted from XML
78
- */
62
+ return _apiRequest(
63
+ this.auth, {
64
+ action: 'Retrieve',
65
+ req: body,
66
+ key: 'RetrieveResponseMsg',
67
+ },
68
+ 1
69
+ );
70
+ }
71
+ /**
72
+ * Method used to retrieve all data via SOAP API
73
+ * @param {string} type -SOAP Object type
74
+ * @param {Array<String>} props - Properties which should be retrieved
75
+ * @param {Object} [requestParams] - additional RetrieveRequest parameters, for example filter or options
76
+ * @returns {Promise<Object>} SOAP object converted from XML
77
+ */
79
78
  async retrieveBulk(type, props, requestParams) {
80
- let status;
81
- let resultsBulk;
82
- do {
83
- const resultsBatch = await this.retrieve(type, props, requestParams);
84
- if (resultsBulk) {
85
- // once first batch is done, the follow just add to result payload
86
- resultsBulk.Results.push(...resultsBatch.Results);
87
- } else {
88
- resultsBulk = resultsBatch;
89
- }
90
- status = resultsBatch.OverallStatus;
91
- if (status === 'MoreDataAvailable') {
92
- requestParams.continueRequest = resultsBatch.RequestID;
93
- if (this.eventHandlers && this.eventHandlers.onLoop) {
94
- this.eventHandlers.onLoop(type, resultsBulk);
79
+ let status;
80
+ let resultsBulk;
81
+ do {
82
+ const resultsBatch = await this.retrieve(type, props, requestParams);
83
+ if (resultsBulk) {
84
+ // once first batch is done, the follow just add to result payload
85
+ resultsBulk.Results.push(...resultsBatch.Results);
86
+ } else {
87
+ resultsBulk = resultsBatch;
95
88
  }
96
- }
97
- } while (status === 'MoreDataAvailable');
98
- return resultsBulk;
99
- }
100
- /**
101
- * Method used to create data via SOAP API
102
- * @param {string} type -SOAP Object type
103
- * @param {Array<String>} props - Properties which should be created
104
- * @param {Object} options - configuration of the request
105
- * @returns {Promise<Object>} SOAP object converted from XML
106
- */
89
+ status = resultsBatch.OverallStatus;
90
+ if (status === 'MoreDataAvailable') {
91
+ requestParams.continueRequest = resultsBatch.RequestID;
92
+ if (this.eventHandlers && this.eventHandlers.onLoop) {
93
+ this.eventHandlers.onLoop(type, resultsBulk);
94
+ }
95
+ }
96
+ } while (status === 'MoreDataAvailable');
97
+ return resultsBulk;
98
+ }
99
+ /**
100
+ * Method used to create data via SOAP API
101
+ * @param {string} type -SOAP Object type
102
+ * @param {Array<String>} props - Properties which should be created
103
+ * @param {Object} options - configuration of the request
104
+ * @returns {Promise<Object>} SOAP object converted from XML
105
+ */
107
106
  create(type, props, options) {
108
- const body = {
109
- CreateRequest: {
110
- '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
111
- Options: options,
112
- Objects: props,
113
- },
114
- };
115
- body.CreateRequest.Objects['@_xsi:type'] = type;
116
- validateOptions(options);
117
- return _apiRequest(
118
- this.auth,
119
- {
120
- action: 'Create',
121
- req: body,
122
- key: 'CreateResponse',
123
- },
124
- 1
125
- );
126
- }
127
- /**
128
- * Method used to update data via SOAP API
129
- * @param {string} type -SOAP Object type
130
- * @param {Array<String>} props - Properties which should be updated
131
- * @param {Object} options - configuration of the request
132
- * @returns {Promise<Object>} SOAP object converted from XML
133
- */
107
+ const body = {
108
+ CreateRequest: {
109
+ '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
110
+ Options: options,
111
+ Objects: props,
112
+ },
113
+ };
114
+ body.CreateRequest.Objects['@_xsi:type'] = type;
115
+ validateOptions(options);
116
+ return _apiRequest(
117
+ this.auth, {
118
+ action: 'Create',
119
+ req: body,
120
+ key: 'CreateResponse',
121
+ },
122
+ 1
123
+ );
124
+ }
125
+ /**
126
+ * Method used to update data via SOAP API
127
+ * @param {string} type -SOAP Object type
128
+ * @param {Array<String>} props - Properties which should be updated
129
+ * @param {Object} options - configuration of the request
130
+ * @returns {Promise<Object>} SOAP object converted from XML
131
+ */
134
132
  update(type, props, options) {
135
- const body = {
136
- UpdateRequest: {
137
- '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
138
- Options: options,
139
- Objects: props,
140
- },
141
- };
142
- body.UpdateRequest.Objects['@_xsi:type'] = type;
143
- validateOptions(options);
144
- return _apiRequest(
145
- this.auth,
146
- {
147
- action: 'Update',
148
- req: body,
149
- key: 'UpdateResponse',
150
- },
151
- 1
152
- );
153
- }
154
- /**
155
- * Method used to delete data via SOAP API
156
- * @param {string} type -SOAP Object type
157
- * @param {Array<String>} props - Properties which should be retrieved
158
- * @param {Object} options - configuration of the request
159
- * @returns {Promise<Object>} SOAP object converted from XML
160
- */
133
+ const body = {
134
+ UpdateRequest: {
135
+ '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
136
+ Options: options,
137
+ Objects: props,
138
+ },
139
+ };
140
+ body.UpdateRequest.Objects['@_xsi:type'] = type;
141
+ validateOptions(options);
142
+ return _apiRequest(
143
+ this.auth, {
144
+ action: 'Update',
145
+ req: body,
146
+ key: 'UpdateResponse',
147
+ },
148
+ 1
149
+ );
150
+ }
151
+ /**
152
+ * Method used to delete data via SOAP API
153
+ * @param {string} type -SOAP Object type
154
+ * @param {Array<String>} props - Properties which should be retrieved
155
+ * @param {Object} options - configuration of the request
156
+ * @returns {Promise<Object>} SOAP object converted from XML
157
+ */
161
158
  delete(type, props, options) {
162
- const body = {
163
- DeleteRequest: {
164
- '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
165
- Options: options,
166
- Objects: props,
167
- },
168
- };
169
- body.DeleteRequest.Objects['@_xsi:type'] = type;
170
- validateOptions(options);
171
- return _apiRequest(
172
- this.auth,
173
- {
174
- action: 'Delete',
175
- req: body,
176
- key: 'DeleteResponse',
177
- },
178
- 1
179
- );
180
- }
181
- /**
182
- * Method used to schedule data via SOAP API
183
- * @param {string} type -SOAP Object type
184
- * @param {Object} schedule -object for what the schedule should be
185
- * @param {Array|Object} interactions - Object or array of interactions
186
- * @param {string} action - type of schedul
187
- * @param {Object} options - configuration of the request
188
- * @returns {Promise<Object>} SOAP object converted from XML
189
- */
159
+ const body = {
160
+ DeleteRequest: {
161
+ '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
162
+ Options: options,
163
+ Objects: props,
164
+ },
165
+ };
166
+ body.DeleteRequest.Objects['@_xsi:type'] = type;
167
+ validateOptions(options);
168
+ return _apiRequest(
169
+ this.auth, {
170
+ action: 'Delete',
171
+ req: body,
172
+ key: 'DeleteResponse',
173
+ },
174
+ 1
175
+ );
176
+ }
177
+ /**
178
+ * Method used to schedule data via SOAP API
179
+ * @param {string} type -SOAP Object type
180
+ * @param {Object} schedule -object for what the schedule should be
181
+ * @param {Array|Object} interactions - Object or array of interactions
182
+ * @param {string} action - type of schedul
183
+ * @param {Object} options - configuration of the request
184
+ * @returns {Promise<Object>} SOAP object converted from XML
185
+ */
190
186
  schedule(type, schedule, interactions, action, options) {
191
- const body = {
192
- ScheduleRequestMsg: {
193
- '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
194
- Action: action,
195
- Options: options,
196
- Schedule: schedule,
197
- Interactions: interactions,
198
- },
199
- };
200
- if (Array.isArray(body.ScheduleRequestMsg.Interactions)) {
201
- body.ScheduleRequestMsg.Interactions = body.ScheduleRequestMsg.Interactions.map((i) => {
202
- i.Interaction['@_xsi:type'] = type;
203
- return i;
204
- });
205
- } else if (isObject(body.ScheduleRequestMsg.Interactions)) {
206
- body.ScheduleRequestMsg.Interactions.Interaction['@_xsi:type'] = type;
207
- } else {
208
- throw new TypeError('Interactions must be of Array or Object Type');
187
+ const body = {
188
+ ScheduleRequestMsg: {
189
+ '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
190
+ Action: action,
191
+ Options: options,
192
+ Schedule: schedule,
193
+ Interactions: interactions,
194
+ },
195
+ };
196
+ if (Array.isArray(body.ScheduleRequestMsg.Interactions)) {
197
+ body.ScheduleRequestMsg.Interactions = body.ScheduleRequestMsg.Interactions.map((i) => {
198
+ i.Interaction['@_xsi:type'] = type;
199
+ return i;
200
+ });
201
+ } else if (isObject(body.ScheduleRequestMsg.Interactions)) {
202
+ body.ScheduleRequestMsg.Interactions.Interaction['@_xsi:type'] = type;
203
+ } else {
204
+ throw new TypeError('Interactions must be of Array or Object Type');
205
+ }
206
+ validateOptions(options);
207
+ return _apiRequest(
208
+ this.auth, {
209
+ action: 'Schedule',
210
+ req: body,
211
+ key: 'ScheduleResponse',
212
+ },
213
+ 1
214
+ );
209
215
  }
210
- validateOptions(options);
211
- return _apiRequest(
212
- this.auth,
213
- {
214
- action: 'Schedule',
215
- req: body,
216
- key: 'ScheduleResponse',
217
- },
218
- 1
219
- );
220
- }
221
- /**
222
- * Method used to describe metadata via SOAP API
223
- * @param {string} type -SOAP Object type
224
- * @returns {Promise<Object>} SOAP object converted from XML
225
- */
216
+ /**
217
+ * Method used to describe metadata via SOAP API
218
+ * @param {string} type -SOAP Object type
219
+ * @returns {Promise<Object>} SOAP object converted from XML
220
+ */
226
221
  describe(type) {
227
- return _apiRequest(
228
- this.auth,
229
- {
230
- action: 'Describe',
231
- req: {
232
- DefinitionRequestMsg: {
233
- '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
234
- DescribeRequests: {
235
- ObjectDefinitionRequest: {
236
- ObjectType: type,
222
+ return _apiRequest(
223
+ this.auth, {
224
+ action: 'Describe',
225
+ req: {
226
+ DefinitionRequestMsg: {
227
+ '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
228
+ DescribeRequests: {
229
+ ObjectDefinitionRequest: {
230
+ ObjectType: type,
231
+ },
237
232
  },
238
233
  },
239
234
  },
235
+ key: 'DefinitionResponseMsg',
240
236
  },
241
- key: 'DefinitionResponseMsg',
242
- },
243
- 1
244
- );
245
- }
246
- /**
247
- * Method used to execute data via SOAP API
248
- * @param {string} type -SOAP Object type
249
- * @param {Array<String>} props - Properties which should be retrieved
250
- * @returns {Promise<Object>} SOAP object converted from XML
251
- */
237
+ 1
238
+ );
239
+ }
240
+ /**
241
+ * Method used to execute data via SOAP API
242
+ * @param {string} type -SOAP Object type
243
+ * @param {Array<String>} props - Properties which should be retrieved
244
+ * @returns {Promise<Object>} SOAP object converted from XML
245
+ */
252
246
  execute(type, props) {
253
- return _apiRequest(
254
- this.auth,
255
- {
256
- action: 'Execute',
257
- req: {
258
- ExecuteRequestMsg: {
259
- '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
260
- Requests: {
261
- Name: type,
262
- Parameters: props,
247
+ return _apiRequest(
248
+ this.auth, {
249
+ action: 'Execute',
250
+ req: {
251
+ ExecuteRequestMsg: {
252
+ '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
253
+ Requests: {
254
+ Name: type,
255
+ Parameters: props,
256
+ },
263
257
  },
264
258
  },
259
+ key: 'ExecuteResponseMsg',
265
260
  },
266
- key: 'ExecuteResponseMsg',
267
- },
268
- 1
269
- );
270
- }
271
- /**
272
- * Method used to execute data via SOAP API
273
- * @param {string} type -SOAP Object type
274
- * @param {Array<String>} props - Properties which should be retrieved
275
- * @returns {Promise<Object>} SOAP object converted from XML
276
- */
261
+ 1
262
+ );
263
+ }
264
+ /**
265
+ * Method used to execute data via SOAP API
266
+ * @param {string} type -SOAP Object type
267
+ * @param {Array<String>} props - Properties which should be retrieved
268
+ * @returns {Promise<Object>} SOAP object converted from XML
269
+ */
277
270
  perform(type) {
278
271
  return _apiRequest(
279
- this.auth,
280
- {
272
+ this.auth, {
281
273
  action: 'perform',
282
274
  req: {
283
275
  PerformRequestMsg: {
284
276
  '@_xmlns': 'http://exacttarget.com/wsdl/partnerAPI',
285
277
  Action: 'start',
286
- Definitions: [
287
- {
288
- Definition: {
289
- '@_xsi:type': type,
290
- },
278
+ Definitions: [{
279
+ Definition: {
280
+ '@_xsi:type': type,
291
281
  },
292
- ],
282
+ }, ],
293
283
  },
294
284
  },
295
285
  key: 'PerformResponseMsg',
@@ -358,7 +348,16 @@ function _parseFilter(filter) {
358
348
  * @return {Promise<Object|Error>} Result of request in Object format
359
349
  */
360
350
  async function _parseResponse(body, key) {
351
+ // const parser = new xml2js.Parser({
352
+ // trim: true,
353
+ // normalize: true,
354
+ // explicitArray: false,
355
+ // ignoreAttrs: true,
356
+ // });
357
+
358
+ // const payload = await parser.parseStringPromise(body);
361
359
  const payload = xmlToJson.parse(body);
360
+
362
361
  const soapBody = payload['soap:Envelope']['soap:Body'];
363
362
  // checks errors in Body Fault
364
363
  if (soapBody['soap:Fault']) {
@@ -395,9 +394,9 @@ async function _parseResponse(body, key) {
395
394
  return soapBody[key];
396
395
  } else {
397
396
  // This is an error
398
- const errorType = soapBody[key].OverallStatus.includes(':')
399
- ? soapBody[key].OverallStatus.split(':')[1].trim()
400
- : soapBody[key].OverallStatus;
397
+ const errorType = soapBody[key].OverallStatus.includes(':') ?
398
+ soapBody[key].OverallStatus.split(':')[1].trim() :
399
+ soapBody[key].OverallStatus;
401
400
  const soapError = new Error(errorType);
402
401
  soapError.requestId = soapBody[key].RequestID;
403
402
  soapError.errorPropagatedFrom = key;
@@ -467,4 +466,4 @@ function validateOptions(options, additional) {
467
466
  throw new Error(`${key} is not a supported Option`);
468
467
  }
469
468
  }
470
- }
469
+ }
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
- "name": "sfmc-sdk",
3
- "version": "0.0.7",
4
- "description": "Libarary to simplify SFMC requests with updated dependencies and less overhead",
5
- "main": "./lib/index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/DougMidgley/SFMC-SDK.git"
12
- },
13
- "author": "Doug Midgley <douglasmidgley@gmail.com>",
14
- "license": "BSD-3-Clause",
15
- "dependencies": {
16
- "axios": "^0.24.0",
17
- "fast-xml-parser": "3.21.1",
18
- "p-limit": "3.1.0"
19
- },
20
- "keywords": [
21
- "fuel",
22
- "exacttarget",
23
- "salesforce",
24
- "marketing",
25
- "cloud",
26
- "soap",
27
- "rest",
28
- "auth",
29
- "sdk"
30
- ]
2
+ "name": "sfmc-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Libarary to simplify SFMC requests with updated dependencies and less overhead",
5
+ "main": "./lib/index.js",
6
+ "scripts": {
7
+ "test": "echo \"No test specified\""
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/DougMidgley/SFMC-SDK.git"
12
+ },
13
+ "author": "Doug Midgley <douglasmidgley@gmail.com>",
14
+ "license": "BSD-3-Clause",
15
+ "dependencies": {
16
+ "axios": "^0.24.0",
17
+ "fast-xml-parser": "3.21.1",
18
+ "p-limit": "3.1.0"
19
+ },
20
+ "keywords": [
21
+ "fuel",
22
+ "exacttarget",
23
+ "salesforce",
24
+ "marketing",
25
+ "cloud",
26
+ "soap",
27
+ "rest",
28
+ "auth",
29
+ "sdk"
30
+ ]
31
31
  }
@@ -1,22 +0,0 @@
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: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- publish-npm:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v2
15
- - uses: actions/setup-node@v2
16
- with:
17
- node-version: 12
18
- registry-url: https://registry.npmjs.org/
19
- - run: npm ci
20
- - run: npm publish
21
- env:
22
- NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
package/.issuetracker DELETED
@@ -1,7 +0,0 @@
1
- # Integration with Issue Tracker
2
- #
3
- # (note that '\' need to be escaped).
4
-
5
- [issuetracker "Jira Rule"]
6
- regex = "CSCLSROZ-(\\d+)"
7
- url = "https://alm.accenture.com/jira/browse/CSCLSROZ-$1"
package/.markdownlint.md DELETED
@@ -1,4 +0,0 @@
1
- # How to set up markdownlint rules
2
-
3
- - [list of rules](https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md)
4
- - [how to configure in vscode](https://github.com/DavidAnson/vscode-markdownlint#configure)
package/CHANGELOG.md DELETED
@@ -1,23 +0,0 @@
1
- # Changelog
2
-
3
- ## SFMC SDK follows [semantic versioning](https://semver.org/).
4
-
5
- ## 0.0.7 - 2021-12-23
6
- - Revert P-Limit Dependency Bump
7
-
8
- ## 0.0.6 - 2021-12-23
9
-
10
- - Bump dependency versions
11
- - Extended SOAP action support to other types
12
- - Added SOAP Retreive Bulk
13
- - Added REST Get Collection & GetBulk features
14
-
15
- ## 0.0.2 - 2021-04-10
16
-
17
- NPM Publishing
18
-
19
- ---
20
-
21
- ## 0.0.1 - 2021-04-10
22
-
23
- Initial Testing