Skip to content

Feat/cs 44220 variants support #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Change log

### Version: 3.19.0
#### Date: March-12-2024
##### New Features:
- Variants Feature support added
### Version: 3.19.0
#### Date: February-02-2024
##### New Features:
Expand Down
44 changes: 44 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,47 @@ export class Taxonomy extends Query {
below(key: string, value: string, levels?: number): Query;
equalAndBelow(key: string, value: string, levels?: number): Query;
}

export class Variants extends Query {
constructor();

entry_uid: string;
content_type_uid: string;
_query: object;
provider: any;
cachePolicy: number;
queryCachePolicy: number;

only(field_uid: string): this;
only(field_uids: string[]): this;
only(reference_field_uid:string, field_uid: string): this;
only(reference_field_uid:string, field_uids: string[]): this;

except(field_uid: string): this;
except(field_uids: string[]): this;
except(reference_field_uid:string, field_uid: string): this;
except(reference_field_uid:string, field_uids: string[]): this;

setCacheProvider(provider: object): this;
setCachePolicy(policy: number): this;
includeReference(val: string[]): this;
includeReference(...val: string[]): this;
language(language_code: string): this;
addQuery(key: string, value: string): this;
includeEmbeddedItems(): this;
includeFallback(): this;
/**
* @deprecated since version 3.3.0
*/
includeSchema(): this;
includeReferenceContentTypeUID(): this;
includeContentType(): this;
/**
* @deprecated since version 3.3.0
*/
includeOwner(): this;
toJSON(): this;
addParam(key: string, value: any): this;
fetch(fetchOptions?: object): Promise<any>;
}

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contentstack",
"version": "3.19.0",
"version": "3.20.0",
"description": "Contentstack Javascript SDK",
"homepage": "https://www.contentstack.com/",
"author": {
Expand Down
17 changes: 17 additions & 0 deletions src/core/modules/entry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Utils from "../lib/utils";
import Variants from "./variants";

/**
* @class
Expand Down Expand Up @@ -378,4 +379,20 @@ export default class Entry {
if (this.fetchOptions.debug) this.fetchOptions.logHandler('error', "Kindly provide an entry uid. e.g. .Entry('asset_uid')");
}
}

/**
* @method Variants
* @memberOf Entry
* @param {String} uid - uid of the variants entry
* @description An initializer is responsible for creating Variants Entry object
* @returns {Variants}
* @instance
*/
Variants(uid) {
let variant_entry = new Variants(uid);
if (uid && typeof uid === "string") {
variant_entry.variant_entry_uid = uid;
}
return Utils.merge(variant_entry, this);
}
}
1 change: 1 addition & 0 deletions src/core/modules/query.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as Utils from '../lib/utils.js';
import Entry from './entry';
import Variants from './variants.js';

const _extend = {
compare: function(type) {
Expand Down
Loading