export function ifParentIsObjectLiteral(this: DeclarationReflection, truthy: boolean, options: any) { const parentIsObjectLiteral = this.parent && this.parent.parent && this.parent.parent.kind === ReflectionKind.ObjectLiteral; if (parentIsObjectLiteral && truthy) { return options.fn(this); } return !parentIsObjectLiteral && !truthy ? options.fn(this) : options.inverse(this); }
export function ifParentIsModule(this: DeclarationReflection, truthy: boolean, options: any) { const parentIsModule = this.parent && this.parent.kind === ReflectionKind.Module; if (parentIsModule && truthy) { return options.fn(this); } return !parentIsModule && !truthy ? options.fn(this) : options.inverse(this); }
/** * Callback used to sort reflections by weight defined by ´CubejsGroupPlugin.WEIGHTS´ and name. * * @param a The left reflection to sort. * @param b The right reflection to sort. * @returns The sorting weight. */ static sortCallback(a: Reflection, b: Reflection): number { const aWeight = CubejsGroupPlugin.orderByName.get(a.name) || CubejsGroupPlugin.WEIGHTS.indexOf(a.kind); const bWeight = CubejsGroupPlugin.orderByName.get(b.name) || CubejsGroupPlugin.WEIGHTS.indexOf(b.kind); if (aWeight === bWeight) { if (a.flags.isStatic && !b.flags.isStatic) { return 1; } if (!a.flags.isStatic && b.flags.isStatic) { return -1; } if (a.name === b.name) { return 0; } return a.name > b.name ? 1 : -1; } else { return aWeight - bWeight; } }