@happyvertical/smrt-subscriptions 0.57.45 → 0.57.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +61 -1
- package/dist/smrt-knowledge.json +3 -3
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { ObjectRegistry, SmrtCollection, SmrtObject, SmrtRecipe, crossPackageRef
|
|
|
7
7
|
import { TenantIsolationError, TenantScoped, getTenantId, isSuperAdminBypass, isSystemContext, tenantId, withSystemContext } from "@happyvertical/smrt-tenancy";
|
|
8
8
|
import { preflightMinorUnitsRescale, rescaleMoneyColumnsToMinorUnits } from "@happyvertical/smrt-core/migrations";
|
|
9
9
|
//#region src/__smrt-register__.ts
|
|
10
|
-
ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-subscriptions","packageVersion":"0.57.45","objects":{"@happyvertical/smrt-subscriptions:SubscriptionPlanCollection":{"name":"subscriptionplancollection","className":"SubscriptionPlanCollection","qualifiedName":"@happyvertical/smrt-subscriptions:SubscriptionPlanCollection","collection":"subscriptionplans","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/collections/SubscriptionPlanCollection.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{"findByPlanKey":{"name":"findByPlanKey","async":true,"parameters":[{"name":"tenantId","type":"string | null","optional":false,"unionBranches":[{"type":"string"},{"type":"null"}]},{"name":"planKey","type":"string","optional":false}],"returnType":"Promise<SubscriptionPlan | null>","isStatic":false,"isPublic":true},"findActive":{"name":"findActive","async":true,"parameters":[],"returnType":"Promise<SubscriptionPlan[]>","isStatic":false,"isPublic":true},"findByProviderPriceId":{"name":"findByProviderPriceId","async":true,"parameters":[{"name":"providerPriceId","type":"string","optional":false}],"returnType":"Promise<SubscriptionPlan | null>","isStatic":false,"isPublic":true},"findByStripePriceId":{"name":"findByStripePriceId","async":true,"parameters":[{"name":"stripePriceId","type":"string","optional":false}],"returnType":"Promise<SubscriptionPlan | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_subscription_plans","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"SubscriptionPlan","exportName":"SubscriptionPlanCollection","collectionExportName":"SubscriptionPlanCollectionCollection","schema":{"tableName":"_smrt_subscription_plans","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_subscription_plans\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"plan_key\\" TEXT DEFAULT '',\\n \\"name\\" TEXT DEFAULT '',\\n \\"description\\" TEXT DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"sort_order\\" INTEGER DEFAULT 0,\\n \\"price_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"billing_interval\\" TEXT DEFAULT 'month',\\n \\"pricing_mode\\" TEXT DEFAULT 'fixed',\\n \\"minimum_amount\\" INTEGER DEFAULT 0,\\n \\"suggested_amount\\" INTEGER DEFAULT 0,\\n \\"external_provider\\" TEXT,\\n \\"provider_product_id\\" TEXT,\\n \\"provider_price_id\\" TEXT,\\n \\"stripe_product_id\\" TEXT,\\n \\"stripe_price_id\\" TEXT,\\n \\"features\\" TEXT DEFAULT '[]',\\n \\"thresholds\\" TEXT DEFAULT '[]',\\n \\"metadata\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"plan_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"sort_order":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"price_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"billing_interval":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"pricing_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed"},"minimum_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"suggested_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"external_provider":{"type":"TEXT","notNull":false,"unique":false},"provider_product_id":{"type":"TEXT","notNull":false,"unique":false},"provider_price_id":{"type":"TEXT","notNull":false,"unique":false},"stripe_product_id":{"type":"TEXT","notNull":false,"unique":false},"stripe_price_id":{"type":"TEXT","notNull":false,"unique":false},"features":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"thresholds":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"metadata":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_subscription_plans_tenant_id_plan_key_idx","columns":["tenant_id","plan_key"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_subscription_plans_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_subscription_plans_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"02602c74"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:SubscriptionPlanVersionCollection":{"name":"subscriptionplanversioncollection","className":"SubscriptionPlanVersionCollection","qualifiedName":"@happyvertical/smrt-subscriptions:SubscriptionPlanVersionCollection","collection":"subscriptionplanversions","description":"Effective-dated plan versions (#4032).","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/collections/SubscriptionPlanVersionCollection.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{"findVisibleById":{"name":"findVisibleById","async":true,"parameters":[{"name":"id","type":"string","optional":false}],"returnType":"Promise<SubscriptionPlanVersion | null>","isStatic":false,"isPublic":true},"listForPlan":{"name":"listForPlan","async":true,"parameters":[{"name":"planId","type":"string","optional":false}],"returnType":"Promise<SubscriptionPlanVersion[]>","isStatic":false,"isPublic":true},"findLatest":{"name":"findLatest","async":true,"parameters":[{"name":"planId","type":"string","optional":false},{"name":"tenantId","type":"string | null","optional":true,"unionBranches":[{"type":"string"},{"type":"null"}]}],"returnType":"Promise<SubscriptionPlanVersion | null>","isStatic":false,"isPublic":true},"findInForce":{"name":"findInForce","async":true,"parameters":[{"name":"planId","type":"string","optional":false},{"name":"at","type":"Date","optional":false}],"returnType":"Promise<SubscriptionPlanVersion | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_subscription_plan_versions","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"SubscriptionPlanVersion","exportName":"SubscriptionPlanVersionCollection","collectionExportName":"SubscriptionPlanVersionCollectionCollection","schema":{"tableName":"_smrt_subscription_plan_versions","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_subscription_plan_versions\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"plan_id\\" UUID,\\n \\"plan_key\\" TEXT DEFAULT '',\\n \\"version\\" INTEGER DEFAULT 0,\\n \\"effective_from\\" TIMESTAMP,\\n \\"name\\" TEXT DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"price_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"billing_interval\\" TEXT DEFAULT 'month',\\n \\"pricing_mode\\" TEXT DEFAULT 'fixed',\\n \\"minimum_amount\\" INTEGER DEFAULT 0,\\n \\"suggested_amount\\" INTEGER DEFAULT 0,\\n \\"features\\" TEXT DEFAULT '[]',\\n \\"thresholds\\" TEXT DEFAULT '[]'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"plan_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plans","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"plan_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"version":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"effective_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"price_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"billing_interval":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"pricing_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed"},"minimum_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"suggested_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"features":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"thresholds":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"}},"indexes":[{"name":"_smrt_subscription_plan_versions_plan_id_version_idx","columns":["plan_id","version"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_subscription_plan_versions_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_subscription_plan_versions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"f610e477"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:TenantSubscriptionCollection":{"name":"tenantsubscriptioncollection","className":"TenantSubscriptionCollection","qualifiedName":"@happyvertical/smrt-subscriptions:TenantSubscriptionCollection","collection":"tenantsubscriptions","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/collections/TenantSubscriptionCollection.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<TenantSubscription[]>","isStatic":false,"isPublic":true},"findCurrentForTenant":{"name":"findCurrentForTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false},{"name":"now","type":"any","optional":true}],"returnType":"Promise<TenantSubscription | null>","isStatic":false,"isPublic":true},"findCurrentForSubscriber":{"name":"findCurrentForSubscriber","async":true,"parameters":[{"name":"subscriber","type":"Subscriber","optional":false},{"name":"now","type":"any","optional":true}],"returnType":"Promise<TenantSubscription | null>","isStatic":false,"isPublic":true},"findByStripeSubscriptionId":{"name":"findByStripeSubscriptionId","async":true,"parameters":[{"name":"stripeSubscriptionId","type":"string","optional":false}],"returnType":"Promise<TenantSubscription | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_tenant_subscriptions","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"TenantSubscription","exportName":"TenantSubscriptionCollection","collectionExportName":"TenantSubscriptionCollectionCollection","schema":{"tableName":"_smrt_tenant_subscriptions","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_subscriptions\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"plan_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'incomplete',\\n \\"started_at\\" TIMESTAMP,\\n \\"current_period_start\\" TIMESTAMP,\\n \\"current_period_end\\" TIMESTAMP,\\n \\"trial_ends_at\\" TIMESTAMP,\\n \\"cancel_at_period_end\\" BOOLEAN DEFAULT FALSE,\\n \\"canceled_at\\" TIMESTAMP,\\n \\"agreed_amount\\" INTEGER,\\n \\"plan_version_id\\" UUID,\\n \\"plan_version_pinned_at\\" TIMESTAMP,\\n \\"plan_version_pin_reason\\" TEXT,\\n \\"plan_version_pin_note\\" TEXT DEFAULT '',\\n \\"retains_paid_period\\" BOOLEAN DEFAULT FALSE,\\n \\"external_provider\\" TEXT,\\n \\"stripe_customer_id\\" TEXT DEFAULT '',\\n \\"stripe_subscription_id\\" TEXT DEFAULT '',\\n \\"stripe_checkout_session_id\\" TEXT DEFAULT '',\\n \\"metadata\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"plan_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plans","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"incomplete"},"started_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"current_period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"current_period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"trial_ends_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"cancel_at_period_end":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"canceled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"agreed_amount":{"type":"INTEGER","notNull":false,"unique":false},"plan_version_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plan_versions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"plan_version_pinned_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"plan_version_pin_reason":{"type":"TEXT","notNull":false,"unique":false},"plan_version_pin_note":{"type":"TEXT","notNull":false,"unique":false,"default":""},"retains_paid_period":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"external_provider":{"type":"TEXT","notNull":false,"unique":false},"stripe_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"stripe_subscription_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"stripe_checkout_session_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metadata":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_tenant_subscriptions_tenant_id_subscriber_kind_idx","columns":["tenant_id","subscriber_kind","subscriber_external_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_tenant_subscriptions_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_tenant_subscriptions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_tenant_subscriptions_plan_id_idx","columns":["plan_id"]},{"name":"_smrt_tenant_subscriptions_plan_version_id_idx","columns":["plan_version_id"]}],"version":"328e412c"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:TenantUsageMetricCollection":{"name":"tenantusagemetriccollection","className":"TenantUsageMetricCollection","qualifiedName":"@happyvertical/smrt-subscriptions:TenantUsageMetricCollection","collection":"tenantusagemetrics","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/collections/TenantUsageMetricCollection.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{"recordUsage":{"name":"recordUsage","async":true,"parameters":[{"name":"options","type":"RecordUsageOptions","optional":false}],"returnType":"Promise<TenantUsageMetric>","isStatic":false,"isPublic":true},"findByTenantAndMetric":{"name":"findByTenantAndMetric","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false},{"name":"metricKey","type":"string","optional":false}],"returnType":"Promise<TenantUsageMetric[]>","isStatic":false,"isPublic":true},"summarizeUsage":{"name":"summarizeUsage","async":true,"parameters":[{"name":"options","type":"SummarizeUsageOptions","optional":false}],"returnType":"Promise<UsageSummary>","isStatic":false,"isPublic":true},"summarizeUsageBatch":{"name":"summarizeUsageBatch","async":true,"parameters":[{"name":"options","type":"SummarizeUsageBatchOptions","optional":false}],"returnType":"Promise<UsageSummary[]>","isStatic":false,"isPublic":true},"summarizeTenantAiUsage":{"name":"summarizeTenantAiUsage","async":true,"parameters":[{"name":"options","type":"SummarizeAiUsageOptions","optional":false}],"returnType":"Promise<AiUsageSummary>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_tenant_usage_metrics","api":{"include":["list","get","create"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get","create"]}},"extends":"SmrtCollection","extendsTypeArg":"TenantUsageMetric","exportName":"TenantUsageMetricCollection","collectionExportName":"TenantUsageMetricCollectionCollection","schema":{"tableName":"_smrt_tenant_usage_metrics","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_usage_metrics\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"window_start\\" TIMESTAMP,\\n \\"window_end\\" TIMESTAMP,\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"dimensions\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"window_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"window_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"dimensions":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_tenant_usage_metrics_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_tenant_usage_metrics_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"b799c746"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:SubscriptionPlan":{"name":"subscriptionplan","className":"SubscriptionPlan","qualifiedName":"@happyvertical/smrt-subscriptions:SubscriptionPlan","collection":"subscriptionplans","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/SubscriptionPlan.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":false,"_meta":{"sqlType":"UUID","nullable":true,"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false}}},"planKey":{"type":"text","required":false,"default":"","description":"A short code that identifies the plan, such as starter or pro.","_meta":{"description":"A short code that identifies the plan, such as starter or pro."}},"name":{"type":"text","required":false,"default":"","description":"What the plan is called, as customers see it.","_meta":{"description":"What the plan is called, as customers see it."}},"description":{"type":"text","required":false,"default":"","description":"A sentence or two about what the plan offers.","_meta":{"description":"A sentence or two about what the plan offers."}},"status":{"type":"text","required":false,"default":"active","description":"Whether the plan is a draft, on sale (active) or archived.","_meta":{"description":"Whether the plan is a draft, on sale (active) or archived."},"enum":["active","archived","draft"]},"sortOrder":{"type":"integer","required":false,"default":0,"description":"Where the plan sits when plans are listed; lower numbers come first.","_meta":{"description":"Where the plan sits when plans are listed; lower numbers come first."}},"priceAmount":{"type":"integer","required":false,"default":0,"description":"What the plan costs each billing period, in cents, as a whole number.","_meta":{"description":"What the plan costs each billing period, in cents, as a whole number."}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency the price is in, such as USD.","_meta":{"description":"The currency the price is in, such as USD."}},"billingInterval":{"type":"text","required":false,"default":"month","description":"How often the subscriber is billed: every day, week, month or year.","_meta":{"description":"How often the subscriber is billed: every day, week, month or year."},"enum":["day","week","month","year"]},"pricingMode":{"type":"text","required":false,"default":"fixed","description":"Whether the plan is free, has a fixed price, or lets the subscriber choose what to pay. It cannot change once the plan is saved.","_meta":{"description":"Whether the plan is free, has a fixed price, or lets the subscriber choose what to pay. It cannot change once the plan is saved."},"enum":["free","fixed","pay_what_you_can"]},"minimumAmount":{"type":"integer","required":false,"default":0,"description":"For a pay-what-you-can plan, the least a subscriber may pay, in cents.","_meta":{"description":"For a pay-what-you-can plan, the least a subscriber may pay, in cents."}},"suggestedAmount":{"type":"integer","required":false,"default":0,"description":"For a pay-what-you-can plan, the amount suggested to the subscriber, in cents.","_meta":{"description":"For a pay-what-you-can plan, the amount suggested to the subscriber, in cents."}},"externalProvider":{"type":"text","required":false},"providerProductId":{"type":"text","required":false},"providerPriceId":{"type":"text","required":false},"stripeProductId":{"type":"text","required":false},"stripePriceId":{"type":"text","required":false},"features":{"type":"text","required":false,"default":"[]"},"thresholds":{"type":"text","required":false,"default":"[]"},"metadata":{"type":"text","required":false,"default":"{}"}},"methods":{"isActive":{"name":"isActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getTerms":{"name":"getTerms","async":false,"parameters":[],"returnType":"PlanTerms","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"publishTerms":{"name":"publishTerms","async":true,"parameters":[{"name":"options","type":"object","optional":true,"memberTypes":["Date"]}],"returnType":"Promise<SubscriptionPlanVersion>","isStatic":false,"isPublic":true},"getVersionInForce":{"name":"getVersionInForce","async":true,"parameters":[{"name":"at","type":"any","optional":true}],"returnType":"Promise<SubscriptionPlanVersion | null>","isStatic":false,"isPublic":true},"getFeatureGrants":{"name":"getFeatureGrants","async":false,"parameters":[],"returnType":"PlanFeatureGrant[]","isStatic":false,"isPublic":true},"setFeatureGrants":{"name":"setFeatureGrants","async":false,"parameters":[{"name":"grants","type":"Array<string | PlanFeatureGrant>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getFeatureKeys":{"name":"getFeatureKeys","async":false,"parameters":[],"returnType":"string[]","isStatic":false,"isPublic":true},"getThresholds":{"name":"getThresholds","async":false,"parameters":[],"returnType":"PlanThreshold[]","isStatic":false,"isPublic":true},"setThresholds":{"name":"setThresholds","async":false,"parameters":[{"name":"thresholds","type":"PlanThreshold[]","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"JsonObject","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"metadata","type":"JsonObject","optional":false}],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_subscription_plans","api":{"include":["list","get","create","update"]},"cli":{"skipApiCheck":true},"mcp":{"include":["list","get"]},"conflictColumns":["tenant_id","plan_key"],"tenantScoped":{"mode":"optional"}},"extends":"SmrtObject","exportName":"SubscriptionPlan","collectionExportName":"SubscriptionPlanCollection","displayLabelField":"name","schema":{"tableName":"_smrt_subscription_plans","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_subscription_plans\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"plan_key\\" TEXT DEFAULT '',\\n \\"name\\" TEXT DEFAULT '',\\n \\"description\\" TEXT DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"sort_order\\" INTEGER DEFAULT 0,\\n \\"price_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"billing_interval\\" TEXT DEFAULT 'month',\\n \\"pricing_mode\\" TEXT DEFAULT 'fixed',\\n \\"minimum_amount\\" INTEGER DEFAULT 0,\\n \\"suggested_amount\\" INTEGER DEFAULT 0,\\n \\"external_provider\\" TEXT,\\n \\"provider_product_id\\" TEXT,\\n \\"provider_price_id\\" TEXT,\\n \\"stripe_product_id\\" TEXT,\\n \\"stripe_price_id\\" TEXT,\\n \\"features\\" TEXT DEFAULT '[]',\\n \\"thresholds\\" TEXT DEFAULT '[]',\\n \\"metadata\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"plan_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"sort_order":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"price_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"billing_interval":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"pricing_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed"},"minimum_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"suggested_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"external_provider":{"type":"TEXT","notNull":false,"unique":false},"provider_product_id":{"type":"TEXT","notNull":false,"unique":false},"provider_price_id":{"type":"TEXT","notNull":false,"unique":false},"stripe_product_id":{"type":"TEXT","notNull":false,"unique":false},"stripe_price_id":{"type":"TEXT","notNull":false,"unique":false},"features":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"thresholds":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"metadata":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_subscription_plans_tenant_id_plan_key_idx","columns":["tenant_id","plan_key"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_subscription_plans_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_subscription_plans_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"02602c74"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:SubscriptionPlanVersion":{"name":"subscriptionplanversion","className":"SubscriptionPlanVersion","qualifiedName":"@happyvertical/smrt-subscriptions:SubscriptionPlanVersion","collection":"subscriptionplanversions","description":"An immutable, effective-dated snapshot of a plan's terms (#4032).","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/SubscriptionPlanVersion.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":false,"_meta":{"sqlType":"UUID","nullable":true,"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false}}},"planId":{"type":"foreignKey","required":false,"related":"SubscriptionPlan","description":"The plan this version belongs to.","_meta":{"description":"The plan this version belongs to."}},"planKey":{"type":"text","required":false,"default":"","description":"The plan code at the time this version was published.","_meta":{"description":"The plan code at the time this version was published."}},"version":{"type":"integer","required":false,"default":0,"description":"Which version of the plan this is, counting from 1.","_meta":{"description":"Which version of the plan this is, counting from 1."}},"effectiveFrom":{"type":"datetime","required":false,"description":"The date and time from which these terms apply.","_meta":{"description":"The date and time from which these terms apply."}},"name":{"type":"text","required":false,"default":"","description":"What the plan was called when this version was published.","_meta":{"description":"What the plan was called when this version was published."}},"status":{"type":"text","required":false,"default":"active","description":"Whether the plan was a draft, on sale (active) or archived under this version.","_meta":{"description":"Whether the plan was a draft, on sale (active) or archived under this version."},"enum":["active","archived","draft"]},"priceAmount":{"type":"integer","required":false,"default":0,"description":"What the plan cost each billing period under this version, in cents.","_meta":{"description":"What the plan cost each billing period under this version, in cents."}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency the price is in, such as USD.","_meta":{"description":"The currency the price is in, such as USD."}},"billingInterval":{"type":"text","required":false,"default":"month","description":"How often the subscriber was billed: every day, week, month or year.","_meta":{"description":"How often the subscriber was billed: every day, week, month or year."},"enum":["day","week","month","year"]},"pricingMode":{"type":"text","required":false,"default":"fixed","description":"Whether the plan was free, had a fixed price, or let the subscriber choose what to pay.","_meta":{"description":"Whether the plan was free, had a fixed price, or let the subscriber choose what to pay."},"enum":["free","fixed","pay_what_you_can"]},"minimumAmount":{"type":"integer","required":false,"default":0,"description":"For a pay-what-you-can plan, the least a subscriber could pay, in cents.","_meta":{"description":"For a pay-what-you-can plan, the least a subscriber could pay, in cents."}},"suggestedAmount":{"type":"integer","required":false,"default":0,"description":"For a pay-what-you-can plan, the amount suggested to the subscriber, in cents.","_meta":{"description":"For a pay-what-you-can plan, the amount suggested to the subscriber, in cents."}},"features":{"type":"text","required":false,"default":"[]"},"thresholds":{"type":"text","required":false,"default":"[]"}},"methods":{"isActive":{"name":"isActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getTerms":{"name":"getTerms","async":false,"parameters":[],"returnType":"PlanTerms","isStatic":false,"isPublic":true},"getFeatureGrants":{"name":"getFeatureGrants","async":false,"parameters":[],"returnType":"PlanFeatureGrant[]","isStatic":false,"isPublic":true},"getFeatureKeys":{"name":"getFeatureKeys","async":false,"parameters":[],"returnType":"string[]","isStatic":false,"isPublic":true},"getThresholds":{"name":"getThresholds","async":false,"parameters":[],"returnType":"PlanThreshold[]","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_subscription_plan_versions","api":{"include":["list","get"]},"cli":{"include":["list","get"]},"mcp":{"include":["list","get"]},"conflictColumns":["plan_id","version"],"hooks":{"beforeDelete":"refuseDelete"},"tenantScoped":{"mode":"optional"}},"extends":"SmrtObject","exportName":"SubscriptionPlanVersion","collectionExportName":"SubscriptionPlanVersionCollection","displayLabelField":"name","schema":{"tableName":"_smrt_subscription_plan_versions","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_subscription_plan_versions\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"plan_id\\" UUID,\\n \\"plan_key\\" TEXT DEFAULT '',\\n \\"version\\" INTEGER DEFAULT 0,\\n \\"effective_from\\" TIMESTAMP,\\n \\"name\\" TEXT DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"price_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"billing_interval\\" TEXT DEFAULT 'month',\\n \\"pricing_mode\\" TEXT DEFAULT 'fixed',\\n \\"minimum_amount\\" INTEGER DEFAULT 0,\\n \\"suggested_amount\\" INTEGER DEFAULT 0,\\n \\"features\\" TEXT DEFAULT '[]',\\n \\"thresholds\\" TEXT DEFAULT '[]'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"plan_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plans","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"plan_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"version":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"effective_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"price_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"billing_interval":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"pricing_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed"},"minimum_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"suggested_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"features":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"thresholds":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"}},"indexes":[{"name":"_smrt_subscription_plan_versions_plan_id_version_idx","columns":["plan_id","version"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_subscription_plan_versions_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_subscription_plan_versions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"f610e477"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:TenantSubscription":{"name":"tenantsubscription","className":"TenantSubscription","qualifiedName":"@happyvertical/smrt-subscriptions:TenantSubscription","collection":"tenantsubscriptions","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/TenantSubscription.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"subscriberKind":{"type":"text","required":false,"default":"tenant","description":"Whether the subscriber is your own workspace (tenant) or an outside customer (external).","_meta":{"description":"Whether the subscriber is your own workspace (tenant) or an outside customer (external)."},"enum":["tenant","external"]},"subscriberExternalId":{"type":"text","required":false,"default":"","description":"Who the outside subscriber is, when the subscriber type is external.","_meta":{"description":"Who the outside subscriber is, when the subscriber type is external."}},"planId":{"type":"foreignKey","required":false,"related":"SubscriptionPlan","description":"The plan this subscription is for.","_meta":{"description":"The plan this subscription is for."}},"status":{"type":"text","required":false,"default":"incomplete","description":"Where the subscription stands: incomplete, trialing, active, past due, unpaid or cancelled.","_meta":{"description":"Where the subscription stands: incomplete, trialing, active, past due, unpaid or cancelled."},"enum":["active","canceled","incomplete","past_due","trialing","unpaid"]},"startedAt":{"type":"datetime","required":false,"description":"The day the subscription began.","_meta":{"description":"The day the subscription began."}},"currentPeriodStart":{"type":"datetime","required":false,"description":"When the current billing period began.","_meta":{"description":"When the current billing period began."}},"currentPeriodEnd":{"type":"datetime","required":false,"description":"When the current billing period ends and the next one is due.","_meta":{"description":"When the current billing period ends and the next one is due."}},"trialEndsAt":{"type":"datetime","required":false,"description":"When the free trial ends, if there is one.","_meta":{"description":"When the free trial ends, if there is one."}},"cancelAtPeriodEnd":{"type":"boolean","required":false,"default":false,"description":"Tick to let the subscription run out at the end of the current period instead of renewing.","_meta":{"description":"Tick to let the subscription run out at the end of the current period instead of renewing."}},"canceledAt":{"type":"datetime","required":false,"description":"When the subscription was cancelled.","_meta":{"description":"When the subscription was cancelled."}},"agreedAmount":{"type":"integer","required":false,"description":"For a pay-what-you-can plan, the amount the subscriber chose to pay, in cents.","_meta":{"description":"For a pay-what-you-can plan, the amount the subscriber chose to pay, in cents."}},"planVersionId":{"type":"foreignKey","required":false,"related":"SubscriptionPlanVersion","description":"The version of the plan terms this subscription is held to for the current period. It is kept up to date automatically.","_meta":{"description":"The version of the plan terms this subscription is held to for the current period. It is kept up to date automatically."}},"planVersionPinnedAt":{"type":"datetime","required":false},"planVersionPinReason":{"type":"text","required":false,"enum":["period_start","renewal","upgrade","authorized","migration"]},"planVersionPinNote":{"type":"text","required":false,"default":""},"retainsPaidPeriod":{"type":"boolean","required":false,"default":false},"externalProvider":{"type":"text","required":false},"stripeCustomerId":{"type":"text","required":false,"default":""},"stripeSubscriptionId":{"type":"text","required":false,"default":""},"stripeCheckoutSessionId":{"type":"text","required":false,"default":""},"metadata":{"type":"text","required":false,"default":"{}"}},"methods":{"replacePlanVersion":{"name":"replacePlanVersion","async":true,"parameters":[{"name":"options","type":"any","optional":false,"typeUnresolved":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isEntitled":{"name":"isEntitled","async":false,"parameters":[{"name":"now","type":"any","optional":true}],"returnType":"boolean","isStatic":false,"isPublic":true},"getSubscriber":{"name":"getSubscriber","async":false,"parameters":[],"returnType":"Subscriber | null","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"JsonObject","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"metadata","type":"JsonObject","optional":false}],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_tenant_subscriptions","api":{"include":["list","get","create","update"]},"cli":{"skipApiCheck":true},"mcp":{"include":["list","get"]},"conflictColumns":["tenant_id","subscriber_kind","subscriber_external_id"],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"TenantSubscription","collectionExportName":"TenantSubscriptionCollection","validationRules":[],"schema":{"tableName":"_smrt_tenant_subscriptions","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_subscriptions\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"plan_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'incomplete',\\n \\"started_at\\" TIMESTAMP,\\n \\"current_period_start\\" TIMESTAMP,\\n \\"current_period_end\\" TIMESTAMP,\\n \\"trial_ends_at\\" TIMESTAMP,\\n \\"cancel_at_period_end\\" BOOLEAN DEFAULT FALSE,\\n \\"canceled_at\\" TIMESTAMP,\\n \\"agreed_amount\\" INTEGER,\\n \\"plan_version_id\\" UUID,\\n \\"plan_version_pinned_at\\" TIMESTAMP,\\n \\"plan_version_pin_reason\\" TEXT,\\n \\"plan_version_pin_note\\" TEXT DEFAULT '',\\n \\"retains_paid_period\\" BOOLEAN DEFAULT FALSE,\\n \\"external_provider\\" TEXT,\\n \\"stripe_customer_id\\" TEXT DEFAULT '',\\n \\"stripe_subscription_id\\" TEXT DEFAULT '',\\n \\"stripe_checkout_session_id\\" TEXT DEFAULT '',\\n \\"metadata\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"plan_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plans","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"incomplete"},"started_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"current_period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"current_period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"trial_ends_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"cancel_at_period_end":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"canceled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"agreed_amount":{"type":"INTEGER","notNull":false,"unique":false},"plan_version_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plan_versions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"plan_version_pinned_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"plan_version_pin_reason":{"type":"TEXT","notNull":false,"unique":false},"plan_version_pin_note":{"type":"TEXT","notNull":false,"unique":false,"default":""},"retains_paid_period":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"external_provider":{"type":"TEXT","notNull":false,"unique":false},"stripe_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"stripe_subscription_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"stripe_checkout_session_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metadata":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_tenant_subscriptions_tenant_id_subscriber_kind_idx","columns":["tenant_id","subscriber_kind","subscriber_external_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_tenant_subscriptions_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_tenant_subscriptions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_tenant_subscriptions_plan_id_idx","columns":["plan_id"]},{"name":"_smrt_tenant_subscriptions_plan_version_id_idx","columns":["plan_version_id"]}],"version":"328e412c"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:TenantUsageMetric":{"name":"tenantusagemetric","className":"TenantUsageMetric","qualifiedName":"@happyvertical/smrt-subscriptions:TenantUsageMetric","collection":"tenantusagemetrics","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/TenantUsageMetric.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"subscriberKind":{"type":"text","required":false,"default":"tenant","enum":["tenant","external"]},"subscriberExternalId":{"type":"text","required":false,"default":""},"metricKey":{"type":"text","required":false,"default":""},"quantity":{"type":"decimal","required":false,"default":0},"windowStart":{"type":"datetime","required":false},"windowEnd":{"type":"datetime","required":false},"source":{"type":"text","required":false,"default":""},"sourceId":{"type":"text","required":false,"default":""},"projectId":{"type":"text","required":false,"default":""},"workRefType":{"type":"text","required":false,"default":""},"workRefId":{"type":"text","required":false,"default":""},"provider":{"type":"text","required":false,"default":""},"dimensions":{"type":"text","required":false,"default":"{}"}},"methods":{"getSubscriber":{"name":"getSubscriber","async":false,"parameters":[],"returnType":"Subscriber | null","isStatic":false,"isPublic":true},"getDimensions":{"name":"getDimensions","async":false,"parameters":[],"returnType":"JsonObject","isStatic":false,"isPublic":true},"setDimensions":{"name":"setDimensions","async":false,"parameters":[{"name":"dimensions","type":"JsonObject","optional":false}],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_tenant_usage_metrics","api":{"include":["list","get","create"]},"cli":{"include":["list","get","create"]},"mcp":{"include":["list","get"]},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"TenantUsageMetric","collectionExportName":"TenantUsageMetricCollection","validationRules":[],"schema":{"tableName":"_smrt_tenant_usage_metrics","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_usage_metrics\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"window_start\\" TIMESTAMP,\\n \\"window_end\\" TIMESTAMP,\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"dimensions\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"window_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"window_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"dimensions":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_tenant_usage_metrics_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_tenant_usage_metrics_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"b799c746"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PricingRule":{"name":"pricingrule","className":"PricingRule","qualifiedName":"@happyvertical/smrt-subscriptions:PricingRule","collection":"pricingrules","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"ruleKey":{"type":"text","required":false,"default":""},"metricKey":{"type":"text","required":false,"default":""},"serviceKey":{"type":"text","required":false,"default":""},"strategy":{"type":"text","required":false,"default":"fixed_unit","enum":["fixed_unit","cost_plus","multiplier","tiered","included_overage","flat","custom"]},"currency":{"type":"text","required":false,"default":"USD"},"effectiveFrom":{"type":"datetime","required":false},"effectiveTo":{"type":"datetime","required":false},"priority":{"type":"integer","required":false,"default":0},"terms":{"type":"text","required":false,"default":"{}"},"active":{"type":"boolean","required":false,"default":true},"priceBookId":{"type":"foreignKey","required":false,"related":"PriceBook"}},"methods":{"getTerms":{"name":"getTerms","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setTerms":{"name":"setTerms","async":false,"parameters":[{"name":"value","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_pricing_rules","api":true,"cli":true,"mcp":true,"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"PricingRule","collectionExportName":"PricingRuleCollection","validationRules":[],"schema":{"tableName":"_smrt_pricing_rules","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_pricing_rules\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"rule_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"strategy\\" TEXT DEFAULT 'fixed_unit',\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"effective_from\\" TIMESTAMP,\\n \\"effective_to\\" TIMESTAMP,\\n \\"priority\\" INTEGER DEFAULT 0,\\n \\"terms\\" TEXT DEFAULT '{}',\\n \\"active\\" BOOLEAN DEFAULT TRUE,\\n \\"price_book_id\\" UUID\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"rule_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"strategy":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed_unit"},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"effective_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"effective_to":{"type":"TIMESTAMP","notNull":false,"unique":false},"priority":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"terms":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"_smrt_pricing_rules_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_pricing_rules_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_pricing_rules_price_book_id_idx","columns":["price_book_id"]}],"version":"65ce9b3f"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:ClientCharge":{"name":"clientcharge","className":"ClientCharge","qualifiedName":"@happyvertical/smrt-subscriptions:ClientCharge","collection":"clientcharges","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"usageEventId":{"type":"foreignKey","required":false,"related":"TenantUsageMetric"},"usageTenantId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-users:Tenant"},"subscriberKind":{"type":"text","required":false,"default":"tenant"},"subscriberExternalId":{"type":"text","required":false,"default":""},"projectId":{"type":"text","required":false,"default":""},"workRefType":{"type":"text","required":false,"default":""},"workRefId":{"type":"text","required":false,"default":""},"provider":{"type":"text","required":false,"default":"","description":"Who supplied the service that was used.","_meta":{"description":"Who supplied the service that was used."}},"serviceKey":{"type":"text","required":false,"default":"","description":"The service that was used.","_meta":{"description":"The service that was used."}},"metricKey":{"type":"text","required":false,"default":"","description":"What was used, such as messages sent or minutes of audio.","_meta":{"description":"What was used, such as messages sent or minutes of audio."}},"quantity":{"type":"decimal","required":false,"default":0,"description":"How much of it was used.","_meta":{"description":"How much of it was used."}},"amount":{"type":"integer","required":false,"default":0,"description":"What it cost, in cents.","_meta":{"description":"What it cost, in cents."}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency the amount is in, such as USD.","_meta":{"description":"The currency the amount is in, such as USD."}},"pricingRuleId":{"type":"foreignKey","required":false,"related":"PricingRule"},"priceBookId":{"type":"foreignKey","required":false,"related":"PriceBook"},"pricingSnapshot":{"type":"text","required":false,"default":"{}"},"status":{"type":"text","required":false,"default":"draft","description":"Where the charge stands: draft, approved or adjusted.","_meta":{"description":"Where the charge stands: draft, approved or adjusted."},"enum":["draft","approved","adjusted"]},"approvedAt":{"type":"datetime","required":false,"description":"When the charge was approved.","_meta":{"description":"When the charge was approved."}}},"methods":{"getPricingSnapshot":{"name":"getPricingSnapshot","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_client_charges","api":{"include":["list","get"]},"cli":{"include":["list","get"]},"mcp":{"include":["list","get"]},"conflictColumns":["usage_event_id"],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"ClientCharge","collectionExportName":"ClientChargeCollection","validationRules":[],"schema":{"tableName":"_smrt_client_charges","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_client_charges\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"usage_event_id\\" UUID,\\n \\"usage_tenant_id\\" UUID,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"pricing_rule_id\\" UUID,\\n \\"price_book_id\\" UUID,\\n \\"pricing_snapshot\\" TEXT DEFAULT '{}',\\n \\"status\\" TEXT DEFAULT 'draft',\\n \\"approved_at\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"usage_event_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_tenant_usage_metrics","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"usage_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"pricing_rule_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_pricing_rules","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_snapshot":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"draft"},"approved_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_client_charges_usage_event_id_idx","columns":["usage_event_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_client_charges_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_client_charges_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_client_charges_usage_tenant_id_idx","columns":["usage_tenant_id"]},{"name":"_smrt_client_charges_pricing_rule_id_idx","columns":["pricing_rule_id"]},{"name":"_smrt_client_charges_price_book_id_idx","columns":["price_book_id"]}],"version":"e542be95"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:BillingAdjustment":{"name":"billingadjustment","className":"BillingAdjustment","qualifiedName":"@happyvertical/smrt-subscriptions:BillingAdjustment","collection":"billingadjustments","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"clientChargeId":{"type":"foreignKey","required":false,"related":"ClientCharge"},"amount":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":"USD"},"reason":{"type":"text","required":false,"default":""},"source":{"type":"text","required":false,"default":""},"sourceId":{"type":"text","required":false,"default":""},"createdBy":{"type":"text","required":false,"default":""}},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_adjustments","api":{"include":["list","get"]},"cli":{"include":["list","get"]},"mcp":{"include":["list","get"]},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"BillingAdjustment","collectionExportName":"BillingAdjustmentCollection","validationRules":[],"schema":{"tableName":"_smrt_billing_adjustments","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_adjustments\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"client_charge_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"reason\\" TEXT DEFAULT '',\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"created_by\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"client_charge_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_client_charges","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"created_by":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_billing_adjustments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_billing_adjustments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_billing_adjustments_client_charge_id_idx","columns":["client_charge_id"]}],"version":"cded0b52"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:SpendingPolicy":{"name":"spendingpolicy","className":"SpendingPolicy","qualifiedName":"@happyvertical/smrt-subscriptions:SpendingPolicy","collection":"spendingpolicies","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"name":{"type":"text","required":false,"default":""},"subscriberKind":{"type":"text","required":false,"default":""},"subscriberExternalId":{"type":"text","required":false,"default":""},"projectId":{"type":"text","required":false,"default":""},"serviceKey":{"type":"text","required":false,"default":""},"metricKey":{"type":"text","required":false,"default":""},"period":{"type":"text","required":false,"default":"month","enum":["day","week","month","year","rolling","balance"]},"rollingSeconds":{"type":"integer","required":false,"default":0},"limitAmount":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":"USD"},"behavior":{"type":"text","required":false,"default":"observe","enum":["observe","warn","block","approval_required"]},"priority":{"type":"integer","required":false,"default":0},"active":{"type":"boolean","required":false,"default":true},"basis":{"type":"text","required":false,"default":"billed","enum":["billed","retail","wholesale"]},"setByTenantId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-users:Tenant"},"balanceFrom":{"type":"datetime","required":false}},"methods":{},"decoratorConfig":{"tableName":"_smrt_spending_policies","conflictColumns":["tenant_id","subscriber_kind","subscriber_external_id","project_id","service_key","metric_key","period","name"],"api":true,"cli":true,"mcp":true,"hooks":{"beforeDelete":"assertDelegationAuthority"},"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"SpendingPolicy","collectionExportName":"SpendingPolicyCollection","displayLabelField":"name","validationRules":[],"schema":{"tableName":"_smrt_spending_policies","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_spending_policies\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"name\\" TEXT DEFAULT '',\\n \\"subscriber_kind\\" TEXT DEFAULT '',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"period\\" TEXT DEFAULT 'month',\\n \\"rolling_seconds\\" INTEGER DEFAULT 0,\\n \\"limit_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"behavior\\" TEXT DEFAULT 'observe',\\n \\"priority\\" INTEGER DEFAULT 0,\\n \\"active\\" BOOLEAN DEFAULT TRUE,\\n \\"basis\\" TEXT DEFAULT 'billed',\\n \\"set_by_tenant_id\\" UUID,\\n \\"balance_from\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"period":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"rolling_seconds":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"limit_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"behavior":{"type":"TEXT","notNull":false,"unique":false,"default":"observe"},"priority":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"basis":{"type":"TEXT","notNull":false,"unique":false,"default":"billed"},"set_by_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"balance_from":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_spending_policies_tenant_id_subscriber_kind_idx","columns":["tenant_id","subscriber_kind","subscriber_external_id","project_id","service_key","metric_key","period","name"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_spending_policies_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_spending_policies_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_spending_policies_set_by_tenant_id_idx","columns":["set_by_tenant_id"]}],"version":"c4ac2f49"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PricingRuleCollection":{"name":"pricingrulecollection","className":"PricingRuleCollection","qualifiedName":"@happyvertical/smrt-subscriptions:PricingRuleCollection","collection":"pricingrules","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_pricing_rules"},"extends":"SmrtCollection","extendsTypeArg":"PricingRule","exportName":"PricingRuleCollection","collectionExportName":"PricingRuleCollectionCollection","schema":{"tableName":"_smrt_pricing_rules","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_pricing_rules\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"rule_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"strategy\\" TEXT DEFAULT 'fixed_unit',\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"effective_from\\" TIMESTAMP,\\n \\"effective_to\\" TIMESTAMP,\\n \\"priority\\" INTEGER DEFAULT 0,\\n \\"terms\\" TEXT DEFAULT '{}',\\n \\"active\\" BOOLEAN DEFAULT TRUE,\\n \\"price_book_id\\" UUID\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"rule_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"strategy":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed_unit"},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"effective_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"effective_to":{"type":"TIMESTAMP","notNull":false,"unique":false},"priority":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"terms":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"_smrt_pricing_rules_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_pricing_rules_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_pricing_rules_price_book_id_idx","columns":["price_book_id"]}],"version":"65ce9b3f"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:ClientChargeCollection":{"name":"clientchargecollection","className":"ClientChargeCollection","qualifiedName":"@happyvertical/smrt-subscriptions:ClientChargeCollection","collection":"clientcharges","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_client_charges","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"ClientCharge","exportName":"ClientChargeCollection","collectionExportName":"ClientChargeCollectionCollection","schema":{"tableName":"_smrt_client_charges","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_client_charges\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"usage_event_id\\" UUID,\\n \\"usage_tenant_id\\" UUID,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"pricing_rule_id\\" UUID,\\n \\"price_book_id\\" UUID,\\n \\"pricing_snapshot\\" TEXT DEFAULT '{}',\\n \\"status\\" TEXT DEFAULT 'draft',\\n \\"approved_at\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"usage_event_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_tenant_usage_metrics","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"usage_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"pricing_rule_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_pricing_rules","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_snapshot":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"draft"},"approved_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_client_charges_usage_event_id_idx","columns":["usage_event_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_client_charges_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_client_charges_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_client_charges_usage_tenant_id_idx","columns":["usage_tenant_id"]},{"name":"_smrt_client_charges_pricing_rule_id_idx","columns":["pricing_rule_id"]},{"name":"_smrt_client_charges_price_book_id_idx","columns":["price_book_id"]}],"version":"e542be95"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:BillingAdjustmentCollection":{"name":"billingadjustmentcollection","className":"BillingAdjustmentCollection","qualifiedName":"@happyvertical/smrt-subscriptions:BillingAdjustmentCollection","collection":"billingadjustments","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_adjustments","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"BillingAdjustment","exportName":"BillingAdjustmentCollection","collectionExportName":"BillingAdjustmentCollectionCollection","schema":{"tableName":"_smrt_billing_adjustments","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_adjustments\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"client_charge_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"reason\\" TEXT DEFAULT '',\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"created_by\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"client_charge_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_client_charges","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"created_by":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_billing_adjustments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_billing_adjustments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_billing_adjustments_client_charge_id_idx","columns":["client_charge_id"]}],"version":"cded0b52"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:SpendingPolicyCollection":{"name":"spendingpolicycollection","className":"SpendingPolicyCollection","qualifiedName":"@happyvertical/smrt-subscriptions:SpendingPolicyCollection","collection":"spendingpolicies","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_spending_policies"},"extends":"SmrtCollection","extendsTypeArg":"SpendingPolicy","exportName":"SpendingPolicyCollection","collectionExportName":"SpendingPolicyCollectionCollection","schema":{"tableName":"_smrt_spending_policies","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_spending_policies\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"name\\" TEXT DEFAULT '',\\n \\"subscriber_kind\\" TEXT DEFAULT '',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"period\\" TEXT DEFAULT 'month',\\n \\"rolling_seconds\\" INTEGER DEFAULT 0,\\n \\"limit_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"behavior\\" TEXT DEFAULT 'observe',\\n \\"priority\\" INTEGER DEFAULT 0,\\n \\"active\\" BOOLEAN DEFAULT TRUE,\\n \\"basis\\" TEXT DEFAULT 'billed',\\n \\"set_by_tenant_id\\" UUID,\\n \\"balance_from\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"period":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"rolling_seconds":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"limit_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"behavior":{"type":"TEXT","notNull":false,"unique":false,"default":"observe"},"priority":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"basis":{"type":"TEXT","notNull":false,"unique":false,"default":"billed"},"set_by_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"balance_from":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_spending_policies_tenant_id_subscriber_kind_idx","columns":["tenant_id","subscriber_kind","subscriber_external_id","project_id","service_key","metric_key","period","name"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_spending_policies_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_spending_policies_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_spending_policies_set_by_tenant_id_idx","columns":["set_by_tenant_id"]}],"version":"c4ac2f49"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PriceBook":{"name":"pricebook","className":"PriceBook","qualifiedName":"@happyvertical/smrt-subscriptions:PriceBook","collection":"pricebooks","description":"A named set of prices published by one seller tenant. Its prices are ordinary PricingRule rows that carry this book's id and the same tenant; one rule per currency gives a price in several currencies.","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"bookKey":{"type":"text","required":false,"default":""},"name":{"type":"text","required":false,"default":""},"kind":{"type":"text","required":false,"default":"retail","enum":["wholesale","retail"]},"active":{"type":"boolean","required":false,"default":true}},"methods":{},"decoratorConfig":{"tableName":"_smrt_price_books","conflictColumns":["tenant_id","book_key"],"api":false,"cli":false,"mcp":false,"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"PriceBook","collectionExportName":"PriceBookCollection","displayLabelField":"name","validationRules":[],"schema":{"tableName":"_smrt_price_books","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_price_books\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"book_key\\" TEXT DEFAULT '',\\n \\"name\\" TEXT DEFAULT '',\\n \\"kind\\" TEXT DEFAULT 'retail',\\n \\"active\\" BOOLEAN DEFAULT TRUE\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"book_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"retail"},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true}},"indexes":[{"name":"_smrt_price_books_tenant_id_book_key_idx","columns":["tenant_id","book_key"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_price_books_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_price_books_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"c7e5f5e0"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PriceBookAssignment":{"name":"pricebookassignment","className":"PriceBookAssignment","qualifiedName":"@happyvertical/smrt-subscriptions:PriceBookAssignment","collection":"pricebookassignments","description":"Which price books rate one child tenant's usage, keyed like the tenancy billing relationship it belongs to (one row per child).","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"childTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"resellerTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"wholesalePriceBookId":{"type":"foreignKey","required":false,"related":"PriceBook"},"wholesaleCurrency":{"type":"text","required":false,"default":""},"retailPriceBookId":{"type":"foreignKey","required":false,"related":"PriceBook"},"retailCurrency":{"type":"text","required":false,"default":""}},"methods":{},"decoratorConfig":{"tableName":"_smrt_price_book_assignments","conflictColumns":["child_tenant_id"],"api":false,"cli":false,"mcp":false},"extends":"SmrtObject","exportName":"PriceBookAssignment","collectionExportName":"PriceBookAssignmentCollection","validationRules":[{"field":"childTenantId","rule":"required","fieldType":"crossPackageRef"},{"field":"resellerTenantId","rule":"required","fieldType":"crossPackageRef"}],"schema":{"tableName":"_smrt_price_book_assignments","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_price_book_assignments\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"child_tenant_id\\" UUID NOT NULL,\\n \\"reseller_tenant_id\\" UUID NOT NULL,\\n \\"wholesale_price_book_id\\" UUID,\\n \\"wholesale_currency\\" TEXT DEFAULT '',\\n \\"retail_price_book_id\\" UUID,\\n \\"retail_currency\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"child_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"reseller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"wholesale_price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"wholesale_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"retail_price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"retail_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_price_book_assignments_child_tenant_id_idx","columns":["child_tenant_id"],"unique":true},{"name":"_smrt_price_book_assignments_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_price_book_assignments_created_at_idx","columns":["created_at"]},{"name":"_smrt_price_book_assignments_reseller_tenant_id_idx","columns":["reseller_tenant_id"]},{"name":"_smrt_price_book_assignments_wholesale_price_book_id_idx","columns":["wholesale_price_book_id"]},{"name":"_smrt_price_book_assignments_retail_price_book_id_idx","columns":["retail_price_book_id"]}],"version":"f24f020e"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:RetailCharge":{"name":"retailcharge","className":"RetailCharge","qualifiedName":"@happyvertical/smrt-subscriptions:RetailCharge","collection":"retailcharges","description":"What a reseller charges one child for one usage event, priced from the reseller's retail book.","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"resellerTenantId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-users:Tenant"},"usageEventId":{"type":"foreignKey","required":false,"related":"TenantUsageMetric"},"clientChargeId":{"type":"foreignKey","required":false,"related":"ClientCharge"},"subscriberKind":{"type":"text","required":false,"default":"tenant"},"subscriberExternalId":{"type":"text","required":false,"default":""},"projectId":{"type":"text","required":false,"default":""},"workRefType":{"type":"text","required":false,"default":""},"workRefId":{"type":"text","required":false,"default":""},"provider":{"type":"text","required":false,"default":""},"serviceKey":{"type":"text","required":false,"default":""},"metricKey":{"type":"text","required":false,"default":""},"quantity":{"type":"decimal","required":false,"default":0},"amount":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":"USD"},"priceBookId":{"type":"foreignKey","required":false,"related":"PriceBook"},"pricingRuleId":{"type":"foreignKey","required":false,"related":"PricingRule"},"pricingSnapshot":{"type":"text","required":false,"default":"{}"},"status":{"type":"text","required":false,"default":"draft","enum":["draft","approved"]},"approvedAt":{"type":"datetime","required":false}},"methods":{"getPricingSnapshot":{"name":"getPricingSnapshot","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_retail_charges","api":{"include":["list","get"]},"cli":{"include":["list","get"]},"mcp":{"include":["list","get"]},"conflictColumns":["usage_event_id"],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"RetailCharge","collectionExportName":"RetailChargeCollection","validationRules":[],"schema":{"tableName":"_smrt_retail_charges","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_retail_charges\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"reseller_tenant_id\\" UUID,\\n \\"usage_event_id\\" UUID,\\n \\"client_charge_id\\" UUID,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"price_book_id\\" UUID,\\n \\"pricing_rule_id\\" UUID,\\n \\"pricing_snapshot\\" TEXT DEFAULT '{}',\\n \\"status\\" TEXT DEFAULT 'draft',\\n \\"approved_at\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"reseller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"usage_event_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_tenant_usage_metrics","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"client_charge_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_client_charges","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_rule_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_pricing_rules","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_snapshot":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"draft"},"approved_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_retail_charges_usage_event_id_idx","columns":["usage_event_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_retail_charges_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_retail_charges_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_retail_charges_reseller_tenant_id_idx","columns":["reseller_tenant_id"]},{"name":"_smrt_retail_charges_client_charge_id_idx","columns":["client_charge_id"]},{"name":"_smrt_retail_charges_price_book_id_idx","columns":["price_book_id"]},{"name":"_smrt_retail_charges_pricing_rule_id_idx","columns":["pricing_rule_id"]}],"version":"1c1ae3c8"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:CreditGrant":{"name":"creditgrant","className":"CreditGrant","qualifiedName":"@happyvertical/smrt-subscriptions:CreditGrant","collection":"creditgrants","description":"An append-only credit on a prepaid (period: 'balance') spending policy. Positive amounts add credit; a negative amount reverses an earlier grant.","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"spendingPolicyId":{"type":"foreignKey","required":false,"related":"SpendingPolicy"},"amount":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":"USD"},"reason":{"type":"text","required":false,"default":""},"source":{"type":"text","required":false,"default":""},"sourceId":{"type":"text","required":false,"default":""},"grantedByTenantId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-users:Tenant"}},"methods":{},"decoratorConfig":{"tableName":"_smrt_credit_grants","api":{"include":["list","get"]},"cli":{"include":["list","get"]},"mcp":{"include":["list","get"]},"hooks":{"beforeDelete":"refuseDelete"},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"CreditGrant","collectionExportName":"CreditGrantCollection","validationRules":[],"schema":{"tableName":"_smrt_credit_grants","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_credit_grants\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"spending_policy_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"reason\\" TEXT DEFAULT '',\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"granted_by_tenant_id\\" UUID\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"spending_policy_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_spending_policies","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"granted_by_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_credit_grants_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_credit_grants_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_credit_grants_spending_policy_id_idx","columns":["spending_policy_id"]},{"name":"_smrt_credit_grants_granted_by_tenant_id_idx","columns":["granted_by_tenant_id"]}],"version":"602c4e02"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PriceBookCollection":{"name":"pricebookcollection","className":"PriceBookCollection","qualifiedName":"@happyvertical/smrt-subscriptions:PriceBookCollection","collection":"pricebooks","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_price_books","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"PriceBook","exportName":"PriceBookCollection","collectionExportName":"PriceBookCollectionCollection","schema":{"tableName":"_smrt_price_books","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_price_books\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"book_key\\" TEXT DEFAULT '',\\n \\"name\\" TEXT DEFAULT '',\\n \\"kind\\" TEXT DEFAULT 'retail',\\n \\"active\\" BOOLEAN DEFAULT TRUE\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"book_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"retail"},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true}},"indexes":[{"name":"_smrt_price_books_tenant_id_book_key_idx","columns":["tenant_id","book_key"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_price_books_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_price_books_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"c7e5f5e0"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PriceBookAssignmentCollection":{"name":"pricebookassignmentcollection","className":"PriceBookAssignmentCollection","qualifiedName":"@happyvertical/smrt-subscriptions:PriceBookAssignmentCollection","collection":"pricebookassignments","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_price_book_assignments","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"PriceBookAssignment","exportName":"PriceBookAssignmentCollection","collectionExportName":"PriceBookAssignmentCollectionCollection","schema":{"tableName":"_smrt_price_book_assignments","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_price_book_assignments\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"child_tenant_id\\" UUID NOT NULL,\\n \\"reseller_tenant_id\\" UUID NOT NULL,\\n \\"wholesale_price_book_id\\" UUID,\\n \\"wholesale_currency\\" TEXT DEFAULT '',\\n \\"retail_price_book_id\\" UUID,\\n \\"retail_currency\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"child_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"reseller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"wholesale_price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"wholesale_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"retail_price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"retail_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_price_book_assignments_child_tenant_id_idx","columns":["child_tenant_id"],"unique":true},{"name":"_smrt_price_book_assignments_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_price_book_assignments_created_at_idx","columns":["created_at"]},{"name":"_smrt_price_book_assignments_reseller_tenant_id_idx","columns":["reseller_tenant_id"]},{"name":"_smrt_price_book_assignments_wholesale_price_book_id_idx","columns":["wholesale_price_book_id"]},{"name":"_smrt_price_book_assignments_retail_price_book_id_idx","columns":["retail_price_book_id"]}],"version":"f24f020e"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:RetailChargeCollection":{"name":"retailchargecollection","className":"RetailChargeCollection","qualifiedName":"@happyvertical/smrt-subscriptions:RetailChargeCollection","collection":"retailcharges","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_retail_charges","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"RetailCharge","exportName":"RetailChargeCollection","collectionExportName":"RetailChargeCollectionCollection","schema":{"tableName":"_smrt_retail_charges","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_retail_charges\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"reseller_tenant_id\\" UUID,\\n \\"usage_event_id\\" UUID,\\n \\"client_charge_id\\" UUID,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"price_book_id\\" UUID,\\n \\"pricing_rule_id\\" UUID,\\n \\"pricing_snapshot\\" TEXT DEFAULT '{}',\\n \\"status\\" TEXT DEFAULT 'draft',\\n \\"approved_at\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"reseller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"usage_event_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_tenant_usage_metrics","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"client_charge_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_client_charges","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_rule_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_pricing_rules","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_snapshot":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"draft"},"approved_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_retail_charges_usage_event_id_idx","columns":["usage_event_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_retail_charges_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_retail_charges_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_retail_charges_reseller_tenant_id_idx","columns":["reseller_tenant_id"]},{"name":"_smrt_retail_charges_client_charge_id_idx","columns":["client_charge_id"]},{"name":"_smrt_retail_charges_price_book_id_idx","columns":["price_book_id"]},{"name":"_smrt_retail_charges_pricing_rule_id_idx","columns":["pricing_rule_id"]}],"version":"1c1ae3c8"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:CreditGrantCollection":{"name":"creditgrantcollection","className":"CreditGrantCollection","qualifiedName":"@happyvertical/smrt-subscriptions:CreditGrantCollection","collection":"creditgrants","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_credit_grants","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"CreditGrant","exportName":"CreditGrantCollection","collectionExportName":"CreditGrantCollectionCollection","schema":{"tableName":"_smrt_credit_grants","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_credit_grants\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"spending_policy_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"reason\\" TEXT DEFAULT '',\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"granted_by_tenant_id\\" UUID\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"spending_policy_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_spending_policies","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"granted_by_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_credit_grants_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_credit_grants_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_credit_grants_spending_policy_id_idx","columns":["spending_policy_id"]},{"name":"_smrt_credit_grants_granted_by_tenant_id_idx","columns":["granted_by_tenant_id"]}],"version":"602c4e02"},"importPath":"@happyvertical/smrt-subscriptions"}},"moduleType":"smrt","recipes":[{"id":"subscriptions.plans","className":"SubscriptionPlansRecipe","label":"Subscriptions","summary":"Sell plans that renew, see who is subscribed to which, and what their usage cost.","synonyms":["subscriptions","subscription plans","plans","memberships","recurring billing","pricing tiers"],"models":["@happyvertical/smrt-subscriptions:SubscriptionPlan","@happyvertical/smrt-subscriptions:SubscriptionPlanVersion","@happyvertical/smrt-subscriptions:TenantSubscription","@happyvertical/smrt-subscriptions:ClientCharge"],"nav":[{"label":"Plans","model":"@happyvertical/smrt-subscriptions:SubscriptionPlan","icon":"tag","description":"The plans you sell, with their price and how often they bill.","noun":"plan"},{"label":"Subscriptions","model":"@happyvertical/smrt-subscriptions:TenantSubscription","icon":"repeat","description":"Who is subscribed to which plan, and where each one stands.","noun":"subscription"},{"label":"Plan versions","model":"@happyvertical/smrt-subscriptions:SubscriptionPlanVersion","icon":"fileText","description":"Every set of terms a plan has had, and from when each applied.","noun":"plan version"},{"label":"Charges","model":"@happyvertical/smrt-subscriptions:ClientCharge","icon":"receipt","description":"What each subscriber used and what it cost them.","noun":"charge"}],"requires":[],"section":{"id":"sales","label":"Sales","icon":"shoppingBag","description":"Customers, orders and quotes: everything you sell."},"options":{"@happyvertical/smrt-subscriptions:SubscriptionPlan":{"fields":{"name":{"order":1},"planKey":{"label":"Plan code","order":2},"description":{"order":3},"status":{"order":4},"priceAmount":{"label":"Price (in cents)","order":5},"currency":{"order":6},"billingInterval":{"label":"Billed every","order":7},"pricingMode":{"label":"How it is priced","order":8},"minimumAmount":{"label":"Minimum (in cents)","visibility":"advanced"},"suggestedAmount":{"label":"Suggested (in cents)","visibility":"advanced"},"sortOrder":{"label":"Position in list","visibility":"advanced"},"tenantId":{"visibility":"hidden"},"features":{"visibility":"hidden"},"thresholds":{"visibility":"hidden"},"externalProvider":{"visibility":"hidden"},"providerProductId":{"visibility":"hidden"},"providerPriceId":{"visibility":"hidden"},"stripeProductId":{"visibility":"hidden"},"stripePriceId":{"visibility":"hidden"},"metadata":{"visibility":"hidden"}}},"@happyvertical/smrt-subscriptions:SubscriptionPlanVersion":{"fields":{"planId":{"label":"Plan","order":1},"version":{"label":"Version number","order":2},"effectiveFrom":{"label":"In force from","order":3},"name":{"order":4},"status":{"order":5},"priceAmount":{"label":"Price (in cents)","order":6},"currency":{"order":7},"billingInterval":{"label":"Billed every","order":8},"planKey":{"label":"Plan code","visibility":"advanced"},"pricingMode":{"label":"How it is priced","visibility":"advanced"},"minimumAmount":{"label":"Minimum (in cents)","visibility":"advanced"},"suggestedAmount":{"label":"Suggested (in cents)","visibility":"advanced"},"tenantId":{"visibility":"hidden"},"features":{"visibility":"hidden"},"thresholds":{"visibility":"hidden"}}},"@happyvertical/smrt-subscriptions:TenantSubscription":{"fields":{"planId":{"label":"Plan","order":1},"status":{"order":2},"startedAt":{"label":"Started on","order":3},"currentPeriodStart":{"label":"Current period starts","order":4},"currentPeriodEnd":{"label":"Current period ends","order":5},"trialEndsAt":{"label":"Trial ends","order":6},"cancelAtPeriodEnd":{"label":"Cancel at end of period","order":7},"canceledAt":{"label":"Cancelled on","visibility":"advanced"},"agreedAmount":{"label":"Agreed amount (in cents)","visibility":"advanced"},"subscriberKind":{"label":"Subscriber type","visibility":"advanced"},"subscriberExternalId":{"label":"Outside subscriber","visibility":"advanced"},"planVersionId":{"label":"Plan version","visibility":"advanced","locked":true},"tenantId":{"visibility":"hidden"},"planVersionPinnedAt":{"visibility":"hidden"},"planVersionPinReason":{"visibility":"hidden"},"planVersionPinNote":{"visibility":"hidden"},"retainsPaidPeriod":{"visibility":"hidden"},"externalProvider":{"visibility":"hidden"},"stripeCustomerId":{"visibility":"hidden"},"stripeSubscriptionId":{"visibility":"hidden"},"stripeCheckoutSessionId":{"visibility":"hidden"},"metadata":{"visibility":"hidden"}}},"@happyvertical/smrt-subscriptions:ClientCharge":{"fields":{"metricKey":{"label":"What was used","order":1},"quantity":{"label":"How much","order":2},"amount":{"label":"Amount (in cents)","order":3},"currency":{"order":4},"status":{"order":5},"approvedAt":{"label":"Approved on","order":6},"serviceKey":{"label":"Service","visibility":"advanced"},"provider":{"visibility":"advanced"},"tenantId":{"visibility":"hidden"},"usageEventId":{"visibility":"hidden"},"usageTenantId":{"visibility":"hidden"},"subscriberKind":{"visibility":"hidden"},"subscriberExternalId":{"visibility":"hidden"},"projectId":{"visibility":"hidden"},"workRefType":{"visibility":"hidden"},"workRefId":{"visibility":"hidden"},"pricingRuleId":{"visibility":"hidden"},"priceBookId":{"visibility":"hidden"},"pricingSnapshot":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nSubscriptions is where you sell plans that renew. A plan says what it costs,\\nhow often it bills and whether it is free, a fixed price or pay what you can.\\nA subscription joins a subscriber to a plan and shows where it stands, from\\ntrial to active to cancelled. Every time you change a plan's terms, the\\nearlier terms are kept as a plan version, so a subscriber who already paid for\\na period keeps what they paid for until it renews. Charges show what each\\nsubscriber used and what it cost them.\\n\\nAll amounts are whole numbers of cents, with no decimal point.\\n\\n## Tasks\\n\\n### Set up a plan\\n\\n1. Open the plans and choose **New**.\\n2. Type the **{field:SubscriptionPlan.name}** customers will see and a short **{field:SubscriptionPlan.planKey}** such as \\"starter\\".\\n3. Choose **{field:SubscriptionPlan.pricingMode}**: free, a fixed price, or pay what you can. This cannot change once the plan is saved; make a new plan instead.\\n4. For a fixed price, enter the **{field:SubscriptionPlan.priceAmount}** in cents and the **{field:SubscriptionPlan.currency}**.\\n5. Set how often it bills in **{field:SubscriptionPlan.billingInterval}**.\\n6. Set the **{field:SubscriptionPlan.status}** to active when it is ready to sell.\\n7. Save.\\n\\n### Change a plan's price or terms\\n\\n1. Open the plan and edit the **{field:SubscriptionPlan.priceAmount}**, **{field:SubscriptionPlan.billingInterval}** or **{field:SubscriptionPlan.status}**.\\n2. Save. The new terms apply to new subscribers and to existing ones from their next renewal; a period already paid for keeps its old terms.\\n\\n### Retire a plan\\n\\n1. Open the plan and set its **{field:SubscriptionPlan.status}** to archived.\\n2. Save. No one new can subscribe to it; existing subscribers keep going until they cancel.\\n\\n### Subscribe someone to a plan\\n\\n1. Open the subscriptions and choose **New**.\\n2. Pick the **{field:TenantSubscription.planId}**.\\n3. Enter the day it **{field:TenantSubscription.startedAt}** and, if there is a free trial, when the **{field:TenantSubscription.trialEndsAt}**.\\n4. Save. The **{field:TenantSubscription.status}** shows where the subscription stands once it has been paid for.\\n\\n### See where a subscription stands\\n\\n1. Open the subscriptions and find the one you want.\\n2. The **{field:TenantSubscription.status}** shows whether it is still incomplete, on trial, active, past due, unpaid or cancelled.\\n3. **{field:TenantSubscription.currentPeriodStart}** and **{field:TenantSubscription.currentPeriodEnd}** show the period that has been paid for.\\n\\n### Cancel a subscription\\n\\n1. Open the subscription.\\n2. Tick **{field:TenantSubscription.cancelAtPeriodEnd}** so it runs out when the current period ends instead of renewing.\\n3. Save.\\n\\n### Look up the terms a subscriber was sold\\n\\nPlan versions are written automatically whenever a plan is saved with changed\\nterms; you cannot add or edit them here.\\n\\n1. Open the plan versions and find the **{field:SubscriptionPlanVersion.planId}** you are interested in.\\n2. Each row shows the **{field:SubscriptionPlanVersion.version}** and the date it was **{field:SubscriptionPlanVersion.effectiveFrom}**.\\n3. Read the **{field:SubscriptionPlanVersion.priceAmount}**, **{field:SubscriptionPlanVersion.currency}** and **{field:SubscriptionPlanVersion.billingInterval}** that applied under it.\\n\\n### See what a subscriber was charged\\n\\nCharges are created by the usage and billing service as usage is recorded;\\nyou cannot add or edit them here.\\n\\n1. Open the charges.\\n2. Each row shows **{field:ClientCharge.metricKey}**, **{field:ClientCharge.quantity}** and the **{field:ClientCharge.amount}** in cents.\\n3. The **{field:ClientCharge.status}** shows whether the charge is still a draft, approved or adjusted.\\n","fieldRefs":["ClientCharge.amount","ClientCharge.metricKey","ClientCharge.quantity","ClientCharge.status","SubscriptionPlan.billingInterval","SubscriptionPlan.currency","SubscriptionPlan.name","SubscriptionPlan.planKey","SubscriptionPlan.priceAmount","SubscriptionPlan.pricingMode","SubscriptionPlan.status","SubscriptionPlanVersion.billingInterval","SubscriptionPlanVersion.currency","SubscriptionPlanVersion.effectiveFrom","SubscriptionPlanVersion.planId","SubscriptionPlanVersion.priceAmount","SubscriptionPlanVersion.version","TenantSubscription.cancelAtPeriodEnd","TenantSubscription.currentPeriodEnd","TenantSubscription.currentPeriodStart","TenantSubscription.planId","TenantSubscription.startedAt","TenantSubscription.status","TenantSubscription.trialEndsAt"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: core migrations (node:crypto, node:os); and its package depends on @happyvertical/smrt-tenancy, which do not build for a browser (#3624, #3626)."]}}],"smrtDependencies":["@happyvertical/smrt-core","@happyvertical/smrt-tenancy"],"browser":{"status":"server-only","issues":["#3624","#3626"],"reason":"core migrations (node:crypto, node:os)","via":["@happyvertical/smrt-tenancy"]},"stampsConstructors":true}`));
|
|
10
|
+
ObjectRegistry.registerPackageManifest(JSON.parse(`{"version":"1.0.0","timestamp":0,"packageName":"@happyvertical/smrt-subscriptions","packageVersion":"0.57.47","objects":{"@happyvertical/smrt-subscriptions:SubscriptionPlanCollection":{"name":"subscriptionplancollection","className":"SubscriptionPlanCollection","qualifiedName":"@happyvertical/smrt-subscriptions:SubscriptionPlanCollection","collection":"subscriptionplans","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/collections/SubscriptionPlanCollection.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{"findByPlanKey":{"name":"findByPlanKey","async":true,"parameters":[{"name":"tenantId","type":"string | null","optional":false,"unionBranches":[{"type":"string"},{"type":"null"}]},{"name":"planKey","type":"string","optional":false}],"returnType":"Promise<SubscriptionPlan | null>","isStatic":false,"isPublic":true},"findActive":{"name":"findActive","async":true,"parameters":[],"returnType":"Promise<SubscriptionPlan[]>","isStatic":false,"isPublic":true},"findByProviderPriceId":{"name":"findByProviderPriceId","async":true,"parameters":[{"name":"providerPriceId","type":"string","optional":false}],"returnType":"Promise<SubscriptionPlan | null>","isStatic":false,"isPublic":true},"findByStripePriceId":{"name":"findByStripePriceId","async":true,"parameters":[{"name":"stripePriceId","type":"string","optional":false}],"returnType":"Promise<SubscriptionPlan | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_subscription_plans","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"SubscriptionPlan","exportName":"SubscriptionPlanCollection","collectionExportName":"SubscriptionPlanCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:SubscriptionPlan","inheritedExposure":["api","mcp"],"schema":{"tableName":"_smrt_subscription_plans","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_subscription_plans\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"plan_key\\" TEXT DEFAULT '',\\n \\"name\\" TEXT DEFAULT '',\\n \\"description\\" TEXT DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"sort_order\\" INTEGER DEFAULT 0,\\n \\"price_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"billing_interval\\" TEXT DEFAULT 'month',\\n \\"pricing_mode\\" TEXT DEFAULT 'fixed',\\n \\"minimum_amount\\" INTEGER DEFAULT 0,\\n \\"suggested_amount\\" INTEGER DEFAULT 0,\\n \\"external_provider\\" TEXT,\\n \\"provider_product_id\\" TEXT,\\n \\"provider_price_id\\" TEXT,\\n \\"stripe_product_id\\" TEXT,\\n \\"stripe_price_id\\" TEXT,\\n \\"features\\" TEXT DEFAULT '[]',\\n \\"thresholds\\" TEXT DEFAULT '[]',\\n \\"metadata\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"plan_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"sort_order":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"price_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"billing_interval":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"pricing_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed"},"minimum_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"suggested_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"external_provider":{"type":"TEXT","notNull":false,"unique":false},"provider_product_id":{"type":"TEXT","notNull":false,"unique":false},"provider_price_id":{"type":"TEXT","notNull":false,"unique":false},"stripe_product_id":{"type":"TEXT","notNull":false,"unique":false},"stripe_price_id":{"type":"TEXT","notNull":false,"unique":false},"features":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"thresholds":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"metadata":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_subscription_plans_tenant_id_plan_key_idx","columns":["tenant_id","plan_key"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_subscription_plans_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_subscription_plans_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"02602c74"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:SubscriptionPlanVersionCollection":{"name":"subscriptionplanversioncollection","className":"SubscriptionPlanVersionCollection","qualifiedName":"@happyvertical/smrt-subscriptions:SubscriptionPlanVersionCollection","collection":"subscriptionplanversions","description":"Effective-dated plan versions (#4032).","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/collections/SubscriptionPlanVersionCollection.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{"findVisibleById":{"name":"findVisibleById","async":true,"parameters":[{"name":"id","type":"string","optional":false}],"returnType":"Promise<SubscriptionPlanVersion | null>","isStatic":false,"isPublic":true},"listForPlan":{"name":"listForPlan","async":true,"parameters":[{"name":"planId","type":"string","optional":false}],"returnType":"Promise<SubscriptionPlanVersion[]>","isStatic":false,"isPublic":true},"findLatest":{"name":"findLatest","async":true,"parameters":[{"name":"planId","type":"string","optional":false},{"name":"tenantId","type":"string | null","optional":true,"unionBranches":[{"type":"string"},{"type":"null"}]}],"returnType":"Promise<SubscriptionPlanVersion | null>","isStatic":false,"isPublic":true},"findInForce":{"name":"findInForce","async":true,"parameters":[{"name":"planId","type":"string","optional":false},{"name":"at","type":"Date","optional":false}],"returnType":"Promise<SubscriptionPlanVersion | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_subscription_plan_versions","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"SubscriptionPlanVersion","exportName":"SubscriptionPlanVersionCollection","collectionExportName":"SubscriptionPlanVersionCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:SubscriptionPlanVersion","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_subscription_plan_versions","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_subscription_plan_versions\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"plan_id\\" UUID,\\n \\"plan_key\\" TEXT DEFAULT '',\\n \\"version\\" INTEGER DEFAULT 0,\\n \\"effective_from\\" TIMESTAMP,\\n \\"name\\" TEXT DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"price_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"billing_interval\\" TEXT DEFAULT 'month',\\n \\"pricing_mode\\" TEXT DEFAULT 'fixed',\\n \\"minimum_amount\\" INTEGER DEFAULT 0,\\n \\"suggested_amount\\" INTEGER DEFAULT 0,\\n \\"features\\" TEXT DEFAULT '[]',\\n \\"thresholds\\" TEXT DEFAULT '[]'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"plan_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plans","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"plan_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"version":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"effective_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"price_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"billing_interval":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"pricing_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed"},"minimum_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"suggested_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"features":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"thresholds":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"}},"indexes":[{"name":"_smrt_subscription_plan_versions_plan_id_version_idx","columns":["plan_id","version"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_subscription_plan_versions_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_subscription_plan_versions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"f610e477"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:TenantSubscriptionCollection":{"name":"tenantsubscriptioncollection","className":"TenantSubscriptionCollection","qualifiedName":"@happyvertical/smrt-subscriptions:TenantSubscriptionCollection","collection":"tenantsubscriptions","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/collections/TenantSubscriptionCollection.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{"findByTenant":{"name":"findByTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false}],"returnType":"Promise<TenantSubscription[]>","isStatic":false,"isPublic":true},"findCurrentForTenant":{"name":"findCurrentForTenant","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false},{"name":"now","type":"any","optional":true}],"returnType":"Promise<TenantSubscription | null>","isStatic":false,"isPublic":true},"findCurrentForSubscriber":{"name":"findCurrentForSubscriber","async":true,"parameters":[{"name":"subscriber","type":"Subscriber","optional":false},{"name":"now","type":"any","optional":true}],"returnType":"Promise<TenantSubscription | null>","isStatic":false,"isPublic":true},"findByStripeSubscriptionId":{"name":"findByStripeSubscriptionId","async":true,"parameters":[{"name":"stripeSubscriptionId","type":"string","optional":false}],"returnType":"Promise<TenantSubscription | null>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_tenant_subscriptions","api":{"include":["list","get","create","update"]},"mcp":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"TenantSubscription","exportName":"TenantSubscriptionCollection","collectionExportName":"TenantSubscriptionCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:TenantSubscription","inheritedExposure":["api","mcp"],"schema":{"tableName":"_smrt_tenant_subscriptions","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_subscriptions\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"plan_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'incomplete',\\n \\"started_at\\" TIMESTAMP,\\n \\"current_period_start\\" TIMESTAMP,\\n \\"current_period_end\\" TIMESTAMP,\\n \\"trial_ends_at\\" TIMESTAMP,\\n \\"cancel_at_period_end\\" BOOLEAN DEFAULT FALSE,\\n \\"canceled_at\\" TIMESTAMP,\\n \\"agreed_amount\\" INTEGER,\\n \\"plan_version_id\\" UUID,\\n \\"plan_version_pinned_at\\" TIMESTAMP,\\n \\"plan_version_pin_reason\\" TEXT,\\n \\"plan_version_pin_note\\" TEXT DEFAULT '',\\n \\"retains_paid_period\\" BOOLEAN DEFAULT FALSE,\\n \\"external_provider\\" TEXT,\\n \\"stripe_customer_id\\" TEXT DEFAULT '',\\n \\"stripe_subscription_id\\" TEXT DEFAULT '',\\n \\"stripe_checkout_session_id\\" TEXT DEFAULT '',\\n \\"metadata\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"plan_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plans","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"incomplete"},"started_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"current_period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"current_period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"trial_ends_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"cancel_at_period_end":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"canceled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"agreed_amount":{"type":"INTEGER","notNull":false,"unique":false},"plan_version_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plan_versions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"plan_version_pinned_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"plan_version_pin_reason":{"type":"TEXT","notNull":false,"unique":false},"plan_version_pin_note":{"type":"TEXT","notNull":false,"unique":false,"default":""},"retains_paid_period":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"external_provider":{"type":"TEXT","notNull":false,"unique":false},"stripe_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"stripe_subscription_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"stripe_checkout_session_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metadata":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_tenant_subscriptions_tenant_id_subscriber_kind_idx","columns":["tenant_id","subscriber_kind","subscriber_external_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_tenant_subscriptions_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_tenant_subscriptions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_tenant_subscriptions_plan_id_idx","columns":["plan_id"]},{"name":"_smrt_tenant_subscriptions_plan_version_id_idx","columns":["plan_version_id"]}],"version":"328e412c"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:TenantUsageMetricCollection":{"name":"tenantusagemetriccollection","className":"TenantUsageMetricCollection","qualifiedName":"@happyvertical/smrt-subscriptions:TenantUsageMetricCollection","collection":"tenantusagemetrics","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/collections/TenantUsageMetricCollection.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{"recordUsage":{"name":"recordUsage","async":true,"parameters":[{"name":"options","type":"RecordUsageOptions","optional":false}],"returnType":"Promise<TenantUsageMetric>","isStatic":false,"isPublic":true},"findByTenantAndMetric":{"name":"findByTenantAndMetric","async":true,"parameters":[{"name":"tenantId","type":"string","optional":false},{"name":"metricKey","type":"string","optional":false}],"returnType":"Promise<TenantUsageMetric[]>","isStatic":false,"isPublic":true},"summarizeUsage":{"name":"summarizeUsage","async":true,"parameters":[{"name":"options","type":"SummarizeUsageOptions","optional":false}],"returnType":"Promise<UsageSummary>","isStatic":false,"isPublic":true},"summarizeUsageBatch":{"name":"summarizeUsageBatch","async":true,"parameters":[{"name":"options","type":"SummarizeUsageBatchOptions","optional":false}],"returnType":"Promise<UsageSummary[]>","isStatic":false,"isPublic":true},"summarizeTenantAiUsage":{"name":"summarizeTenantAiUsage","async":true,"parameters":[{"name":"options","type":"SummarizeAiUsageOptions","optional":false}],"returnType":"Promise<AiUsageSummary>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_tenant_usage_metrics","api":{"include":["list","get","create"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get","create"]}},"extends":"SmrtCollection","extendsTypeArg":"TenantUsageMetric","exportName":"TenantUsageMetricCollection","collectionExportName":"TenantUsageMetricCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:TenantUsageMetric","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_tenant_usage_metrics","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_usage_metrics\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"window_start\\" TIMESTAMP,\\n \\"window_end\\" TIMESTAMP,\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"dimensions\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"window_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"window_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"dimensions":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_tenant_usage_metrics_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_tenant_usage_metrics_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"b799c746"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:SubscriptionPlan":{"name":"subscriptionplan","className":"SubscriptionPlan","qualifiedName":"@happyvertical/smrt-subscriptions:SubscriptionPlan","collection":"subscriptionplans","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/SubscriptionPlan.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":false,"_meta":{"sqlType":"UUID","nullable":true,"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false}}},"planKey":{"type":"text","required":false,"default":"","description":"A short code that identifies the plan, such as starter or pro.","_meta":{"description":"A short code that identifies the plan, such as starter or pro."}},"name":{"type":"text","required":false,"default":"","description":"What the plan is called, as customers see it.","_meta":{"description":"What the plan is called, as customers see it."}},"description":{"type":"text","required":false,"default":"","description":"A sentence or two about what the plan offers.","_meta":{"description":"A sentence or two about what the plan offers."}},"status":{"type":"text","required":false,"default":"active","description":"Whether the plan is a draft, on sale (active) or archived.","_meta":{"description":"Whether the plan is a draft, on sale (active) or archived."},"enum":["active","archived","draft"]},"sortOrder":{"type":"integer","required":false,"default":0,"description":"Where the plan sits when plans are listed; lower numbers come first.","_meta":{"description":"Where the plan sits when plans are listed; lower numbers come first."}},"priceAmount":{"type":"integer","required":false,"default":0,"description":"What the plan costs each billing period, in cents, as a whole number.","_meta":{"description":"What the plan costs each billing period, in cents, as a whole number."}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency the price is in, such as USD.","_meta":{"description":"The currency the price is in, such as USD."}},"billingInterval":{"type":"text","required":false,"default":"month","description":"How often the subscriber is billed: every day, week, month or year.","_meta":{"description":"How often the subscriber is billed: every day, week, month or year."},"enum":["day","week","month","year"]},"pricingMode":{"type":"text","required":false,"default":"fixed","description":"Whether the plan is free, has a fixed price, or lets the subscriber choose what to pay. It cannot change once the plan is saved.","_meta":{"description":"Whether the plan is free, has a fixed price, or lets the subscriber choose what to pay. It cannot change once the plan is saved."},"enum":["free","fixed","pay_what_you_can"]},"minimumAmount":{"type":"integer","required":false,"default":0,"description":"For a pay-what-you-can plan, the least a subscriber may pay, in cents.","_meta":{"description":"For a pay-what-you-can plan, the least a subscriber may pay, in cents."}},"suggestedAmount":{"type":"integer","required":false,"default":0,"description":"For a pay-what-you-can plan, the amount suggested to the subscriber, in cents.","_meta":{"description":"For a pay-what-you-can plan, the amount suggested to the subscriber, in cents."}},"externalProvider":{"type":"text","required":false},"providerProductId":{"type":"text","required":false},"providerPriceId":{"type":"text","required":false},"stripeProductId":{"type":"text","required":false},"stripePriceId":{"type":"text","required":false},"features":{"type":"text","required":false,"default":"[]"},"thresholds":{"type":"text","required":false,"default":"[]"},"metadata":{"type":"text","required":false,"default":"{}"}},"methods":{"isActive":{"name":"isActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getTerms":{"name":"getTerms","async":false,"parameters":[],"returnType":"PlanTerms","isStatic":false,"isPublic":true},"save":{"name":"save","async":true,"parameters":[{"name":"options","type":"SmrtSaveOptions","optional":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"publishTerms":{"name":"publishTerms","async":true,"parameters":[{"name":"options","type":"object","optional":true,"memberTypes":["Date"]}],"returnType":"Promise<SubscriptionPlanVersion>","isStatic":false,"isPublic":true},"getVersionInForce":{"name":"getVersionInForce","async":true,"parameters":[{"name":"at","type":"any","optional":true}],"returnType":"Promise<SubscriptionPlanVersion | null>","isStatic":false,"isPublic":true},"getFeatureGrants":{"name":"getFeatureGrants","async":false,"parameters":[],"returnType":"PlanFeatureGrant[]","isStatic":false,"isPublic":true},"setFeatureGrants":{"name":"setFeatureGrants","async":false,"parameters":[{"name":"grants","type":"Array<string | PlanFeatureGrant>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getFeatureKeys":{"name":"getFeatureKeys","async":false,"parameters":[],"returnType":"string[]","isStatic":false,"isPublic":true},"getThresholds":{"name":"getThresholds","async":false,"parameters":[],"returnType":"PlanThreshold[]","isStatic":false,"isPublic":true},"setThresholds":{"name":"setThresholds","async":false,"parameters":[{"name":"thresholds","type":"PlanThreshold[]","optional":false}],"returnType":"void","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"JsonObject","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"metadata","type":"JsonObject","optional":false}],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_subscription_plans","api":{"include":["list","get","create","update"]},"cli":{"skipApiCheck":true},"mcp":{"include":["list","get"]},"conflictColumns":["tenant_id","plan_key"],"tenantScoped":{"mode":"optional"}},"extends":"SmrtObject","exportName":"SubscriptionPlan","collectionExportName":"SubscriptionPlanCollection","displayLabelField":"name","schema":{"tableName":"_smrt_subscription_plans","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_subscription_plans\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"plan_key\\" TEXT DEFAULT '',\\n \\"name\\" TEXT DEFAULT '',\\n \\"description\\" TEXT DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"sort_order\\" INTEGER DEFAULT 0,\\n \\"price_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"billing_interval\\" TEXT DEFAULT 'month',\\n \\"pricing_mode\\" TEXT DEFAULT 'fixed',\\n \\"minimum_amount\\" INTEGER DEFAULT 0,\\n \\"suggested_amount\\" INTEGER DEFAULT 0,\\n \\"external_provider\\" TEXT,\\n \\"provider_product_id\\" TEXT,\\n \\"provider_price_id\\" TEXT,\\n \\"stripe_product_id\\" TEXT,\\n \\"stripe_price_id\\" TEXT,\\n \\"features\\" TEXT DEFAULT '[]',\\n \\"thresholds\\" TEXT DEFAULT '[]',\\n \\"metadata\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"plan_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"description":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"sort_order":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"price_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"billing_interval":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"pricing_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed"},"minimum_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"suggested_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"external_provider":{"type":"TEXT","notNull":false,"unique":false},"provider_product_id":{"type":"TEXT","notNull":false,"unique":false},"provider_price_id":{"type":"TEXT","notNull":false,"unique":false},"stripe_product_id":{"type":"TEXT","notNull":false,"unique":false},"stripe_price_id":{"type":"TEXT","notNull":false,"unique":false},"features":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"thresholds":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"metadata":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_subscription_plans_tenant_id_plan_key_idx","columns":["tenant_id","plan_key"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_subscription_plans_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_subscription_plans_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"02602c74"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:SubscriptionPlanVersion":{"name":"subscriptionplanversion","className":"SubscriptionPlanVersion","qualifiedName":"@happyvertical/smrt-subscriptions:SubscriptionPlanVersion","collection":"subscriptionplanversions","description":"An immutable, effective-dated snapshot of a plan's terms (#4032).","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/SubscriptionPlanVersion.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":false,"_meta":{"sqlType":"UUID","nullable":true,"__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":false,"autoPopulate":true,"nullable":true,"mode":"optional","field":"tenantId","allowSuperAdminBypass":false}}},"planId":{"type":"foreignKey","required":false,"related":"SubscriptionPlan","description":"The plan this version belongs to.","_meta":{"description":"The plan this version belongs to."}},"planKey":{"type":"text","required":false,"default":"","description":"The plan code at the time this version was published.","_meta":{"description":"The plan code at the time this version was published."}},"version":{"type":"integer","required":false,"default":0,"description":"Which version of the plan this is, counting from 1.","_meta":{"description":"Which version of the plan this is, counting from 1."}},"effectiveFrom":{"type":"datetime","required":false,"description":"The date and time from which these terms apply.","_meta":{"description":"The date and time from which these terms apply."}},"name":{"type":"text","required":false,"default":"","description":"What the plan was called when this version was published.","_meta":{"description":"What the plan was called when this version was published."}},"status":{"type":"text","required":false,"default":"active","description":"Whether the plan was a draft, on sale (active) or archived under this version.","_meta":{"description":"Whether the plan was a draft, on sale (active) or archived under this version."},"enum":["active","archived","draft"]},"priceAmount":{"type":"integer","required":false,"default":0,"description":"What the plan cost each billing period under this version, in cents.","_meta":{"description":"What the plan cost each billing period under this version, in cents."}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency the price is in, such as USD.","_meta":{"description":"The currency the price is in, such as USD."}},"billingInterval":{"type":"text","required":false,"default":"month","description":"How often the subscriber was billed: every day, week, month or year.","_meta":{"description":"How often the subscriber was billed: every day, week, month or year."},"enum":["day","week","month","year"]},"pricingMode":{"type":"text","required":false,"default":"fixed","description":"Whether the plan was free, had a fixed price, or let the subscriber choose what to pay.","_meta":{"description":"Whether the plan was free, had a fixed price, or let the subscriber choose what to pay."},"enum":["free","fixed","pay_what_you_can"]},"minimumAmount":{"type":"integer","required":false,"default":0,"description":"For a pay-what-you-can plan, the least a subscriber could pay, in cents.","_meta":{"description":"For a pay-what-you-can plan, the least a subscriber could pay, in cents."}},"suggestedAmount":{"type":"integer","required":false,"default":0,"description":"For a pay-what-you-can plan, the amount suggested to the subscriber, in cents.","_meta":{"description":"For a pay-what-you-can plan, the amount suggested to the subscriber, in cents."}},"features":{"type":"text","required":false,"default":"[]"},"thresholds":{"type":"text","required":false,"default":"[]"}},"methods":{"isActive":{"name":"isActive","async":false,"parameters":[],"returnType":"boolean","isStatic":false,"isPublic":true},"getTerms":{"name":"getTerms","async":false,"parameters":[],"returnType":"PlanTerms","isStatic":false,"isPublic":true},"getFeatureGrants":{"name":"getFeatureGrants","async":false,"parameters":[],"returnType":"PlanFeatureGrant[]","isStatic":false,"isPublic":true},"getFeatureKeys":{"name":"getFeatureKeys","async":false,"parameters":[],"returnType":"string[]","isStatic":false,"isPublic":true},"getThresholds":{"name":"getThresholds","async":false,"parameters":[],"returnType":"PlanThreshold[]","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_subscription_plan_versions","api":{"include":["list","get"]},"cli":{"include":["list","get"]},"mcp":{"include":["list","get"]},"conflictColumns":["plan_id","version"],"hooks":{"beforeDelete":"refuseDelete"},"tenantScoped":{"mode":"optional"}},"extends":"SmrtObject","exportName":"SubscriptionPlanVersion","collectionExportName":"SubscriptionPlanVersionCollection","displayLabelField":"name","schema":{"tableName":"_smrt_subscription_plan_versions","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_subscription_plan_versions\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID,\\n \\"plan_id\\" UUID,\\n \\"plan_key\\" TEXT DEFAULT '',\\n \\"version\\" INTEGER DEFAULT 0,\\n \\"effective_from\\" TIMESTAMP,\\n \\"name\\" TEXT DEFAULT '',\\n \\"status\\" TEXT DEFAULT 'active',\\n \\"price_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"billing_interval\\" TEXT DEFAULT 'month',\\n \\"pricing_mode\\" TEXT DEFAULT 'fixed',\\n \\"minimum_amount\\" INTEGER DEFAULT 0,\\n \\"suggested_amount\\" INTEGER DEFAULT 0,\\n \\"features\\" TEXT DEFAULT '[]',\\n \\"thresholds\\" TEXT DEFAULT '[]'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":false,"unique":false},"plan_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plans","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"plan_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"version":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"effective_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"active"},"price_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"billing_interval":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"pricing_mode":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed"},"minimum_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"suggested_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"features":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"},"thresholds":{"type":"TEXT","notNull":false,"unique":false,"default":"[]"}},"indexes":[{"name":"_smrt_subscription_plan_versions_plan_id_version_idx","columns":["plan_id","version"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_subscription_plan_versions_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_subscription_plan_versions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"f610e477"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:TenantSubscription":{"name":"tenantsubscription","className":"TenantSubscription","qualifiedName":"@happyvertical/smrt-subscriptions:TenantSubscription","collection":"tenantsubscriptions","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/TenantSubscription.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"subscriberKind":{"type":"text","required":false,"default":"tenant","description":"Whether the subscriber is your own workspace (tenant) or an outside customer (external).","_meta":{"description":"Whether the subscriber is your own workspace (tenant) or an outside customer (external)."},"enum":["tenant","external"]},"subscriberExternalId":{"type":"text","required":false,"default":"","description":"Who the outside subscriber is, when the subscriber type is external.","_meta":{"description":"Who the outside subscriber is, when the subscriber type is external."}},"planId":{"type":"foreignKey","required":false,"related":"SubscriptionPlan","description":"The plan this subscription is for.","_meta":{"description":"The plan this subscription is for."}},"status":{"type":"text","required":false,"default":"incomplete","description":"Where the subscription stands: incomplete, trialing, active, past due, unpaid or cancelled.","_meta":{"description":"Where the subscription stands: incomplete, trialing, active, past due, unpaid or cancelled."},"enum":["active","canceled","incomplete","past_due","trialing","unpaid"]},"startedAt":{"type":"datetime","required":false,"description":"The day the subscription began.","_meta":{"description":"The day the subscription began."}},"currentPeriodStart":{"type":"datetime","required":false,"description":"When the current billing period began.","_meta":{"description":"When the current billing period began."}},"currentPeriodEnd":{"type":"datetime","required":false,"description":"When the current billing period ends and the next one is due.","_meta":{"description":"When the current billing period ends and the next one is due."}},"trialEndsAt":{"type":"datetime","required":false,"description":"When the free trial ends, if there is one.","_meta":{"description":"When the free trial ends, if there is one."}},"cancelAtPeriodEnd":{"type":"boolean","required":false,"default":false,"description":"Tick to let the subscription run out at the end of the current period instead of renewing.","_meta":{"description":"Tick to let the subscription run out at the end of the current period instead of renewing."}},"canceledAt":{"type":"datetime","required":false,"description":"When the subscription was cancelled.","_meta":{"description":"When the subscription was cancelled."}},"agreedAmount":{"type":"integer","required":false,"description":"For a pay-what-you-can plan, the amount the subscriber chose to pay, in cents.","_meta":{"description":"For a pay-what-you-can plan, the amount the subscriber chose to pay, in cents."}},"planVersionId":{"type":"foreignKey","required":false,"related":"SubscriptionPlanVersion","description":"The version of the plan terms this subscription is held to for the current period. It is kept up to date automatically.","_meta":{"description":"The version of the plan terms this subscription is held to for the current period. It is kept up to date automatically."}},"planVersionPinnedAt":{"type":"datetime","required":false},"planVersionPinReason":{"type":"text","required":false,"enum":["period_start","renewal","upgrade","authorized","migration"]},"planVersionPinNote":{"type":"text","required":false,"default":""},"retainsPaidPeriod":{"type":"boolean","required":false,"default":false},"externalProvider":{"type":"text","required":false},"stripeCustomerId":{"type":"text","required":false,"default":""},"stripeSubscriptionId":{"type":"text","required":false,"default":""},"stripeCheckoutSessionId":{"type":"text","required":false,"default":""},"metadata":{"type":"text","required":false,"default":"{}"}},"methods":{"replacePlanVersion":{"name":"replacePlanVersion","async":true,"parameters":[{"name":"options","type":"any","optional":false,"typeUnresolved":true}],"returnType":"Promise<this>","isStatic":false,"isPublic":true},"isEntitled":{"name":"isEntitled","async":false,"parameters":[{"name":"now","type":"any","optional":true}],"returnType":"boolean","isStatic":false,"isPublic":true},"getSubscriber":{"name":"getSubscriber","async":false,"parameters":[],"returnType":"Subscriber | null","isStatic":false,"isPublic":true},"getMetadata":{"name":"getMetadata","async":false,"parameters":[],"returnType":"JsonObject","isStatic":false,"isPublic":true},"setMetadata":{"name":"setMetadata","async":false,"parameters":[{"name":"metadata","type":"JsonObject","optional":false}],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_tenant_subscriptions","api":{"include":["list","get","create","update"]},"cli":{"skipApiCheck":true},"mcp":{"include":["list","get"]},"conflictColumns":["tenant_id","subscriber_kind","subscriber_external_id"],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"TenantSubscription","collectionExportName":"TenantSubscriptionCollection","validationRules":[],"schema":{"tableName":"_smrt_tenant_subscriptions","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_subscriptions\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"plan_id\\" UUID,\\n \\"status\\" TEXT DEFAULT 'incomplete',\\n \\"started_at\\" TIMESTAMP,\\n \\"current_period_start\\" TIMESTAMP,\\n \\"current_period_end\\" TIMESTAMP,\\n \\"trial_ends_at\\" TIMESTAMP,\\n \\"cancel_at_period_end\\" BOOLEAN DEFAULT FALSE,\\n \\"canceled_at\\" TIMESTAMP,\\n \\"agreed_amount\\" INTEGER,\\n \\"plan_version_id\\" UUID,\\n \\"plan_version_pinned_at\\" TIMESTAMP,\\n \\"plan_version_pin_reason\\" TEXT,\\n \\"plan_version_pin_note\\" TEXT DEFAULT '',\\n \\"retains_paid_period\\" BOOLEAN DEFAULT FALSE,\\n \\"external_provider\\" TEXT,\\n \\"stripe_customer_id\\" TEXT DEFAULT '',\\n \\"stripe_subscription_id\\" TEXT DEFAULT '',\\n \\"stripe_checkout_session_id\\" TEXT DEFAULT '',\\n \\"metadata\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"plan_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plans","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"incomplete"},"started_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"current_period_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"current_period_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"trial_ends_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"cancel_at_period_end":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"canceled_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"agreed_amount":{"type":"INTEGER","notNull":false,"unique":false},"plan_version_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_subscription_plan_versions","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"plan_version_pinned_at":{"type":"TIMESTAMP","notNull":false,"unique":false},"plan_version_pin_reason":{"type":"TEXT","notNull":false,"unique":false},"plan_version_pin_note":{"type":"TEXT","notNull":false,"unique":false,"default":""},"retains_paid_period":{"type":"BOOLEAN","notNull":false,"unique":false,"default":false},"external_provider":{"type":"TEXT","notNull":false,"unique":false},"stripe_customer_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"stripe_subscription_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"stripe_checkout_session_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metadata":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_tenant_subscriptions_tenant_id_subscriber_kind_idx","columns":["tenant_id","subscriber_kind","subscriber_external_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_tenant_subscriptions_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_tenant_subscriptions_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_tenant_subscriptions_plan_id_idx","columns":["plan_id"]},{"name":"_smrt_tenant_subscriptions_plan_version_id_idx","columns":["plan_version_id"]}],"version":"328e412c"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:TenantUsageMetric":{"name":"tenantusagemetric","className":"TenantUsageMetric","qualifiedName":"@happyvertical/smrt-subscriptions:TenantUsageMetric","collection":"tenantusagemetrics","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/TenantUsageMetric.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"subscriberKind":{"type":"text","required":false,"default":"tenant","enum":["tenant","external"]},"subscriberExternalId":{"type":"text","required":false,"default":""},"metricKey":{"type":"text","required":false,"default":""},"quantity":{"type":"decimal","required":false,"default":0},"windowStart":{"type":"datetime","required":false},"windowEnd":{"type":"datetime","required":false},"source":{"type":"text","required":false,"default":""},"sourceId":{"type":"text","required":false,"default":""},"projectId":{"type":"text","required":false,"default":""},"workRefType":{"type":"text","required":false,"default":""},"workRefId":{"type":"text","required":false,"default":""},"provider":{"type":"text","required":false,"default":""},"dimensions":{"type":"text","required":false,"default":"{}"}},"methods":{"getSubscriber":{"name":"getSubscriber","async":false,"parameters":[],"returnType":"Subscriber | null","isStatic":false,"isPublic":true},"getDimensions":{"name":"getDimensions","async":false,"parameters":[],"returnType":"JsonObject","isStatic":false,"isPublic":true},"setDimensions":{"name":"setDimensions","async":false,"parameters":[{"name":"dimensions","type":"JsonObject","optional":false}],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_tenant_usage_metrics","api":{"include":["list","get","create"]},"cli":{"include":["list","get","create"]},"mcp":{"include":["list","get"]},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"TenantUsageMetric","collectionExportName":"TenantUsageMetricCollection","validationRules":[],"schema":{"tableName":"_smrt_tenant_usage_metrics","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_tenant_usage_metrics\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"window_start\\" TIMESTAMP,\\n \\"window_end\\" TIMESTAMP,\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"dimensions\\" TEXT DEFAULT '{}'\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"window_start":{"type":"TIMESTAMP","notNull":false,"unique":false},"window_end":{"type":"TIMESTAMP","notNull":false,"unique":false},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"dimensions":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"}},"indexes":[{"name":"_smrt_tenant_usage_metrics_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_tenant_usage_metrics_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"b799c746"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PricingRule":{"name":"pricingrule","className":"PricingRule","qualifiedName":"@happyvertical/smrt-subscriptions:PricingRule","collection":"pricingrules","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"ruleKey":{"type":"text","required":false,"default":""},"metricKey":{"type":"text","required":false,"default":""},"serviceKey":{"type":"text","required":false,"default":""},"strategy":{"type":"text","required":false,"default":"fixed_unit","enum":["fixed_unit","cost_plus","multiplier","tiered","included_overage","flat","custom"]},"currency":{"type":"text","required":false,"default":"USD"},"effectiveFrom":{"type":"datetime","required":false},"effectiveTo":{"type":"datetime","required":false},"priority":{"type":"integer","required":false,"default":0},"terms":{"type":"text","required":false,"default":"{}"},"active":{"type":"boolean","required":false,"default":true},"priceBookId":{"type":"foreignKey","required":false,"related":"PriceBook"}},"methods":{"getTerms":{"name":"getTerms","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true},"setTerms":{"name":"setTerms","async":false,"parameters":[{"name":"value","type":"Record<string, unknown>","optional":false}],"returnType":"void","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_pricing_rules","api":true,"cli":true,"mcp":true,"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"PricingRule","collectionExportName":"PricingRuleCollection","validationRules":[],"schema":{"tableName":"_smrt_pricing_rules","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_pricing_rules\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"rule_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"strategy\\" TEXT DEFAULT 'fixed_unit',\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"effective_from\\" TIMESTAMP,\\n \\"effective_to\\" TIMESTAMP,\\n \\"priority\\" INTEGER DEFAULT 0,\\n \\"terms\\" TEXT DEFAULT '{}',\\n \\"active\\" BOOLEAN DEFAULT TRUE,\\n \\"price_book_id\\" UUID\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"rule_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"strategy":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed_unit"},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"effective_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"effective_to":{"type":"TIMESTAMP","notNull":false,"unique":false},"priority":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"terms":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"_smrt_pricing_rules_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_pricing_rules_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_pricing_rules_price_book_id_idx","columns":["price_book_id"]}],"version":"65ce9b3f"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:ClientCharge":{"name":"clientcharge","className":"ClientCharge","qualifiedName":"@happyvertical/smrt-subscriptions:ClientCharge","collection":"clientcharges","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"usageEventId":{"type":"foreignKey","required":false,"related":"TenantUsageMetric"},"usageTenantId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-users:Tenant"},"subscriberKind":{"type":"text","required":false,"default":"tenant"},"subscriberExternalId":{"type":"text","required":false,"default":""},"projectId":{"type":"text","required":false,"default":""},"workRefType":{"type":"text","required":false,"default":""},"workRefId":{"type":"text","required":false,"default":""},"provider":{"type":"text","required":false,"default":"","description":"Who supplied the service that was used.","_meta":{"description":"Who supplied the service that was used."}},"serviceKey":{"type":"text","required":false,"default":"","description":"The service that was used.","_meta":{"description":"The service that was used."}},"metricKey":{"type":"text","required":false,"default":"","description":"What was used, such as messages sent or minutes of audio.","_meta":{"description":"What was used, such as messages sent or minutes of audio."}},"quantity":{"type":"decimal","required":false,"default":0,"description":"How much of it was used.","_meta":{"description":"How much of it was used."}},"amount":{"type":"integer","required":false,"default":0,"description":"What it cost, in cents.","_meta":{"description":"What it cost, in cents."}},"currency":{"type":"text","required":false,"default":"USD","description":"The currency the amount is in, such as USD.","_meta":{"description":"The currency the amount is in, such as USD."}},"pricingRuleId":{"type":"foreignKey","required":false,"related":"PricingRule"},"priceBookId":{"type":"foreignKey","required":false,"related":"PriceBook"},"pricingSnapshot":{"type":"text","required":false,"default":"{}"},"status":{"type":"text","required":false,"default":"draft","description":"Where the charge stands: draft, approved or adjusted.","_meta":{"description":"Where the charge stands: draft, approved or adjusted."},"enum":["draft","approved","adjusted"]},"approvedAt":{"type":"datetime","required":false,"description":"When the charge was approved.","_meta":{"description":"When the charge was approved."}}},"methods":{"getPricingSnapshot":{"name":"getPricingSnapshot","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_client_charges","api":{"include":["list","get"]},"cli":{"include":["list","get"]},"mcp":{"include":["list","get"]},"conflictColumns":["usage_event_id"],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"ClientCharge","collectionExportName":"ClientChargeCollection","validationRules":[],"schema":{"tableName":"_smrt_client_charges","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_client_charges\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"usage_event_id\\" UUID,\\n \\"usage_tenant_id\\" UUID,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"pricing_rule_id\\" UUID,\\n \\"price_book_id\\" UUID,\\n \\"pricing_snapshot\\" TEXT DEFAULT '{}',\\n \\"status\\" TEXT DEFAULT 'draft',\\n \\"approved_at\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"usage_event_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_tenant_usage_metrics","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"usage_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"pricing_rule_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_pricing_rules","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_snapshot":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"draft"},"approved_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_client_charges_usage_event_id_idx","columns":["usage_event_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_client_charges_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_client_charges_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_client_charges_usage_tenant_id_idx","columns":["usage_tenant_id"]},{"name":"_smrt_client_charges_pricing_rule_id_idx","columns":["pricing_rule_id"]},{"name":"_smrt_client_charges_price_book_id_idx","columns":["price_book_id"]}],"version":"e542be95"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:BillingAdjustment":{"name":"billingadjustment","className":"BillingAdjustment","qualifiedName":"@happyvertical/smrt-subscriptions:BillingAdjustment","collection":"billingadjustments","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"clientChargeId":{"type":"foreignKey","required":false,"related":"ClientCharge"},"amount":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":"USD"},"reason":{"type":"text","required":false,"default":""},"source":{"type":"text","required":false,"default":""},"sourceId":{"type":"text","required":false,"default":""},"createdBy":{"type":"text","required":false,"default":""}},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_adjustments","api":{"include":["list","get"]},"cli":{"include":["list","get"]},"mcp":{"include":["list","get"]},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"BillingAdjustment","collectionExportName":"BillingAdjustmentCollection","validationRules":[],"schema":{"tableName":"_smrt_billing_adjustments","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_adjustments\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"client_charge_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"reason\\" TEXT DEFAULT '',\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"created_by\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"client_charge_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_client_charges","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"created_by":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_billing_adjustments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_billing_adjustments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_billing_adjustments_client_charge_id_idx","columns":["client_charge_id"]}],"version":"cded0b52"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:SpendingPolicy":{"name":"spendingpolicy","className":"SpendingPolicy","qualifiedName":"@happyvertical/smrt-subscriptions:SpendingPolicy","collection":"spendingpolicies","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"name":{"type":"text","required":false,"default":""},"subscriberKind":{"type":"text","required":false,"default":""},"subscriberExternalId":{"type":"text","required":false,"default":""},"projectId":{"type":"text","required":false,"default":""},"serviceKey":{"type":"text","required":false,"default":""},"metricKey":{"type":"text","required":false,"default":""},"period":{"type":"text","required":false,"default":"month","enum":["day","week","month","year","rolling","balance"]},"rollingSeconds":{"type":"integer","required":false,"default":0},"limitAmount":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":"USD"},"behavior":{"type":"text","required":false,"default":"observe","enum":["observe","warn","block","approval_required"]},"priority":{"type":"integer","required":false,"default":0},"active":{"type":"boolean","required":false,"default":true},"basis":{"type":"text","required":false,"default":"billed","enum":["billed","retail","wholesale"]},"setByTenantId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-users:Tenant"},"balanceFrom":{"type":"datetime","required":false}},"methods":{},"decoratorConfig":{"tableName":"_smrt_spending_policies","conflictColumns":["tenant_id","subscriber_kind","subscriber_external_id","project_id","service_key","metric_key","period","name"],"api":true,"cli":true,"mcp":true,"hooks":{"beforeDelete":"assertDelegationAuthority"},"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"SpendingPolicy","collectionExportName":"SpendingPolicyCollection","displayLabelField":"name","validationRules":[],"schema":{"tableName":"_smrt_spending_policies","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_spending_policies\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"name\\" TEXT DEFAULT '',\\n \\"subscriber_kind\\" TEXT DEFAULT '',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"period\\" TEXT DEFAULT 'month',\\n \\"rolling_seconds\\" INTEGER DEFAULT 0,\\n \\"limit_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"behavior\\" TEXT DEFAULT 'observe',\\n \\"priority\\" INTEGER DEFAULT 0,\\n \\"active\\" BOOLEAN DEFAULT TRUE,\\n \\"basis\\" TEXT DEFAULT 'billed',\\n \\"set_by_tenant_id\\" UUID,\\n \\"balance_from\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"period":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"rolling_seconds":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"limit_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"behavior":{"type":"TEXT","notNull":false,"unique":false,"default":"observe"},"priority":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"basis":{"type":"TEXT","notNull":false,"unique":false,"default":"billed"},"set_by_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"balance_from":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_spending_policies_tenant_id_subscriber_kind_idx","columns":["tenant_id","subscriber_kind","subscriber_external_id","project_id","service_key","metric_key","period","name"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_spending_policies_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_spending_policies_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_spending_policies_set_by_tenant_id_idx","columns":["set_by_tenant_id"]}],"version":"c4ac2f49"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PricingRuleCollection":{"name":"pricingrulecollection","className":"PricingRuleCollection","qualifiedName":"@happyvertical/smrt-subscriptions:PricingRuleCollection","collection":"pricingrules","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_pricing_rules"},"extends":"SmrtCollection","extendsTypeArg":"PricingRule","exportName":"PricingRuleCollection","collectionExportName":"PricingRuleCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:PricingRule","schema":{"tableName":"_smrt_pricing_rules","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_pricing_rules\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"rule_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"strategy\\" TEXT DEFAULT 'fixed_unit',\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"effective_from\\" TIMESTAMP,\\n \\"effective_to\\" TIMESTAMP,\\n \\"priority\\" INTEGER DEFAULT 0,\\n \\"terms\\" TEXT DEFAULT '{}',\\n \\"active\\" BOOLEAN DEFAULT TRUE,\\n \\"price_book_id\\" UUID\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"rule_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"strategy":{"type":"TEXT","notNull":false,"unique":false,"default":"fixed_unit"},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"effective_from":{"type":"TIMESTAMP","notNull":false,"unique":false},"effective_to":{"type":"TIMESTAMP","notNull":false,"unique":false},"priority":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"terms":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}}},"indexes":[{"name":"_smrt_pricing_rules_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_pricing_rules_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_pricing_rules_price_book_id_idx","columns":["price_book_id"]}],"version":"65ce9b3f"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:ClientChargeCollection":{"name":"clientchargecollection","className":"ClientChargeCollection","qualifiedName":"@happyvertical/smrt-subscriptions:ClientChargeCollection","collection":"clientcharges","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_client_charges","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"ClientCharge","exportName":"ClientChargeCollection","collectionExportName":"ClientChargeCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:ClientCharge","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_client_charges","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_client_charges\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"usage_event_id\\" UUID,\\n \\"usage_tenant_id\\" UUID,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"pricing_rule_id\\" UUID,\\n \\"price_book_id\\" UUID,\\n \\"pricing_snapshot\\" TEXT DEFAULT '{}',\\n \\"status\\" TEXT DEFAULT 'draft',\\n \\"approved_at\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"usage_event_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_tenant_usage_metrics","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"usage_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"pricing_rule_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_pricing_rules","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_snapshot":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"draft"},"approved_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_client_charges_usage_event_id_idx","columns":["usage_event_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_client_charges_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_client_charges_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_client_charges_usage_tenant_id_idx","columns":["usage_tenant_id"]},{"name":"_smrt_client_charges_pricing_rule_id_idx","columns":["pricing_rule_id"]},{"name":"_smrt_client_charges_price_book_id_idx","columns":["price_book_id"]}],"version":"e542be95"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:BillingAdjustmentCollection":{"name":"billingadjustmentcollection","className":"BillingAdjustmentCollection","qualifiedName":"@happyvertical/smrt-subscriptions:BillingAdjustmentCollection","collection":"billingadjustments","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_billing_adjustments","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"BillingAdjustment","exportName":"BillingAdjustmentCollection","collectionExportName":"BillingAdjustmentCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:BillingAdjustment","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_billing_adjustments","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_billing_adjustments\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"client_charge_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"reason\\" TEXT DEFAULT '',\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"created_by\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"client_charge_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_client_charges","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"created_by":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_billing_adjustments_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_billing_adjustments_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_billing_adjustments_client_charge_id_idx","columns":["client_charge_id"]}],"version":"cded0b52"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:SpendingPolicyCollection":{"name":"spendingpolicycollection","className":"SpendingPolicyCollection","qualifiedName":"@happyvertical/smrt-subscriptions:SpendingPolicyCollection","collection":"spendingpolicies","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/commercial.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_spending_policies"},"extends":"SmrtCollection","extendsTypeArg":"SpendingPolicy","exportName":"SpendingPolicyCollection","collectionExportName":"SpendingPolicyCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:SpendingPolicy","schema":{"tableName":"_smrt_spending_policies","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_spending_policies\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"name\\" TEXT DEFAULT '',\\n \\"subscriber_kind\\" TEXT DEFAULT '',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"period\\" TEXT DEFAULT 'month',\\n \\"rolling_seconds\\" INTEGER DEFAULT 0,\\n \\"limit_amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"behavior\\" TEXT DEFAULT 'observe',\\n \\"priority\\" INTEGER DEFAULT 0,\\n \\"active\\" BOOLEAN DEFAULT TRUE,\\n \\"basis\\" TEXT DEFAULT 'billed',\\n \\"set_by_tenant_id\\" UUID,\\n \\"balance_from\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":""},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"period":{"type":"TEXT","notNull":false,"unique":false,"default":"month"},"rolling_seconds":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"limit_amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"behavior":{"type":"TEXT","notNull":false,"unique":false,"default":"observe"},"priority":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true},"basis":{"type":"TEXT","notNull":false,"unique":false,"default":"billed"},"set_by_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"balance_from":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_spending_policies_tenant_id_subscriber_kind_idx","columns":["tenant_id","subscriber_kind","subscriber_external_id","project_id","service_key","metric_key","period","name"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_spending_policies_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_spending_policies_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_spending_policies_set_by_tenant_id_idx","columns":["set_by_tenant_id"]}],"version":"c4ac2f49"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PriceBook":{"name":"pricebook","className":"PriceBook","qualifiedName":"@happyvertical/smrt-subscriptions:PriceBook","collection":"pricebooks","description":"A named set of prices published by one seller tenant. Its prices are ordinary PricingRule rows that carry this book's id and the same tenant; one rule per currency gives a price in several currencies.","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"bookKey":{"type":"text","required":false,"default":""},"name":{"type":"text","required":false,"default":""},"kind":{"type":"text","required":false,"default":"retail","enum":["wholesale","retail"]},"active":{"type":"boolean","required":false,"default":true}},"methods":{},"decoratorConfig":{"tableName":"_smrt_price_books","conflictColumns":["tenant_id","book_key"],"api":false,"cli":false,"mcp":false,"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"PriceBook","collectionExportName":"PriceBookCollection","displayLabelField":"name","validationRules":[],"schema":{"tableName":"_smrt_price_books","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_price_books\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"book_key\\" TEXT DEFAULT '',\\n \\"name\\" TEXT DEFAULT '',\\n \\"kind\\" TEXT DEFAULT 'retail',\\n \\"active\\" BOOLEAN DEFAULT TRUE\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"book_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"retail"},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true}},"indexes":[{"name":"_smrt_price_books_tenant_id_book_key_idx","columns":["tenant_id","book_key"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_price_books_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_price_books_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"c7e5f5e0"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PriceBookAssignment":{"name":"pricebookassignment","className":"PriceBookAssignment","qualifiedName":"@happyvertical/smrt-subscriptions:PriceBookAssignment","collection":"pricebookassignments","description":"Which price books rate one child tenant's usage, keyed like the tenancy billing relationship it belongs to (one row per child).","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"childTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"resellerTenantId":{"type":"crossPackageRef","required":true,"related":"@happyvertical/smrt-users:Tenant","_meta":{"required":true}},"wholesalePriceBookId":{"type":"foreignKey","required":false,"related":"PriceBook"},"wholesaleCurrency":{"type":"text","required":false,"default":""},"retailPriceBookId":{"type":"foreignKey","required":false,"related":"PriceBook"},"retailCurrency":{"type":"text","required":false,"default":""}},"methods":{},"decoratorConfig":{"tableName":"_smrt_price_book_assignments","conflictColumns":["child_tenant_id"],"api":false,"cli":false,"mcp":false},"extends":"SmrtObject","exportName":"PriceBookAssignment","collectionExportName":"PriceBookAssignmentCollection","validationRules":[{"field":"childTenantId","rule":"required","fieldType":"crossPackageRef"},{"field":"resellerTenantId","rule":"required","fieldType":"crossPackageRef"}],"schema":{"tableName":"_smrt_price_book_assignments","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_price_book_assignments\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"child_tenant_id\\" UUID NOT NULL,\\n \\"reseller_tenant_id\\" UUID NOT NULL,\\n \\"wholesale_price_book_id\\" UUID,\\n \\"wholesale_currency\\" TEXT DEFAULT '',\\n \\"retail_price_book_id\\" UUID,\\n \\"retail_currency\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"child_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"reseller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"wholesale_price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"wholesale_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"retail_price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"retail_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_price_book_assignments_child_tenant_id_idx","columns":["child_tenant_id"],"unique":true},{"name":"_smrt_price_book_assignments_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_price_book_assignments_created_at_idx","columns":["created_at"]},{"name":"_smrt_price_book_assignments_reseller_tenant_id_idx","columns":["reseller_tenant_id"]},{"name":"_smrt_price_book_assignments_wholesale_price_book_id_idx","columns":["wholesale_price_book_id"]},{"name":"_smrt_price_book_assignments_retail_price_book_id_idx","columns":["retail_price_book_id"]}],"version":"f24f020e"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:RetailCharge":{"name":"retailcharge","className":"RetailCharge","qualifiedName":"@happyvertical/smrt-subscriptions:RetailCharge","collection":"retailcharges","description":"What a reseller charges one child for one usage event, priced from the reseller's retail book.","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"resellerTenantId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-users:Tenant"},"usageEventId":{"type":"foreignKey","required":false,"related":"TenantUsageMetric"},"clientChargeId":{"type":"foreignKey","required":false,"related":"ClientCharge"},"subscriberKind":{"type":"text","required":false,"default":"tenant"},"subscriberExternalId":{"type":"text","required":false,"default":""},"projectId":{"type":"text","required":false,"default":""},"workRefType":{"type":"text","required":false,"default":""},"workRefId":{"type":"text","required":false,"default":""},"provider":{"type":"text","required":false,"default":""},"serviceKey":{"type":"text","required":false,"default":""},"metricKey":{"type":"text","required":false,"default":""},"quantity":{"type":"decimal","required":false,"default":0},"amount":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":"USD"},"priceBookId":{"type":"foreignKey","required":false,"related":"PriceBook"},"pricingRuleId":{"type":"foreignKey","required":false,"related":"PricingRule"},"pricingSnapshot":{"type":"text","required":false,"default":"{}"},"status":{"type":"text","required":false,"default":"draft","enum":["draft","approved"]},"approvedAt":{"type":"datetime","required":false}},"methods":{"getPricingSnapshot":{"name":"getPricingSnapshot","async":false,"parameters":[],"returnType":"Record<string, unknown>","isStatic":false,"isPublic":true}},"decoratorConfig":{"tableName":"_smrt_retail_charges","api":{"include":["list","get"]},"cli":{"include":["list","get"]},"mcp":{"include":["list","get"]},"conflictColumns":["usage_event_id"],"tenantScoped":{"mode":"required"}},"extends":"SmrtObject","exportName":"RetailCharge","collectionExportName":"RetailChargeCollection","validationRules":[],"schema":{"tableName":"_smrt_retail_charges","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_retail_charges\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"reseller_tenant_id\\" UUID,\\n \\"usage_event_id\\" UUID,\\n \\"client_charge_id\\" UUID,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"price_book_id\\" UUID,\\n \\"pricing_rule_id\\" UUID,\\n \\"pricing_snapshot\\" TEXT DEFAULT '{}',\\n \\"status\\" TEXT DEFAULT 'draft',\\n \\"approved_at\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"reseller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"usage_event_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_tenant_usage_metrics","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"client_charge_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_client_charges","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_rule_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_pricing_rules","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_snapshot":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"draft"},"approved_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_retail_charges_usage_event_id_idx","columns":["usage_event_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_retail_charges_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_retail_charges_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_retail_charges_reseller_tenant_id_idx","columns":["reseller_tenant_id"]},{"name":"_smrt_retail_charges_client_charge_id_idx","columns":["client_charge_id"]},{"name":"_smrt_retail_charges_price_book_id_idx","columns":["price_book_id"]},{"name":"_smrt_retail_charges_pricing_rule_id_idx","columns":["pricing_rule_id"]}],"version":"1c1ae3c8"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:CreditGrant":{"name":"creditgrant","className":"CreditGrant","qualifiedName":"@happyvertical/smrt-subscriptions:CreditGrant","collection":"creditgrants","description":"An append-only credit on a prepaid (period: 'balance') spending policy. Positive amounts add credit; a negative amount reverses an earlier grant.","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{"tenantId":{"type":"text","required":true,"_meta":{"sqlType":"UUID","__tenancy":{"isTenantIdField":true,"autoFilter":true,"required":true,"autoPopulate":true,"nullable":false,"mode":"required","field":"tenantId","allowSuperAdminBypass":false}}},"spendingPolicyId":{"type":"foreignKey","required":false,"related":"SpendingPolicy"},"amount":{"type":"integer","required":false,"default":0},"currency":{"type":"text","required":false,"default":"USD"},"reason":{"type":"text","required":false,"default":""},"source":{"type":"text","required":false,"default":""},"sourceId":{"type":"text","required":false,"default":""},"grantedByTenantId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-users:Tenant"}},"methods":{},"decoratorConfig":{"tableName":"_smrt_credit_grants","api":{"include":["list","get"]},"cli":{"include":["list","get"]},"mcp":{"include":["list","get"]},"hooks":{"beforeDelete":"refuseDelete"},"tenantScoped":{"mode":"required"},"conflictColumns":["tenant_id","slug","context"]},"extends":"SmrtObject","exportName":"CreditGrant","collectionExportName":"CreditGrantCollection","validationRules":[],"schema":{"tableName":"_smrt_credit_grants","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_credit_grants\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"spending_policy_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"reason\\" TEXT DEFAULT '',\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"granted_by_tenant_id\\" UUID\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"spending_policy_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_spending_policies","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"granted_by_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_credit_grants_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_credit_grants_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_credit_grants_spending_policy_id_idx","columns":["spending_policy_id"]},{"name":"_smrt_credit_grants_granted_by_tenant_id_idx","columns":["granted_by_tenant_id"]}],"version":"602c4e02"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PriceBookCollection":{"name":"pricebookcollection","className":"PriceBookCollection","qualifiedName":"@happyvertical/smrt-subscriptions:PriceBookCollection","collection":"pricebooks","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_price_books","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"PriceBook","exportName":"PriceBookCollection","collectionExportName":"PriceBookCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:PriceBook","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_price_books","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_price_books\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"book_key\\" TEXT DEFAULT '',\\n \\"name\\" TEXT DEFAULT '',\\n \\"kind\\" TEXT DEFAULT 'retail',\\n \\"active\\" BOOLEAN DEFAULT TRUE\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"book_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"name":{"type":"TEXT","notNull":false,"unique":false,"default":""},"kind":{"type":"TEXT","notNull":false,"unique":false,"default":"retail"},"active":{"type":"BOOLEAN","notNull":false,"unique":false,"default":true}},"indexes":[{"name":"_smrt_price_books_tenant_id_book_key_idx","columns":["tenant_id","book_key"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_price_books_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_price_books_tenant_id_created_at_idx","columns":["tenant_id","created_at"]}],"version":"c7e5f5e0"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:PriceBookAssignmentCollection":{"name":"pricebookassignmentcollection","className":"PriceBookAssignmentCollection","qualifiedName":"@happyvertical/smrt-subscriptions:PriceBookAssignmentCollection","collection":"pricebookassignments","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_price_book_assignments","api":false,"mcp":false,"cli":false},"extends":"SmrtCollection","extendsTypeArg":"PriceBookAssignment","exportName":"PriceBookAssignmentCollection","collectionExportName":"PriceBookAssignmentCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:PriceBookAssignment","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_price_book_assignments","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_price_book_assignments\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"child_tenant_id\\" UUID NOT NULL,\\n \\"reseller_tenant_id\\" UUID NOT NULL,\\n \\"wholesale_price_book_id\\" UUID,\\n \\"wholesale_currency\\" TEXT DEFAULT '',\\n \\"retail_price_book_id\\" UUID,\\n \\"retail_currency\\" TEXT DEFAULT ''\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"child_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"reseller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":true,"unique":false},"wholesale_price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"wholesale_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""},"retail_price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"retail_currency":{"type":"TEXT","notNull":false,"unique":false,"default":""}},"indexes":[{"name":"_smrt_price_book_assignments_child_tenant_id_idx","columns":["child_tenant_id"],"unique":true},{"name":"_smrt_price_book_assignments_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_price_book_assignments_created_at_idx","columns":["created_at"]},{"name":"_smrt_price_book_assignments_reseller_tenant_id_idx","columns":["reseller_tenant_id"]},{"name":"_smrt_price_book_assignments_wholesale_price_book_id_idx","columns":["wholesale_price_book_id"]},{"name":"_smrt_price_book_assignments_retail_price_book_id_idx","columns":["retail_price_book_id"]}],"version":"f24f020e"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:RetailChargeCollection":{"name":"retailchargecollection","className":"RetailChargeCollection","qualifiedName":"@happyvertical/smrt-subscriptions:RetailChargeCollection","collection":"retailcharges","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_retail_charges","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"RetailCharge","exportName":"RetailChargeCollection","collectionExportName":"RetailChargeCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:RetailCharge","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_retail_charges","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_retail_charges\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"reseller_tenant_id\\" UUID,\\n \\"usage_event_id\\" UUID,\\n \\"client_charge_id\\" UUID,\\n \\"subscriber_kind\\" TEXT DEFAULT 'tenant',\\n \\"subscriber_external_id\\" TEXT DEFAULT '',\\n \\"project_id\\" TEXT DEFAULT '',\\n \\"work_ref_type\\" TEXT DEFAULT '',\\n \\"work_ref_id\\" TEXT DEFAULT '',\\n \\"provider\\" TEXT DEFAULT '',\\n \\"service_key\\" TEXT DEFAULT '',\\n \\"metric_key\\" TEXT DEFAULT '',\\n \\"quantity\\" REAL DEFAULT 0,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"price_book_id\\" UUID,\\n \\"pricing_rule_id\\" UUID,\\n \\"pricing_snapshot\\" TEXT DEFAULT '{}',\\n \\"status\\" TEXT DEFAULT 'draft',\\n \\"approved_at\\" TIMESTAMP\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"reseller_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"usage_event_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_tenant_usage_metrics","column":"id","onDelete":"CASCADE","onUpdate":"CASCADE"}},"client_charge_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_client_charges","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"subscriber_kind":{"type":"TEXT","notNull":false,"unique":false,"default":"tenant"},"subscriber_external_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"project_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_type":{"type":"TEXT","notNull":false,"unique":false,"default":""},"work_ref_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"provider":{"type":"TEXT","notNull":false,"unique":false,"default":""},"service_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"metric_key":{"type":"TEXT","notNull":false,"unique":false,"default":""},"quantity":{"type":"REAL","notNull":false,"unique":false,"default":0},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"price_book_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_price_books","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_rule_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_pricing_rules","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"pricing_snapshot":{"type":"TEXT","notNull":false,"unique":false,"default":"{}"},"status":{"type":"TEXT","notNull":false,"unique":false,"default":"draft"},"approved_at":{"type":"TIMESTAMP","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_retail_charges_usage_event_id_idx","columns":["usage_event_id"],"unique":true,"nullsNotDistinct":true},{"name":"_smrt_retail_charges_slug_context_idx","columns":["slug","context"]},{"name":"_smrt_retail_charges_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_retail_charges_reseller_tenant_id_idx","columns":["reseller_tenant_id"]},{"name":"_smrt_retail_charges_client_charge_id_idx","columns":["client_charge_id"]},{"name":"_smrt_retail_charges_price_book_id_idx","columns":["price_book_id"]},{"name":"_smrt_retail_charges_pricing_rule_id_idx","columns":["pricing_rule_id"]}],"version":"1c1ae3c8"},"importPath":"@happyvertical/smrt-subscriptions"},"@happyvertical/smrt-subscriptions:CreditGrantCollection":{"name":"creditgrantcollection","className":"CreditGrantCollection","qualifiedName":"@happyvertical/smrt-subscriptions:CreditGrantCollection","collection":"creditgrants","filePath":"/home/runner/work/smrt/smrt/packages/subscriptions/src/models/reseller.ts","packageName":"@happyvertical/smrt-subscriptions","fields":{},"methods":{},"decoratorConfig":{"tableName":"_smrt_credit_grants","api":{"include":["list","get"]},"mcp":{"include":["list","get"]},"cli":{"include":["list","get"]}},"extends":"SmrtCollection","extendsTypeArg":"CreditGrant","exportName":"CreditGrantCollection","collectionExportName":"CreditGrantCollectionCollection","collectionOf":"@happyvertical/smrt-subscriptions:CreditGrant","inheritedExposure":["api","mcp","cli"],"schema":{"tableName":"_smrt_credit_grants","ddl":"CREATE TABLE IF NOT EXISTS \\"_smrt_credit_grants\\" (\\n \\"id\\" UUID PRIMARY KEY NOT NULL,\\n \\"slug\\" TEXT NOT NULL,\\n \\"context\\" TEXT NOT NULL DEFAULT '',\\n \\"created_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"updated_at\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\"tenant_id\\" UUID NOT NULL,\\n \\"spending_policy_id\\" UUID,\\n \\"amount\\" INTEGER DEFAULT 0,\\n \\"currency\\" TEXT DEFAULT 'USD',\\n \\"reason\\" TEXT DEFAULT '',\\n \\"source\\" TEXT DEFAULT '',\\n \\"source_id\\" TEXT DEFAULT '',\\n \\"granted_by_tenant_id\\" UUID\\n);","columns":{"id":{"type":"UUID","primaryKey":true,"referenceKind":"id","notNull":true},"slug":{"type":"TEXT","notNull":true},"context":{"type":"TEXT","notNull":true,"default":""},"created_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"updated_at":{"type":"TIMESTAMP","notNull":true,"default":"current_timestamp"},"tenant_id":{"type":"UUID","referenceKind":"tenantId","notNull":true,"unique":false},"spending_policy_id":{"type":"UUID","referenceKind":"foreignKey","notNull":false,"unique":false,"foreignKey":{"table":"_smrt_spending_policies","column":"id","onDelete":"NO ACTION","onUpdate":"CASCADE"}},"amount":{"type":"INTEGER","notNull":false,"unique":false,"default":0},"currency":{"type":"TEXT","notNull":false,"unique":false,"default":"USD"},"reason":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source":{"type":"TEXT","notNull":false,"unique":false,"default":""},"source_id":{"type":"TEXT","notNull":false,"unique":false,"default":""},"granted_by_tenant_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false}},"indexes":[{"name":"_smrt_credit_grants_slug_context_idx","columns":["tenant_id","slug","context"],"unique":true},{"name":"_smrt_credit_grants_tenant_id_created_at_idx","columns":["tenant_id","created_at"]},{"name":"_smrt_credit_grants_spending_policy_id_idx","columns":["spending_policy_id"]},{"name":"_smrt_credit_grants_granted_by_tenant_id_idx","columns":["granted_by_tenant_id"]}],"version":"602c4e02"},"importPath":"@happyvertical/smrt-subscriptions"}},"moduleType":"smrt","recipes":[{"id":"subscriptions.plans","className":"SubscriptionPlansRecipe","label":"Subscriptions","summary":"Sell plans that renew, see who is subscribed to which, and what their usage cost.","synonyms":["subscriptions","subscription plans","plans","memberships","recurring billing","pricing tiers"],"models":["@happyvertical/smrt-subscriptions:SubscriptionPlan","@happyvertical/smrt-subscriptions:SubscriptionPlanVersion","@happyvertical/smrt-subscriptions:TenantSubscription","@happyvertical/smrt-subscriptions:ClientCharge"],"nav":[{"label":"Plans","model":"@happyvertical/smrt-subscriptions:SubscriptionPlan","icon":"tag","description":"The plans you sell, with their price and how often they bill.","noun":"plan"},{"label":"Subscriptions","model":"@happyvertical/smrt-subscriptions:TenantSubscription","icon":"repeat","description":"Who is subscribed to which plan, and where each one stands.","noun":"subscription"},{"label":"Plan versions","model":"@happyvertical/smrt-subscriptions:SubscriptionPlanVersion","icon":"fileText","description":"Every set of terms a plan has had, and from when each applied.","noun":"plan version"},{"label":"Charges","model":"@happyvertical/smrt-subscriptions:ClientCharge","icon":"receipt","description":"What each subscriber used and what it cost them.","noun":"charge"}],"requires":[],"section":{"id":"sales","label":"Sales","icon":"shoppingBag","description":"Customers, orders and quotes: everything you sell."},"options":{"@happyvertical/smrt-subscriptions:SubscriptionPlan":{"fields":{"name":{"order":1},"planKey":{"label":"Plan code","order":2},"description":{"order":3},"status":{"order":4},"priceAmount":{"label":"Price (in cents)","order":5},"currency":{"order":6},"billingInterval":{"label":"Billed every","order":7},"pricingMode":{"label":"How it is priced","order":8},"minimumAmount":{"label":"Minimum (in cents)","visibility":"advanced"},"suggestedAmount":{"label":"Suggested (in cents)","visibility":"advanced"},"sortOrder":{"label":"Position in list","visibility":"advanced"},"tenantId":{"visibility":"hidden"},"features":{"visibility":"hidden"},"thresholds":{"visibility":"hidden"},"externalProvider":{"visibility":"hidden"},"providerProductId":{"visibility":"hidden"},"providerPriceId":{"visibility":"hidden"},"stripeProductId":{"visibility":"hidden"},"stripePriceId":{"visibility":"hidden"},"metadata":{"visibility":"hidden"}}},"@happyvertical/smrt-subscriptions:SubscriptionPlanVersion":{"fields":{"planId":{"label":"Plan","order":1},"version":{"label":"Version number","order":2},"effectiveFrom":{"label":"In force from","order":3},"name":{"order":4},"status":{"order":5},"priceAmount":{"label":"Price (in cents)","order":6},"currency":{"order":7},"billingInterval":{"label":"Billed every","order":8},"planKey":{"label":"Plan code","visibility":"advanced"},"pricingMode":{"label":"How it is priced","visibility":"advanced"},"minimumAmount":{"label":"Minimum (in cents)","visibility":"advanced"},"suggestedAmount":{"label":"Suggested (in cents)","visibility":"advanced"},"tenantId":{"visibility":"hidden"},"features":{"visibility":"hidden"},"thresholds":{"visibility":"hidden"}}},"@happyvertical/smrt-subscriptions:TenantSubscription":{"fields":{"planId":{"label":"Plan","order":1},"status":{"order":2},"startedAt":{"label":"Started on","order":3},"currentPeriodStart":{"label":"Current period starts","order":4},"currentPeriodEnd":{"label":"Current period ends","order":5},"trialEndsAt":{"label":"Trial ends","order":6},"cancelAtPeriodEnd":{"label":"Cancel at end of period","order":7},"canceledAt":{"label":"Cancelled on","visibility":"advanced"},"agreedAmount":{"label":"Agreed amount (in cents)","visibility":"advanced"},"subscriberKind":{"label":"Subscriber type","visibility":"advanced"},"subscriberExternalId":{"label":"Outside subscriber","visibility":"advanced"},"planVersionId":{"label":"Plan version","visibility":"advanced","locked":true},"tenantId":{"visibility":"hidden"},"planVersionPinnedAt":{"visibility":"hidden"},"planVersionPinReason":{"visibility":"hidden"},"planVersionPinNote":{"visibility":"hidden"},"retainsPaidPeriod":{"visibility":"hidden"},"externalProvider":{"visibility":"hidden"},"stripeCustomerId":{"visibility":"hidden"},"stripeSubscriptionId":{"visibility":"hidden"},"stripeCheckoutSessionId":{"visibility":"hidden"},"metadata":{"visibility":"hidden"}}},"@happyvertical/smrt-subscriptions:ClientCharge":{"fields":{"metricKey":{"label":"What was used","order":1},"quantity":{"label":"How much","order":2},"amount":{"label":"Amount (in cents)","order":3},"currency":{"order":4},"status":{"order":5},"approvedAt":{"label":"Approved on","order":6},"serviceKey":{"label":"Service","visibility":"advanced"},"provider":{"visibility":"advanced"},"tenantId":{"visibility":"hidden"},"usageEventId":{"visibility":"hidden"},"usageTenantId":{"visibility":"hidden"},"subscriberKind":{"visibility":"hidden"},"subscriberExternalId":{"visibility":"hidden"},"projectId":{"visibility":"hidden"},"workRefType":{"visibility":"hidden"},"workRefId":{"visibility":"hidden"},"pricingRuleId":{"visibility":"hidden"},"priceBookId":{"visibility":"hidden"},"pricingSnapshot":{"visibility":"hidden"}}}},"help":{"markdown":"## Overview\\n\\nSubscriptions is where you sell plans that renew. A plan says what it costs,\\nhow often it bills and whether it is free, a fixed price or pay what you can.\\nA subscription joins a subscriber to a plan and shows where it stands, from\\ntrial to active to cancelled. Every time you change a plan's terms, the\\nearlier terms are kept as a plan version, so a subscriber who already paid for\\na period keeps what they paid for until it renews. Charges show what each\\nsubscriber used and what it cost them.\\n\\nAll amounts are whole numbers of cents, with no decimal point.\\n\\n## Tasks\\n\\n### Set up a plan\\n\\n1. Open the plans and choose **New**.\\n2. Type the **{field:SubscriptionPlan.name}** customers will see and a short **{field:SubscriptionPlan.planKey}** such as \\"starter\\".\\n3. Choose **{field:SubscriptionPlan.pricingMode}**: free, a fixed price, or pay what you can. This cannot change once the plan is saved; make a new plan instead.\\n4. For a fixed price, enter the **{field:SubscriptionPlan.priceAmount}** in cents and the **{field:SubscriptionPlan.currency}**.\\n5. Set how often it bills in **{field:SubscriptionPlan.billingInterval}**.\\n6. Set the **{field:SubscriptionPlan.status}** to active when it is ready to sell.\\n7. Save.\\n\\n### Change a plan's price or terms\\n\\n1. Open the plan and edit the **{field:SubscriptionPlan.priceAmount}**, **{field:SubscriptionPlan.billingInterval}** or **{field:SubscriptionPlan.status}**.\\n2. Save. The new terms apply to new subscribers and to existing ones from their next renewal; a period already paid for keeps its old terms.\\n\\n### Retire a plan\\n\\n1. Open the plan and set its **{field:SubscriptionPlan.status}** to archived.\\n2. Save. No one new can subscribe to it; existing subscribers keep going until they cancel.\\n\\n### Subscribe someone to a plan\\n\\n1. Open the subscriptions and choose **New**.\\n2. Pick the **{field:TenantSubscription.planId}**.\\n3. Enter the day it **{field:TenantSubscription.startedAt}** and, if there is a free trial, when the **{field:TenantSubscription.trialEndsAt}**.\\n4. Save. The **{field:TenantSubscription.status}** shows where the subscription stands once it has been paid for.\\n\\n### See where a subscription stands\\n\\n1. Open the subscriptions and find the one you want.\\n2. The **{field:TenantSubscription.status}** shows whether it is still incomplete, on trial, active, past due, unpaid or cancelled.\\n3. **{field:TenantSubscription.currentPeriodStart}** and **{field:TenantSubscription.currentPeriodEnd}** show the period that has been paid for.\\n\\n### Cancel a subscription\\n\\n1. Open the subscription.\\n2. Tick **{field:TenantSubscription.cancelAtPeriodEnd}** so it runs out when the current period ends instead of renewing.\\n3. Save.\\n\\n### Look up the terms a subscriber was sold\\n\\nPlan versions are written automatically whenever a plan is saved with changed\\nterms; you cannot add or edit them here.\\n\\n1. Open the plan versions and find the **{field:SubscriptionPlanVersion.planId}** you are interested in.\\n2. Each row shows the **{field:SubscriptionPlanVersion.version}** and the date it was **{field:SubscriptionPlanVersion.effectiveFrom}**.\\n3. Read the **{field:SubscriptionPlanVersion.priceAmount}**, **{field:SubscriptionPlanVersion.currency}** and **{field:SubscriptionPlanVersion.billingInterval}** that applied under it.\\n\\n### See what a subscriber was charged\\n\\nCharges are created by the usage and billing service as usage is recorded;\\nyou cannot add or edit them here.\\n\\n1. Open the charges.\\n2. Each row shows **{field:ClientCharge.metricKey}**, **{field:ClientCharge.quantity}** and the **{field:ClientCharge.amount}** in cents.\\n3. The **{field:ClientCharge.status}** shows whether the charge is still a draft, approved or adjusted.\\n","fieldRefs":["ClientCharge.amount","ClientCharge.metricKey","ClientCharge.quantity","ClientCharge.status","SubscriptionPlan.billingInterval","SubscriptionPlan.currency","SubscriptionPlan.name","SubscriptionPlan.planKey","SubscriptionPlan.priceAmount","SubscriptionPlan.pricingMode","SubscriptionPlan.status","SubscriptionPlanVersion.billingInterval","SubscriptionPlanVersion.currency","SubscriptionPlanVersion.effectiveFrom","SubscriptionPlanVersion.planId","SubscriptionPlanVersion.priceAmount","SubscriptionPlanVersion.version","TenantSubscription.cancelAtPeriodEnd","TenantSubscription.currentPeriodEnd","TenantSubscription.currentPeriodStart","TenantSubscription.planId","TenantSubscription.startedAt","TenantSubscription.status","TenantSubscription.trialEndsAt"]},"demo":{"mode":"server","reasons":["Needs a server because its package does not build for a browser: core migrations (node:crypto, node:os); and its package depends on @happyvertical/smrt-tenancy, which do not build for a browser (#3624, #3626)."]}}],"smrtDependencies":["@happyvertical/smrt-core","@happyvertical/smrt-tenancy"],"browser":{"status":"server-only","issues":["#3624","#3626"],"reason":"core migrations (node:crypto, node:os)","via":["@happyvertical/smrt-tenancy"]},"stampsConstructors":true}`));
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/models/TenantSubscription.ts
|
|
13
13
|
var __defProp$3 = Object.defineProperty;
|