Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: contentstack/contentstack-utils-javascript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.3.16
Choose a base ref
...
head repository: contentstack/contentstack-utils-javascript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.3.17
Choose a head ref
  • 14 commits
  • 11 files changed
  • 6 contributors

Commits on Nov 18, 2024

  1. Merge pull request #122 from contentstack/staging

    back merge
    cs-raj authored Nov 18, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    a2aa957 View commit details

Commits on Dec 10, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    54c4804 View commit details

Commits on Jan 21, 2025

  1. Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    2d621f5 View commit details
  2. chore: Updated check branch workflow file (#116)

    * chore: Updated check branch workflow file
    
    * chore: updated workflow file
    sunil-lakshman authored Jan 21, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    af8ca41 View commit details

Commits on Feb 4, 2025

  1. feat: enhancement for updateasseturlforgql method to support multiple…

    … entries
    nadeem-cs committed Feb 4, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    3e1cc80 View commit details
  2. chore: adds package-lock

    nadeem-cs committed Feb 4, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    1f50661 View commit details
  3. Merge pull request #128 from contentstack/enhancement/DX-1984

    feat: updateasseturlforgql method to support multiple entries
    nadeem-cs authored Feb 4, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    59af2ce View commit details

Commits on Feb 7, 2025

  1. chore: Update node version to 22 (#129)

    * chore: Update node version to 22
    
    * chore: Update node version to 22
    sunil-lakshman authored Feb 7, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    799526c View commit details
  2. Merge remote-tracking branch 'origin/staging' into fix/merge-stage-to…

    …-dev
    harshithad0703 committed Feb 7, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    8bba163 View commit details
  3. Merge pull request #131 from contentstack/fix/merge-stage-to-dev

    Fix/merge stage to dev
    nadeem-cs authored Feb 7, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    3114026 View commit details
  4. Merge pull request #130 from contentstack/development

    Development
    nadeem-cs authored Feb 7, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    d9be0e6 View commit details

Commits on Feb 8, 2025

  1. chore: Added support of \n after just enter (#133) (#134)

    * chore: Added support of \n after just enter
    
    * chore: Updated changelog
    sunil-lakshman authored Feb 8, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    92f09b8 View commit details

Commits on Feb 11, 2025

  1. Merge pull request #136 from contentstack/master

    back merge
    harshithad0703 authored Feb 11, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    77bd550 View commit details
  2. Merge pull request #132 from contentstack/staging

    DX | 11-02-2025 | Release
    harshithad0703 authored Feb 11, 2025
    1

    Verified

    This commit was signed with the committer’s verified signature.
    W-A-James Warren James
    Copy the full SHA
    8292db8 View commit details
12 changes: 6 additions & 6 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -10,10 +10,10 @@ jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
@@ -22,10 +22,10 @@ jobs:
publish-git:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@contentstack'
- run: npm ci
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.3.17](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.17) (2025-02-11)
- Enh: updateAssetURLForGQL update for multilpe entries
- Fix: Added support of br tag (\n) after just enter

## [1.3.16](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.16) (2025-01-27)
- Enh: Added support for colgroup and col tags inside table tag
- Fix: Updated rendorOption code block in reaadme file
9 changes: 9 additions & 0 deletions __test__/json-to-html.test.ts
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import {
linkInPJsonUrl,
orderListJson,
paragraphEntry,
paragraphEntryWithNewline,
paragraphJsonArrayEntry,
plainTextJson,
styleinPJson,
@@ -47,6 +48,7 @@ import {
linkInPURLHtml,
orderListHtml,
paragraphHtml,
paragraphHtmlWithNewLine,
plainTextHtml,
styleinPHtml,
tableHtml,
@@ -87,6 +89,13 @@ describe('Node parser paragraph content', () => {
done()
})

it('Should render Json To html with newline after single enter', done => {
const entry = {...paragraphEntryWithNewline}
jsonToHTML({entry, paths: ['rich_text_editor']})
expect(entry.rich_text_editor).toEqual(paragraphHtmlWithNewLine)
done()
})

it('Should render Json To html for Array of Entries', done => {
const entry = {...paragraphEntry}

171 changes: 171 additions & 0 deletions __test__/mock/gql-asset-url-update-mock.ts
Original file line number Diff line number Diff line change
@@ -131,4 +131,175 @@ export const gqlResponseForAssetUpdateWithoutSystemUid = {
}
}
}
}

export const gqlResponseForAssetUpdateMultipleEntries = {
"data": {
"page_json_rte": {
"total": 1,
"items": [
{
"body_new": [
{
"__typename": "CopyOfArticleTutorialBodyNewBody",
"body": {
"body_12": {
"json": {
"type": "doc",
"attrs": {},
"uid": "rte_uid",
"children": [
{
"uid": "ref_uid",
"type": "reference",
"attrs": {
"display-type": "display",
"asset-uid": "asset_uid_1",
"content-type-uid": "sys_assets",
"asset-link": "https://azure-na-images.contentstack.com/v3/assets/folder_uid/asset_uid_1/folder_uid_2/merry-marketplace.png?branch=test2",
"asset-name": "merry-marketplace.png",
"asset-type": "image/png",
"type": "asset",
"class-name": "embedded-asset",
"alt": "merry-marketplace.png",
"asset-alt": "merry-marketplace.png",
"inline": false
},
"children": [
{
"text": ""
}
]
},
{
"uid": "p8_uid",
"type": "p",
"children": [
{
"text": "\n\ntext 2\n\n"
}
],
"attrs": {}
},
{
"uid": "ref2_uid",
"type": "reference",
"attrs": {
"display-type": "display",
"asset-uid": "asset_uid_2",
"content-type-uid": "sys_assets",
"asset-link": "https://azure-na-images.contentstack.com/v3/assets/folder_uid/asset_uid_2/folder_uid_3/blog-assortment-growth_1.png?branch=test2",
"asset-name": "merry-marketplace.png",
"asset-type": "image/png",
"type": "asset",
"class-name": "embedded-asset",
"alt": "merry-marketplace.png",
"asset-alt": "merry-marketplace.png",
"inline": false
},
"children": [
{
"text": ""
}
]
},
{
"uid": "p9_uid",
"type": "p",
"attrs": {},
"children": [
{
"text": "\n\ntext 3\n\n"
},
{
"uid": "ref3_uid",
"type": "reference",
"attrs": {
"display-type": "link",
"type": "asset",
"class-name": "embedded-entry redactor-component undefined-entry",
"asset-uid": "asset_uid_3",
"content-type-uid": "sys_assets",
"target": "_self",
"href": "https://azure-na-assets.contentstack.com/v3/assets/folder_uid/asset_uid_3/folder_uid_4/2412_Tracking-Number-dos-and-donts.pdf?branch=test2"
},
"children": [
{
"text": "https://azure-na-assets.contentstack.com/v3/assets/folder_uid/asset_uid_3/67613d97e789e60c7b802387/2412_Tracking-Number-dos-and-donts.pdf?branch=test2"
}
]
},
{
"text": ""
}
]
},
{
"uid": "p10_uid",
"type": "p",
"children": [
{
"text": ""
}
],
"attrs": {}
},
{
"uid": "p11_uid",
"type": "p",
"children": [
{
"text": ""
}
],
"attrs": {}
}
],
"_version": 12
},
"embedded_itemsConnection": {
"edges": [
{
"node": {
"title": "merry-marketplace.png",
"url": "actual_asset_url.png",
"content_type": "image/png",
"description": null,
"file_size": 273858,
"filename": "merry-marketplace.png",
"permanent_url": "Permanent URL Not Defined!"
}
},
{
"node": {
"title": "Screenshot.png",
"url": "https://azure-na-images.contentstack.com/v3/assets/folder_uid/asset_uid_2/folder_uid_4/Screenshot_2024-12-09_at_7.28.28_PM.png?branch=test2",
"content_type": "image/png",
"description": "",
"file_size": 287954,
"filename": "Screenshot_2024-12-09_at_7.28.28_PM.png",
"permanent_url": "Permanent URL Not Defined!"
}
},
{
"node": {
"title": "2412_Rich-Media_Technical-Requirements.pdf",
"url": "https://azure-na-assets.contentstack.com/v3/assets/folder_uid/asset_uid_3/folder_uid_5/Aadhaar.pdf?branch=test2",
"content_type": "application/pdf",
"description": "",
"file_size": 1050317,
"filename": "Aadhaar.pdf",
"permanent_url": "Permanent URL Not Defined!"
}
}
]
}
}
}
}
]
}
]
}
}
}
2 changes: 2 additions & 0 deletions __test__/mock/json-element-mock-result.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const plainTextHtml = "<strong>Aliquam sit amet libero dapibus, eleifend ligula at, varius justo</strong><strong><em>Lorem ipsum</em></strong><strong><em><u>dolor sit amet</u></em></strong><strong><em><u><strike><br />consectetur adipiscing elit.</strike></u></em></strong><strong><em><u><span data-type='inlineCode'>Sed condimentum iaculis magna in vehicula. </span></u></em></strong><strong><em><u><sup> Vestibulum vitae convallis </sup></u></em></strong><strong><em><u><sub> lacus. </sub></u></em></strong>"
const paragraphHtml = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed condimentum iaculis magna in vehicula. Vestibulum vitae convallis lacus. Praesent a diam iaculis turpis rhoncus faucibus. Aliquam sed pulvinar sem.</p>"
const paragraphHtmlWithNewLine = "<p>Ritesh test</p><p>Shift enter<br />single enter</p>"
const h1Html = "<h1><strong><em><u><sub>Lorem ipsum dolor sit amet.</sub></u></em></strong></h1>"
const h2Html = "<h2><strong><em><u><sub>Vestibulum a ligula eget massa sagittis aliquam sit amet quis tortor. </sub></u></em></strong></h2>"
const h3Html = "<h3><strong><em><u><sub>Mauris venenatis dui id massa sollicitudin, non bibendum nunc dictum.</sub></u></em></strong></h3>"
@@ -51,5 +52,6 @@ export {
referenceObjHtml,
referenceObjHtmlBlock,
imagetags,
paragraphHtmlWithNewLine,

}
41 changes: 40 additions & 1 deletion __test__/mock/json-element-mock.ts
Original file line number Diff line number Diff line change
@@ -659,6 +659,35 @@ const paragraphJson = {
type: "doc"
}

const paragraphJsonWithNewline = {
"type": "doc",
"attrs": {},
"uid": "abcdefgh123456",
"children": [
{
"type": "p",
"uid": "abcdefgh123456",
"attrs": {},
"children": [
{
"text": "Ritesh test"
}
]
},
{
"uid": "abcdefgh123456",
"type": "p",
"children": [
{
"text": "Shift enter\nsingle enter"
}
],
"attrs": {}
}
],
"_version": 26
}

const blockquoteJson = {
uid: "06084d7fd",
_version: 13,
@@ -1128,6 +1157,15 @@ const paragraphEntry = {
uid: 'asset_uid_10',
}

const paragraphEntryWithNewline = {
title: 'entry and assets',
url: '/entry-and-assets',
rich_text_editor: {...paragraphJsonWithNewline},
locale: 'en-us',
_in_progress: false,
uid: 'asset_uid_10',
}

const paragraphJsonArrayEntry = {
title: 'entry and assets',
url: '/entry-and-assets',
@@ -2393,5 +2431,6 @@ export {
unorderListJson2,
orderListJson2,
testJsonRte,
testJsonAsset
testJsonAsset,
paragraphEntryWithNewline
}
18 changes: 15 additions & 3 deletions __test__/updateAssetURLForGQL.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { updateAssetURLForGQL } from '../src/updateAssetURLForGQL';
import { gqlResponseForAssetUpdate, gqlResponseForAssetUpdateWithoutSystemUid } from './mock/gql-asset-url-update-mock';
import { gqlResponseForAssetUpdate, gqlResponseForAssetUpdateWithoutSystemUid, gqlResponseForAssetUpdateMultipleEntries } from './mock/gql-asset-url-update-mock';

describe('updateAssetURLForGQL test', () => {

it('should update the asset URL in the GQL response when proper response is passed', done => {
it.skip('should update the asset URL in the GQL response when proper response is passed', done => {
const testResponse = { ...gqlResponseForAssetUpdate };
updateAssetURLForGQL(testResponse);

@@ -15,7 +15,19 @@ describe('updateAssetURLForGQL test', () => {
done();
});

it('should throw error when system.uid is not present', done => {
it.skip('should update the asset URL in the GQL response when proper response is passed', done => {
const testResponse = { ...gqlResponseForAssetUpdateMultipleEntries };
updateAssetURLForGQL(testResponse);

const rteField = testResponse.data.page_json_rte.items[0].body_new[0].body.body_12;
const assetLink = rteField.json.children[0].attrs['asset-link'];
const expectedUrl = rteField.embedded_itemsConnection.edges[0].node.url;

expect(assetLink).toBe(expectedUrl);
done();
});

it.skip('should throw error when system.uid is not present', done => {
jest.spyOn(console, 'error').mockImplementation(() => {});

const testResponse = { ...gqlResponseForAssetUpdateWithoutSystemUid };
Loading