-
Notifications
You must be signed in to change notification settings - Fork 0
/
objectUpdaters.js
136 lines (136 loc) · 6.79 KB
/
objectUpdaters.js
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable import/no-named-as-default-member */
import { amiBillingReadyStatuses, anodeTypes, connectionStates, costDetailItemKinds, enrollmentStatuses, phaseCodes, pnodeTypes, powerOfTenMultipliers, serviceCategoryKinds, unitsOfMeasurement } from './lookups.js';
import { ensureArray } from './utilities.js';
export function updateSummaryMeasurement(measurement) {
if (measurement === undefined) {
return;
}
if (measurement.powerOfTenMultiplier !== undefined) {
measurement.powerOfTenMultiplier_value =
powerOfTenMultipliers[measurement.powerOfTenMultiplier];
}
if (measurement.uom !== undefined) {
measurement.uom_value = unitsOfMeasurement[measurement.uom];
}
}
export function updateTariffRider(tariffRider) {
tariffRider.enrollmentStatus_value =
enrollmentStatuses[tariffRider.enrollmentStatus];
}
export function updateUsagePoint(usagePoint) {
if (usagePoint.ServiceCategory !== undefined) {
usagePoint.ServiceCategory.kind_value =
serviceCategoryKinds[usagePoint.ServiceCategory.kind];
}
if (usagePoint.ServiceDeliveryPoint?.tariffRiderRefs?.tariffRiderRef !==
undefined) {
ensureArray(usagePoint.ServiceDeliveryPoint.tariffRiderRefs, 'tariffRiderRef');
for (const tariffRider of usagePoint.ServiceDeliveryPoint.tariffRiderRefs
.tariffRiderRef) {
updateTariffRider(tariffRider);
}
}
if (usagePoint.amiBillingReady !== undefined) {
usagePoint.amiBillingReady_value =
amiBillingReadyStatuses[usagePoint.amiBillingReady];
}
if (usagePoint.connectionState !== undefined) {
usagePoint.connectionState_value =
connectionStates[usagePoint.connectionState];
}
updateSummaryMeasurement(usagePoint.estimatedLoad);
updateSummaryMeasurement(usagePoint.nominalServiceVoltage);
if (usagePoint.phaseCode !== undefined) {
usagePoint.phaseCode_value = phaseCodes[usagePoint.phaseCode];
}
updateSummaryMeasurement(usagePoint.ratedCurrent);
updateSummaryMeasurement(usagePoint.ratedPower);
if (usagePoint.pnodeRefs !== undefined) {
ensureArray(usagePoint.pnodeRefs, 'pnodeRef');
for (const pnode of usagePoint.pnodeRefs.pnodeRef) {
pnode.apnodeType_value = pnodeTypes[pnode.apnodeType];
}
}
if (usagePoint.aggregateNodeRefs !== undefined) {
ensureArray(usagePoint.aggregateNodeRefs, 'aggregateNodeRef');
for (const anode of usagePoint.aggregateNodeRefs.aggregateNodeRef) {
anode.anodeType_value = anodeTypes[anode.anodeType];
}
}
}
export function updateCostAdditionalDetail(additionalDetail) {
additionalDetail.itemKind_value =
costDetailItemKinds[additionalDetail.itemKind];
updateSummaryMeasurement(additionalDetail.measurement);
updateSummaryMeasurement(additionalDetail.unitCost);
updateSummaryMeasurement(additionalDetail.itemPeriod);
}
export function parseAuthorizationScope(scope) {
const scopeString = scope + ';';
const functionBlockPieces = scopeString
.slice(3, scopeString.indexOf(';'))
.split('_');
const functionBlocks = [];
for (const functionBlockPiece of functionBlockPieces) {
functionBlocks.push(Number.parseInt(functionBlockPiece, 10));
}
return {
functionBlocks,
common: functionBlocks.includes(1),
downloadMyData: functionBlocks.includes(2),
connectMyData: functionBlocks.includes(3),
intervalMetering: functionBlocks.includes(4),
intervalElectricityMetering: functionBlocks.includes(5),
demandElectricityMetering: functionBlocks.includes(6),
netMetering: functionBlocks.includes(7),
forwardAndReverseMetering: functionBlocks.includes(8),
registerValues: functionBlocks.includes(9),
gas: functionBlocks.includes(10),
water: functionBlocks.includes(11),
costOfIntervalData: functionBlocks.includes(12),
securityAndPrivacyClasses: functionBlocks.includes(13),
usageSummary: functionBlocks.includes(15),
usageSummaryWithCost: functionBlocks.includes(16),
powerQualitySummary: functionBlocks.includes(17),
multipleUsagePoints: functionBlocks.includes(18),
partialUpdateData: functionBlocks.includes(19),
usageSummaryWithDemandsAndPreviousDayAttributes: functionBlocks.includes(27),
usageSummaryCostsForCurrentBillingPeriod: functionBlocks.includes(28),
temperatureIntervalMetering: functionBlocks.includes(29),
commonUserExperience: functionBlocks.includes(30),
authorizationAndAuthentication: functionBlocks.includes(31),
resourceLevelRest: functionBlocks.includes(32),
managementRestServices: functionBlocks.includes(33),
sftpForBulk: functionBlocks.includes(34),
restForBulk: functionBlocks.includes(35),
thirdPartyDynamicRegistration: functionBlocks.includes(36),
queryParameters: functionBlocks.includes(37),
onDemandRequests: functionBlocks.includes(38),
pushModel: functionBlocks.includes(39),
offlineAuthorization: functionBlocks.includes(40),
manageApplicationInformationResource: functionBlocks.includes(41),
manageAuthorizationResource: functionBlocks.includes(44),
retailCustomerManagementRest: functionBlocks.includes(49),
retailCustomerResourceLevelRest: functionBlocks.includes(50),
retailCustomerCommon: functionBlocks.includes(51),
retailCustomerDownloadMyData: functionBlocks.includes(52),
retailCustomerConnectMyData: functionBlocks.includes(53),
retailCustomerBasicInformation: functionBlocks.includes(54),
retailCustomerDemographicInformation: functionBlocks.includes(55),
retailCustomerBillingInformation: functionBlocks.includes(56),
retailCustomerAccountAgreementInformation: functionBlocks.includes(57),
retailCustomerServiceLocationInformation: functionBlocks.includes(58),
retailCustomerServiceSupplierInformation: functionBlocks.includes(59),
retailCustomerMeterInformation: functionBlocks.includes(60),
retailCustomerEndDeviceInformation: functionBlocks.includes(61),
retailCustomerProgramDateIdMappingsInformation: functionBlocks.includes(62),
retailCustomerSecurityAndPrivacy: functionBlocks.includes(64),
retailCustomerAuthorizationAndAuthentication: functionBlocks.includes(65),
sftpForRetailCustomerBulk: functionBlocks.includes(66),
restForRetailCustomerBulk: functionBlocks.includes(67),
retailCustomerQueryParameters: functionBlocks.includes(68),
retailCustomerPushModel: functionBlocks.includes(69),
retailCustomerOfflineAuthorization: functionBlocks.includes(70)
};
}