/
getBasePropertyMap.ts
75 lines (74 loc) · 1.82 KB
/
getBasePropertyMap.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { EntityResourceMap } from "../types";
import { IPropertyMap } from "./PropertyMapper";
/**
* Returns an Array of IPropertyMap objects
* that define the standard projection of properties from a IModel an entity interface
* @returns
*/
export function getBasePropertyMap(): IPropertyMap[] {
const itemProps = [
"access",
"created",
"culture",
"description",
"extent",
"id",
"itemControl",
"modified",
"owner",
"tags",
"categories",
"type",
"typeKeywords",
"thumbnail",
"url",
"orgId",
// NOTE: Read-only props like canRecycle are handled in the PropertyMapper itself
];
const dataProps = ["display", "geometry", "view", "associations"];
const resourceProps = Object.keys(EntityResourceMap);
const map: IPropertyMap[] = [];
itemProps.forEach((entry) => {
map.push({ entityKey: entry, storeKey: `item.${entry}` });
});
dataProps.forEach((entry) => {
map.push({ entityKey: entry, storeKey: `data.${entry}` });
});
resourceProps.forEach((entry) => {
map.push({ entityKey: entry, storeKey: `resources.${entry}` });
});
// Deeper mappings
map.push({
entityKey: "slug",
storeKey: "item.properties.slug",
});
map.push({
entityKey: "summary",
storeKey: "item.snippet",
});
map.push({
entityKey: "schemaVersion",
storeKey: "item.properties.schemaVersion",
});
map.push({
entityKey: "orgUrlKey",
storeKey: "item.properties.orgUrlKey",
});
map.push({
entityKey: "name",
storeKey: "item.title",
});
map.push({
entityKey: "boundary",
storeKey: "item.properties.boundary",
});
map.push({
entityKey: "discussionSettings",
storeKey: "entitySettings.settings.discussions",
});
map.push({
entityKey: "entitySettingsId",
storeKey: "entitySettings.id",
});
return map;
}