Skip to content

DX | 27-01-2025 | Release #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a9161ab
fix: added fix for updateasseturl for handling jrte within blocks
Dec 2, 2024
3e93b8a
Merge pull request #254 from contentstack/master
cs-raj Dec 5, 2024
e657d79
Merge pull request #255 from contentstack/staging
cs-raj Dec 5, 2024
8b9f81d
Merge pull request #253 from contentstack/fix/DX-1371
vkalta Dec 5, 2024
df971ed
dropping isomorphic-fetch and node-fetch
harshithad0703 Dec 16, 2024
499b179
version bumpt to 3.23.1
harshithad0703 Dec 16, 2024
677abe5
removed commented lines
harshithad0703 Dec 17, 2024
894080a
Updated error codes in testcases
sunil-lakshman Dec 17, 2024
4567296
Merge pull request #260 from contentstack/fix/http_code_testcases
harshithad0703 Dec 17, 2024
8bb371e
Merge pull request #259 from contentstack/fix/dx-1415-drop-isomorphic…
harshithad0703 Dec 17, 2024
b0c9256
fix: disable minification for improved debugging
Dec 18, 2024
869ec7c
fix: setting minimize to true for browser
Jan 9, 2025
eb9cff9
verison bump
cs-raj Jan 13, 2025
de608da
license update
cs-raj Jan 13, 2025
58c64c5
Updated slack bolt and qs
cs-raj Jan 18, 2025
aaa5b73
Merge pull request #263 from contentstack/fix/VersionBump
cs-raj Jan 20, 2025
bf9df98
version fixed
cs-raj Jan 20, 2025
060c4b3
Merge pull request #264 from contentstack/fix/VersionBump
cs-raj Jan 20, 2025
e1424ff
sanity update for dev11
harshithad0703 Jan 21, 2025
d246c5b
Merge pull request #265 from contentstack/fix/dx-2069-sanity-update-d…
harshithad0703 Jan 21, 2025
5da7a6e
Merge pull request #261 from contentstack/feat/DX-1417
vkalta Jan 21, 2025
aed6af6
Merge branch 'master' into staging
cs-raj Jan 21, 2025
9341dc8
Merge pull request #266 from contentstack/fix/stage
cs-raj Jan 21, 2025
be96351
Merge pull request #267 from contentstack/staging
cs-raj Jan 21, 2025
6c0266c
Merge pull request #268 from contentstack/development
cs-raj Jan 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The MIT License (MIT)


Copyright (c) 2016-2024 Contentstack
Copyright (c) 2016-2025 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2,913 changes: 1,422 additions & 1,491 deletions package-lock.json

Large diffs are not rendered by default.

39 changes: 19 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contentstack",
"version": "3.23.0",
"version": "3.24.0",
"description": "Contentstack Javascript SDK",
"homepage": "https://www.contentstack.com/",
"author": {
Expand Down Expand Up @@ -65,46 +65,45 @@
"tmp": "tmp/contentstack-3.15.0.tgz_1477830884275_0.9869455888401717"
},
"devDependencies": {
"@babel/core": "^7.25.9",
"@babel/preset-env": "^7.25.9",
"@babel/runtime": "^7.25.9",
"@slack/bolt": "^3.22.0",
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@babel/runtime": "^7.26.0",
"@slack/bolt": "^4.2.0",
"@types/jest": "^26.0.24",
"babel-loader": "^9.2.1",
"clean-webpack-plugin": "^4.0.0",
"compression-webpack-plugin": "^10.0.0",
"dotenv": "^16.4.5",
"compression-webpack-plugin": "^11.1.0",
"dotenv": "^16.4.7",
"es3ify-loader": "0.2.0",
"fetch-mock-jest": "^1.5.1",
"http-proxy-agent": "^3.0.0",
"http-proxy-agent": "^7.0.2",
"jest": "^29.7.0",
"jest-html-reporters": "^2.1.7",
"jest-html-reporters": "^3.1.7",
"jsdoc": "^4.0.4",
"jshint": "^2.13.6",
"minami": "^1.2.3",
"node-request-interceptor": "^0.6.3",
"nodemailer": "^6.9.15",
"nodemailer": "^6.9.16",
"string-replace-loader": "^3.1.0",
"tap-html": "^1.1.0",
"tap-json": "1.0.0",
"tape": "4.17.0",
"terser-webpack-plugin": "^5.3.10",
"terser-webpack-plugin": "^5.3.11",
"ts-jest": "^29.2.5",
"typescript": "^4.9.5",
"uglify-js": "2.8.29",
"webpack": "^5.95.0",
"webpack-cli": "^4.10.0",
"webpack-md5-hash": "0.0.5",
"webpack-merge": "4.1.5",
"uglify-js": "3.19.3",
"webpack": "^5.97.1",
"webpack-cli": "^6.0.1",
"webpack-md5-hash": "0.0.6",
"webpack-merge": "6.0.1",
"webpack-node-externals": "^3.0.0"
},
"dependencies": {
"@contentstack/utils": "^1.3.12",
"@contentstack/utils": "^1.3.15",
"cheerio": "^1.0.0",
"es6-promise": "^4.2.8",
"fetch-mock": "^11.1.5",
"isomorphic-fetch": "^3.0.0",
"fetch-mock": "^12.2.0",
"localStorage": "1.0.4",
"qs": "^6.13.0"
"qs": "^6.14.0"
}
}
91 changes: 91 additions & 0 deletions sanity-report-dev11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const fs = require("fs");
const dotenv = require("dotenv");
const cheerio = require("cheerio");

dotenv.config();

const user1 = process.env.USER1;
const user2 = process.env.USER2;
const user3 = process.env.USER3;
const user4 = process.env.USER4;

const tapHtmlContent = fs.readFileSync("./tap-html.html", "utf8");
const $ = cheerio.load(tapHtmlContent);

const totalCount = $(".nav a:nth-child(2)")
.text()
.trim()
.replace("Total Count", "");
const totalPass = $(".nav a:nth-child(3)")
.text()
.trim()
.replace("Total Pass", "");
const totalFail = $(".nav a:nth-child(4)")
.text()
.trim()
.replace("Total Fail", "");

const totalTime = $(".nav a:nth-child(1)")
.text()
.trim()
.replace("Total Time", "");

const milliseconds = parseInt(totalTime.replace(/\D/g, ''), 10);
const totalSeconds = Math.floor(milliseconds / 1000);
const durationInMinutes = Math.floor(totalSeconds / 60);
const durationInSeconds = totalSeconds % 60;

const passedTests = parseInt(totalPass, 10);
const totalTests = parseInt(totalCount, 10);

const resultMessage =
passedTests === totalTests
? `:white_check_mark: Success (${passedTests} / ${totalTests} Passed)`
: `:x: Failure (${passedTests} / ${totalTests} Passed)`;

const pipelineName = process.env.GO_PIPELINE_NAME;
const pipelineCounter = process.env.GO_PIPELINE_COUNTER;
const goCdServer = process.env.GOCD_SERVER;

const reportUrl = `http://${goCdServer}/go/files/${pipelineName}/${pipelineCounter}/sanity/1/sanity/test-results/tap-html.html`;

let tagUsers = ``;
if (totalFail > 0) {
tagUsers = `<@${user1}> <@${user2}> <@${user3}> <@${user4}>`;
}

const slackMessage = {
text: `Dev11, CDA SDK Full Sanity
*Result:* ${resultMessage}. ${durationInMinutes}m ${durationInSeconds}s
*Failed Tests:* ${totalFail}
<${reportUrl}|View Report>
${tagUsers}`,
};

const slackWebhookUrl = process.env.SLACK_WEBHOOK_URL;

const sendSlackMessage = async (message) => {
const payload = {
text: message,
};

try {
const response = await fetch(slackWebhookUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});

if (!response.ok) {
throw new Error(`Error sending message to Slack: ${response.statusText}`);
}

console.log("Message sent to Slack successfully");
} catch (error) {
console.error("Error:", error);
}
};

sendSlackMessage(slackMessage.text);
4 changes: 2 additions & 2 deletions sanity-report.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const Slack = require('@slack/bolt')
const { App } = require('@slack/bolt');
const dotenv = require('dotenv')
dotenv.config()

Expand Down Expand Up @@ -39,7 +39,7 @@ const slackMessage = `
• Total Duration: *${durationInMinutes}m ${durationInSeconds}s*
`

const app = new Slack.App({
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET
})
Expand Down
14 changes: 13 additions & 1 deletion src/core/contentstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,19 @@ class Contentstack {
}
}
}
x(entry[key].children);
let _entry = {...entry};
const keys = key.split(".");
for (const k of keys) {
if (_entry[k]) _entry = _entry[k];
else if (_entry.length) {
for (const block of _entry) {
if (block[k]) {
_entry = block[k];
}
}
}
}
if (_entry.children) x(_entry.children);
if (correspondingAsset) {
correspondingAsset['href'] = item.url;
}
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/node/http.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ES6Promise from 'es6-promise';
import fetch from 'node-fetch';

ES6Promise.polyfill();

export default fetch;
export default fetch; // fetch API available in Node.js 18 and later
3 changes: 1 addition & 2 deletions src/runtime/web/http.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ES6Promise from 'es6-promise';
import fetch from 'isomorphic-fetch';
ES6Promise.polyfill();

export default fetch;
export default fetch; // fetch API available in Node.js 18 and later
38 changes: 9 additions & 29 deletions test/entry/findone.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,55 +743,35 @@ test('findOne: .except() - For the reference - Array', function(assert) {
* HTTP Error Handling
* !*/

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

Query
.toJSON()
.findOne()
.then(function success() {
assert.fail("Expected 404 error but got a successful response.");
assert.fail("Expected 422 error but got a successful response.");
assert.end();
}, function error(err) {
assert.equal(err.http_code, 404, 'Should return HTTP status 404.');
assert.ok(err.http_message, 'Error message should be present.');
console.error("Error:", err.http_message);
assert.equal(err.http_code, 422, 'Should return HTTP status 422.');
assert.ok(err.http_message, 'Unprocessable Entity');
assert.end();
});
});

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

Query
.toJSON()
.findOne()
.then(function success() {
assert.fail("Expected 401 error but got a successful response.");
assert.fail("Expected 412 error but got a successful response.");
assert.end();
}, function error(err) {
assert.equal(err.http_code, 401, 'Should return HTTP status 401.');
assert.ok(err.http_message, 'Error message should be present.');
console.error("Error:", err.http_message);
assert.equal(err.http_code, 412, 'Should return HTTP status 412.');
assert.ok(err.http_message, 'Precondition Failed.');
assert.end();
});
});

test('findOne: should handle 500 Internal Server Error', function(assert) {
const mockStack = Contentstack.Stack({ ...init.stack, host: 'invalid.host' }); // Simulating a server error
const Query = mockStack.ContentType(contentTypes.source).Query();

Query
.toJSON()
.findOne()
.then(function success() {
assert.fail("Expected 500 error but got a successful response.");
assert.end();
}, function error(err) {
assert.equal(err.http_code, 500, 'Should return HTTP status 500.');
assert.ok(err.http_message, 'Error message should be present.');
console.error("Error:", err.http_message);
assert.end();
});
});
5 changes: 4 additions & 1 deletion webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ module.exports = function(options) {
protectWebpackAssets: false,
cleanAfterEveryBuildPatterns: ['*.LICENSE.txt']
})
]
],
optimization: {
minimize: false, // Prevents code compression/minification
},
};
}
9 changes: 6 additions & 3 deletions webpack/webpack.nativescript.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';

const path = require('path');
const webpackMerge = require('webpack-merge');
const { merge } = require('webpack-merge');
var nodeExternals = require('webpack-node-externals');

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

module.exports = function(options) {
return webpackMerge(commonConfig(), {
return merge(commonConfig(), {
output: {
libraryTarget: "commonjs2",
path: path.join(__dirname, "../dist/nativescript"),
Expand Down Expand Up @@ -50,6 +50,9 @@ module.exports = function(options) {
}
],
}]
}
},
optimization: {
minimize: false, // Prevents code compression/minification
},
});
}
7 changes: 5 additions & 2 deletions webpack/webpack.node.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';
const path = require('path');
const webpackMerge = require('webpack-merge');
const { merge } = require('webpack-merge');
var nodeExternals = require('webpack-node-externals');

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

module.exports = function(options) {
return webpackMerge(commonConfig(), {
return merge(commonConfig(), {
output: {
libraryTarget: "commonjs2",
path: path.join(__dirname, "../dist/node"),
Expand Down Expand Up @@ -49,5 +49,8 @@ module.exports = function(options) {
}],
}]
},
optimization: {
minimize: false, // Prevents code compression/minification
},
});
}
Loading
Loading