33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.expandCollection = void 0;
|
|
const type_utilities_1 = require("@activity-kit/type-utilities");
|
|
async function expandCollection(collection) {
|
|
if (!type_utilities_1.guard.isApCollection(collection)) {
|
|
return null;
|
|
}
|
|
const items = this.getCollectionItems(collection);
|
|
const expandedItems = await Promise.all(items.map(async (item) => {
|
|
var _a;
|
|
if (type_utilities_1.guard.isApEntity(item)) {
|
|
return item;
|
|
}
|
|
return (_a = (await this.queryById(item))) !== null && _a !== void 0 ? _a : item;
|
|
}));
|
|
if (type_utilities_1.guard.isArray(collection.orderedItems) &&
|
|
collection.orderedItems.length) {
|
|
return {
|
|
...collection,
|
|
orderedItems: expandedItems,
|
|
};
|
|
}
|
|
else if (type_utilities_1.guard.isArray(collection.items) && collection.items.length) {
|
|
return {
|
|
...collection,
|
|
items: expandedItems,
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
exports.expandCollection = expandCollection;
|
|
//# sourceMappingURL=expandCollection.js.map
|