diff --git a/.gitignore b/.gitignore index 52bba02c..b16a4a66 100644 --- a/.gitignore +++ b/.gitignore @@ -67,4 +67,5 @@ tsconfig.json .next .dccache dist -jsdocs \ No newline at end of file +jsdocs +.early.coverage \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 4f1fbbc3..ede0c885 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,11 +1,30 @@ #!/usr/bin/env sh -# Pre-commit hook to run Snyk and Talisman scans, completing both before deciding to commit +# Pre-commit hook to run lint, Snyk and Talisman scans, completing all before deciding to commit # Function to check if a command exists command_exists() { command -v "$1" >/dev/null 2>&1 } +# Allow bypassing the hook with an environment variable +if [ "$SKIP_HOOK" = "1" ]; then + echo "Skipping lint, Snyk and Talisman scans (SKIP_HOOK=1)." + exit 0 +fi + +# Run ESLint check first +echo "Running ESLint check..." +npm run lint +lint_exit_code=$? + +if [ $lint_exit_code -ne 0 ]; then + echo "ESLint check failed. Please fix the linting issues and try again." + echo "You can run 'npm run format' to auto-fix most issues." + exit 1 +fi + +echo "ESLint check passed." + # Check if Snyk is installed if ! command_exists snyk; then echo "Error: Snyk is not installed. Please install it and try again." @@ -18,12 +37,6 @@ if ! command_exists talisman; then exit 1 fi -# Allow bypassing the hook with an environment variable -if [ "$SKIP_HOOK" = "1" ]; then - echo "Skipping Snyk and Talisman scans (SKIP_HOOK=1)." - exit 0 -fi - # Initialize variables to track scan results snyk_failed=false talisman_failed=false @@ -63,7 +76,7 @@ if [ "$snyk_failed" = true ] || [ "$talisman_failed" = true ]; then exit 1 fi -# If both scans pass, allow the commit -echo "All scans passed. Proceeding with commit.cd ." +# If all checks pass, allow the commit +echo "All checks passed (ESLint, Snyk, Talisman). Proceeding with commit." rm -f snyk_output.log talisman_output.log exit 0 \ No newline at end of file diff --git a/.talismanrc b/.talismanrc index 61cb65f1..df7a3fac 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,27 +1,6 @@ fileignoreconfig: -- filename: .github/workflows/secrets-scan.yml - ignore_detectors: - - filecontent -- filename: package-lock.json - checksum: 9d0340f9359927d477fe8ab4650642c068c592be63fb817651d866849e0dbbc2 -- filename: .husky/pre-commit - checksum: 5baabd7d2c391648163f9371f0e5e9484f8fb90fa2284cfc378732ec3192c193 + - filename: .husky/pre-commit + checksum: 52a664f536cf5d1be0bea19cb6031ca6e8107b45b6314fe7d47b7fad7d800632 + - filename: test/sanity-check/api/user-test.js + checksum: 6bb8251aad584e09f4d963a913bd0007e5f6e089357a44c3fb1529e3fda5509d version: "" -fileignoreconfig: -- filename: test/unit/globalField-test.js - checksum: 25185e3400a12e10a043dc47502d8f30b7e1c4f2b6b4d3b8b55cdc19850c48bf -version: "1.0" -fileignoreconfig: -- filename: lib/stack/index.js - checksum: 6aab5edf85efb17951418b4dc4402889cd24c8d786c671185074aeb4d50f0242 -- filename: test/sanity-check/api/stack-test.js - checksum: 198d5cf7ead33b079249dc3ecdee61a9c57453e93f1073ed0341400983e5aa53 -version: "1.0" -fileignoreconfig: -- filename: test/sanity-check/api/previewToken-test.js - checksum: 9a42e079b7c71f76932896a0d2390d86ac626678ab20d36821dcf962820a886c -- filename: lib/stack/deliveryToken/index.js - checksum: 51ae00f07f4cc75c1cd832b311c2e2482f04a8467a0139da6013ceb88fbdda2f -- filename: lib/stack/deliveryToken/previewToken/index.js - checksum: b506f33bffdd20dfc701f964370707f5d7b28a2c05c70665f0edb7b3c53c165b -version: "1.0" diff --git a/CHANGELOG.md b/CHANGELOG.md index 8abd625d..5cfd4f98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog +## [v1.22.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.22.0) (2025-07-07) + - Enhancement + - AWS-AU Region support added + - Fix + - Fixed branch header conflits ## [v1.21.7](https://github.com/contentstack/contentstack-management-javascript/tree/v1.21.7) (2025-06-30) - Fix - Fixed Request-URI Too Large error diff --git a/lib/contentstack.js b/lib/contentstack.js index 18ded7fd..02088318 100644 --- a/lib/contentstack.js +++ b/lib/contentstack.js @@ -10,6 +10,7 @@ import httpClient from './core/contentstackHTTPClient.js' const regionHostMap = { NA: 'api.contentstack.io', EU: 'eu-api.contentstack.com', + AU: 'au-api.contentstack.com', AZURE_NA: 'azure-na-api.contentstack.com', AZURE_EU: 'azure-eu-api.contentstack.com', GCP_NA: 'gcp-na-api.contentstack.com', diff --git a/lib/entity.js b/lib/entity.js index cf8ac93b..dc5742b7 100644 --- a/lib/entity.js +++ b/lib/entity.js @@ -313,7 +313,6 @@ export const move = (http, type, force = false, params = {}) => { try { let updateData = {} const json = cloneDeep(this) - delete json.parent_uid if (type) { updateData[type] = json } else { @@ -328,7 +327,7 @@ export const move = (http, type, force = false, params = {}) => { if (force === true) { headers.params.force = true } - const response = await http.put(`${this.urlPath}/move`, updateData, headers) + const response = await http.put(`${this.urlPath}/move`, param, headers) if (response.data) { return new this.constructor(http, parseData(response, this.stackHeaders, this.content_type_uid, this.taxonomy_uid, http)) } else { diff --git a/lib/stack/index.js b/lib/stack/index.js index c954e81c..f4a4984c 100644 --- a/lib/stack/index.js +++ b/lib/stack/index.js @@ -168,8 +168,8 @@ export function Stack (http, data) { this.globalField = (uidOrOptions = null, option = {}) => { let globalFieldUid = null let apiVersion = '3.0' - let branch = 'main' const stackHeaders = { ...this.stackHeaders } + let branch = stackHeaders.branch || http.defaults.headers.branch || 'main' if (typeof uidOrOptions === 'object' && uidOrOptions !== null) { option = uidOrOptions } else { diff --git a/package-lock.json b/package-lock.json index a1c14318..76926083 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/management", - "version": "1.21.7", + "version": "1.22.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/management", - "version": "1.21.7", + "version": "1.22.0", "license": "MIT", "dependencies": { "assert": "^2.1.0", diff --git a/package.json b/package.json index 376be90e..106a4501 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/management", - "version": "1.21.7", + "version": "1.22.0", "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", diff --git a/test/sanity-check/api/terms-test.js b/test/sanity-check/api/terms-test.js index 871f870e..771ed9a0 100644 --- a/test/sanity-check/api/terms-test.js +++ b/test/sanity-check/api/terms-test.js @@ -135,13 +135,14 @@ describe('Terms API Test', () => { }) it('should move the term to parent uid passed', done => { - makeTerms(taxonomy.uid, childTerm2.term.uid).fetch() + const term = { + parent_uid: 'term_test_child1', + order: 1 + } + makeTerms(taxonomy.uid, childTerm2.term.uid).move({ term, force: true }) .then(async (term) => { - term.parent_uid = null - const moveTerm = await term.move({ force: true }) - expect(moveTerm.parent_uid).to.be.equal(null) + expect(term.parent_uid).to.not.equal(null) done() - return moveTerm }) .catch(done) }) diff --git a/test/sanity-check/api/user-test.js b/test/sanity-check/api/user-test.js index 015307fa..8010834d 100644 --- a/test/sanity-check/api/user-test.js +++ b/test/sanity-check/api/user-test.js @@ -111,6 +111,13 @@ describe('Contentstack User Session api Test', () => { done() }) + it('should get host for AU region', done => { + const client = contentstack.client({ region: 'AU' }) + const baseUrl = client.axiosInstance.defaults.baseURL + expect(baseUrl).to.include('au-api.contentstack.com', 'region AU set correctly') + done() + }) + it('should get host for AZURE_NA region', done => { const client = contentstack.client({ region: 'AZURE_NA' }) const baseUrl = client.axiosInstance.defaults.baseURL diff --git a/test/unit/Util-test.js b/test/unit/Util-test.js index 0e125976..b7845fff 100644 --- a/test/unit/Util-test.js +++ b/test/unit/Util-test.js @@ -123,6 +123,7 @@ describe('Get User Agent', () => { expect(isHost('contentstack.io:2Sdrd')).to.be.equal(true, 'contentstack.io:2Sdrd should be host') expect(isHost('contentstack.io:wedsfa2')).to.be.equal(true, 'contentstack.io:wedsfa2 should be host') expect(isHost('eu-api.contentstack.com')).to.be.equal(true, 'eu-api.contentstack.com should be host') + expect(isHost('au-api.contentstack.com')).to.be.equal(true, 'au-api.contentstack.com should be host') expect(isHost('contentstack.io/path')).to.be.equal(false, 'contentstack.io/path should not host') done() })