@happyvertical/smrt-subscriptions 0.30.0

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.
Files changed (59) hide show
  1. package/AGENTS.md +26 -0
  2. package/CLAUDE.md +1 -0
  3. package/LICENSE +7 -0
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/__smrt-register__.d.ts +2 -0
  6. package/dist/__smrt-register__.d.ts.map +1 -0
  7. package/dist/collections/SubscriptionPlanCollection.d.ts +9 -0
  8. package/dist/collections/SubscriptionPlanCollection.d.ts.map +1 -0
  9. package/dist/collections/TenantSubscriptionCollection.d.ts +29 -0
  10. package/dist/collections/TenantSubscriptionCollection.d.ts.map +1 -0
  11. package/dist/collections/TenantUsageMetricCollection.d.ts +28 -0
  12. package/dist/collections/TenantUsageMetricCollection.d.ts.map +1 -0
  13. package/dist/collections/index.d.ts +4 -0
  14. package/dist/collections/index.d.ts.map +1 -0
  15. package/dist/index.d.ts +6 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +1271 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/manifest.json +1291 -0
  20. package/dist/models/SubscriptionPlan.d.ts +30 -0
  21. package/dist/models/SubscriptionPlan.d.ts.map +1 -0
  22. package/dist/models/TenantSubscription.d.ts +59 -0
  23. package/dist/models/TenantSubscription.d.ts.map +1 -0
  24. package/dist/models/TenantUsageMetric.d.ts +35 -0
  25. package/dist/models/TenantUsageMetric.d.ts.map +1 -0
  26. package/dist/models/index.d.ts +4 -0
  27. package/dist/models/index.d.ts.map +1 -0
  28. package/dist/services/index.d.ts +5 -0
  29. package/dist/services/index.d.ts.map +1 -0
  30. package/dist/services/subscription-resolver.d.ts +96 -0
  31. package/dist/services/subscription-resolver.d.ts.map +1 -0
  32. package/dist/services/threshold-evaluator.d.ts +4 -0
  33. package/dist/services/threshold-evaluator.d.ts.map +1 -0
  34. package/dist/services/usage-meter.d.ts +32 -0
  35. package/dist/services/usage-meter.d.ts.map +1 -0
  36. package/dist/smrt-knowledge.json +883 -0
  37. package/dist/svelte/PlanPicker.svelte +82 -0
  38. package/dist/svelte/PlanPicker.svelte.d.ts +10 -0
  39. package/dist/svelte/PlanPicker.svelte.d.ts.map +1 -0
  40. package/dist/svelte/SubscriptionSummary.svelte +65 -0
  41. package/dist/svelte/SubscriptionSummary.svelte.d.ts +8 -0
  42. package/dist/svelte/SubscriptionSummary.svelte.d.ts.map +1 -0
  43. package/dist/svelte/UsageThresholds.svelte +71 -0
  44. package/dist/svelte/UsageThresholds.svelte.d.ts +8 -0
  45. package/dist/svelte/UsageThresholds.svelte.d.ts.map +1 -0
  46. package/dist/svelte/i18n.d.ts +5 -0
  47. package/dist/svelte/i18n.d.ts.map +1 -0
  48. package/dist/svelte/i18n.js +9 -0
  49. package/dist/svelte/index.d.ts +4 -0
  50. package/dist/svelte/index.d.ts.map +1 -0
  51. package/dist/svelte/index.js +3 -0
  52. package/dist/types.d.ts +175 -0
  53. package/dist/types.d.ts.map +1 -0
  54. package/dist/types.js +2 -0
  55. package/dist/types.js.map +1 -0
  56. package/dist/utils.d.ts +59 -0
  57. package/dist/utils.d.ts.map +1 -0
  58. package/package.json +80 -0
  59. package/scripts/migrate-1454-drop-legacy-conflict-index.ts +110 -0
@@ -0,0 +1,1291 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "timestamp": 1782177077524,
4
+ "packageName": "@happyvertical/smrt-subscriptions",
5
+ "packageVersion": "0.30.0",
6
+ "objects": {
7
+ "@happyvertical/smrt-subscriptions:SubscriptionPlanCollection": {
8
+ "name": "subscriptionplancollection",
9
+ "className": "SubscriptionPlanCollection",
10
+ "qualifiedName": "@happyvertical/smrt-subscriptions:SubscriptionPlanCollection",
11
+ "collection": "subscriptionplans",
12
+ "filePath": "/home/runner/_work/smrt/smrt/packages/subscriptions/src/collections/SubscriptionPlanCollection.ts",
13
+ "packageName": "@happyvertical/smrt-subscriptions",
14
+ "fields": {},
15
+ "methods": {
16
+ "findByPlanKey": {
17
+ "name": "findByPlanKey",
18
+ "async": true,
19
+ "parameters": [
20
+ {
21
+ "name": "planKey",
22
+ "type": "string",
23
+ "optional": false
24
+ }
25
+ ],
26
+ "returnType": "Promise<SubscriptionPlan | null>",
27
+ "isStatic": false,
28
+ "isPublic": true
29
+ },
30
+ "findActive": {
31
+ "name": "findActive",
32
+ "async": true,
33
+ "parameters": [],
34
+ "returnType": "Promise<SubscriptionPlan[]>",
35
+ "isStatic": false,
36
+ "isPublic": true
37
+ },
38
+ "findByStripePriceId": {
39
+ "name": "findByStripePriceId",
40
+ "async": true,
41
+ "parameters": [
42
+ {
43
+ "name": "stripePriceId",
44
+ "type": "string",
45
+ "optional": false
46
+ }
47
+ ],
48
+ "returnType": "Promise<SubscriptionPlan | null>",
49
+ "isStatic": false,
50
+ "isPublic": true
51
+ }
52
+ },
53
+ "decoratorConfig": {
54
+ "tableName": "_smrt_subscription_plans"
55
+ },
56
+ "extends": "SmrtCollection",
57
+ "extendsTypeArg": "SubscriptionPlan",
58
+ "exportName": "SubscriptionPlanCollection",
59
+ "collectionExportName": "SubscriptionPlanCollectionCollection",
60
+ "schema": {
61
+ "tableName": "_smrt_subscription_plans",
62
+ "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);",
63
+ "columns": {
64
+ "id": {
65
+ "type": "UUID",
66
+ "primaryKey": true,
67
+ "referenceKind": "id",
68
+ "notNull": true
69
+ },
70
+ "slug": {
71
+ "type": "TEXT",
72
+ "notNull": true
73
+ },
74
+ "context": {
75
+ "type": "TEXT",
76
+ "notNull": true,
77
+ "default": ""
78
+ },
79
+ "created_at": {
80
+ "type": "TIMESTAMP",
81
+ "notNull": true,
82
+ "default": "current_timestamp"
83
+ },
84
+ "updated_at": {
85
+ "type": "TIMESTAMP",
86
+ "notNull": true,
87
+ "default": "current_timestamp"
88
+ }
89
+ },
90
+ "indexes": [
91
+ {
92
+ "name": "_smrt_subscription_plans_id_idx",
93
+ "columns": [
94
+ "id"
95
+ ]
96
+ },
97
+ {
98
+ "name": "_smrt_subscription_plans_slug_context_idx",
99
+ "columns": [
100
+ "slug",
101
+ "context"
102
+ ],
103
+ "unique": true
104
+ }
105
+ ],
106
+ "version": "e693208d"
107
+ }
108
+ },
109
+ "@happyvertical/smrt-subscriptions:TenantSubscriptionCollection": {
110
+ "name": "tenantsubscriptioncollection",
111
+ "className": "TenantSubscriptionCollection",
112
+ "qualifiedName": "@happyvertical/smrt-subscriptions:TenantSubscriptionCollection",
113
+ "collection": "tenantsubscriptions",
114
+ "filePath": "/home/runner/_work/smrt/smrt/packages/subscriptions/src/collections/TenantSubscriptionCollection.ts",
115
+ "packageName": "@happyvertical/smrt-subscriptions",
116
+ "fields": {},
117
+ "methods": {
118
+ "findByTenant": {
119
+ "name": "findByTenant",
120
+ "async": true,
121
+ "parameters": [
122
+ {
123
+ "name": "tenantId",
124
+ "type": "string",
125
+ "optional": false
126
+ }
127
+ ],
128
+ "returnType": "Promise<TenantSubscription[]>",
129
+ "isStatic": false,
130
+ "isPublic": true
131
+ },
132
+ "findCurrentForTenant": {
133
+ "name": "findCurrentForTenant",
134
+ "async": true,
135
+ "parameters": [
136
+ {
137
+ "name": "tenantId",
138
+ "type": "string",
139
+ "optional": false
140
+ },
141
+ {
142
+ "name": "now",
143
+ "type": "any",
144
+ "optional": true
145
+ }
146
+ ],
147
+ "returnType": "Promise<TenantSubscription | null>",
148
+ "isStatic": false,
149
+ "isPublic": true
150
+ },
151
+ "findCurrentForSubscriber": {
152
+ "name": "findCurrentForSubscriber",
153
+ "async": true,
154
+ "parameters": [
155
+ {
156
+ "name": "subscriber",
157
+ "type": "Subscriber",
158
+ "optional": false
159
+ },
160
+ {
161
+ "name": "now",
162
+ "type": "any",
163
+ "optional": true
164
+ }
165
+ ],
166
+ "returnType": "Promise<TenantSubscription | null>",
167
+ "isStatic": false,
168
+ "isPublic": true
169
+ },
170
+ "findByStripeSubscriptionId": {
171
+ "name": "findByStripeSubscriptionId",
172
+ "async": true,
173
+ "parameters": [
174
+ {
175
+ "name": "stripeSubscriptionId",
176
+ "type": "string",
177
+ "optional": false
178
+ }
179
+ ],
180
+ "returnType": "Promise<TenantSubscription | null>",
181
+ "isStatic": false,
182
+ "isPublic": true
183
+ }
184
+ },
185
+ "decoratorConfig": {
186
+ "tableName": "_smrt_tenant_subscriptions"
187
+ },
188
+ "extends": "SmrtCollection",
189
+ "extendsTypeArg": "TenantSubscription",
190
+ "exportName": "TenantSubscriptionCollection",
191
+ "collectionExportName": "TenantSubscriptionCollectionCollection",
192
+ "schema": {
193
+ "tableName": "_smrt_tenant_subscriptions",
194
+ "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);",
195
+ "columns": {
196
+ "id": {
197
+ "type": "UUID",
198
+ "primaryKey": true,
199
+ "referenceKind": "id",
200
+ "notNull": true
201
+ },
202
+ "slug": {
203
+ "type": "TEXT",
204
+ "notNull": true
205
+ },
206
+ "context": {
207
+ "type": "TEXT",
208
+ "notNull": true,
209
+ "default": ""
210
+ },
211
+ "created_at": {
212
+ "type": "TIMESTAMP",
213
+ "notNull": true,
214
+ "default": "current_timestamp"
215
+ },
216
+ "updated_at": {
217
+ "type": "TIMESTAMP",
218
+ "notNull": true,
219
+ "default": "current_timestamp"
220
+ }
221
+ },
222
+ "indexes": [
223
+ {
224
+ "name": "_smrt_tenant_subscriptions_id_idx",
225
+ "columns": [
226
+ "id"
227
+ ]
228
+ },
229
+ {
230
+ "name": "_smrt_tenant_subscriptions_slug_context_idx",
231
+ "columns": [
232
+ "slug",
233
+ "context"
234
+ ],
235
+ "unique": true
236
+ }
237
+ ],
238
+ "version": "1d17f963"
239
+ }
240
+ },
241
+ "@happyvertical/smrt-subscriptions:TenantUsageMetricCollection": {
242
+ "name": "tenantusagemetriccollection",
243
+ "className": "TenantUsageMetricCollection",
244
+ "qualifiedName": "@happyvertical/smrt-subscriptions:TenantUsageMetricCollection",
245
+ "collection": "tenantusagemetrics",
246
+ "filePath": "/home/runner/_work/smrt/smrt/packages/subscriptions/src/collections/TenantUsageMetricCollection.ts",
247
+ "packageName": "@happyvertical/smrt-subscriptions",
248
+ "fields": {},
249
+ "methods": {
250
+ "recordUsage": {
251
+ "name": "recordUsage",
252
+ "async": true,
253
+ "parameters": [
254
+ {
255
+ "name": "options",
256
+ "type": "RecordUsageOptions",
257
+ "optional": false
258
+ }
259
+ ],
260
+ "returnType": "Promise<TenantUsageMetric>",
261
+ "isStatic": false,
262
+ "isPublic": true
263
+ },
264
+ "findByTenantAndMetric": {
265
+ "name": "findByTenantAndMetric",
266
+ "async": true,
267
+ "parameters": [
268
+ {
269
+ "name": "tenantId",
270
+ "type": "string",
271
+ "optional": false
272
+ },
273
+ {
274
+ "name": "metricKey",
275
+ "type": "string",
276
+ "optional": false
277
+ }
278
+ ],
279
+ "returnType": "Promise<TenantUsageMetric[]>",
280
+ "isStatic": false,
281
+ "isPublic": true
282
+ },
283
+ "summarizeUsage": {
284
+ "name": "summarizeUsage",
285
+ "async": true,
286
+ "parameters": [
287
+ {
288
+ "name": "options",
289
+ "type": "SummarizeUsageOptions",
290
+ "optional": false
291
+ }
292
+ ],
293
+ "returnType": "Promise<UsageSummary>",
294
+ "isStatic": false,
295
+ "isPublic": true
296
+ },
297
+ "summarizeUsageBatch": {
298
+ "name": "summarizeUsageBatch",
299
+ "async": true,
300
+ "parameters": [
301
+ {
302
+ "name": "options",
303
+ "type": "SummarizeUsageBatchOptions",
304
+ "optional": false
305
+ }
306
+ ],
307
+ "returnType": "Promise<UsageSummary[]>",
308
+ "isStatic": false,
309
+ "isPublic": true
310
+ },
311
+ "summarizeTenantAiUsage": {
312
+ "name": "summarizeTenantAiUsage",
313
+ "async": true,
314
+ "parameters": [
315
+ {
316
+ "name": "options",
317
+ "type": "SummarizeAiUsageOptions",
318
+ "optional": false
319
+ }
320
+ ],
321
+ "returnType": "Promise<AiUsageSummary>",
322
+ "isStatic": false,
323
+ "isPublic": true
324
+ }
325
+ },
326
+ "decoratorConfig": {
327
+ "tableName": "_smrt_tenant_usage_metrics"
328
+ },
329
+ "extends": "SmrtCollection",
330
+ "extendsTypeArg": "TenantUsageMetric",
331
+ "exportName": "TenantUsageMetricCollection",
332
+ "collectionExportName": "TenantUsageMetricCollectionCollection",
333
+ "schema": {
334
+ "tableName": "_smrt_tenant_usage_metrics",
335
+ "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);",
336
+ "columns": {
337
+ "id": {
338
+ "type": "UUID",
339
+ "primaryKey": true,
340
+ "referenceKind": "id",
341
+ "notNull": true
342
+ },
343
+ "slug": {
344
+ "type": "TEXT",
345
+ "notNull": true
346
+ },
347
+ "context": {
348
+ "type": "TEXT",
349
+ "notNull": true,
350
+ "default": ""
351
+ },
352
+ "created_at": {
353
+ "type": "TIMESTAMP",
354
+ "notNull": true,
355
+ "default": "current_timestamp"
356
+ },
357
+ "updated_at": {
358
+ "type": "TIMESTAMP",
359
+ "notNull": true,
360
+ "default": "current_timestamp"
361
+ }
362
+ },
363
+ "indexes": [
364
+ {
365
+ "name": "_smrt_tenant_usage_metrics_id_idx",
366
+ "columns": [
367
+ "id"
368
+ ]
369
+ },
370
+ {
371
+ "name": "_smrt_tenant_usage_metrics_slug_context_idx",
372
+ "columns": [
373
+ "slug",
374
+ "context"
375
+ ],
376
+ "unique": true
377
+ }
378
+ ],
379
+ "version": "8617d4ac"
380
+ }
381
+ },
382
+ "@happyvertical/smrt-subscriptions:SubscriptionPlan": {
383
+ "name": "subscriptionplan",
384
+ "className": "SubscriptionPlan",
385
+ "qualifiedName": "@happyvertical/smrt-subscriptions:SubscriptionPlan",
386
+ "collection": "subscriptionplans",
387
+ "filePath": "/home/runner/_work/smrt/smrt/packages/subscriptions/src/models/SubscriptionPlan.ts",
388
+ "packageName": "@happyvertical/smrt-subscriptions",
389
+ "fields": {
390
+ "tenantId": {
391
+ "type": "text",
392
+ "required": false,
393
+ "_meta": {
394
+ "sqlType": "UUID",
395
+ "nullable": true,
396
+ "__tenancy": {
397
+ "isTenantIdField": true,
398
+ "autoFilter": true,
399
+ "required": false,
400
+ "autoPopulate": true,
401
+ "nullable": true,
402
+ "mode": "optional",
403
+ "field": "tenantId",
404
+ "allowSuperAdminBypass": false
405
+ }
406
+ }
407
+ },
408
+ "planKey": {
409
+ "type": "text",
410
+ "required": false,
411
+ "default": ""
412
+ },
413
+ "name": {
414
+ "type": "text",
415
+ "required": false,
416
+ "default": ""
417
+ },
418
+ "description": {
419
+ "type": "text",
420
+ "required": false,
421
+ "default": ""
422
+ },
423
+ "status": {
424
+ "type": "text",
425
+ "required": false,
426
+ "default": "active"
427
+ },
428
+ "sortOrder": {
429
+ "type": "integer",
430
+ "required": false,
431
+ "default": 0
432
+ },
433
+ "priceAmount": {
434
+ "type": "decimal",
435
+ "required": false,
436
+ "default": 0
437
+ },
438
+ "currency": {
439
+ "type": "text",
440
+ "required": false,
441
+ "default": "USD"
442
+ },
443
+ "billingInterval": {
444
+ "type": "text",
445
+ "required": false,
446
+ "default": "month"
447
+ },
448
+ "externalProvider": {
449
+ "type": "text",
450
+ "required": false,
451
+ "default": "stripe"
452
+ },
453
+ "stripeProductId": {
454
+ "type": "text",
455
+ "required": false,
456
+ "default": ""
457
+ },
458
+ "stripePriceId": {
459
+ "type": "text",
460
+ "required": false,
461
+ "default": ""
462
+ },
463
+ "features": {
464
+ "type": "text",
465
+ "required": false,
466
+ "default": "[]"
467
+ },
468
+ "thresholds": {
469
+ "type": "text",
470
+ "required": false,
471
+ "default": "[]"
472
+ },
473
+ "metadata": {
474
+ "type": "text",
475
+ "required": false,
476
+ "default": "{}"
477
+ }
478
+ },
479
+ "methods": {
480
+ "isActive": {
481
+ "name": "isActive",
482
+ "async": false,
483
+ "parameters": [],
484
+ "returnType": "boolean",
485
+ "isStatic": false,
486
+ "isPublic": true
487
+ },
488
+ "getFeatureGrants": {
489
+ "name": "getFeatureGrants",
490
+ "async": false,
491
+ "parameters": [],
492
+ "returnType": "PlanFeatureGrant[]",
493
+ "isStatic": false,
494
+ "isPublic": true
495
+ },
496
+ "setFeatureGrants": {
497
+ "name": "setFeatureGrants",
498
+ "async": false,
499
+ "parameters": [
500
+ {
501
+ "name": "grants",
502
+ "type": "Array<string | PlanFeatureGrant>",
503
+ "optional": false
504
+ }
505
+ ],
506
+ "returnType": "void",
507
+ "isStatic": false,
508
+ "isPublic": true
509
+ },
510
+ "getFeatureKeys": {
511
+ "name": "getFeatureKeys",
512
+ "async": false,
513
+ "parameters": [],
514
+ "returnType": "string[]",
515
+ "isStatic": false,
516
+ "isPublic": true
517
+ },
518
+ "getThresholds": {
519
+ "name": "getThresholds",
520
+ "async": false,
521
+ "parameters": [],
522
+ "returnType": "PlanThreshold[]",
523
+ "isStatic": false,
524
+ "isPublic": true
525
+ },
526
+ "setThresholds": {
527
+ "name": "setThresholds",
528
+ "async": false,
529
+ "parameters": [
530
+ {
531
+ "name": "thresholds",
532
+ "type": "PlanThreshold[]",
533
+ "optional": false
534
+ }
535
+ ],
536
+ "returnType": "void",
537
+ "isStatic": false,
538
+ "isPublic": true
539
+ },
540
+ "getMetadata": {
541
+ "name": "getMetadata",
542
+ "async": false,
543
+ "parameters": [],
544
+ "returnType": "JsonObject",
545
+ "isStatic": false,
546
+ "isPublic": true
547
+ },
548
+ "setMetadata": {
549
+ "name": "setMetadata",
550
+ "async": false,
551
+ "parameters": [
552
+ {
553
+ "name": "metadata",
554
+ "type": "JsonObject",
555
+ "optional": false
556
+ }
557
+ ],
558
+ "returnType": "void",
559
+ "isStatic": false,
560
+ "isPublic": true
561
+ }
562
+ },
563
+ "decoratorConfig": {
564
+ "tableName": "_smrt_subscription_plans",
565
+ "api": {
566
+ "include": [
567
+ "list",
568
+ "get",
569
+ "create",
570
+ "update"
571
+ ]
572
+ },
573
+ "cli": true,
574
+ "mcp": {
575
+ "include": [
576
+ "list",
577
+ "get"
578
+ ]
579
+ },
580
+ "conflictColumns": [
581
+ "plan_key"
582
+ ],
583
+ "tenantScoped": {
584
+ "mode": "optional"
585
+ }
586
+ },
587
+ "extends": "SmrtObject",
588
+ "exportName": "SubscriptionPlan",
589
+ "collectionExportName": "SubscriptionPlanCollection",
590
+ "schema": {
591
+ "tableName": "_smrt_subscription_plans",
592
+ "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);",
593
+ "columns": {
594
+ "id": {
595
+ "type": "UUID",
596
+ "primaryKey": true,
597
+ "referenceKind": "id",
598
+ "notNull": true
599
+ },
600
+ "slug": {
601
+ "type": "TEXT",
602
+ "notNull": true
603
+ },
604
+ "context": {
605
+ "type": "TEXT",
606
+ "notNull": true,
607
+ "default": ""
608
+ },
609
+ "created_at": {
610
+ "type": "TIMESTAMP",
611
+ "notNull": true,
612
+ "default": "current_timestamp"
613
+ },
614
+ "updated_at": {
615
+ "type": "TIMESTAMP",
616
+ "notNull": true,
617
+ "default": "current_timestamp"
618
+ },
619
+ "tenant_id": {
620
+ "type": "UUID",
621
+ "referenceKind": "tenantId",
622
+ "notNull": false,
623
+ "unique": false
624
+ },
625
+ "plan_key": {
626
+ "type": "TEXT",
627
+ "notNull": false,
628
+ "unique": false,
629
+ "default": ""
630
+ },
631
+ "name": {
632
+ "type": "TEXT",
633
+ "notNull": false,
634
+ "unique": false,
635
+ "default": ""
636
+ },
637
+ "description": {
638
+ "type": "TEXT",
639
+ "notNull": false,
640
+ "unique": false,
641
+ "default": ""
642
+ },
643
+ "status": {
644
+ "type": "TEXT",
645
+ "notNull": false,
646
+ "unique": false,
647
+ "default": "active"
648
+ },
649
+ "sort_order": {
650
+ "type": "INTEGER",
651
+ "notNull": false,
652
+ "unique": false,
653
+ "default": 0
654
+ },
655
+ "price_amount": {
656
+ "type": "REAL",
657
+ "notNull": false,
658
+ "unique": false,
659
+ "default": 0
660
+ },
661
+ "currency": {
662
+ "type": "TEXT",
663
+ "notNull": false,
664
+ "unique": false,
665
+ "default": "USD"
666
+ },
667
+ "billing_interval": {
668
+ "type": "TEXT",
669
+ "notNull": false,
670
+ "unique": false,
671
+ "default": "month"
672
+ },
673
+ "external_provider": {
674
+ "type": "TEXT",
675
+ "notNull": false,
676
+ "unique": false,
677
+ "default": "stripe"
678
+ },
679
+ "stripe_product_id": {
680
+ "type": "TEXT",
681
+ "notNull": false,
682
+ "unique": false,
683
+ "default": ""
684
+ },
685
+ "stripe_price_id": {
686
+ "type": "TEXT",
687
+ "notNull": false,
688
+ "unique": false,
689
+ "default": ""
690
+ },
691
+ "features": {
692
+ "type": "TEXT",
693
+ "notNull": false,
694
+ "unique": false,
695
+ "default": "[]"
696
+ },
697
+ "thresholds": {
698
+ "type": "TEXT",
699
+ "notNull": false,
700
+ "unique": false,
701
+ "default": "[]"
702
+ },
703
+ "metadata": {
704
+ "type": "TEXT",
705
+ "notNull": false,
706
+ "unique": false,
707
+ "default": "{}"
708
+ }
709
+ },
710
+ "indexes": [
711
+ {
712
+ "name": "_smrt_subscription_plans_id_idx",
713
+ "columns": [
714
+ "id"
715
+ ]
716
+ },
717
+ {
718
+ "name": "_smrt_subscription_plans_plan_key_idx",
719
+ "columns": [
720
+ "plan_key"
721
+ ],
722
+ "unique": true
723
+ }
724
+ ],
725
+ "version": "bbe13cf9"
726
+ }
727
+ },
728
+ "@happyvertical/smrt-subscriptions:TenantSubscription": {
729
+ "name": "tenantsubscription",
730
+ "className": "TenantSubscription",
731
+ "qualifiedName": "@happyvertical/smrt-subscriptions:TenantSubscription",
732
+ "collection": "tenantsubscriptions",
733
+ "filePath": "/home/runner/_work/smrt/smrt/packages/subscriptions/src/models/TenantSubscription.ts",
734
+ "packageName": "@happyvertical/smrt-subscriptions",
735
+ "fields": {
736
+ "tenantId": {
737
+ "type": "text",
738
+ "required": true,
739
+ "_meta": {
740
+ "sqlType": "UUID",
741
+ "__tenancy": {
742
+ "isTenantIdField": true,
743
+ "autoFilter": true,
744
+ "required": true,
745
+ "autoPopulate": true,
746
+ "nullable": false,
747
+ "mode": "required",
748
+ "field": "tenantId",
749
+ "allowSuperAdminBypass": false
750
+ }
751
+ }
752
+ },
753
+ "subscriberKind": {
754
+ "type": "text",
755
+ "required": false,
756
+ "default": "tenant"
757
+ },
758
+ "subscriberExternalId": {
759
+ "type": "text",
760
+ "required": false,
761
+ "default": ""
762
+ },
763
+ "planId": {
764
+ "type": "foreignKey",
765
+ "required": false,
766
+ "related": "SubscriptionPlan"
767
+ },
768
+ "status": {
769
+ "type": "text",
770
+ "required": false,
771
+ "default": "incomplete"
772
+ },
773
+ "startedAt": {
774
+ "type": "datetime",
775
+ "required": false
776
+ },
777
+ "currentPeriodStart": {
778
+ "type": "datetime",
779
+ "required": false
780
+ },
781
+ "currentPeriodEnd": {
782
+ "type": "datetime",
783
+ "required": false
784
+ },
785
+ "trialEndsAt": {
786
+ "type": "datetime",
787
+ "required": false
788
+ },
789
+ "cancelAtPeriodEnd": {
790
+ "type": "boolean",
791
+ "required": false,
792
+ "default": false
793
+ },
794
+ "canceledAt": {
795
+ "type": "datetime",
796
+ "required": false
797
+ },
798
+ "externalProvider": {
799
+ "type": "text",
800
+ "required": false,
801
+ "default": "stripe"
802
+ },
803
+ "stripeCustomerId": {
804
+ "type": "text",
805
+ "required": false,
806
+ "default": ""
807
+ },
808
+ "stripeSubscriptionId": {
809
+ "type": "text",
810
+ "required": false,
811
+ "default": ""
812
+ },
813
+ "stripeCheckoutSessionId": {
814
+ "type": "text",
815
+ "required": false,
816
+ "default": ""
817
+ },
818
+ "metadata": {
819
+ "type": "text",
820
+ "required": false,
821
+ "default": "{}"
822
+ }
823
+ },
824
+ "methods": {
825
+ "isEntitled": {
826
+ "name": "isEntitled",
827
+ "async": false,
828
+ "parameters": [
829
+ {
830
+ "name": "now",
831
+ "type": "any",
832
+ "optional": true
833
+ }
834
+ ],
835
+ "returnType": "boolean",
836
+ "isStatic": false,
837
+ "isPublic": true
838
+ },
839
+ "getSubscriber": {
840
+ "name": "getSubscriber",
841
+ "async": false,
842
+ "parameters": [],
843
+ "returnType": "Subscriber | null",
844
+ "isStatic": false,
845
+ "isPublic": true
846
+ },
847
+ "getMetadata": {
848
+ "name": "getMetadata",
849
+ "async": false,
850
+ "parameters": [],
851
+ "returnType": "JsonObject",
852
+ "isStatic": false,
853
+ "isPublic": true
854
+ },
855
+ "setMetadata": {
856
+ "name": "setMetadata",
857
+ "async": false,
858
+ "parameters": [
859
+ {
860
+ "name": "metadata",
861
+ "type": "JsonObject",
862
+ "optional": false
863
+ }
864
+ ],
865
+ "returnType": "void",
866
+ "isStatic": false,
867
+ "isPublic": true
868
+ }
869
+ },
870
+ "decoratorConfig": {
871
+ "tableName": "_smrt_tenant_subscriptions",
872
+ "api": {
873
+ "include": [
874
+ "list",
875
+ "get",
876
+ "create",
877
+ "update"
878
+ ]
879
+ },
880
+ "cli": true,
881
+ "mcp": {
882
+ "include": [
883
+ "list",
884
+ "get"
885
+ ]
886
+ },
887
+ "conflictColumns": [
888
+ "tenant_id",
889
+ "subscriber_kind",
890
+ "subscriber_external_id"
891
+ ],
892
+ "tenantScoped": {
893
+ "mode": "required"
894
+ }
895
+ },
896
+ "extends": "SmrtObject",
897
+ "exportName": "TenantSubscription",
898
+ "collectionExportName": "TenantSubscriptionCollection",
899
+ "validationRules": [
900
+ {
901
+ "field": "tenantId",
902
+ "rule": "required",
903
+ "fieldType": "text"
904
+ }
905
+ ],
906
+ "schema": {
907
+ "tableName": "_smrt_tenant_subscriptions",
908
+ "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);",
909
+ "columns": {
910
+ "id": {
911
+ "type": "UUID",
912
+ "primaryKey": true,
913
+ "referenceKind": "id",
914
+ "notNull": true
915
+ },
916
+ "slug": {
917
+ "type": "TEXT",
918
+ "notNull": true
919
+ },
920
+ "context": {
921
+ "type": "TEXT",
922
+ "notNull": true,
923
+ "default": ""
924
+ },
925
+ "created_at": {
926
+ "type": "TIMESTAMP",
927
+ "notNull": true,
928
+ "default": "current_timestamp"
929
+ },
930
+ "updated_at": {
931
+ "type": "TIMESTAMP",
932
+ "notNull": true,
933
+ "default": "current_timestamp"
934
+ },
935
+ "tenant_id": {
936
+ "type": "UUID",
937
+ "referenceKind": "tenantId",
938
+ "notNull": true,
939
+ "unique": false
940
+ },
941
+ "subscriber_kind": {
942
+ "type": "TEXT",
943
+ "notNull": false,
944
+ "unique": false,
945
+ "default": "tenant"
946
+ },
947
+ "subscriber_external_id": {
948
+ "type": "TEXT",
949
+ "notNull": false,
950
+ "unique": false,
951
+ "default": ""
952
+ },
953
+ "plan_id": {
954
+ "type": "UUID",
955
+ "referenceKind": "foreignKey",
956
+ "notNull": false,
957
+ "unique": false
958
+ },
959
+ "status": {
960
+ "type": "TEXT",
961
+ "notNull": false,
962
+ "unique": false,
963
+ "default": "incomplete"
964
+ },
965
+ "started_at": {
966
+ "type": "TIMESTAMP",
967
+ "notNull": false,
968
+ "unique": false
969
+ },
970
+ "current_period_start": {
971
+ "type": "TIMESTAMP",
972
+ "notNull": false,
973
+ "unique": false
974
+ },
975
+ "current_period_end": {
976
+ "type": "TIMESTAMP",
977
+ "notNull": false,
978
+ "unique": false
979
+ },
980
+ "trial_ends_at": {
981
+ "type": "TIMESTAMP",
982
+ "notNull": false,
983
+ "unique": false
984
+ },
985
+ "cancel_at_period_end": {
986
+ "type": "BOOLEAN",
987
+ "notNull": false,
988
+ "unique": false,
989
+ "default": false
990
+ },
991
+ "canceled_at": {
992
+ "type": "TIMESTAMP",
993
+ "notNull": false,
994
+ "unique": false
995
+ },
996
+ "external_provider": {
997
+ "type": "TEXT",
998
+ "notNull": false,
999
+ "unique": false,
1000
+ "default": "stripe"
1001
+ },
1002
+ "stripe_customer_id": {
1003
+ "type": "TEXT",
1004
+ "notNull": false,
1005
+ "unique": false,
1006
+ "default": ""
1007
+ },
1008
+ "stripe_subscription_id": {
1009
+ "type": "TEXT",
1010
+ "notNull": false,
1011
+ "unique": false,
1012
+ "default": ""
1013
+ },
1014
+ "stripe_checkout_session_id": {
1015
+ "type": "TEXT",
1016
+ "notNull": false,
1017
+ "unique": false,
1018
+ "default": ""
1019
+ },
1020
+ "metadata": {
1021
+ "type": "TEXT",
1022
+ "notNull": false,
1023
+ "unique": false,
1024
+ "default": "{}"
1025
+ }
1026
+ },
1027
+ "indexes": [
1028
+ {
1029
+ "name": "_smrt_tenant_subscriptions_id_idx",
1030
+ "columns": [
1031
+ "id"
1032
+ ]
1033
+ },
1034
+ {
1035
+ "name": "_smrt_tenant_subscriptions_tenant_id_subscriber_kind_idx",
1036
+ "columns": [
1037
+ "tenant_id",
1038
+ "subscriber_kind",
1039
+ "subscriber_external_id"
1040
+ ],
1041
+ "unique": true
1042
+ }
1043
+ ],
1044
+ "version": "ef3d8be5"
1045
+ }
1046
+ },
1047
+ "@happyvertical/smrt-subscriptions:TenantUsageMetric": {
1048
+ "name": "tenantusagemetric",
1049
+ "className": "TenantUsageMetric",
1050
+ "qualifiedName": "@happyvertical/smrt-subscriptions:TenantUsageMetric",
1051
+ "collection": "tenantusagemetrics",
1052
+ "filePath": "/home/runner/_work/smrt/smrt/packages/subscriptions/src/models/TenantUsageMetric.ts",
1053
+ "packageName": "@happyvertical/smrt-subscriptions",
1054
+ "fields": {
1055
+ "tenantId": {
1056
+ "type": "text",
1057
+ "required": true,
1058
+ "_meta": {
1059
+ "sqlType": "UUID",
1060
+ "__tenancy": {
1061
+ "isTenantIdField": true,
1062
+ "autoFilter": true,
1063
+ "required": true,
1064
+ "autoPopulate": true,
1065
+ "nullable": false,
1066
+ "mode": "required",
1067
+ "field": "tenantId",
1068
+ "allowSuperAdminBypass": false
1069
+ }
1070
+ }
1071
+ },
1072
+ "subscriberKind": {
1073
+ "type": "text",
1074
+ "required": false,
1075
+ "default": "tenant"
1076
+ },
1077
+ "subscriberExternalId": {
1078
+ "type": "text",
1079
+ "required": false,
1080
+ "default": ""
1081
+ },
1082
+ "metricKey": {
1083
+ "type": "text",
1084
+ "required": false,
1085
+ "default": ""
1086
+ },
1087
+ "quantity": {
1088
+ "type": "decimal",
1089
+ "required": false,
1090
+ "default": 0
1091
+ },
1092
+ "windowStart": {
1093
+ "type": "datetime",
1094
+ "required": false
1095
+ },
1096
+ "windowEnd": {
1097
+ "type": "datetime",
1098
+ "required": false
1099
+ },
1100
+ "source": {
1101
+ "type": "text",
1102
+ "required": false,
1103
+ "default": ""
1104
+ },
1105
+ "sourceId": {
1106
+ "type": "text",
1107
+ "required": false,
1108
+ "default": ""
1109
+ },
1110
+ "dimensions": {
1111
+ "type": "text",
1112
+ "required": false,
1113
+ "default": "{}"
1114
+ }
1115
+ },
1116
+ "methods": {
1117
+ "getSubscriber": {
1118
+ "name": "getSubscriber",
1119
+ "async": false,
1120
+ "parameters": [],
1121
+ "returnType": "Subscriber | null",
1122
+ "isStatic": false,
1123
+ "isPublic": true
1124
+ },
1125
+ "getDimensions": {
1126
+ "name": "getDimensions",
1127
+ "async": false,
1128
+ "parameters": [],
1129
+ "returnType": "JsonObject",
1130
+ "isStatic": false,
1131
+ "isPublic": true
1132
+ },
1133
+ "setDimensions": {
1134
+ "name": "setDimensions",
1135
+ "async": false,
1136
+ "parameters": [
1137
+ {
1138
+ "name": "dimensions",
1139
+ "type": "JsonObject",
1140
+ "optional": false
1141
+ }
1142
+ ],
1143
+ "returnType": "void",
1144
+ "isStatic": false,
1145
+ "isPublic": true
1146
+ }
1147
+ },
1148
+ "decoratorConfig": {
1149
+ "tableName": "_smrt_tenant_usage_metrics",
1150
+ "api": {
1151
+ "include": [
1152
+ "list",
1153
+ "get",
1154
+ "create"
1155
+ ]
1156
+ },
1157
+ "cli": true,
1158
+ "mcp": {
1159
+ "include": [
1160
+ "list",
1161
+ "get"
1162
+ ]
1163
+ },
1164
+ "tenantScoped": {
1165
+ "mode": "required"
1166
+ }
1167
+ },
1168
+ "extends": "SmrtObject",
1169
+ "exportName": "TenantUsageMetric",
1170
+ "collectionExportName": "TenantUsageMetricCollection",
1171
+ "validationRules": [
1172
+ {
1173
+ "field": "tenantId",
1174
+ "rule": "required",
1175
+ "fieldType": "text"
1176
+ }
1177
+ ],
1178
+ "schema": {
1179
+ "tableName": "_smrt_tenant_usage_metrics",
1180
+ "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 \"dimensions\" TEXT DEFAULT '{}'\n);",
1181
+ "columns": {
1182
+ "id": {
1183
+ "type": "UUID",
1184
+ "primaryKey": true,
1185
+ "referenceKind": "id",
1186
+ "notNull": true
1187
+ },
1188
+ "slug": {
1189
+ "type": "TEXT",
1190
+ "notNull": true
1191
+ },
1192
+ "context": {
1193
+ "type": "TEXT",
1194
+ "notNull": true,
1195
+ "default": ""
1196
+ },
1197
+ "created_at": {
1198
+ "type": "TIMESTAMP",
1199
+ "notNull": true,
1200
+ "default": "current_timestamp"
1201
+ },
1202
+ "updated_at": {
1203
+ "type": "TIMESTAMP",
1204
+ "notNull": true,
1205
+ "default": "current_timestamp"
1206
+ },
1207
+ "tenant_id": {
1208
+ "type": "UUID",
1209
+ "referenceKind": "tenantId",
1210
+ "notNull": true,
1211
+ "unique": false
1212
+ },
1213
+ "subscriber_kind": {
1214
+ "type": "TEXT",
1215
+ "notNull": false,
1216
+ "unique": false,
1217
+ "default": "tenant"
1218
+ },
1219
+ "subscriber_external_id": {
1220
+ "type": "TEXT",
1221
+ "notNull": false,
1222
+ "unique": false,
1223
+ "default": ""
1224
+ },
1225
+ "metric_key": {
1226
+ "type": "TEXT",
1227
+ "notNull": false,
1228
+ "unique": false,
1229
+ "default": ""
1230
+ },
1231
+ "quantity": {
1232
+ "type": "REAL",
1233
+ "notNull": false,
1234
+ "unique": false,
1235
+ "default": 0
1236
+ },
1237
+ "window_start": {
1238
+ "type": "TIMESTAMP",
1239
+ "notNull": false,
1240
+ "unique": false
1241
+ },
1242
+ "window_end": {
1243
+ "type": "TIMESTAMP",
1244
+ "notNull": false,
1245
+ "unique": false
1246
+ },
1247
+ "source": {
1248
+ "type": "TEXT",
1249
+ "notNull": false,
1250
+ "unique": false,
1251
+ "default": ""
1252
+ },
1253
+ "source_id": {
1254
+ "type": "TEXT",
1255
+ "notNull": false,
1256
+ "unique": false,
1257
+ "default": ""
1258
+ },
1259
+ "dimensions": {
1260
+ "type": "TEXT",
1261
+ "notNull": false,
1262
+ "unique": false,
1263
+ "default": "{}"
1264
+ }
1265
+ },
1266
+ "indexes": [
1267
+ {
1268
+ "name": "_smrt_tenant_usage_metrics_id_idx",
1269
+ "columns": [
1270
+ "id"
1271
+ ]
1272
+ },
1273
+ {
1274
+ "name": "_smrt_tenant_usage_metrics_slug_context_idx",
1275
+ "columns": [
1276
+ "slug",
1277
+ "context"
1278
+ ],
1279
+ "unique": true
1280
+ }
1281
+ ],
1282
+ "version": "ec6ea717"
1283
+ }
1284
+ }
1285
+ },
1286
+ "moduleType": "smrt",
1287
+ "smrtDependencies": [
1288
+ "@happyvertical/smrt-core",
1289
+ "@happyvertical/smrt-tenancy"
1290
+ ]
1291
+ }