Skip to content

Commit 82ec4d6

Browse files
Added variants support.
1 parent 9511aa8 commit 82ec4d6

File tree

8 files changed

+471
-4
lines changed

8 files changed

+471
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Change log
2-
2+
### Version: 3.19.0
3+
#### Date: March-12-2024
4+
##### New Features:
5+
- Variants Feature support added
36
### Version: 3.19.0
47
#### Date: February-02-2024
58
##### New Features:

index.d.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,47 @@ export class Taxonomy extends Query {
300300
below(key: string, value: string, levels?: number): Query;
301301
equalAndBelow(key: string, value: string, levels?: number): Query;
302302
}
303+
304+
export class Variants extends Query {
305+
constructor();
306+
307+
entry_uid: string;
308+
content_type_uid: string;
309+
_query: object;
310+
provider: any;
311+
cachePolicy: number;
312+
queryCachePolicy: number;
313+
314+
only(field_uid: string): this;
315+
only(field_uids: string[]): this;
316+
only(reference_field_uid:string, field_uid: string): this;
317+
only(reference_field_uid:string, field_uids: string[]): this;
318+
319+
except(field_uid: string): this;
320+
except(field_uids: string[]): this;
321+
except(reference_field_uid:string, field_uid: string): this;
322+
except(reference_field_uid:string, field_uids: string[]): this;
323+
324+
setCacheProvider(provider: object): this;
325+
setCachePolicy(policy: number): this;
326+
includeReference(val: string[]): this;
327+
includeReference(...val: string[]): this;
328+
language(language_code: string): this;
329+
addQuery(key: string, value: string): this;
330+
includeEmbeddedItems(): this;
331+
includeFallback(): this;
332+
/**
333+
* @deprecated since version 3.3.0
334+
*/
335+
includeSchema(): this;
336+
includeReferenceContentTypeUID(): this;
337+
includeContentType(): this;
338+
/**
339+
* @deprecated since version 3.3.0
340+
*/
341+
includeOwner(): this;
342+
toJSON(): this;
343+
addParam(key: string, value: any): this;
344+
fetch(fetchOptions?: object): Promise<any>;
345+
}
346+

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "contentstack",
3-
"version": "3.19.0",
3+
"version": "3.20.0",
44
"description": "Contentstack Javascript SDK",
55
"homepage": "https://www.contentstack.com/",
66
"author": {

src/core/modules/entry.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as Utils from "../lib/utils";
2+
import Variants from "./variants";
23

34
/**
45
* @class
@@ -378,4 +379,20 @@ export default class Entry {
378379
if (this.fetchOptions.debug) this.fetchOptions.logHandler('error', "Kindly provide an entry uid. e.g. .Entry('asset_uid')");
379380
}
380381
}
382+
383+
/**
384+
* @method Variants
385+
* @memberOf Entry
386+
* @param {String} uid - uid of the variants entry
387+
* @description An initializer is responsible for creating Variants Entry object
388+
* @returns {Variants}
389+
* @instance
390+
*/
391+
Variants(uid) {
392+
let variant_entry = new Variants(uid);
393+
if (uid && typeof uid === "string") {
394+
variant_entry.variant_entry_uid = uid;
395+
}
396+
return Utils.merge(variant_entry, this);
397+
}
381398
}

src/core/modules/query.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as Utils from '../lib/utils.js';
22
import Entry from './entry';
3+
import Variants from './variants.js';
34

45
const _extend = {
56
compare: function(type) {

0 commit comments

Comments
 (0)