Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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,541 changes: 1,392 additions & 1,149 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/management",
"version": "1.19.0",
"version": "1.19.1",
"description": "The Content Management API is used to manage the content of your Contentstack account",
"main": "./dist/node/contentstack-management.js",
"browser": "./dist/web/contentstack-management.js",
Expand Down Expand Up @@ -52,27 +52,27 @@
"author": "Contentstack",
"license": "MIT",
"dependencies": {
"axios": "^1.7.8",
"form-data": "^3.0.2",
"axios": "^1.7.9",
"form-data": "^4.0.1",
"lodash": "^4.17.21",
"qs": "^6.13.1"
"qs": "^6.14.0"
},
"keywords": [
"contentstack management api",
"contentstack",
"management api"
],
"devDependencies": {
"@babel/cli": "^7.25.9",
"@babel/cli": "^7.26.4",
"@babel/core": "^7.26.0",
"@babel/plugin-transform-runtime": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/register": "^7.25.9",
"@babel/runtime": "^7.26.0",
"@slack/bolt": "^3.22.0",
"@slack/bolt": "^4.2.0",
"@types/chai": "^4.3.20",
"@types/jest": "^28.1.8",
"@types/lodash": "^4.17.13",
"@types/lodash": "^4.17.14",
"@types/mocha": "^7.0.2",
"axios-mock-adapter": "^1.22.0",
"babel-loader": "^8.4.1",
Expand All @@ -83,7 +83,7 @@
"chai": "^4.5.0",
"clean-webpack-plugin": "^4.0.0",
"docdash": "^1.2.0",
"dotenv": "^8.6.0",
"dotenv": "^16.4.7",
"eslint": "^8.57.1",
"eslint-config-standard": "^13.0.1",
"eslint-plugin-import": "^2.31.0",
Expand All @@ -99,14 +99,14 @@
"nock": "^10.0.6",
"nyc": "^15.1.0",
"os-browserify": "^0.3.0",
"rimraf": "^2.7.1",
"rimraf": "^6.0.1",
"sinon": "^7.5.0",
"string-replace-loader": "^3.1.0",
"ts-jest": "^28.0.8",
"typescript": "^4.9.5",
"webpack": "^5.96.1",
"webpack-cli": "^4.10.0",
"webpack-merge": "4.2.2"
"webpack": "^5.97.1",
"webpack-cli": "^6.0.1",
"webpack-merge": "6.0.1"
},
"homepage": "https://www.contentstack.com"
}
74 changes: 74 additions & 0 deletions sanity-report-dev11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const dotenv = require("dotenv");
const fs = require("fs");

dotenv.config();

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

const mochawesomeJsonOutput = fs.readFileSync(
"./mochawesome-report/mochawesome.json",
"utf-8"
);
const mochawesomeReport = JSON.parse(mochawesomeJsonOutput);

const totalTests = mochawesomeReport.stats.tests;
const passedTests = mochawesomeReport.stats.passes;
const failedTests = mochawesomeReport.stats.failures;

let durationInSeconds = Math.floor(mochawesomeReport.stats.duration / 1000);
const durationInMinutes = Math.floor(durationInSeconds / 60);
durationInSeconds %= 60;

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/mochawesome-report/sanity-report.html`;

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

const slackMessage = {
text: `Dev11, CMA SDK Full Sanity
*Result:* ${resultMessage}. ${durationInMinutes}m ${durationInSeconds}s
*Failed Tests:* ${failedTests}
<${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);
3 changes: 2 additions & 1 deletion sanity-report.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Slack from '@slack/bolt'
const { App } = Slack
import dotenv from 'dotenv'
import fs from 'fs'

Expand Down Expand Up @@ -34,7 +35,7 @@ const slackMessage = `
• Total Duration: *${durationInMinutes}m ${durationInSeconds.toFixed(2)}s*
`

const app = new Slack.App({
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET
})
Expand Down
22 changes: 9 additions & 13 deletions test/sanity-check/api/branch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@ describe('Branch api Test', () => {
client = contentstackClient(user.authtoken)
})

it('should create a dev branch from stage branch', done => {
makeBranch()
.create({ branch: devBranch })
.then((response) => {
expect(response.uid).to.be.equal(devBranch.uid)
expect(response.source).to.be.equal(devBranch.source)
expect(response.alias).to.not.equal(undefined)
expect(response.delete).to.not.equal(undefined)
expect(response.fetch).to.not.equal(undefined)
done()
})
.catch(done)
})
it('should create a dev branch from stage branch',async () => {
const response = await makeBranch().create({ branch: devBranch });
expect(response.uid).to.be.equal(devBranch.uid);
expect(response.source).to.be.equal(devBranch.source);
expect(response.alias).to.not.equal(undefined);
expect(response.delete).to.not.equal(undefined);
expect(response.fetch).to.not.equal(undefined);
await new Promise(resolve => setTimeout(resolve, 15000));
});

it('should return main branch when query is called', done => {
makeBranch()
Expand Down
2 changes: 1 addition & 1 deletion test/sanity-check/api/taxonomy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('taxonomy api Test', () => {
.catch(done)
})

it('should fetch taxonomy of the uid passe', done => {
it('should fetch taxonomy of the uid passed', done => {
makeTaxonomy(taxonomyUID)
.fetch()
.then((taxonomyResponse) => {
Expand Down
57 changes: 22 additions & 35 deletions test/sanity-check/api/terms-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,22 @@ describe('Terms API Test', () => {
await client.stack({ api_key: process.env.API_KEY }).taxonomy().create({ taxonomy })
}, 10000)

it('should create term', done => {
makeTerms(taxonomy.uid).create(term)
.then((response) => {
expect(response.uid).to.be.equal(term.term.uid)
done()
})
.catch(done)
it('should create term', async () => {
const response = await makeTerms(taxonomy.uid).create(term)
expect(response.uid).to.be.equal(term.term.uid)
await new Promise(resolve => setTimeout(resolve, 15000));
})

it('should create child term 1', done => {
makeTerms(taxonomy.uid).create(childTerm1)
.then((response) => {
expect(response.uid).to.be.equal(childTerm1.term.uid)
done()
})
.catch(done)
it('should create child term 1', async () => {
const response = await makeTerms(taxonomy.uid).create(childTerm1)
expect(response.uid).to.be.equal(childTerm1.term.uid)
await new Promise(resolve => setTimeout(resolve, 15000));
})

it('should create child term 2', done => {
makeTerms(taxonomy.uid).create(childTerm2)
.then((response) => {
expect(response.uid).to.be.equal(childTerm2.term.uid)
done()
})
.catch(done)
it('should create child term 2', async () => {
const response = await makeTerms(taxonomy.uid).create(childTerm2)
expect(response.uid).to.be.equal(childTerm2.term.uid)
await new Promise(resolve => setTimeout(resolve, 15000));
})

it('should query and get all terms', done => {
Expand Down Expand Up @@ -180,20 +171,16 @@ describe('Branch creation api Test', () => {
client = contentstackClient(user.authtoken)
})

it('should create staging branch', done => {
makeBranch()
.create({ branch: stageBranch })
.then((response) => {
expect(response.uid).to.be.equal(stageBranch.uid)
expect(response.urlPath).to.be.equal(`/stacks/branches/${stageBranch.uid}`)
expect(response.source).to.be.equal(stageBranch.source)
expect(response.alias).to.not.equal(undefined)
expect(response.delete).to.not.equal(undefined)
expect(response.fetch).to.not.equal(undefined)
done()
})
.catch(done)
})
it('should create staging branch', async () => {
const response = await makeBranch().create({ branch: stageBranch });
expect(response.uid).to.be.equal(stageBranch.uid);
expect(response.urlPath).to.be.equal(`/stacks/branches/${stageBranch.uid}`);
expect(response.source).to.be.equal(stageBranch.source);
expect(response.alias).to.not.equal(undefined);
expect(response.fetch).to.not.equal(undefined);
expect(response.delete).to.not.equal(undefined);
await new Promise(resolve => setTimeout(resolve, 15000));
});
})

function makeBranch (uid = null) {
Expand Down
1 change: 0 additions & 1 deletion test/typescript/variants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from "chai"
import path from "path"
import { Stack } from "../../types/stack";
import { Variant, Variants } from "../../types/stack/VariantGroup/variants";
import { variantEntry, variantEntry2 } from "./mock/variants";
var tokenUID = ''
export function createVariant(stack: Stack) {
Expand Down
4 changes: 2 additions & 2 deletions types/stack/VariantGroup/variants/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AnyProperty, SystemFields } from "../../../utility/fields";
import { Queryable, SystemFunction } from "../../../utility/operations";

export interface Variant extends SystemFields, SystemFunction<Variants> {
export interface VariantGroupVariant extends SystemFields, SystemFunction<VariantGroupVariants> {

}

export interface Variants extends Queryable<Variants, {variant: VariantData}> {
export interface VariantGroupVariants extends Queryable<VariantGroupVariants, {variant: VariantData}> {

}

Expand Down
6 changes: 3 additions & 3 deletions types/stack/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Taxonomy, Taxonomies } from "./taxonomy";
import { ManagementToken, ManagementTokens } from "./managementToken";
import { Variant, Variants } from "./variants";
import { VariantGroup, VariantGroups } from "./VariantGroup";
import { Variant, Variants } from "./VariantGroup/variants";
import { VariantGroupVariant, VariantGroupVariants } from "./VariantGroup/variants";

export interface StackConfig {
api_key:string
Expand Down Expand Up @@ -110,6 +110,6 @@ export interface Stack extends SystemFields {
variantGroup(): VariantGroups
variantGroup(uid: string): VariantGroup

variant(): Variants
variant(uid: string): Variant
variant(): VariantGroupVariants
variant(uid: string): VariantGroupVariant
}
4 changes: 2 additions & 2 deletions webpack/webpack.nativescript.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const path = require('path')
const webpackMerge = require('webpack-merge')
const { merge } = require('webpack-merge')

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
4 changes: 2 additions & 2 deletions webpack/webpack.node.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const path = require('path')
const webpackMerge = require('webpack-merge')
const { merge } = require('webpack-merge')
const commonConfig = require('./webpack.common')

module.exports = function (options) {
return webpackMerge(commonConfig(), {
return merge(commonConfig(), {
output: {
libraryTarget: 'commonjs2',
path: path.join(__dirname, '../dist/node'),
Expand Down
4 changes: 2 additions & 2 deletions webpack/webpack.react-native.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const path = require('path')
const webpackMerge = require('webpack-merge')
const { merge } = require('webpack-merge')

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

module.exports = function (options) {
return webpackMerge(commonConfig(), {
return merge(commonConfig(), {
output: {
libraryTarget: 'commonjs2',
path: path.join(__dirname, '../dist/react-native'),
Expand Down
4 changes: 2 additions & 2 deletions webpack/webpack.web.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')

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

module.exports = function (options) {
delete commonConfig.externals;
return webpackMerge(commonConfig, {
return merge(commonConfig, {
output: {
libraryTarget: 'umd',
path: path.join(__dirname, '../dist/web'),
Expand Down
Loading