@grouparoo/app-templates
Advanced tools
Comparing version 0.7.0-alpha.2 to 0.7.0-alpha.3
@@ -12,3 +12,4 @@ "use strict"; | ||
const tableName = (_a = sourceOptions[pluginMethods_1.tableNameKey]) === null || _a === void 0 ? void 0 : _a.toString(); | ||
const columnNames = properties.map((p) => { var _a; return (_a = propertyOptions[p.id][pluginMethods_1.columnNameKey]) === null || _a === void 0 ? void 0 : _a.toString(); }); | ||
const rawColumnNames = properties.map((p) => { var _a; return (_a = propertyOptions[p.id][pluginMethods_1.columnNameKey]) === null || _a === void 0 ? void 0 : _a.toString(); }); | ||
const columnNames = [...new Set(rawColumnNames)]; | ||
const aggregationMethod = (propertyOptions[Object.keys(propertyOptions)[0]][pluginMethods_1.aggregationMethodKey]); | ||
@@ -21,5 +22,5 @@ const sortColumn = (_b = propertyOptions[Object.keys(propertyOptions)[0]][pluginMethods_1.sortColumnKey]) === null || _b === void 0 ? void 0 : _b.toString(); | ||
const primaryKeysHash = {}; | ||
for (const profile of records) { | ||
responsesById[profile.id] = {}; | ||
const recordProperties = await profile.getProperties(); | ||
for (const record of records) { | ||
responsesById[record.id] = {}; | ||
const recordProperties = await record.getProperties(); | ||
for (const property of properties) { | ||
@@ -33,3 +34,3 @@ // prepare primaryKeysHash to assign results to properties | ||
primaryKeysHash[k] = []; | ||
primaryKeysHash[k].push(profile.id); | ||
primaryKeysHash[k].push(record.id); | ||
} | ||
@@ -39,3 +40,3 @@ // set default values to help with aggregation issues | ||
aggregationMethod === core_1.AggregationMethod.Count) { | ||
responsesById[profile.id][property.id] = [0]; | ||
responsesById[record.id][property.id] = [0]; | ||
} | ||
@@ -74,7 +75,7 @@ else { | ||
for (const column of Object.keys(responsesByPrimaryKey[pk])) { | ||
const property = properties.find((p) => propertyOptions[p.id][pluginMethods_1.columnNameKey] === column); | ||
if (!property) | ||
continue; | ||
responsesById[recordId][property.id] = | ||
responsesByPrimaryKey[pk][column]; | ||
const propertiesFound = properties.filter((p) => propertyOptions[p.id][pluginMethods_1.columnNameKey] === column); | ||
propertiesFound.forEach((property) => { | ||
responsesById[recordId][property.id] = | ||
responsesByPrimaryKey[pk][column]; | ||
}); | ||
} | ||
@@ -81,0 +82,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"description": "Common patterns for Grouparoo plugins that contribute apps", | ||
"version": "0.7.0-alpha.2", | ||
"version": "0.7.0-alpha.3", | ||
"license": "MPL-2.0", | ||
@@ -32,8 +32,8 @@ "private": false, | ||
"devDependencies": { | ||
"@grouparoo/core": "0.7.0-alpha.2", | ||
"@grouparoo/spec-helper": "0.7.0-alpha.2", | ||
"@grouparoo/core": "0.7.0-alpha.3", | ||
"@grouparoo/spec-helper": "0.7.0-alpha.3", | ||
"@types/jest": "*", | ||
"@types/node": "*", | ||
"@types/uuid": "*", | ||
"actionhero": "27.0.3", | ||
"actionhero": "27.1.2", | ||
"jest": "27.1.0", | ||
@@ -46,3 +46,3 @@ "nock": "13.1.3", | ||
}, | ||
"gitHead": "d4c2b8b0da304b63ab748be2389f6eb07f19cf63" | ||
"gitHead": "1590f1a4dfac2ed851ca9c898dd9c7244ac3dbfa" | ||
} |
@@ -38,5 +38,6 @@ import { | ||
const tableName = sourceOptions[tableNameKey]?.toString(); | ||
const columnNames = properties.map((p) => | ||
const rawColumnNames = properties.map((p) => | ||
propertyOptions[p.id][columnNameKey]?.toString() | ||
); | ||
const columnNames = [...new Set(rawColumnNames)]; | ||
const aggregationMethod = <AggregationMethod>( | ||
@@ -55,6 +56,5 @@ propertyOptions[Object.keys(propertyOptions)[0]][aggregationMethodKey] | ||
const primaryKeysHash: { [pk: string]: string[] } = {}; | ||
for (const profile of records) { | ||
responsesById[profile.id] = {}; | ||
const recordProperties = await profile.getProperties(); | ||
for (const record of records) { | ||
responsesById[record.id] = {}; | ||
const recordProperties = await record.getProperties(); | ||
for (const property of properties) { | ||
@@ -68,3 +68,3 @@ // prepare primaryKeysHash to assign results to properties | ||
if (!primaryKeysHash[k]) primaryKeysHash[k] = []; | ||
primaryKeysHash[k].push(profile.id); | ||
primaryKeysHash[k].push(record.id); | ||
} | ||
@@ -77,3 +77,3 @@ | ||
) { | ||
responsesById[profile.id][property.id] = [0]; | ||
responsesById[record.id][property.id] = [0]; | ||
} else { | ||
@@ -116,9 +116,10 @@ // leave undefined | ||
for (const column of Object.keys(responsesByPrimaryKey[pk])) { | ||
const property = properties.find( | ||
const propertiesFound = properties.filter( | ||
(p) => propertyOptions[p.id][columnNameKey] === column | ||
); | ||
if (!property) continue; | ||
responsesById[recordId][property.id] = | ||
responsesByPrimaryKey[pk][column]; | ||
propertiesFound.forEach((property) => { | ||
responsesById[recordId][property.id] = | ||
responsesByPrimaryKey[pk][column]; | ||
}); | ||
} | ||
@@ -125,0 +126,0 @@ }); |
241577
6528