@happyvertical/smrt-subscriptions 0.40.26 → 0.40.28
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/manifest.json +2 -2
- package/dist/smrt-knowledge.json +4 -4
- package/dist/svelte/PlanPicker.svelte +52 -5
- package/dist/svelte/PlanPicker.svelte.d.ts +26 -3
- package/dist/svelte/PlanPicker.svelte.d.ts.map +1 -1
- package/dist/svelte/PlanPicker.test.js +63 -0
- package/dist/svelte/SubscriptionSummary.svelte +41 -1
- package/dist/svelte/SubscriptionSummary.svelte.d.ts +8 -0
- package/dist/svelte/SubscriptionSummary.svelte.d.ts.map +1 -1
- package/dist/svelte/SubscriptionSummary.test.js +34 -0
- package/dist/svelte/i18n.d.ts +4 -0
- package/dist/svelte/i18n.d.ts.map +1 -1
- package/dist/svelte/i18n.js +4 -0
- package/dist/svelte/index.d.ts +2 -0
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +1 -0
- package/dist/svelte/subscription-summary.d.ts +2 -0
- package/dist/svelte/subscription-summary.d.ts.map +1 -0
- package/dist/svelte/subscription-summary.js +14 -0
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ObjectRegistry, SmrtCollection, SmrtObject, foreignKey, smrt } from "@happyvertical/smrt-core";
|
|
2
2
|
import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy";
|
|
3
3
|
//#region src/__smrt-register__.ts
|
|
4
|
-
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":1785075165139,\"packageName\":\"@happyvertical/smrt-subscriptions\",\"packageVersion\":\"0.40.26\",\"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\":\"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},\"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\"},\"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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_subscription_plans_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_subscription_plans_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"e693208d\"}},\"@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\"},\"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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_tenant_subscriptions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_tenant_subscriptions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"1d17f963\"}},\"@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\"},\"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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_tenant_usage_metrics_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_tenant_usage_metrics_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"8617d4ac\"}},\"@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\":\"\"},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"description\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"active\"},\"sortOrder\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"priceAmount\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"billingInterval\":{\"type\":\"text\",\"required\":false,\"default\":\"month\"},\"externalProvider\":{\"type\":\"text\",\"required\":false,\"default\":\"stripe\"},\"stripeProductId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"stripePriceId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"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},\"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\":true,\"mcp\":{\"include\":[\"list\",\"get\"]},\"conflictColumns\":[\"plan_key\"],\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"SubscriptionPlan\",\"collectionExportName\":\"SubscriptionPlanCollection\",\"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\\\" REAL DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\n \\\"billing_interval\\\" TEXT DEFAULT 'month',\\n \\\"external_provider\\\" TEXT DEFAULT 'stripe',\\n \\\"stripe_product_id\\\" TEXT DEFAULT '',\\n \\\"stripe_price_id\\\" TEXT DEFAULT '',\\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\":\"REAL\",\"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\"},\"external_provider\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"stripe\"},\"stripe_product_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"stripe_price_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"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_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_subscription_plans_plan_key_idx\",\"columns\":[\"plan_key\"],\"unique\":true}],\"version\":\"bbe13cf9\"}},\"@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\"},\"subscriberExternalId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"planId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"SubscriptionPlan\"},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"incomplete\"},\"startedAt\":{\"type\":\"datetime\",\"required\":false},\"currentPeriodStart\":{\"type\":\"datetime\",\"required\":false},\"currentPeriodEnd\":{\"type\":\"datetime\",\"required\":false},\"trialEndsAt\":{\"type\":\"datetime\",\"required\":false},\"cancelAtPeriodEnd\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"canceledAt\":{\"type\":\"datetime\",\"required\":false},\"externalProvider\":{\"type\":\"text\",\"required\":false,\"default\":\"stripe\"},\"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\":{\"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\":true,\"mcp\":{\"include\":[\"list\",\"get\"]},\"conflictColumns\":[\"tenant_id\",\"subscriber_kind\",\"subscriber_external_id\"],\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"TenantSubscription\",\"collectionExportName\":\"TenantSubscriptionCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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 \\\"external_provider\\\" TEXT DEFAULT 'stripe',\\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},\"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},\"external_provider\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"stripe\"},\"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_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_tenant_subscriptions_tenant_id_subscriber_kind_idx\",\"columns\":[\"tenant_id\",\"subscriber_kind\",\"subscriber_external_id\"],\"unique\":true}],\"version\":\"ef3d8be5\"}},\"@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\"},\"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\"}},\"extends\":\"SmrtObject\",\"exportName\":\"TenantUsageMetric\",\"collectionExportName\":\"TenantUsageMetricCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_tenant_usage_metrics_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"b799c746\"}},\"@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\"},\"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}},\"methods\":{\"getTerms\":{\"name\":\"getTerms\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string>\",\"isStatic\":false,\"isPublic\":true},\"setTerms\":{\"name\":\"setTerms\",\"async\":false,\"parameters\":[{\"name\":\"value\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"_smrt_pricing_rules\",\"api\":true,\"cli\":true,\"mcp\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"PricingRule\",\"collectionExportName\":\"PricingRuleCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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);\",\"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}},\"indexes\":[{\"name\":\"_smrt_pricing_rules_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_pricing_rules_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"88642897\"}},\"@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\"},\"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\":\"decimal\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"pricingRuleId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"PricingRule\"},\"pricingSnapshot\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"draft\"},\"approvedAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{\"getPricingSnapshot\":{\"name\":\"getPricingSnapshot\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string>\",\"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\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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 \\\"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\\\" REAL DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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},\"usage_event_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"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\":\"REAL\",\"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},\"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_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_client_charges_usage_event_id_idx\",\"columns\":[\"usage_event_id\"],\"unique\":true}],\"version\":\"9bee0a3e\"}},\"@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\":\"decimal\",\"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\"}},\"extends\":\"SmrtObject\",\"exportName\":\"BillingAdjustment\",\"collectionExportName\":\"BillingAdjustmentCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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\\\" REAL 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},\"amount\":{\"type\":\"REAL\",\"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_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_billing_adjustments_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"fefa2538\"}},\"@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\"},\"rollingSeconds\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"limitAmount\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"behavior\":{\"type\":\"text\",\"required\":false,\"default\":\"observe\"},\"priority\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"active\":{\"type\":\"boolean\",\"required\":false,\"default\":true}},\"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,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"SpendingPolicy\",\"collectionExportName\":\"SpendingPolicyCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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\\\" REAL DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\n \\\"behavior\\\" TEXT DEFAULT 'observe',\\n \\\"priority\\\" INTEGER DEFAULT 0,\\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},\"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\":\"REAL\",\"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}},\"indexes\":[{\"name\":\"_smrt_spending_policies_id_idx\",\"columns\":[\"id\"]},{\"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}],\"version\":\"af20dc21\"}},\"@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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_pricing_rules_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_pricing_rules_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"3fb55a6a\"}},\"@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\"},\"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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_client_charges_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_client_charges_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"96756a5d\"}},\"@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\"},\"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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_billing_adjustments_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_billing_adjustments_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"5ca89c74\"}},\"@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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_spending_policies_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_spending_policies_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"4f25df0f\"}}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-tenancy\"]}"));
|
|
4
|
+
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":1785095301158,\"packageName\":\"@happyvertical/smrt-subscriptions\",\"packageVersion\":\"0.40.28\",\"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\":\"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},\"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\"},\"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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_subscription_plans_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_subscription_plans_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"e693208d\"}},\"@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\"},\"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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_tenant_subscriptions_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_tenant_subscriptions_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"1d17f963\"}},\"@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\"},\"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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_tenant_usage_metrics_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_tenant_usage_metrics_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"8617d4ac\"}},\"@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\":\"\"},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"description\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"active\"},\"sortOrder\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"priceAmount\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"billingInterval\":{\"type\":\"text\",\"required\":false,\"default\":\"month\"},\"externalProvider\":{\"type\":\"text\",\"required\":false,\"default\":\"stripe\"},\"stripeProductId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"stripePriceId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"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},\"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\":true,\"mcp\":{\"include\":[\"list\",\"get\"]},\"conflictColumns\":[\"plan_key\"],\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"SubscriptionPlan\",\"collectionExportName\":\"SubscriptionPlanCollection\",\"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\\\" REAL DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\n \\\"billing_interval\\\" TEXT DEFAULT 'month',\\n \\\"external_provider\\\" TEXT DEFAULT 'stripe',\\n \\\"stripe_product_id\\\" TEXT DEFAULT '',\\n \\\"stripe_price_id\\\" TEXT DEFAULT '',\\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\":\"REAL\",\"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\"},\"external_provider\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"stripe\"},\"stripe_product_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"stripe_price_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"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_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_subscription_plans_plan_key_idx\",\"columns\":[\"plan_key\"],\"unique\":true}],\"version\":\"bbe13cf9\"}},\"@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\"},\"subscriberExternalId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"planId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"SubscriptionPlan\"},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"incomplete\"},\"startedAt\":{\"type\":\"datetime\",\"required\":false},\"currentPeriodStart\":{\"type\":\"datetime\",\"required\":false},\"currentPeriodEnd\":{\"type\":\"datetime\",\"required\":false},\"trialEndsAt\":{\"type\":\"datetime\",\"required\":false},\"cancelAtPeriodEnd\":{\"type\":\"boolean\",\"required\":false,\"default\":false},\"canceledAt\":{\"type\":\"datetime\",\"required\":false},\"externalProvider\":{\"type\":\"text\",\"required\":false,\"default\":\"stripe\"},\"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\":{\"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\":true,\"mcp\":{\"include\":[\"list\",\"get\"]},\"conflictColumns\":[\"tenant_id\",\"subscriber_kind\",\"subscriber_external_id\"],\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"TenantSubscription\",\"collectionExportName\":\"TenantSubscriptionCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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 \\\"external_provider\\\" TEXT DEFAULT 'stripe',\\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},\"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},\"external_provider\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"stripe\"},\"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_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_tenant_subscriptions_tenant_id_subscriber_kind_idx\",\"columns\":[\"tenant_id\",\"subscriber_kind\",\"subscriber_external_id\"],\"unique\":true}],\"version\":\"ef3d8be5\"}},\"@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\"},\"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\"}},\"extends\":\"SmrtObject\",\"exportName\":\"TenantUsageMetric\",\"collectionExportName\":\"TenantUsageMetricCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_tenant_usage_metrics_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"b799c746\"}},\"@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\"},\"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}},\"methods\":{\"getTerms\":{\"name\":\"getTerms\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string>\",\"isStatic\":false,\"isPublic\":true},\"setTerms\":{\"name\":\"setTerms\",\"async\":false,\"parameters\":[{\"name\":\"value\",\"type\":\"Record<string>\",\"optional\":false}],\"returnType\":\"void\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"_smrt_pricing_rules\",\"api\":true,\"cli\":true,\"mcp\":true,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"PricingRule\",\"collectionExportName\":\"PricingRuleCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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);\",\"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}},\"indexes\":[{\"name\":\"_smrt_pricing_rules_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_pricing_rules_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"88642897\"}},\"@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\"},\"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\":\"decimal\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"pricingRuleId\":{\"type\":\"foreignKey\",\"required\":false,\"related\":\"PricingRule\"},\"pricingSnapshot\":{\"type\":\"text\",\"required\":false,\"default\":\"{}\"},\"status\":{\"type\":\"text\",\"required\":false,\"default\":\"draft\"},\"approvedAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{\"getPricingSnapshot\":{\"name\":\"getPricingSnapshot\",\"async\":false,\"parameters\":[],\"returnType\":\"Record<string>\",\"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\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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 \\\"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\\\" REAL DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\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},\"usage_event_id\":{\"type\":\"UUID\",\"referenceKind\":\"foreignKey\",\"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\":\"REAL\",\"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},\"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_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_client_charges_usage_event_id_idx\",\"columns\":[\"usage_event_id\"],\"unique\":true}],\"version\":\"9bee0a3e\"}},\"@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\":\"decimal\",\"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\"}},\"extends\":\"SmrtObject\",\"exportName\":\"BillingAdjustment\",\"collectionExportName\":\"BillingAdjustmentCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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\\\" REAL 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},\"amount\":{\"type\":\"REAL\",\"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_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_billing_adjustments_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"fefa2538\"}},\"@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\"},\"rollingSeconds\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"limitAmount\":{\"type\":\"decimal\",\"required\":false,\"default\":0},\"currency\":{\"type\":\"text\",\"required\":false,\"default\":\"USD\"},\"behavior\":{\"type\":\"text\",\"required\":false,\"default\":\"observe\"},\"priority\":{\"type\":\"integer\",\"required\":false,\"default\":0},\"active\":{\"type\":\"boolean\",\"required\":false,\"default\":true}},\"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,\"tenantScoped\":{\"mode\":\"required\"}},\"extends\":\"SmrtObject\",\"exportName\":\"SpendingPolicy\",\"collectionExportName\":\"SpendingPolicyCollection\",\"validationRules\":[{\"field\":\"tenantId\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"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\\\" REAL DEFAULT 0,\\n \\\"currency\\\" TEXT DEFAULT 'USD',\\n \\\"behavior\\\" TEXT DEFAULT 'observe',\\n \\\"priority\\\" INTEGER DEFAULT 0,\\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},\"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\":\"REAL\",\"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}},\"indexes\":[{\"name\":\"_smrt_spending_policies_id_idx\",\"columns\":[\"id\"]},{\"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}],\"version\":\"af20dc21\"}},\"@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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_pricing_rules_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_pricing_rules_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"3fb55a6a\"}},\"@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\"},\"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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_client_charges_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_client_charges_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"96756a5d\"}},\"@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\"},\"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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_billing_adjustments_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_billing_adjustments_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"5ca89c74\"}},\"@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);\",\"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\"}},\"indexes\":[{\"name\":\"_smrt_spending_policies_id_idx\",\"columns\":[\"id\"]},{\"name\":\"_smrt_spending_policies_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true}],\"version\":\"4f25df0f\"}}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-tenancy\"]}"));
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/utils.ts
|
|
7
7
|
var THRESHOLD_WINDOWS = [
|
package/dist/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "1.0.0",
|
|
3
|
-
"timestamp":
|
|
3
|
+
"timestamp": 1785095301158,
|
|
4
4
|
"packageName": "@happyvertical/smrt-subscriptions",
|
|
5
|
-
"packageVersion": "0.40.
|
|
5
|
+
"packageVersion": "0.40.28",
|
|
6
6
|
"objects": {
|
|
7
7
|
"@happyvertical/smrt-subscriptions:SubscriptionPlanCollection": {
|
|
8
8
|
"name": "subscriptionplancollection",
|
package/dist/smrt-knowledge.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-07-
|
|
3
|
+
"generatedAt": "2026-07-26T19:48:24.186Z",
|
|
4
4
|
"packageName": "@happyvertical/smrt-subscriptions",
|
|
5
|
-
"packageVersion": "0.40.
|
|
5
|
+
"packageVersion": "0.40.28",
|
|
6
6
|
"sourceManifestPath": "dist/manifest.json",
|
|
7
7
|
"agentDocPath": "AGENTS.md",
|
|
8
8
|
"sourceHashes": {
|
|
9
|
-
"manifest": "
|
|
10
|
-
"packageJson": "
|
|
9
|
+
"manifest": "2f867d4ca95d89f188a059b9b693e2ca3fd1919abd29dd4993b66b0dd84ccda0",
|
|
10
|
+
"packageJson": "6439d70a00f5c4ed7970163affa5b923b892b3f3617a59e8296953f313e935d1",
|
|
11
11
|
"agents": "065d7d121a55a300284b8cff9e9a1c3ac1cc87187634377af82fdf8a9b9c27f8"
|
|
12
12
|
},
|
|
13
13
|
"exports": [
|
|
@@ -1,19 +1,66 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Serializable plan shape accepted by PlanPicker. `SubscriptionPlan` model
|
|
4
|
+
* instances satisfy it structurally, but it can also be plain data returned
|
|
5
|
+
* from a SvelteKit `load` — models lose their methods across serialization,
|
|
6
|
+
* so components must not *require* them. `featureKeys` is accepted as an
|
|
7
|
+
* explicit view-model field; `features` supports the framework's normal
|
|
8
|
+
* serialized model shape; and model instances can still use getFeatureKeys().
|
|
9
|
+
*/
|
|
10
|
+
type SerializedFeatureGrant =
|
|
11
|
+
| string
|
|
12
|
+
| { featureKey?: string; enabled?: boolean };
|
|
13
|
+
|
|
14
|
+
export interface PlanPickerPlan {
|
|
15
|
+
id?: string;
|
|
16
|
+
planKey: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string | null;
|
|
19
|
+
priceAmount: number;
|
|
20
|
+
currency: string;
|
|
21
|
+
billingInterval: string;
|
|
22
|
+
featureKeys?: string[];
|
|
23
|
+
features?: string | SerializedFeatureGrant[];
|
|
24
|
+
getFeatureKeys?: () => string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function featureCount(plan: PlanPickerPlan): number {
|
|
28
|
+
if (plan.featureKeys) return plan.featureKeys.length;
|
|
29
|
+
if (plan.getFeatureKeys) return plan.getFeatureKeys().length;
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const features =
|
|
33
|
+
typeof plan.features === 'string'
|
|
34
|
+
? (JSON.parse(plan.features) as unknown)
|
|
35
|
+
: plan.features;
|
|
36
|
+
if (!Array.isArray(features)) return 0;
|
|
37
|
+
return features.filter(
|
|
38
|
+
(feature) =>
|
|
39
|
+
typeof feature === 'string' ||
|
|
40
|
+
(feature !== null &&
|
|
41
|
+
typeof feature === 'object' &&
|
|
42
|
+
'featureKey' in feature &&
|
|
43
|
+
typeof feature.featureKey === 'string' &&
|
|
44
|
+
feature.enabled !== false),
|
|
45
|
+
).length;
|
|
46
|
+
} catch {
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
3
50
|
|
|
4
51
|
let {
|
|
5
52
|
plans = [],
|
|
6
53
|
selectedPlanKey = null,
|
|
7
54
|
onSelect,
|
|
8
55
|
}: {
|
|
9
|
-
plans?:
|
|
56
|
+
plans?: PlanPickerPlan[];
|
|
10
57
|
selectedPlanKey?: string | null;
|
|
11
|
-
onSelect?: (plan:
|
|
58
|
+
onSelect?: (plan: PlanPickerPlan) => void;
|
|
12
59
|
} = $props();
|
|
13
60
|
</script>
|
|
14
61
|
|
|
15
62
|
<div class="smrt-plan-picker">
|
|
16
|
-
{#each plans as plan (plan.
|
|
63
|
+
{#each plans as plan (plan.planKey)}
|
|
17
64
|
<!-- raw-primitive-allow: pressable selection card (aria-pressed toggle with multi-line plan summary), not a standard action button -->
|
|
18
65
|
<button
|
|
19
66
|
aria-pressed={plan.planKey === selectedPlanKey}
|
|
@@ -34,7 +81,7 @@ let {
|
|
|
34
81
|
<span class="smrt-plan-picker__description">{plan.description}</span>
|
|
35
82
|
{/if}
|
|
36
83
|
<span class="smrt-plan-picker__features">
|
|
37
|
-
{plan
|
|
84
|
+
{featureCount(plan)} features
|
|
38
85
|
</span>
|
|
39
86
|
</button>
|
|
40
87
|
{/each}
|
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Serializable plan shape accepted by PlanPicker. `SubscriptionPlan` model
|
|
3
|
+
* instances satisfy it structurally, but it can also be plain data returned
|
|
4
|
+
* from a SvelteKit `load` — models lose their methods across serialization,
|
|
5
|
+
* so components must not *require* them. `featureKeys` is accepted as an
|
|
6
|
+
* explicit view-model field; `features` supports the framework's normal
|
|
7
|
+
* serialized model shape; and model instances can still use getFeatureKeys().
|
|
8
|
+
*/
|
|
9
|
+
type SerializedFeatureGrant = string | {
|
|
10
|
+
featureKey?: string;
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export interface PlanPickerPlan {
|
|
14
|
+
id?: string;
|
|
15
|
+
planKey: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description?: string | null;
|
|
18
|
+
priceAmount: number;
|
|
19
|
+
currency: string;
|
|
20
|
+
billingInterval: string;
|
|
21
|
+
featureKeys?: string[];
|
|
22
|
+
features?: string | SerializedFeatureGrant[];
|
|
23
|
+
getFeatureKeys?: () => string[];
|
|
24
|
+
}
|
|
2
25
|
type $$ComponentProps = {
|
|
3
|
-
plans?:
|
|
26
|
+
plans?: PlanPickerPlan[];
|
|
4
27
|
selectedPlanKey?: string | null;
|
|
5
|
-
onSelect?: (plan:
|
|
28
|
+
onSelect?: (plan: PlanPickerPlan) => void;
|
|
6
29
|
};
|
|
7
30
|
declare const PlanPicker: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
31
|
type PlanPicker = ReturnType<typeof PlanPicker>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanPicker.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/PlanPicker.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"PlanPicker.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/PlanPicker.svelte.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,KAAK,sBAAsB,GACvB,MAAM,GACN;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,sBAAsB,EAAE,CAAC;IAC7C,cAAc,CAAC,EAAE,MAAM,MAAM,EAAE,CAAC;CACjC;AACA,KAAK,gBAAgB,GAAI;IACxB,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;CAC3C,CAAC;AA8DF,QAAA,MAAM,UAAU,sDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { render } from 'svelte/server';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { SubscriptionPlan } from '../models/SubscriptionPlan.js';
|
|
4
|
+
import PlanPicker from './PlanPicker.svelte';
|
|
5
|
+
import planPickerSource from './PlanPicker.svelte?raw';
|
|
6
|
+
describe('PlanPicker', () => {
|
|
7
|
+
it('keys serialized id-less plans by planKey', () => {
|
|
8
|
+
const plans = [
|
|
9
|
+
{
|
|
10
|
+
planKey: 'starter',
|
|
11
|
+
name: 'Starter',
|
|
12
|
+
priceAmount: 0,
|
|
13
|
+
currency: 'USD',
|
|
14
|
+
billingInterval: 'month',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
planKey: 'pro',
|
|
18
|
+
name: 'Pro',
|
|
19
|
+
priceAmount: 10,
|
|
20
|
+
currency: 'USD',
|
|
21
|
+
billingInterval: 'month',
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
const { body } = render(PlanPicker, {
|
|
25
|
+
props: { plans },
|
|
26
|
+
});
|
|
27
|
+
expect(body.match(/smrt-plan-picker__plan/g)).toHaveLength(2);
|
|
28
|
+
expect(planPickerSource).toContain('{#each plans as plan (plan.planKey)}');
|
|
29
|
+
});
|
|
30
|
+
it('counts enabled features from the normal model serialization shape', () => {
|
|
31
|
+
const plan = new SubscriptionPlan({
|
|
32
|
+
planKey: 'pro',
|
|
33
|
+
name: 'Pro',
|
|
34
|
+
priceAmount: 10,
|
|
35
|
+
currency: 'USD',
|
|
36
|
+
billingInterval: 'month',
|
|
37
|
+
features: JSON.stringify([
|
|
38
|
+
'smrt:chat',
|
|
39
|
+
{ featureKey: 'smrt:projects', enabled: true },
|
|
40
|
+
{ featureKey: 'smrt:disabled', enabled: false },
|
|
41
|
+
]),
|
|
42
|
+
});
|
|
43
|
+
const serialized = plan.toJSON();
|
|
44
|
+
const { body } = render(PlanPicker, {
|
|
45
|
+
props: { plans: [serialized] },
|
|
46
|
+
});
|
|
47
|
+
expect(body).toContain('2 features');
|
|
48
|
+
});
|
|
49
|
+
it('treats malformed serialized feature JSON as empty', () => {
|
|
50
|
+
const plan = {
|
|
51
|
+
planKey: 'broken',
|
|
52
|
+
name: 'Broken',
|
|
53
|
+
priceAmount: 0,
|
|
54
|
+
currency: 'USD',
|
|
55
|
+
billingInterval: 'month',
|
|
56
|
+
features: '{bad json',
|
|
57
|
+
};
|
|
58
|
+
const { body } = render(PlanPicker, {
|
|
59
|
+
props: { plans: [plan] },
|
|
60
|
+
});
|
|
61
|
+
expect(body).toContain('0 features');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -2,14 +2,48 @@
|
|
|
2
2
|
import { useI18n } from '@happyvertical/smrt-ui/i18n';
|
|
3
3
|
import type { EntitlementResolution } from '../types.js';
|
|
4
4
|
import { M } from './i18n.js';
|
|
5
|
+
import { formatPeriodDate } from './subscription-summary.js';
|
|
5
6
|
|
|
6
7
|
let {
|
|
7
8
|
resolution = null,
|
|
9
|
+
periodEnd = null,
|
|
10
|
+
periodDisposition = 'unknown',
|
|
11
|
+
periodDateLocale,
|
|
12
|
+
periodTimeZone = 'UTC',
|
|
8
13
|
}: {
|
|
9
14
|
resolution?: EntitlementResolution | null;
|
|
15
|
+
/** ISO date string (or null) for the current billing period end. */
|
|
16
|
+
periodEnd?: string | null;
|
|
17
|
+
/** How to describe `periodEnd`: renews / ends / perpetual / unknown. */
|
|
18
|
+
periodDisposition?: 'perpetual' | 'renews' | 'ends' | 'unknown';
|
|
19
|
+
/** Stable locale override for the billing date. Defaults to the i18n locale. */
|
|
20
|
+
periodDateLocale?: string;
|
|
21
|
+
/** Billing timezone used by both SSR and hydration. Defaults to UTC. */
|
|
22
|
+
periodTimeZone?: string;
|
|
10
23
|
} = $props();
|
|
11
24
|
|
|
12
|
-
const
|
|
25
|
+
const i18n = useI18n();
|
|
26
|
+
const { t } = i18n;
|
|
27
|
+
|
|
28
|
+
const formattedPeriodEnd = $derived(
|
|
29
|
+
periodEnd
|
|
30
|
+
? formatPeriodDate(
|
|
31
|
+
periodEnd,
|
|
32
|
+
periodDateLocale ?? i18n.locale,
|
|
33
|
+
periodTimeZone,
|
|
34
|
+
)
|
|
35
|
+
: null,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const periodLabel = $derived(
|
|
39
|
+
periodDisposition === 'perpetual'
|
|
40
|
+
? t(M['subscriptions.summary.no_expiration'])
|
|
41
|
+
: periodDisposition === 'renews' && formattedPeriodEnd
|
|
42
|
+
? `${t(M['subscriptions.summary.renews'])} ${formattedPeriodEnd}`
|
|
43
|
+
: periodDisposition === 'ends' && formattedPeriodEnd
|
|
44
|
+
? `${t(M['subscriptions.summary.ends'])} ${formattedPeriodEnd}`
|
|
45
|
+
: null,
|
|
46
|
+
);
|
|
13
47
|
</script>
|
|
14
48
|
|
|
15
49
|
<section class="smrt-subscription-summary">
|
|
@@ -30,6 +64,12 @@ const { t } = useI18n();
|
|
|
30
64
|
<dt>Thresholds</dt>
|
|
31
65
|
<dd>{resolution?.thresholds.length ?? 0}</dd>
|
|
32
66
|
</div>
|
|
67
|
+
{#if periodLabel}
|
|
68
|
+
<div>
|
|
69
|
+
<dt>{t(M['subscriptions.summary.period'])}</dt>
|
|
70
|
+
<dd>{periodLabel}</dd>
|
|
71
|
+
</div>
|
|
72
|
+
{/if}
|
|
33
73
|
</dl>
|
|
34
74
|
</section>
|
|
35
75
|
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { EntitlementResolution } from '../types.js';
|
|
2
2
|
type $$ComponentProps = {
|
|
3
3
|
resolution?: EntitlementResolution | null;
|
|
4
|
+
/** ISO date string (or null) for the current billing period end. */
|
|
5
|
+
periodEnd?: string | null;
|
|
6
|
+
/** How to describe `periodEnd`: renews / ends / perpetual / unknown. */
|
|
7
|
+
periodDisposition?: 'perpetual' | 'renews' | 'ends' | 'unknown';
|
|
8
|
+
/** Stable locale override for the billing date. Defaults to the i18n locale. */
|
|
9
|
+
periodDateLocale?: string;
|
|
10
|
+
/** Billing timezone used by both SSR and hydration. Defaults to UTC. */
|
|
11
|
+
periodTimeZone?: string;
|
|
4
12
|
};
|
|
5
13
|
declare const SubscriptionSummary: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
14
|
type SubscriptionSummary = ReturnType<typeof SubscriptionSummary>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionSummary.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/SubscriptionSummary.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"SubscriptionSummary.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/SubscriptionSummary.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAIxD,KAAK,gBAAgB,GAAI;IACxB,UAAU,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC1C,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IAChE,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAsEF,QAAA,MAAM,mBAAmB,sDAAwC,CAAC;AAClE,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAClE,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { render } from 'svelte/server';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import SubscriptionSummary from './SubscriptionSummary.svelte';
|
|
4
|
+
describe('SubscriptionSummary', () => {
|
|
5
|
+
it('renders period dates with a deterministic locale and timezone', () => {
|
|
6
|
+
const { body } = render(SubscriptionSummary, {
|
|
7
|
+
props: {
|
|
8
|
+
periodDisposition: 'renews',
|
|
9
|
+
periodEnd: '2026-07-01T00:00:00Z',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
expect(body).toContain('Jul 1, 2026');
|
|
13
|
+
});
|
|
14
|
+
it('honours an explicit billing timezone', () => {
|
|
15
|
+
const { body } = render(SubscriptionSummary, {
|
|
16
|
+
props: {
|
|
17
|
+
periodDisposition: 'ends',
|
|
18
|
+
periodEnd: '2026-07-01T00:00:00Z',
|
|
19
|
+
periodTimeZone: 'America/Edmonton',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
expect(body).toContain('Jun 30, 2026');
|
|
23
|
+
});
|
|
24
|
+
it('does not render an invalid billing date', () => {
|
|
25
|
+
const { body } = render(SubscriptionSummary, {
|
|
26
|
+
props: {
|
|
27
|
+
periodDisposition: 'renews',
|
|
28
|
+
periodEnd: 'not-a-date',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
expect(body).not.toContain('Invalid Date');
|
|
32
|
+
expect(body).not.toContain('Period');
|
|
33
|
+
});
|
|
34
|
+
});
|
package/dist/svelte/i18n.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export declare const M: {
|
|
2
2
|
readonly 'subscriptions.commercial.overview_label': "subscriptions.commercial.overview_label";
|
|
3
3
|
readonly 'subscriptions.summary.current_plan': "subscriptions.summary.current_plan";
|
|
4
|
+
readonly 'subscriptions.summary.ends': "subscriptions.summary.ends";
|
|
4
5
|
readonly 'subscriptions.summary.no_active_plan': "subscriptions.summary.no_active_plan";
|
|
6
|
+
readonly 'subscriptions.summary.no_expiration': "subscriptions.summary.no_expiration";
|
|
7
|
+
readonly 'subscriptions.summary.period': "subscriptions.summary.period";
|
|
8
|
+
readonly 'subscriptions.summary.renews': "subscriptions.summary.renews";
|
|
5
9
|
};
|
|
6
10
|
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/svelte/i18n.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,CAAC
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/svelte/i18n.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,CAAC;;;;;;;;CAQZ,CAAC"}
|
package/dist/svelte/i18n.js
CHANGED
|
@@ -6,5 +6,9 @@ import { defineMessages } from '@happyvertical/smrt-ui/i18n';
|
|
|
6
6
|
export const M = defineMessages({
|
|
7
7
|
'subscriptions.commercial.overview_label': 'Commercial usage overview',
|
|
8
8
|
'subscriptions.summary.current_plan': 'Current plan',
|
|
9
|
+
'subscriptions.summary.ends': 'Ends',
|
|
9
10
|
'subscriptions.summary.no_active_plan': 'No active plan',
|
|
11
|
+
'subscriptions.summary.no_expiration': 'No expiration',
|
|
12
|
+
'subscriptions.summary.period': 'Billing period',
|
|
13
|
+
'subscriptions.summary.renews': 'Renews',
|
|
10
14
|
});
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export type { CommercialMetricView } from './CommercialOverview.svelte';
|
|
2
2
|
export { default as CommercialOverview } from './CommercialOverview.svelte';
|
|
3
|
+
export type { PlanPickerPlan } from './PlanPicker.svelte';
|
|
3
4
|
export { default as PlanPicker } from './PlanPicker.svelte';
|
|
4
5
|
export { default as SubscriptionSummary } from './SubscriptionSummary.svelte';
|
|
6
|
+
export { formatPeriodDate } from './subscription-summary.js';
|
|
5
7
|
export { default as UsageThresholds } from './UsageThresholds.svelte';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/svelte/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/svelte/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/svelte/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as CommercialOverview } from './CommercialOverview.svelte';
|
|
2
2
|
export { default as PlanPicker } from './PlanPicker.svelte';
|
|
3
3
|
export { default as SubscriptionSummary } from './SubscriptionSummary.svelte';
|
|
4
|
+
export { formatPeriodDate } from './subscription-summary.js';
|
|
4
5
|
export { default as UsageThresholds } from './UsageThresholds.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-summary.d.ts","sourceRoot":"","sources":["../../src/svelte/subscription-summary.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,MAAM,SAAU,EAChB,QAAQ,SAAQ,GACf,MAAM,GAAG,IAAI,CAYf"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function formatPeriodDate(value, locale = 'en-US', timeZone = 'UTC') {
|
|
2
|
+
const date = new Date(value);
|
|
3
|
+
if (Number.isNaN(date.getTime()))
|
|
4
|
+
return null;
|
|
5
|
+
try {
|
|
6
|
+
return new Intl.DateTimeFormat(locale, {
|
|
7
|
+
dateStyle: 'medium',
|
|
8
|
+
timeZone,
|
|
9
|
+
}).format(date);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-subscriptions",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.28",
|
|
4
4
|
"description": "Tenant subscriptions, entitlement resolution, usage thresholds, and subscription UI for SMRT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"smrtRawPrimitives": "strict",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@happyvertical/sql": "^0.
|
|
30
|
-
"@happyvertical/smrt-core": "0.40.
|
|
31
|
-
"@happyvertical/smrt-tenancy": "0.40.
|
|
32
|
-
"@happyvertical/smrt-ui": "0.40.
|
|
29
|
+
"@happyvertical/sql": "^0.84.0",
|
|
30
|
+
"@happyvertical/smrt-core": "0.40.28",
|
|
31
|
+
"@happyvertical/smrt-tenancy": "0.40.28",
|
|
32
|
+
"@happyvertical/smrt-ui": "0.40.28"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"svelte": "^5.56.4"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"typescript": "5.9.3",
|
|
48
48
|
"vite": "8.1.4",
|
|
49
49
|
"vitest": "4.1.10",
|
|
50
|
-
"@happyvertical/smrt-vitest": "0.40.
|
|
50
|
+
"@happyvertical/smrt-vitest": "0.40.28"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"smrt",
|