Files
zeekay d57cb038bd chore: rename all PostHog references to Insights/Hanzo
Bulk rename across 989 files:
- Package names: posthog-js → @hanzo/insights, posthog-node → @hanzo/insights-node, etc.
- Repository URLs: posthog/posthog-js → hanzoai/insights-js
- Brand names: PostHog → Insights
- File renames: 259 reference JSON files, source files, workflow files
- Directory rename: eslint-plugin-posthog-js → eslint-plugin-insights

Remaining: 8 refs to @posthog/rrweb-* (real npm deps, need fork+publish)
2026-03-06 01:41:12 -08:00

76 lines
2.5 KiB
JavaScript

const { ReleaseTag, ApiItemKind } = require('@microsoft/api-extractor-model');
const { getInheritanceChain } = require('./inheritance');
// for release tag mapping
const releaseTagMap = {
[ReleaseTag.Internal]: 'internal',
[ReleaseTag.Alpha]: 'alpha',
[ReleaseTag.Beta]: 'beta',
[ReleaseTag.Public]: 'public'
};
/**
* Get method release tag
* @param {any} apiMethod - API method to get release tag from
* @returns {string} - Release tag string
*/
const getMethodReleaseTag = (apiMethod) =>
releaseTagMap[apiMethod.releaseTag] || 'public';
// Deprecation detection functions
const hasDeprecatedBlock = (apiMethod) =>
apiMethod.tsdocComment?.deprecatedBlock !== undefined;
/**
* Check if method is deprecated
* @param {any} apiMethod - API method to check
* @returns {boolean} - Whether method is deprecated
*/
const isMethodDeprecated = hasDeprecatedBlock;
/**
* Collect all public methods from a class and its inheritance chain
* @param {any} insightsClass - Starting class
* @param {string} rootClass - Root class name for constructor display
* @returns {any[]} - Array of unique public methods
*/
const collectMethodsWithInheritance = (insightsClass, rootClass) => {
if (!insightsClass) return [];
const allMethods = new Map();
const apiPackage = insightsClass.getAssociatedPackage();
const inheritanceChain = getInheritanceChain(insightsClass, apiPackage);
// Collect methods from each class in the inheritance chain
for (const currentClass of inheritanceChain) {
const inheritanceResult = currentClass.findMembersWithInheritance();
const members = inheritanceResult.items || [];
const methods = members.filter(member => {
if (member.kind === ApiItemKind.Constructor) return true;
if (member.kind !== ApiItemKind.Method) return false;
// Exclude private-by-convention (leading _) and protected methods
if (member.name.startsWith('_')) return false;
if (member.isProtected) return false;
return true;
});
// Add methods to map (child methods take precedence over parent methods)
methods.forEach(method => {
if (method.kind === ApiItemKind.Constructor) {
method.name = rootClass;
}
if (!allMethods.has(method.name)) {
allMethods.set(method.name, method);
}
});
}
return Array.from(allMethods.values());
};
module.exports = {
getMethodReleaseTag,
isMethodDeprecated,
collectMethodsWithInheritance,
};