Skip to content

Commit

Permalink
Merge pull request #48 from contentstack/embedded_objects
Browse files Browse the repository at this point in the history
Embedded Items Feature support added
  • Loading branch information
uttamukkoji authored Apr 6, 2021
2 parents df89b61 + aaa8361 commit 63244fe
Show file tree
Hide file tree
Showing 12 changed files with 2,317 additions and 2,295 deletions.
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ examples/
mocktest.json
webpack
typescript-html-report
coverage
webpack
jest.config.js
coverage
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

### Version: 3.13.0
#### Date:

##### Update API:
- [Query]: Added support for method includeEmbeddedItems
- [Entry]: Added support for method includeEmbeddedItems

### Version: 3.12.2
#### Date: Feb-19-2021

Expand Down
153 changes: 148 additions & 5 deletions dist/nativescript/contentstack.js

Large diffs are not rendered by default.

153 changes: 148 additions & 5 deletions dist/react-native/contentstack.js

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions dist/web/contentstack.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/node/contentstack-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ContentstackDemo {
//console.log("datattatata", Contentstack.Region.EUROPE)

this.Stack = Contentstack.Stack(...config);
console.log(Contentstack.Utils.render());
}


Expand Down
13 changes: 12 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
// Type definitions for contentstack 3.12.2
// Project: https://www.contentstack.com/
// Definitions by: Contentstack <https://github.com/contentstack>
import { EntryEmbedable, Option, RenderOption } from '@contentstack/utils'

// Utils
export class Utils {
static render(option: {
entry: EntryEmbedable| EntryEmbedable[],
renderOption?: RenderOption,
paths?: string[]
}): void;
static renderContent(content: (string | string[]), option: Option): (string| string[]);
}

//Enum for Contentstack Region
export enum Region {
Expand Down Expand Up @@ -137,8 +148,8 @@ export class Entry {
includeReference(...val: string[]): this;
language(language_code: string): this;
addQuery(key: string, value: string): this;
includeEmbeddedItems(): this;
includeFallback(): this;

/**
* @deprecated since verion 3.3.0
*/
Expand Down
4,207 changes: 1,935 additions & 2,272 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contentstack",
"version": "3.12.2",
"version": "3.13.0",
"description": "Contentstack Javascript SDK",
"homepage": "https://www.contentstack.com/",
"author": {
Expand All @@ -10,7 +10,7 @@
"main": "dist/node/contentstack.js",
"browser": "dist/web/contentstack.js",
"types": "./index.d.ts",
"_id": "contentstack@3.12.2",
"_id": "contentstack@3.13.0",
"scripts": {
"test": "npm run test:e2e && npm run test:typescript",
"test:e2e": "istanbul cover tape test/index.js | tap-html --out ./tap-html.html",
Expand All @@ -20,8 +20,9 @@
"buildweb": "webpack -p --config webpack/webpack.web.js",
"buildreactnative": "webpack --config webpack/webpack.react-native.js",
"buildnativescript": "webpack --config webpack/webpack.nativescript.js",
"buildall": "NODE_ENV=production&&npm run buildnode&npm run buildweb&npm run buildreactnative&npm run buildnativescript",
"generate-docs": "node_modules/.bin/jsdoc --configure docs-config.json --verbose"
"build": "NODE_ENV=production && npm run buildnode && npm run buildweb && npm run buildreactnative && npm run buildnativescript",
"generate-docs": "node_modules/.bin/jsdoc --configure docs-config.json --verbose",
"prepare": "npm run build"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -51,14 +52,14 @@
],
"dist": {
"shasum": "a328ed07240476a26b31a23261355dc929e1da63",
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.12.2.tgz"
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.13.0.tgz"
},
"license": "MIT",
"directories": {},
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.12.2.tgz",
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.13.0.tgz",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/contentstack-3.12.2.tgz_1477830884275_0.9869455888401717"
"tmp": "tmp/contentstack-3.13.0.tgz_1477830884275_0.9869455888401717"
},
"devDependencies": {
"@types/jest": "^26.0.13",
Expand Down Expand Up @@ -95,6 +96,7 @@
"webpack-merge": "4.1.0"
},
"dependencies": {
"@contentstack/utils": "1.0.0",
"es6-promise": "4.1.1",
"localStorage": "1.0.3",
"node-fetch": "^2.6.1"
Expand Down
22 changes: 21 additions & 1 deletion src/core/contentstack.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Stack from "./stack";
import CacheProvider from './cache-provider/index';
import ContentstackRegion from "./contentstackregion";

import {render , renderContent} from '@contentstack/utils';

/**
* @class
Expand All @@ -25,6 +25,26 @@ class Contentstack {
*/
this.CachePolicy = CacheProvider.policies;
this.Region = ContentstackRegion;

this.Utils = {
/**
* @memberof Contentstack
* @description Renders embedded objects in Rich text from Entry or Multiple Entry Object.
*
* @param {EntryEmbedable| EntryEmbedable[]} entry - Objects that contains RTE with embedded objects
* @param {string[]} keyPaths - Key paths for RTE contents in Entry object
* @param {RenderOption?} renderOption - Optional render options to render content
*/
render,
/**
* @memberof Contentstack
* @description Renders embedded objects in Rich text from String or String of array.
* @param {string | string[]} content - RTE content to render
* @param {EntryEmbedable} options.entry - Entry object containing embedded objects
* @param {RenderOption?} options.renderOption - Optional render options to render content
*/
renderContent
}
}
/**
Expand Down
5 changes: 4 additions & 1 deletion src/core/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Request from './request';
import Result from '../modules/result';
import config from '../../../config';
/**
* @method addSpread
* @description method to add the spread.
Expand Down Expand Up @@ -237,7 +238,9 @@ export function sendRequest(queryObject, options) {
let tojson = (typeof self.tojson !== 'undefined') ? self.tojson : false;
let isSingle = (self.entry_uid || self.singleEntry || self.asset_uid) ? true : false;
let hashQuery = getHash(parseQueryFromParams(self, isSingle, tojson));

if (queryObject.requestParams.url.includes(config.urls.sync)) {
cachePolicy = -1;
}
/**
for new api v3
*/
Expand Down
13 changes: 13 additions & 0 deletions src/core/modules/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ export default class Entry {
}
}

/**
* @method includeEmbeddedItems
* @memberOf Entry
* @description Include Embedded Objects (Entries and Assets) along with entry/entries details.
* @example Stack.ContentType("contentType_uid").Entry("entry_uid").includeEmbeddedObjects().fetch()
* @returns {Entry}
* @instance
*/
includeEmbeddedItems() {
this._query['include_embedded_items'] = ["BASE"];
return this;
}

/**
* @method includeSchema
* @memberOf Entry
Expand Down

0 comments on commit 63244fe

Please sign in to comment.