|
1
|
|
|
|
|
2
|
|
|
module.exports = { |
|
3
|
|
|
buildAuthenticationHeader: function (inAuthenticationArray) { |
|
4
|
|
|
var aReturn; |
|
5
|
|
|
switch (inAuthenticationArray.type) { |
|
6
|
|
|
case 'Addin': |
|
7
|
|
|
aReturn = inAuthenticationArray.credentials_Addin; |
|
8
|
|
|
break; |
|
9
|
|
|
case 'SAML': |
|
10
|
|
|
aReturn = inAuthenticationArray.credentials_SAML; |
|
11
|
|
|
break; |
|
12
|
|
|
default: |
|
13
|
|
|
aReturn = false; |
|
14
|
|
|
break; |
|
15
|
|
|
} |
|
16
|
|
|
return aReturn; |
|
17
|
|
|
}, |
|
18
|
|
|
buildCurrentListAttributeValues: function (inObjectListsConfiguredAttributes, inCurrentList) { |
|
19
|
|
|
var crtListAttributes = []; |
|
20
|
|
|
Object.keys(inObjectListsConfiguredAttributes).map(function (itemList) { |
|
21
|
|
|
if (itemList.substring(0, 4) === 'Date') { |
|
22
|
|
|
if (inCurrentList[inObjectListsConfiguredAttributes[itemList]] === null) { |
|
23
|
|
|
crtListAttributes[itemList] = ''; |
|
24
|
|
|
} else { |
|
25
|
|
|
crtListAttributes[itemList] = inCurrentList[inObjectListsConfiguredAttributes[itemList]].replace('T', ' ').replace('Z', ''); |
|
26
|
|
|
} |
|
27
|
|
|
} else { |
|
28
|
|
|
crtListAttributes[itemList] = inCurrentList[inObjectListsConfiguredAttributes[itemList]]; |
|
29
|
|
|
} |
|
30
|
|
|
}); |
|
31
|
|
|
return crtListAttributes; |
|
32
|
|
|
}, |
|
33
|
|
|
buildCurrentItemValues: function (fieldAttributes, item) { |
|
34
|
|
|
var crtRecord = []; |
|
35
|
|
|
var counterF = 0; |
|
36
|
|
|
Object.keys(fieldAttributes).map(function (itemF) { |
|
37
|
|
|
switch (fieldAttributes[itemF]['Type']) { |
|
38
|
|
|
case 'DateTime': |
|
39
|
|
|
if (item[fieldAttributes[itemF]['Technical Name']] === null) { |
|
40
|
|
|
crtRecord[counterF] = ''; |
|
41
|
|
|
} else { |
|
42
|
|
|
crtRecord[counterF] = item[fieldAttributes[itemF]['Technical Name']].replace('T', ' ').replace('Z', ''); |
|
43
|
|
|
} |
|
44
|
|
|
break; |
|
45
|
|
|
case 'Lookup': |
|
46
|
|
|
case 'User': |
|
47
|
|
|
crtRecord[counterF] = item[fieldAttributes[itemF]['Technical Name'] + 'Id']; |
|
48
|
|
|
break; |
|
49
|
|
|
default: |
|
50
|
|
|
crtRecord[counterF] = item[fieldAttributes[itemF]['Technical Name']]; |
|
51
|
|
|
break; |
|
52
|
|
|
} |
|
53
|
|
|
counterF++; |
|
54
|
|
|
}); |
|
55
|
|
|
return crtRecord; |
|
56
|
|
|
}, |
|
57
|
|
|
buildRequestQuery: function (targetSharePointURL, arStandardLists, crtListName, queryType, inData) { |
|
58
|
|
|
var queryPrefix = ''; |
|
59
|
|
|
if (Object.keys(arStandardLists).indexOf(queryType) > -1) { |
|
60
|
|
|
queryPrefix = '_api/Web/' + arStandardLists[queryType]['WebAPItrunk'] |
|
61
|
|
|
+ '/' + arStandardLists[queryType]['WebAPIdeterminationFunction'] + '(\'' |
|
62
|
|
|
+ crtListName + '\')/' + arStandardLists[queryType]['WebAPIdeterminationElement']; |
|
63
|
|
|
} else { |
|
64
|
|
|
queryPrefix = '_api/Web/' + queryType; |
|
65
|
|
|
} |
|
66
|
|
|
var headerOptions = inData.headers; |
|
67
|
|
|
headerOptions['Accept'] = 'application/json;odata=verbose'; |
|
68
|
|
|
return { |
|
69
|
|
|
url: targetSharePointURL + queryPrefix, |
|
70
|
|
|
headers: headerOptions, |
|
71
|
|
|
json: true |
|
72
|
|
|
}; |
|
73
|
|
|
}, |
|
74
|
|
|
decideBlackListWhiteList: function (inDecisionValue, inEvaluatedValueForBlackList, inBlackListArray, inEvaluatedValueForWhiteList, inWhiteListArray, inValueToEvaluate) { |
|
75
|
|
|
var bolReturn = false; |
|
76
|
|
|
if ((inDecisionValue === inEvaluatedValueForBlackList) && (inBlackListArray.indexOf(inValueToEvaluate) === -1)) { |
|
77
|
|
|
bolReturn = true; |
|
78
|
|
|
} |
|
79
|
|
|
if ((inDecisionValue === inEvaluatedValueForWhiteList) && (inWhiteListArray.indexOf(inValueToEvaluate) > -1)) { |
|
80
|
|
|
bolReturn = true; |
|
81
|
|
|
} |
|
82
|
|
|
return bolReturn; |
|
83
|
|
|
}, |
|
84
|
|
|
internalQueryStructureArray: function (maxRecords) { |
|
85
|
|
|
return { |
|
86
|
|
|
'Fields': { |
|
87
|
|
|
'WebAPItrunk': 'Lists', |
|
88
|
|
|
'WebAPIdeterminationFunction': 'GetByTitle', |
|
89
|
|
|
'WebAPIdeterminationElement': 'Fields' |
|
90
|
|
|
}, |
|
91
|
|
|
'GroupMembers': { |
|
92
|
|
|
'WebAPItrunk': 'SiteGroups', |
|
93
|
|
|
'WebAPIdeterminationFunction': 'GetById', |
|
94
|
|
|
'WebAPIdeterminationElement': 'Users' |
|
95
|
|
|
}, |
|
96
|
|
|
'Items': { |
|
97
|
|
|
'WebAPItrunk': 'Lists', |
|
98
|
|
|
'WebAPIdeterminationFunction': 'GetByTitle', |
|
99
|
|
|
'WebAPIdeterminationElement': 'Items' + '?$top=' + maxRecords |
|
100
|
|
|
}, |
|
101
|
|
|
'Views': { |
|
102
|
|
|
'WebAPItrunk': 'Lists', |
|
103
|
|
|
'WebAPIdeterminationFunction': 'GetByTitle', |
|
104
|
|
|
'WebAPIdeterminationElement': 'Views' |
|
105
|
|
|
} |
|
106
|
|
|
}; |
|
107
|
|
|
} |
|
108
|
|
|
}; |
|
109
|
|
|
|