Initial commit - Event Planner application

This commit is contained in:
mberlin
2026-03-18 14:55:56 -03:00
commit 86d779eb4d
7548 changed files with 1006324 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import { InjectionToken } from '@nestjs/common';
import { InstanceWrapper } from '../../injector/instance-wrapper.js';
export declare function getInstancesGroupedByHierarchyLevel(...collections: Array<Map<InjectionToken, InstanceWrapper> | Array<[InjectionToken, InstanceWrapper]>>): Map<number, unknown[]>;

View File

@@ -0,0 +1,27 @@
export function getInstancesGroupedByHierarchyLevel(...collections) {
const groupedByHierarchyLevel = new Map();
for (const collection of collections) {
for (const [_, wrapper] of collection) {
if (!wrapper.isDependencyTreeStatic()) {
continue;
}
const level = wrapper.hierarchyLevel;
if (!groupedByHierarchyLevel.has(level)) {
groupedByHierarchyLevel.set(level, []);
}
const byHierarchyLevelGroup = groupedByHierarchyLevel.get(level);
if (wrapper.isTransient) {
const staticTransientInstances = wrapper
.getStaticTransientInstances()
.filter(i => !!i)
.map(i => i.instance);
byHierarchyLevelGroup.push(...staticTransientInstances);
continue;
}
if (wrapper.instance) {
byHierarchyLevelGroup.push(wrapper.instance);
}
}
}
return groupedByHierarchyLevel;
}

View File

@@ -0,0 +1 @@
export declare function getSortedHierarchyLevels(groups: Map<number, unknown[]>, order?: 'ASC' | 'DESC'): number[];

View File

@@ -0,0 +1,7 @@
export function getSortedHierarchyLevels(groups, order = 'ASC') {
const comparator = order === 'ASC'
? (a, b) => a - b
: (a, b) => b - a;
const levels = Array.from(groups.keys()).sort(comparator);
return levels;
}