mcdev 6.0.1 → 6.0.2

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 (42) hide show
  1. package/.github/ISSUE_TEMPLATE/bug.yml +1 -0
  2. package/.github/PULL_REQUEST_TEMPLATE/pr_template_release.md +4 -3
  3. package/.vscode/settings.json +2 -2
  4. package/docs/dist/documentation.md +11 -23
  5. package/lib/Retriever.js +3 -2
  6. package/lib/metadataTypes/DataExtension.js +9 -18
  7. package/lib/metadataTypes/EmailSend.js +48 -28
  8. package/lib/metadataTypes/Journey.js +2 -2
  9. package/lib/metadataTypes/TransactionalSMS.js +18 -38
  10. package/lib/metadataTypes/definitions/MobileKeyword.definition.js +1 -1
  11. package/lib/util/file.js +9 -9
  12. package/package.json +7 -7
  13. package/test/mockRoot/.mcdevrc.json +1 -1
  14. package/test/resources/9999999/asset/block-1157-retrieve-expected.html +17 -8
  15. package/test/resources/9999999/automation/v1/scripts/get-response.json +32 -2
  16. package/test/resources/9999999/legacy/v1/beta/mobile/keyword/get-response.json +1 -1
  17. package/test/resources/9999999/legacy/v1/beta/mobile/message/get-response.json +1 -1
  18. package/test/resources/9999999/messaging/v1/sms/definitions/post-response.json +3 -1
  19. package/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/get-response.json +3 -1
  20. package/test/resources/9999999/messaging/v1/sms/definitions/testExisting_tsms/patch-response.json +3 -1
  21. package/test/resources/9999999/mobileKeyword/build-expected.amp +5 -1
  22. package/test/resources/9999999/mobileKeyword/get-expected.amp +5 -1
  23. package/test/resources/9999999/mobileKeyword/post-create-expected.amp +1 -1
  24. package/test/resources/9999999/mobileKeyword/template-expected.amp +5 -1
  25. package/test/resources/9999999/mobileMessage/build-expected.amp +6 -1
  26. package/test/resources/9999999/mobileMessage/get-expected.amp +6 -1
  27. package/test/resources/9999999/mobileMessage/post-create-expected.amp +1 -1
  28. package/test/resources/9999999/mobileMessage/post-update-expected.amp +1 -1
  29. package/test/resources/9999999/mobileMessage/template-expected.amp +6 -1
  30. package/test/resources/9999999/script/get_ampincluded-expected.json +8 -0
  31. package/test/resources/9999999/script/get_ampincluded-expected.ssjs +5 -0
  32. package/test/resources/9999999/script/get_ampscript-expected.html +5 -0
  33. package/test/resources/9999999/script/get_ampscript-expected.json +8 -0
  34. package/test/resources/9999999/script/get_mixed-expected.html +9 -0
  35. package/test/resources/9999999/script/get_mixed-expected.json +8 -0
  36. package/test/resources/9999999/transactionalSMS/build-expected.amp +105 -1
  37. package/test/resources/9999999/transactionalSMS/get-expected.amp +105 -1
  38. package/test/resources/9999999/transactionalSMS/patch-expected.amp +99 -1
  39. package/test/resources/9999999/transactionalSMS/post-expected.amp +99 -1
  40. package/test/resources/9999999/transactionalSMS/template-expected.amp +105 -1
  41. package/test/type.script.test.js +54 -14
  42. package/test/utils.js +3 -0
@@ -1,4 +1,108 @@
1
-
1
+ line1
2
+ %%[
3
+ SET @test = '{{{description}}}'
4
+ ]%%
5
+ line2 %%= v(@test) =%% still line2
6
+ line3
2
7
  %%[
3
8
  SET @key = '{{{secret}}}'
4
9
  ]%%
10
+
11
+ %%[
12
+ SET @unsubMessages = 'UnsubscribeSMSMessages_DEV'
13
+ SET @unsubEvents = 'UnsubscribeSMS_DEV'
14
+ SET @num = concat('+', [MOBILE_NUMBER])
15
+ SET @rs = RetrieveSalesforceObjects(
16
+ 'Contact',
17
+ 'Id,et4ae5__HasOptedOutOfMobile__c',
18
+ 'MobilePhone',
19
+ '=',
20
+ @num
21
+ )
22
+ SET @count = rowCount(@rs)
23
+ VAR @response
24
+ SET @rx = '^\+((?:9[679]\d8[035789]\d|6[789]\d|5[90]\d|42\d|3[578]\d|2[1-689]\d)|9[0-58]|8[1246]|6[0-6]|5[1-8]|4[013-9]|3[0-469]|2[70]|7|1)'
25
+ SET @prefix = concat('+', RegExMatch(@num, @rx, 1))
26
+ IF @count>0 THEN
27
+ FOR @I = 1 TO @COUNT DO
28
+ SET @sk = Field(Row(@rs, @i), 'Id')
29
+ IF Field(Row(@rs, 1), 'et4ae5__HasOptedOutOfMobile__c') == 'false' THEN
30
+ SET @result = UpdateSingleSalesforceObject('Contact', @sk, 'et4ae5__HasOptedOutOfMobile__c', 'true')
31
+ IF @result == 0 THEN
32
+ InsertData(
33
+ @unsubEvents,
34
+ 'MobileNumber',
35
+ @num,
36
+ 'Message',
37
+ [MSG(0).NOUNS],
38
+ 'ContactId',
39
+ @sk,
40
+ 'Status',
41
+ 'Error Updating'
42
+ )
43
+ ELSE
44
+ InsertData(
45
+ @unsubEvents,
46
+ 'MobileNumber',
47
+ @num,
48
+ 'Message',
49
+ [MSG(0).NOUNS],
50
+ 'ContactId',
51
+ @sk,
52
+ 'Status',
53
+ 'Successfully Unsubscribed'
54
+ )
55
+ ENDIF
56
+ ELSE
57
+ InsertData(
58
+ @unsubEvents,
59
+ 'MobileNumber',
60
+ @num,
61
+ 'Message',
62
+ [MSG(0).NOUNS],
63
+ 'ContactId',
64
+ @sk,
65
+ 'Status',
66
+ 'Already Unsubscribed'
67
+ )
68
+ ENDIF
69
+ NEXT @i
70
+ SET @msg = Lookup(
71
+ @unsubMessages,
72
+ 'Message',
73
+ 'Prefix',
74
+ @prefix,
75
+ 'Type',
76
+ 'Found'
77
+ )
78
+ IF Length(@msg) == 0 THEN
79
+ SET @response = 'You have unsubscribed and will no longer receive any messages.|'
80
+ ELSE
81
+ SET @response = @msg
82
+ ENDIF
83
+ ELSE
84
+ InsertData(
85
+ @unsubEvents,
86
+ 'MobileNumber',
87
+ @num,
88
+ 'Message',
89
+ [MSG(0).NOUNS],
90
+ 'Status',
91
+ 'Not Found'
92
+ )
93
+ SET @msg = Lookup(
94
+ @unsubMessages,
95
+ 'Message',
96
+ 'Prefix',
97
+ @prefix,
98
+ 'Type',
99
+ 'NotFound'
100
+ )
101
+ IF Length(@msg) == 0 THEN
102
+ SET @response = 'Sorry, we could not find you'
103
+ ELSE
104
+ SET @response = @msg
105
+ ENDIF
106
+ ENDIF
107
+ ]%%
108
+ %%=v(@response)=%%
@@ -20,22 +20,21 @@ describe('type: script', () => {
20
20
  const retrieve = await handler.retrieve('testInstance/testBU', ['script']);
21
21
  // THEN
22
22
  assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
23
-
24
23
  // retrieve result
25
24
  assert.equal(
26
25
  retrieve['testInstance/testBU'].script
27
26
  ? Object.keys(retrieve['testInstance/testBU'].script).length
28
27
  : 0,
29
- 2,
30
- 'only 2 scripts expected in retrieve response'
28
+ 5,
29
+ 'only 5 scripts expected in retrieve response'
31
30
  );
32
31
 
33
32
  // get results from cache
34
33
  const result = cache.getCache();
35
34
  assert.equal(
36
35
  result.script ? Object.keys(result.script).length : 0,
37
- 2,
38
- 'only 2 scripts expected'
36
+ 5,
37
+ 'only 5 scripts expected'
39
38
  );
40
39
  // normal test
41
40
  assert.deepEqual(
@@ -49,6 +48,7 @@ describe('type: script', () => {
49
48
  file(testUtils.getExpectedFile('9999999', 'script', 'get', 'ssjs'))
50
49
  );
51
50
 
51
+ // test with no script tag
52
52
  assert.deepEqual(
53
53
  await testUtils.getActualJson('testExisting_script_noScriptTag', 'script'),
54
54
  await testUtils.getExpectedJson('9999999', 'script', 'get_noScriptTag'),
@@ -63,6 +63,47 @@ describe('type: script', () => {
63
63
  file(testUtils.getActualFile('testExisting_script_noScriptTag', 'script', 'ssjs'))
64
64
  ).to.not.exist;
65
65
 
66
+ // test with ampscript
67
+ assert.deepEqual(
68
+ await testUtils.getActualJson('testExisting_script_ampscript', 'script'),
69
+ await testUtils.getExpectedJson('9999999', 'script', 'get_ampscript'),
70
+ 'returned metadata was not equal expected'
71
+ );
72
+ expect(
73
+ file(testUtils.getActualFile('testExisting_script_ampscript', 'script', 'html'))
74
+ ).to.equal(
75
+ file(testUtils.getExpectedFile('9999999', 'script', 'get_ampscript', 'html'))
76
+ );
77
+ expect(file(testUtils.getActualFile('testExisting_script_ampscript', 'script', 'ssjs')))
78
+ .to.not.exist;
79
+
80
+ // test with mixed code (ampscript inside of ssjs)
81
+ assert.deepEqual(
82
+ await testUtils.getActualJson('testExisting_script_ampincluded', 'script'),
83
+ await testUtils.getExpectedJson('9999999', 'script', 'get_ampincluded'),
84
+ 'returned metadata was not equal expected'
85
+ );
86
+ expect(
87
+ file(testUtils.getActualFile('testExisting_script_ampincluded', 'script', 'html'))
88
+ ).to.not.exist;
89
+ expect(
90
+ file(testUtils.getActualFile('testExisting_script_ampincluded', 'script', 'ssjs'))
91
+ ).to.equal(
92
+ file(testUtils.getExpectedFile('9999999', 'script', 'get_ampincluded', 'ssjs'))
93
+ );
94
+
95
+ // test with mixed code (ssjs and ampscript side-by-side)
96
+ assert.deepEqual(
97
+ await testUtils.getActualJson('testExisting_script_mixed', 'script'),
98
+ await testUtils.getExpectedJson('9999999', 'script', 'get_mixed'),
99
+ 'returned metadata was not equal expected'
100
+ );
101
+ expect(
102
+ file(testUtils.getActualFile('testExisting_script_mixed', 'script', 'html'))
103
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'script', 'get_mixed', 'html')));
104
+ expect(file(testUtils.getActualFile('testExisting_script_mixed', 'script', 'ssjs'))).to
105
+ .not.exist;
106
+
66
107
  assert.equal(
67
108
  testUtils.getAPIHistoryLength(),
68
109
  3,
@@ -122,8 +163,8 @@ describe('type: script', () => {
122
163
  const result = cache.getCache();
123
164
  assert.equal(
124
165
  result.script ? Object.keys(result.script).length : 0,
125
- 2,
126
- 'two scripts in cache expected'
166
+ 5,
167
+ '5 scripts in cache expected'
127
168
  );
128
169
  assert.deepEqual(
129
170
  await testUtils.getActualJson('testExisting_script', 'script'),
@@ -162,8 +203,8 @@ describe('type: script', () => {
162
203
  const result = cache.getCache();
163
204
  assert.equal(
164
205
  result.script ? Object.keys(result.script).length : 0,
165
- 2,
166
- 'two scripts in cache expected'
206
+ 5,
207
+ '5 scripts in cache expected'
167
208
  );
168
209
 
169
210
  expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.not
@@ -189,8 +230,8 @@ describe('type: script', () => {
189
230
  const result = cache.getCache();
190
231
  assert.equal(
191
232
  result.script ? Object.keys(result.script).length : 0,
192
- 3,
193
- 'three scripts expected'
233
+ 6,
234
+ '6 scripts expected'
194
235
  );
195
236
  // confirm created item
196
237
  assert.deepEqual(
@@ -198,15 +239,14 @@ describe('type: script', () => {
198
239
  await testUtils.getExpectedJson('9999999', 'script', 'post'),
199
240
  'returned metadata was not equal expected for insert script'
200
241
  );
201
- expect(file(testUtils.getActualFile('testNew_script', 'script', 'ssjs'))).to.equal(
202
- file(testUtils.getExpectedFile('9999999', 'script', 'post', 'ssjs'))
203
- );
204
242
  // confirm updated item
205
243
  assert.deepEqual(
206
244
  await testUtils.getActualJson('testExisting_script', 'script'),
207
245
  await testUtils.getExpectedJson('9999999', 'script', 'patch'),
208
246
  'returned metadata was not equal expected for insert script'
209
247
  );
248
+ expect(file(testUtils.getActualFile('testExisting_script', 'script', 'html'))).to.not
249
+ .exist;
210
250
  expect(file(testUtils.getActualFile('testExisting_script', 'script', 'ssjs'))).to.equal(
211
251
  file(testUtils.getExpectedFile('9999999', 'script', 'patch', 'ssjs'))
212
252
  );
package/test/utils.js CHANGED
@@ -156,6 +156,9 @@ export function mockSetup(isDeploy) {
156
156
  'node_modules/prettier-plugin-sql': fsmock.load(
157
157
  path.resolve(__dirname, '../node_modules/prettier-plugin-sql')
158
158
  ),
159
+ 'node_modules/beauty-amp-core2': fsmock.load(
160
+ path.resolve(__dirname, '../node_modules/beauty-amp-core2')
161
+ ),
159
162
  'node_modules/node-sql-parser': fsmock.load(
160
163
  path.resolve(__dirname, '../node_modules/node-sql-parser')
161
164
  ),