Skip to content

Commit f089dd0

Browse files
cs-rajVikram Kaltavkaltaharshithad0703sunil-lakshman
authored
DX | 27-01-2025 | Release (#269)
* fix: added fix for updateasseturl for handling jrte within blocks * dropping isomorphic-fetch and node-fetch * version bumpt to 3.23.1 * removed commented lines * Updated error codes in testcases * fix: disable minification for improved debugging * fix: setting minimize to true for browser * verison bump * license update * Updated slack bolt and qs * version fixed * sanity update for dev11 --------- Co-authored-by: Vikram Kalta <[email protected]> Co-authored-by: Vikram Kalta <[email protected]> Co-authored-by: harshitha.d <[email protected]> Co-authored-by: sunil-lakshman <[email protected]> Co-authored-by: harshithad0703 <[email protected]>
1 parent 33bd86a commit f089dd0

14 files changed

+1592
-1566
lines changed

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The MIT License (MIT)
22

33

4-
Copyright (c) 2016-2024 Contentstack
4+
Copyright (c) 2016-2025 Contentstack
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

package-lock.json

+1,422-1,491
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+19-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "contentstack",
3-
"version": "3.23.0",
3+
"version": "3.24.0",
44
"description": "Contentstack Javascript SDK",
55
"homepage": "https://www.contentstack.com/",
66
"author": {
@@ -65,46 +65,45 @@
6565
"tmp": "tmp/contentstack-3.15.0.tgz_1477830884275_0.9869455888401717"
6666
},
6767
"devDependencies": {
68-
"@babel/core": "^7.25.9",
69-
"@babel/preset-env": "^7.25.9",
70-
"@babel/runtime": "^7.25.9",
71-
"@slack/bolt": "^3.22.0",
68+
"@babel/core": "^7.26.0",
69+
"@babel/preset-env": "^7.26.0",
70+
"@babel/runtime": "^7.26.0",
71+
"@slack/bolt": "^4.2.0",
7272
"@types/jest": "^26.0.24",
7373
"babel-loader": "^9.2.1",
7474
"clean-webpack-plugin": "^4.0.0",
75-
"compression-webpack-plugin": "^10.0.0",
76-
"dotenv": "^16.4.5",
75+
"compression-webpack-plugin": "^11.1.0",
76+
"dotenv": "^16.4.7",
7777
"es3ify-loader": "0.2.0",
7878
"fetch-mock-jest": "^1.5.1",
79-
"http-proxy-agent": "^3.0.0",
79+
"http-proxy-agent": "^7.0.2",
8080
"jest": "^29.7.0",
81-
"jest-html-reporters": "^2.1.7",
81+
"jest-html-reporters": "^3.1.7",
8282
"jsdoc": "^4.0.4",
8383
"jshint": "^2.13.6",
8484
"minami": "^1.2.3",
8585
"node-request-interceptor": "^0.6.3",
86-
"nodemailer": "^6.9.15",
86+
"nodemailer": "^6.9.16",
8787
"string-replace-loader": "^3.1.0",
8888
"tap-html": "^1.1.0",
8989
"tap-json": "1.0.0",
9090
"tape": "4.17.0",
91-
"terser-webpack-plugin": "^5.3.10",
91+
"terser-webpack-plugin": "^5.3.11",
9292
"ts-jest": "^29.2.5",
9393
"typescript": "^4.9.5",
94-
"uglify-js": "2.8.29",
95-
"webpack": "^5.95.0",
96-
"webpack-cli": "^4.10.0",
97-
"webpack-md5-hash": "0.0.5",
98-
"webpack-merge": "4.1.5",
94+
"uglify-js": "3.19.3",
95+
"webpack": "^5.97.1",
96+
"webpack-cli": "^6.0.1",
97+
"webpack-md5-hash": "0.0.6",
98+
"webpack-merge": "6.0.1",
9999
"webpack-node-externals": "^3.0.0"
100100
},
101101
"dependencies": {
102-
"@contentstack/utils": "^1.3.12",
102+
"@contentstack/utils": "^1.3.15",
103103
"cheerio": "^1.0.0",
104104
"es6-promise": "^4.2.8",
105-
"fetch-mock": "^11.1.5",
106-
"isomorphic-fetch": "^3.0.0",
105+
"fetch-mock": "^12.2.0",
107106
"localStorage": "1.0.4",
108-
"qs": "^6.13.0"
107+
"qs": "^6.14.0"
109108
}
110109
}

sanity-report-dev11.js

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
const fs = require("fs");
2+
const dotenv = require("dotenv");
3+
const cheerio = require("cheerio");
4+
5+
dotenv.config();
6+
7+
const user1 = process.env.USER1;
8+
const user2 = process.env.USER2;
9+
const user3 = process.env.USER3;
10+
const user4 = process.env.USER4;
11+
12+
const tapHtmlContent = fs.readFileSync("./tap-html.html", "utf8");
13+
const $ = cheerio.load(tapHtmlContent);
14+
15+
const totalCount = $(".nav a:nth-child(2)")
16+
.text()
17+
.trim()
18+
.replace("Total Count", "");
19+
const totalPass = $(".nav a:nth-child(3)")
20+
.text()
21+
.trim()
22+
.replace("Total Pass", "");
23+
const totalFail = $(".nav a:nth-child(4)")
24+
.text()
25+
.trim()
26+
.replace("Total Fail", "");
27+
28+
const totalTime = $(".nav a:nth-child(1)")
29+
.text()
30+
.trim()
31+
.replace("Total Time", "");
32+
33+
const milliseconds = parseInt(totalTime.replace(/\D/g, ''), 10);
34+
const totalSeconds = Math.floor(milliseconds / 1000);
35+
const durationInMinutes = Math.floor(totalSeconds / 60);
36+
const durationInSeconds = totalSeconds % 60;
37+
38+
const passedTests = parseInt(totalPass, 10);
39+
const totalTests = parseInt(totalCount, 10);
40+
41+
const resultMessage =
42+
passedTests === totalTests
43+
? `:white_check_mark: Success (${passedTests} / ${totalTests} Passed)`
44+
: `:x: Failure (${passedTests} / ${totalTests} Passed)`;
45+
46+
const pipelineName = process.env.GO_PIPELINE_NAME;
47+
const pipelineCounter = process.env.GO_PIPELINE_COUNTER;
48+
const goCdServer = process.env.GOCD_SERVER;
49+
50+
const reportUrl = `http://${goCdServer}/go/files/${pipelineName}/${pipelineCounter}/sanity/1/sanity/test-results/tap-html.html`;
51+
52+
let tagUsers = ``;
53+
if (totalFail > 0) {
54+
tagUsers = `<@${user1}> <@${user2}> <@${user3}> <@${user4}>`;
55+
}
56+
57+
const slackMessage = {
58+
text: `Dev11, CDA SDK Full Sanity
59+
*Result:* ${resultMessage}. ${durationInMinutes}m ${durationInSeconds}s
60+
*Failed Tests:* ${totalFail}
61+
<${reportUrl}|View Report>
62+
${tagUsers}`,
63+
};
64+
65+
const slackWebhookUrl = process.env.SLACK_WEBHOOK_URL;
66+
67+
const sendSlackMessage = async (message) => {
68+
const payload = {
69+
text: message,
70+
};
71+
72+
try {
73+
const response = await fetch(slackWebhookUrl, {
74+
method: "POST",
75+
headers: {
76+
"Content-Type": "application/json",
77+
},
78+
body: JSON.stringify(payload),
79+
});
80+
81+
if (!response.ok) {
82+
throw new Error(`Error sending message to Slack: ${response.statusText}`);
83+
}
84+
85+
console.log("Message sent to Slack successfully");
86+
} catch (error) {
87+
console.error("Error:", error);
88+
}
89+
};
90+
91+
sendSlackMessage(slackMessage.text);

sanity-report.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const fs = require('fs');
2-
const Slack = require('@slack/bolt')
2+
const { App } = require('@slack/bolt');
33
const dotenv = require('dotenv')
44
dotenv.config()
55

@@ -39,7 +39,7 @@ const slackMessage = `
3939
• Total Duration: *${durationInMinutes}m ${durationInSeconds}s*
4040
`
4141

42-
const app = new Slack.App({
42+
const app = new App({
4343
token: process.env.SLACK_BOT_TOKEN,
4444
signingSecret: process.env.SLACK_SIGNING_SECRET
4545
})

src/core/contentstack.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,19 @@ class Contentstack {
6363
}
6464
}
6565
}
66-
x(entry[key].children);
66+
let _entry = {...entry};
67+
const keys = key.split(".");
68+
for (const k of keys) {
69+
if (_entry[k]) _entry = _entry[k];
70+
else if (_entry.length) {
71+
for (const block of _entry) {
72+
if (block[k]) {
73+
_entry = block[k];
74+
}
75+
}
76+
}
77+
}
78+
if (_entry.children) x(_entry.children);
6779
if (correspondingAsset) {
6880
correspondingAsset['href'] = item.url;
6981
}

src/runtime/node/http.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import ES6Promise from 'es6-promise';
2-
import fetch from 'node-fetch';
32

43
ES6Promise.polyfill();
54

6-
export default fetch;
5+
export default fetch; // fetch API available in Node.js 18 and later

src/runtime/web/http.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ES6Promise from 'es6-promise';
2-
import fetch from 'isomorphic-fetch';
32
ES6Promise.polyfill();
43

5-
export default fetch;
4+
export default fetch; // fetch API available in Node.js 18 and later

test/entry/findone.js

+9-29
Original file line numberDiff line numberDiff line change
@@ -743,55 +743,35 @@ test('findOne: .except() - For the reference - Array', function(assert) {
743743
* HTTP Error Handling
744744
* !*/
745745

746-
test('findOne: should handle 404 Not Found error', function(assert) {
747-
const Query = Stack.ContentType(contentTypes.invalid_type).Query();
746+
test('findOne: should handle 422 Unprocessable Entity error', function(assert) {
747+
const Query = Stack.ContentType("invalid_content_type").Query();
748748

749749
Query
750750
.toJSON()
751751
.findOne()
752752
.then(function success() {
753-
assert.fail("Expected 404 error but got a successful response.");
753+
assert.fail("Expected 422 error but got a successful response.");
754754
assert.end();
755755
}, function error(err) {
756-
assert.equal(err.http_code, 404, 'Should return HTTP status 404.');
757-
assert.ok(err.http_message, 'Error message should be present.');
758-
console.error("Error:", err.http_message);
756+
assert.equal(err.http_code, 422, 'Should return HTTP status 422.');
757+
assert.ok(err.http_message, 'Unprocessable Entity');
759758
assert.end();
760759
});
761760
});
762761

763-
test('findOne: should handle 401 Unauthorized error', function(assert) {
762+
test('findOne: should handle 412 Unauthorized error', function(assert) {
764763
Stack.headers = { authorization: 'InvalidAPIKey' }; // Simulating an invalid API key
765764
const Query = Stack.ContentType(contentTypes.source).Query();
766765

767766
Query
768767
.toJSON()
769768
.findOne()
770769
.then(function success() {
771-
assert.fail("Expected 401 error but got a successful response.");
770+
assert.fail("Expected 412 error but got a successful response.");
772771
assert.end();
773772
}, function error(err) {
774-
assert.equal(err.http_code, 401, 'Should return HTTP status 401.');
775-
assert.ok(err.http_message, 'Error message should be present.');
776-
console.error("Error:", err.http_message);
773+
assert.equal(err.http_code, 412, 'Should return HTTP status 412.');
774+
assert.ok(err.http_message, 'Precondition Failed.');
777775
assert.end();
778776
});
779777
});
780-
781-
test('findOne: should handle 500 Internal Server Error', function(assert) {
782-
const mockStack = Contentstack.Stack({ ...init.stack, host: 'invalid.host' }); // Simulating a server error
783-
const Query = mockStack.ContentType(contentTypes.source).Query();
784-
785-
Query
786-
.toJSON()
787-
.findOne()
788-
.then(function success() {
789-
assert.fail("Expected 500 error but got a successful response.");
790-
assert.end();
791-
}, function error(err) {
792-
assert.equal(err.http_code, 500, 'Should return HTTP status 500.');
793-
assert.ok(err.http_message, 'Error message should be present.');
794-
console.error("Error:", err.http_message);
795-
assert.end();
796-
});
797-
});

webpack/webpack.common.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ module.exports = function(options) {
4242
protectWebpackAssets: false,
4343
cleanAfterEveryBuildPatterns: ['*.LICENSE.txt']
4444
})
45-
]
45+
],
46+
optimization: {
47+
minimize: false, // Prevents code compression/minification
48+
},
4649
};
4750
}

webpack/webpack.nativescript.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use strict';
22

33
const path = require('path');
4-
const webpackMerge = require('webpack-merge');
4+
const { merge } = require('webpack-merge');
55
var nodeExternals = require('webpack-node-externals');
66

77
const commonConfig = require('./webpack.common.js');
88

99
module.exports = function(options) {
10-
return webpackMerge(commonConfig(), {
10+
return merge(commonConfig(), {
1111
output: {
1212
libraryTarget: "commonjs2",
1313
path: path.join(__dirname, "../dist/nativescript"),
@@ -50,6 +50,9 @@ module.exports = function(options) {
5050
}
5151
],
5252
}]
53-
}
53+
},
54+
optimization: {
55+
minimize: false, // Prevents code compression/minification
56+
},
5457
});
5558
}

webpack/webpack.node.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
22
const path = require('path');
3-
const webpackMerge = require('webpack-merge');
3+
const { merge } = require('webpack-merge');
44
var nodeExternals = require('webpack-node-externals');
55

66
const commonConfig = require('./webpack.common.js');
77

88
module.exports = function(options) {
9-
return webpackMerge(commonConfig(), {
9+
return merge(commonConfig(), {
1010
output: {
1111
libraryTarget: "commonjs2",
1212
path: path.join(__dirname, "../dist/node"),
@@ -49,5 +49,8 @@ module.exports = function(options) {
4949
}],
5050
}]
5151
},
52+
optimization: {
53+
minimize: false, // Prevents code compression/minification
54+
},
5255
});
5356
}

0 commit comments

Comments
 (0)