import { authModelsSpec, createPluginModelSyncChecker, FeatureUtils, PluginUtils, } from '@baseplate-dev/project-builder-lib';
import { createBillingPartialDefinition } from './models.js';
export function createStripeSchemaChecker(pluginKey) {
    return createPluginModelSyncChecker({
        pluginKey,
        pluginLabel: 'Stripe',
        buildPartialDef: (container) => {
            const stripeConfig = PluginUtils.configByKey(container.definition, pluginKey);
            if (!stripeConfig?.billing.enabled || !stripeConfig.billing.featureRef) {
                return undefined;
            }
            try {
                const authModels = container.pluginStore.use(authModelsSpec);
                const userModelName = authModels.getAuthModelsOrThrow(container.definition).user;
                const featureName = FeatureUtils.getFeaturePathByIdOrThrow(container.definition, stripeConfig.billing.featureRef);
                return createBillingPartialDefinition(featureName, userModelName);
            }
            catch {
                return undefined;
            }
        },
    });
}
//# sourceMappingURL=schema-issue-checker.js.map