22.1.1 • Published 10 months ago
@constellation4sitecore/mapper v22.1.1
Constellation Mapper
Installation
npm install @constellation4sitecore/mapper --save
Usage
Map To New
This function is really useful quen you perform a Graphql query for example:
query {
item(path: "my-path", language: "en") {
fields {
name
jsonValue
}
}
}
The structure of the current result is kind of array of fields { name, jsonvalue}. Within mapToNew
you can cast to model object instead of looping an array of fields.
import { mapToNew } from '@constellation4sitecore/mapper';
export type MyExampleType = {
logo: ImageField;
primaryNavigation: Field<string>;
copyright: Field<string>;
socialIntroText: Field<string>;
cookieSettings: Field<string>;
};
var fieldsProps = mapToNew<MyExampleType>(results);
Cast Item
In some scenarios you have the item reference which has a fields property but you need to type the fields into a type model
import { castItem } from '@constellation4sitecore/mapper';
// Given item as
// item {
// copyright: {
// value: "Text"
// }
//}
export type MyExampleType = {
copyright: Field<string>;
};
var fieldsProps = castItem<MyExampleType>(item);
22.1.2-beta.1
10 months ago
22.1.2-beta.2
10 months ago
22.1.2-beta.3
10 months ago
22.1.2-beta.4
10 months ago
22.0.2-beta.13
1 year ago
22.0.2-beta.12
1 year ago
22.0.2-beta.15
1 year ago
22.0.2-beta.2
1 year ago
22.0.2-beta.14
1 year ago
22.0.2-beta.1
1 year ago
22.0.2-beta.17
1 year ago
22.0.2-beta.4
1 year ago
22.0.2-beta.16
1 year ago
22.0.2-beta.3
1 year ago
22.0.2-beta.19
12 months ago
22.0.2-beta.6
1 year ago
22.0.2-beta.18
12 months ago
22.0.2-beta.5
1 year ago
22.0.2-beta.11
1 year ago
22.0.2-beta.10
1 year ago
22.1.1
10 months ago
22.0.1
1 year ago
22.1.0-beta.1
10 months ago
22.0.2-beta.20
12 months ago
22.0.2-beta.21
12 months ago
22.0.2-beta.8
1 year ago
22.0.2-beta.7
1 year ago
22.0.2-beta.9
1 year ago
22.0.1-beta.1
1 year ago
1.0.5
1 year ago
1.0.4-beta.21
1 year ago
1.0.4-beta.20
1 year ago