@happyvertical/smrt-subscriptions 0.40.69 → 0.41.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.
- package/AGENTS.md +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +85 -3
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +175 -104
- package/dist/migrations/moneyMinorUnits.d.ts +31 -0
- package/dist/migrations/moneyMinorUnits.d.ts.map +1 -0
- package/dist/models/SubscriptionPlan.d.ts +5 -0
- package/dist/models/SubscriptionPlan.d.ts.map +1 -1
- package/dist/models/commercial.d.ts +23 -0
- package/dist/models/commercial.d.ts.map +1 -1
- package/dist/services/commercial.d.ts +26 -0
- package/dist/services/commercial.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +28 -13
- package/dist/svelte/CommercialOverview.svelte +21 -1
- package/dist/svelte/CommercialOverview.svelte.d.ts +1 -0
- package/dist/svelte/CommercialOverview.svelte.d.ts.map +1 -1
- package/dist/svelte/PlanPicker.svelte +21 -4
- package/dist/svelte/PlanPicker.svelte.d.ts +1 -0
- package/dist/svelte/PlanPicker.svelte.d.ts.map +1 -1
- package/dist/svelte/PlanPicker.test.js +31 -0
- package/package.json +6 -5
package/dist/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": "1.0.0",
|
|
3
3
|
"timestamp": 0,
|
|
4
4
|
"packageName": "@happyvertical/smrt-subscriptions",
|
|
5
|
-
"packageVersion": "0.
|
|
5
|
+
"packageVersion": "0.41.0",
|
|
6
6
|
"objects": {
|
|
7
7
|
"@happyvertical/smrt-subscriptions:SubscriptionPlanCollection": {
|
|
8
8
|
"name": "subscriptionplancollection",
|
|
@@ -88,12 +88,6 @@
|
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
"indexes": [
|
|
91
|
-
{
|
|
92
|
-
"name": "_smrt_subscription_plans_id_idx",
|
|
93
|
-
"columns": [
|
|
94
|
-
"id"
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
91
|
{
|
|
98
92
|
"name": "_smrt_subscription_plans_slug_context_idx",
|
|
99
93
|
"columns": [
|
|
@@ -101,6 +95,12 @@
|
|
|
101
95
|
"context"
|
|
102
96
|
],
|
|
103
97
|
"unique": true
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "_smrt_subscription_plans_created_at_idx",
|
|
101
|
+
"columns": [
|
|
102
|
+
"created_at"
|
|
103
|
+
]
|
|
104
104
|
}
|
|
105
105
|
],
|
|
106
106
|
"version": "e693208d"
|
|
@@ -220,12 +220,6 @@
|
|
|
220
220
|
}
|
|
221
221
|
},
|
|
222
222
|
"indexes": [
|
|
223
|
-
{
|
|
224
|
-
"name": "_smrt_tenant_subscriptions_id_idx",
|
|
225
|
-
"columns": [
|
|
226
|
-
"id"
|
|
227
|
-
]
|
|
228
|
-
},
|
|
229
223
|
{
|
|
230
224
|
"name": "_smrt_tenant_subscriptions_slug_context_idx",
|
|
231
225
|
"columns": [
|
|
@@ -233,6 +227,12 @@
|
|
|
233
227
|
"context"
|
|
234
228
|
],
|
|
235
229
|
"unique": true
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "_smrt_tenant_subscriptions_created_at_idx",
|
|
233
|
+
"columns": [
|
|
234
|
+
"created_at"
|
|
235
|
+
]
|
|
236
236
|
}
|
|
237
237
|
],
|
|
238
238
|
"version": "1d17f963"
|
|
@@ -361,12 +361,6 @@
|
|
|
361
361
|
}
|
|
362
362
|
},
|
|
363
363
|
"indexes": [
|
|
364
|
-
{
|
|
365
|
-
"name": "_smrt_tenant_usage_metrics_id_idx",
|
|
366
|
-
"columns": [
|
|
367
|
-
"id"
|
|
368
|
-
]
|
|
369
|
-
},
|
|
370
364
|
{
|
|
371
365
|
"name": "_smrt_tenant_usage_metrics_slug_context_idx",
|
|
372
366
|
"columns": [
|
|
@@ -374,6 +368,12 @@
|
|
|
374
368
|
"context"
|
|
375
369
|
],
|
|
376
370
|
"unique": true
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"name": "_smrt_tenant_usage_metrics_created_at_idx",
|
|
374
|
+
"columns": [
|
|
375
|
+
"created_at"
|
|
376
|
+
]
|
|
377
377
|
}
|
|
378
378
|
],
|
|
379
379
|
"version": "8617d4ac"
|
|
@@ -431,7 +431,7 @@
|
|
|
431
431
|
"default": 0
|
|
432
432
|
},
|
|
433
433
|
"priceAmount": {
|
|
434
|
-
"type": "
|
|
434
|
+
"type": "integer",
|
|
435
435
|
"required": false,
|
|
436
436
|
"default": 0
|
|
437
437
|
},
|
|
@@ -589,7 +589,7 @@
|
|
|
589
589
|
"collectionExportName": "SubscriptionPlanCollection",
|
|
590
590
|
"schema": {
|
|
591
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\"
|
|
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\" INTEGER 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
593
|
"columns": {
|
|
594
594
|
"id": {
|
|
595
595
|
"type": "UUID",
|
|
@@ -653,7 +653,7 @@
|
|
|
653
653
|
"default": 0
|
|
654
654
|
},
|
|
655
655
|
"price_amount": {
|
|
656
|
-
"type": "
|
|
656
|
+
"type": "INTEGER",
|
|
657
657
|
"notNull": false,
|
|
658
658
|
"unique": false,
|
|
659
659
|
"default": 0
|
|
@@ -708,21 +708,29 @@
|
|
|
708
708
|
}
|
|
709
709
|
},
|
|
710
710
|
"indexes": [
|
|
711
|
-
{
|
|
712
|
-
"name": "_smrt_subscription_plans_id_idx",
|
|
713
|
-
"columns": [
|
|
714
|
-
"id"
|
|
715
|
-
]
|
|
716
|
-
},
|
|
717
711
|
{
|
|
718
712
|
"name": "_smrt_subscription_plans_plan_key_idx",
|
|
719
713
|
"columns": [
|
|
720
714
|
"plan_key"
|
|
721
715
|
],
|
|
722
716
|
"unique": true
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
"name": "_smrt_subscription_plans_slug_context_idx",
|
|
720
|
+
"columns": [
|
|
721
|
+
"slug",
|
|
722
|
+
"context"
|
|
723
|
+
]
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
"name": "_smrt_subscription_plans_tenant_id_created_at_idx",
|
|
727
|
+
"columns": [
|
|
728
|
+
"tenant_id",
|
|
729
|
+
"created_at"
|
|
730
|
+
]
|
|
723
731
|
}
|
|
724
732
|
],
|
|
725
|
-
"version": "
|
|
733
|
+
"version": "65765fd0"
|
|
726
734
|
}
|
|
727
735
|
},
|
|
728
736
|
"@happyvertical/smrt-subscriptions:TenantSubscription": {
|
|
@@ -1025,12 +1033,6 @@
|
|
|
1025
1033
|
}
|
|
1026
1034
|
},
|
|
1027
1035
|
"indexes": [
|
|
1028
|
-
{
|
|
1029
|
-
"name": "_smrt_tenant_subscriptions_id_idx",
|
|
1030
|
-
"columns": [
|
|
1031
|
-
"id"
|
|
1032
|
-
]
|
|
1033
|
-
},
|
|
1034
1036
|
{
|
|
1035
1037
|
"name": "_smrt_tenant_subscriptions_tenant_id_subscriber_kind_idx",
|
|
1036
1038
|
"columns": [
|
|
@@ -1039,6 +1041,26 @@
|
|
|
1039
1041
|
"subscriber_external_id"
|
|
1040
1042
|
],
|
|
1041
1043
|
"unique": true
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
"name": "_smrt_tenant_subscriptions_slug_context_idx",
|
|
1047
|
+
"columns": [
|
|
1048
|
+
"slug",
|
|
1049
|
+
"context"
|
|
1050
|
+
]
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
"name": "_smrt_tenant_subscriptions_tenant_id_created_at_idx",
|
|
1054
|
+
"columns": [
|
|
1055
|
+
"tenant_id",
|
|
1056
|
+
"created_at"
|
|
1057
|
+
]
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
"name": "_smrt_tenant_subscriptions_plan_id_idx",
|
|
1061
|
+
"columns": [
|
|
1062
|
+
"plan_id"
|
|
1063
|
+
]
|
|
1042
1064
|
}
|
|
1043
1065
|
],
|
|
1044
1066
|
"version": "ef3d8be5"
|
|
@@ -1189,7 +1211,12 @@
|
|
|
1189
1211
|
},
|
|
1190
1212
|
"tenantScoped": {
|
|
1191
1213
|
"mode": "required"
|
|
1192
|
-
}
|
|
1214
|
+
},
|
|
1215
|
+
"conflictColumns": [
|
|
1216
|
+
"tenant_id",
|
|
1217
|
+
"slug",
|
|
1218
|
+
"context"
|
|
1219
|
+
]
|
|
1193
1220
|
},
|
|
1194
1221
|
"extends": "SmrtObject",
|
|
1195
1222
|
"exportName": "TenantUsageMetric",
|
|
@@ -1314,19 +1341,21 @@
|
|
|
1314
1341
|
}
|
|
1315
1342
|
},
|
|
1316
1343
|
"indexes": [
|
|
1317
|
-
{
|
|
1318
|
-
"name": "_smrt_tenant_usage_metrics_id_idx",
|
|
1319
|
-
"columns": [
|
|
1320
|
-
"id"
|
|
1321
|
-
]
|
|
1322
|
-
},
|
|
1323
1344
|
{
|
|
1324
1345
|
"name": "_smrt_tenant_usage_metrics_slug_context_idx",
|
|
1325
1346
|
"columns": [
|
|
1347
|
+
"tenant_id",
|
|
1326
1348
|
"slug",
|
|
1327
1349
|
"context"
|
|
1328
1350
|
],
|
|
1329
1351
|
"unique": true
|
|
1352
|
+
},
|
|
1353
|
+
{
|
|
1354
|
+
"name": "_smrt_tenant_usage_metrics_tenant_id_created_at_idx",
|
|
1355
|
+
"columns": [
|
|
1356
|
+
"tenant_id",
|
|
1357
|
+
"created_at"
|
|
1358
|
+
]
|
|
1330
1359
|
}
|
|
1331
1360
|
],
|
|
1332
1361
|
"version": "b799c746"
|
|
@@ -1437,7 +1466,12 @@
|
|
|
1437
1466
|
"mcp": true,
|
|
1438
1467
|
"tenantScoped": {
|
|
1439
1468
|
"mode": "required"
|
|
1440
|
-
}
|
|
1469
|
+
},
|
|
1470
|
+
"conflictColumns": [
|
|
1471
|
+
"tenant_id",
|
|
1472
|
+
"slug",
|
|
1473
|
+
"context"
|
|
1474
|
+
]
|
|
1441
1475
|
},
|
|
1442
1476
|
"extends": "SmrtObject",
|
|
1443
1477
|
"exportName": "PricingRule",
|
|
@@ -1544,19 +1578,21 @@
|
|
|
1544
1578
|
}
|
|
1545
1579
|
},
|
|
1546
1580
|
"indexes": [
|
|
1547
|
-
{
|
|
1548
|
-
"name": "_smrt_pricing_rules_id_idx",
|
|
1549
|
-
"columns": [
|
|
1550
|
-
"id"
|
|
1551
|
-
]
|
|
1552
|
-
},
|
|
1553
1581
|
{
|
|
1554
1582
|
"name": "_smrt_pricing_rules_slug_context_idx",
|
|
1555
1583
|
"columns": [
|
|
1584
|
+
"tenant_id",
|
|
1556
1585
|
"slug",
|
|
1557
1586
|
"context"
|
|
1558
1587
|
],
|
|
1559
1588
|
"unique": true
|
|
1589
|
+
},
|
|
1590
|
+
{
|
|
1591
|
+
"name": "_smrt_pricing_rules_tenant_id_created_at_idx",
|
|
1592
|
+
"columns": [
|
|
1593
|
+
"tenant_id",
|
|
1594
|
+
"created_at"
|
|
1595
|
+
]
|
|
1560
1596
|
}
|
|
1561
1597
|
],
|
|
1562
1598
|
"version": "88642897"
|
|
@@ -1638,7 +1674,7 @@
|
|
|
1638
1674
|
"default": 0
|
|
1639
1675
|
},
|
|
1640
1676
|
"amount": {
|
|
1641
|
-
"type": "
|
|
1677
|
+
"type": "integer",
|
|
1642
1678
|
"required": false,
|
|
1643
1679
|
"default": 0
|
|
1644
1680
|
},
|
|
@@ -1716,7 +1752,7 @@
|
|
|
1716
1752
|
],
|
|
1717
1753
|
"schema": {
|
|
1718
1754
|
"tableName": "_smrt_client_charges",
|
|
1719
|
-
"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\"
|
|
1755
|
+
"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\" INTEGER 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);",
|
|
1720
1756
|
"columns": {
|
|
1721
1757
|
"id": {
|
|
1722
1758
|
"type": "UUID",
|
|
@@ -1810,7 +1846,7 @@
|
|
|
1810
1846
|
"default": 0
|
|
1811
1847
|
},
|
|
1812
1848
|
"amount": {
|
|
1813
|
-
"type": "
|
|
1849
|
+
"type": "INTEGER",
|
|
1814
1850
|
"notNull": false,
|
|
1815
1851
|
"unique": false,
|
|
1816
1852
|
"default": 0
|
|
@@ -1846,21 +1882,35 @@
|
|
|
1846
1882
|
}
|
|
1847
1883
|
},
|
|
1848
1884
|
"indexes": [
|
|
1849
|
-
{
|
|
1850
|
-
"name": "_smrt_client_charges_id_idx",
|
|
1851
|
-
"columns": [
|
|
1852
|
-
"id"
|
|
1853
|
-
]
|
|
1854
|
-
},
|
|
1855
1885
|
{
|
|
1856
1886
|
"name": "_smrt_client_charges_usage_event_id_idx",
|
|
1857
1887
|
"columns": [
|
|
1858
1888
|
"usage_event_id"
|
|
1859
1889
|
],
|
|
1860
1890
|
"unique": true
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
"name": "_smrt_client_charges_slug_context_idx",
|
|
1894
|
+
"columns": [
|
|
1895
|
+
"slug",
|
|
1896
|
+
"context"
|
|
1897
|
+
]
|
|
1898
|
+
},
|
|
1899
|
+
{
|
|
1900
|
+
"name": "_smrt_client_charges_tenant_id_created_at_idx",
|
|
1901
|
+
"columns": [
|
|
1902
|
+
"tenant_id",
|
|
1903
|
+
"created_at"
|
|
1904
|
+
]
|
|
1905
|
+
},
|
|
1906
|
+
{
|
|
1907
|
+
"name": "_smrt_client_charges_pricing_rule_id_idx",
|
|
1908
|
+
"columns": [
|
|
1909
|
+
"pricing_rule_id"
|
|
1910
|
+
]
|
|
1861
1911
|
}
|
|
1862
1912
|
],
|
|
1863
|
-
"version": "
|
|
1913
|
+
"version": "eeee66e0"
|
|
1864
1914
|
}
|
|
1865
1915
|
},
|
|
1866
1916
|
"@happyvertical/smrt-subscriptions:BillingAdjustment": {
|
|
@@ -1894,7 +1944,7 @@
|
|
|
1894
1944
|
"related": "ClientCharge"
|
|
1895
1945
|
},
|
|
1896
1946
|
"amount": {
|
|
1897
|
-
"type": "
|
|
1947
|
+
"type": "integer",
|
|
1898
1948
|
"required": false,
|
|
1899
1949
|
"default": 0
|
|
1900
1950
|
},
|
|
@@ -1947,7 +1997,12 @@
|
|
|
1947
1997
|
},
|
|
1948
1998
|
"tenantScoped": {
|
|
1949
1999
|
"mode": "required"
|
|
1950
|
-
}
|
|
2000
|
+
},
|
|
2001
|
+
"conflictColumns": [
|
|
2002
|
+
"tenant_id",
|
|
2003
|
+
"slug",
|
|
2004
|
+
"context"
|
|
2005
|
+
]
|
|
1951
2006
|
},
|
|
1952
2007
|
"extends": "SmrtObject",
|
|
1953
2008
|
"exportName": "BillingAdjustment",
|
|
@@ -1961,7 +2016,7 @@
|
|
|
1961
2016
|
],
|
|
1962
2017
|
"schema": {
|
|
1963
2018
|
"tableName": "_smrt_billing_adjustments",
|
|
1964
|
-
"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\"
|
|
2019
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_billing_adjustments\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"client_charge_id\" UUID,\n \"amount\" INTEGER DEFAULT 0,\n \"currency\" TEXT DEFAULT 'USD',\n \"reason\" TEXT DEFAULT '',\n \"source\" TEXT DEFAULT '',\n \"source_id\" TEXT DEFAULT '',\n \"created_by\" TEXT DEFAULT ''\n);",
|
|
1965
2020
|
"columns": {
|
|
1966
2021
|
"id": {
|
|
1967
2022
|
"type": "UUID",
|
|
@@ -2001,7 +2056,7 @@
|
|
|
2001
2056
|
"unique": false
|
|
2002
2057
|
},
|
|
2003
2058
|
"amount": {
|
|
2004
|
-
"type": "
|
|
2059
|
+
"type": "INTEGER",
|
|
2005
2060
|
"notNull": false,
|
|
2006
2061
|
"unique": false,
|
|
2007
2062
|
"default": 0
|
|
@@ -2038,22 +2093,30 @@
|
|
|
2038
2093
|
}
|
|
2039
2094
|
},
|
|
2040
2095
|
"indexes": [
|
|
2041
|
-
{
|
|
2042
|
-
"name": "_smrt_billing_adjustments_id_idx",
|
|
2043
|
-
"columns": [
|
|
2044
|
-
"id"
|
|
2045
|
-
]
|
|
2046
|
-
},
|
|
2047
2096
|
{
|
|
2048
2097
|
"name": "_smrt_billing_adjustments_slug_context_idx",
|
|
2049
2098
|
"columns": [
|
|
2099
|
+
"tenant_id",
|
|
2050
2100
|
"slug",
|
|
2051
2101
|
"context"
|
|
2052
2102
|
],
|
|
2053
2103
|
"unique": true
|
|
2104
|
+
},
|
|
2105
|
+
{
|
|
2106
|
+
"name": "_smrt_billing_adjustments_tenant_id_created_at_idx",
|
|
2107
|
+
"columns": [
|
|
2108
|
+
"tenant_id",
|
|
2109
|
+
"created_at"
|
|
2110
|
+
]
|
|
2111
|
+
},
|
|
2112
|
+
{
|
|
2113
|
+
"name": "_smrt_billing_adjustments_client_charge_id_idx",
|
|
2114
|
+
"columns": [
|
|
2115
|
+
"client_charge_id"
|
|
2116
|
+
]
|
|
2054
2117
|
}
|
|
2055
2118
|
],
|
|
2056
|
-
"version": "
|
|
2119
|
+
"version": "1c7ec461"
|
|
2057
2120
|
}
|
|
2058
2121
|
},
|
|
2059
2122
|
"@happyvertical/smrt-subscriptions:SpendingPolicy": {
|
|
@@ -2122,7 +2185,7 @@
|
|
|
2122
2185
|
"default": 0
|
|
2123
2186
|
},
|
|
2124
2187
|
"limitAmount": {
|
|
2125
|
-
"type": "
|
|
2188
|
+
"type": "integer",
|
|
2126
2189
|
"required": false,
|
|
2127
2190
|
"default": 0
|
|
2128
2191
|
},
|
|
@@ -2179,7 +2242,7 @@
|
|
|
2179
2242
|
],
|
|
2180
2243
|
"schema": {
|
|
2181
2244
|
"tableName": "_smrt_spending_policies",
|
|
2182
|
-
"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\"
|
|
2245
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_spending_policies\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"name\" TEXT DEFAULT '',\n \"subscriber_kind\" TEXT DEFAULT '',\n \"subscriber_external_id\" TEXT DEFAULT '',\n \"project_id\" TEXT DEFAULT '',\n \"service_key\" TEXT DEFAULT '',\n \"metric_key\" TEXT DEFAULT '',\n \"period\" TEXT DEFAULT 'month',\n \"rolling_seconds\" INTEGER DEFAULT 0,\n \"limit_amount\" INTEGER DEFAULT 0,\n \"currency\" TEXT DEFAULT 'USD',\n \"behavior\" TEXT DEFAULT 'observe',\n \"priority\" INTEGER DEFAULT 0,\n \"active\" BOOLEAN DEFAULT TRUE\n);",
|
|
2183
2246
|
"columns": {
|
|
2184
2247
|
"id": {
|
|
2185
2248
|
"type": "UUID",
|
|
@@ -2261,7 +2324,7 @@
|
|
|
2261
2324
|
"default": 0
|
|
2262
2325
|
},
|
|
2263
2326
|
"limit_amount": {
|
|
2264
|
-
"type": "
|
|
2327
|
+
"type": "INTEGER",
|
|
2265
2328
|
"notNull": false,
|
|
2266
2329
|
"unique": false,
|
|
2267
2330
|
"default": 0
|
|
@@ -2292,12 +2355,6 @@
|
|
|
2292
2355
|
}
|
|
2293
2356
|
},
|
|
2294
2357
|
"indexes": [
|
|
2295
|
-
{
|
|
2296
|
-
"name": "_smrt_spending_policies_id_idx",
|
|
2297
|
-
"columns": [
|
|
2298
|
-
"id"
|
|
2299
|
-
]
|
|
2300
|
-
},
|
|
2301
2358
|
{
|
|
2302
2359
|
"name": "_smrt_spending_policies_tenant_id_subscriber_kind_idx",
|
|
2303
2360
|
"columns": [
|
|
@@ -2311,9 +2368,23 @@
|
|
|
2311
2368
|
"name"
|
|
2312
2369
|
],
|
|
2313
2370
|
"unique": true
|
|
2371
|
+
},
|
|
2372
|
+
{
|
|
2373
|
+
"name": "_smrt_spending_policies_slug_context_idx",
|
|
2374
|
+
"columns": [
|
|
2375
|
+
"slug",
|
|
2376
|
+
"context"
|
|
2377
|
+
]
|
|
2378
|
+
},
|
|
2379
|
+
{
|
|
2380
|
+
"name": "_smrt_spending_policies_tenant_id_created_at_idx",
|
|
2381
|
+
"columns": [
|
|
2382
|
+
"tenant_id",
|
|
2383
|
+
"created_at"
|
|
2384
|
+
]
|
|
2314
2385
|
}
|
|
2315
2386
|
],
|
|
2316
|
-
"version": "
|
|
2387
|
+
"version": "6a413cf4"
|
|
2317
2388
|
}
|
|
2318
2389
|
},
|
|
2319
2390
|
"@happyvertical/smrt-subscriptions:PricingRuleCollection": {
|
|
@@ -2363,12 +2434,6 @@
|
|
|
2363
2434
|
}
|
|
2364
2435
|
},
|
|
2365
2436
|
"indexes": [
|
|
2366
|
-
{
|
|
2367
|
-
"name": "_smrt_pricing_rules_id_idx",
|
|
2368
|
-
"columns": [
|
|
2369
|
-
"id"
|
|
2370
|
-
]
|
|
2371
|
-
},
|
|
2372
2437
|
{
|
|
2373
2438
|
"name": "_smrt_pricing_rules_slug_context_idx",
|
|
2374
2439
|
"columns": [
|
|
@@ -2376,6 +2441,12 @@
|
|
|
2376
2441
|
"context"
|
|
2377
2442
|
],
|
|
2378
2443
|
"unique": true
|
|
2444
|
+
},
|
|
2445
|
+
{
|
|
2446
|
+
"name": "_smrt_pricing_rules_created_at_idx",
|
|
2447
|
+
"columns": [
|
|
2448
|
+
"created_at"
|
|
2449
|
+
]
|
|
2379
2450
|
}
|
|
2380
2451
|
],
|
|
2381
2452
|
"version": "3fb55a6a"
|
|
@@ -2428,12 +2499,6 @@
|
|
|
2428
2499
|
}
|
|
2429
2500
|
},
|
|
2430
2501
|
"indexes": [
|
|
2431
|
-
{
|
|
2432
|
-
"name": "_smrt_client_charges_id_idx",
|
|
2433
|
-
"columns": [
|
|
2434
|
-
"id"
|
|
2435
|
-
]
|
|
2436
|
-
},
|
|
2437
2502
|
{
|
|
2438
2503
|
"name": "_smrt_client_charges_slug_context_idx",
|
|
2439
2504
|
"columns": [
|
|
@@ -2441,6 +2506,12 @@
|
|
|
2441
2506
|
"context"
|
|
2442
2507
|
],
|
|
2443
2508
|
"unique": true
|
|
2509
|
+
},
|
|
2510
|
+
{
|
|
2511
|
+
"name": "_smrt_client_charges_created_at_idx",
|
|
2512
|
+
"columns": [
|
|
2513
|
+
"created_at"
|
|
2514
|
+
]
|
|
2444
2515
|
}
|
|
2445
2516
|
],
|
|
2446
2517
|
"version": "96756a5d"
|
|
@@ -2493,12 +2564,6 @@
|
|
|
2493
2564
|
}
|
|
2494
2565
|
},
|
|
2495
2566
|
"indexes": [
|
|
2496
|
-
{
|
|
2497
|
-
"name": "_smrt_billing_adjustments_id_idx",
|
|
2498
|
-
"columns": [
|
|
2499
|
-
"id"
|
|
2500
|
-
]
|
|
2501
|
-
},
|
|
2502
2567
|
{
|
|
2503
2568
|
"name": "_smrt_billing_adjustments_slug_context_idx",
|
|
2504
2569
|
"columns": [
|
|
@@ -2506,6 +2571,12 @@
|
|
|
2506
2571
|
"context"
|
|
2507
2572
|
],
|
|
2508
2573
|
"unique": true
|
|
2574
|
+
},
|
|
2575
|
+
{
|
|
2576
|
+
"name": "_smrt_billing_adjustments_created_at_idx",
|
|
2577
|
+
"columns": [
|
|
2578
|
+
"created_at"
|
|
2579
|
+
]
|
|
2509
2580
|
}
|
|
2510
2581
|
],
|
|
2511
2582
|
"version": "5ca89c74"
|
|
@@ -2558,12 +2629,6 @@
|
|
|
2558
2629
|
}
|
|
2559
2630
|
},
|
|
2560
2631
|
"indexes": [
|
|
2561
|
-
{
|
|
2562
|
-
"name": "_smrt_spending_policies_id_idx",
|
|
2563
|
-
"columns": [
|
|
2564
|
-
"id"
|
|
2565
|
-
]
|
|
2566
|
-
},
|
|
2567
2632
|
{
|
|
2568
2633
|
"name": "_smrt_spending_policies_slug_context_idx",
|
|
2569
2634
|
"columns": [
|
|
@@ -2571,6 +2636,12 @@
|
|
|
2571
2636
|
"context"
|
|
2572
2637
|
],
|
|
2573
2638
|
"unique": true
|
|
2639
|
+
},
|
|
2640
|
+
{
|
|
2641
|
+
"name": "_smrt_spending_policies_created_at_idx",
|
|
2642
|
+
"columns": [
|
|
2643
|
+
"created_at"
|
|
2644
|
+
]
|
|
2574
2645
|
}
|
|
2575
2646
|
],
|
|
2576
2647
|
"version": "4f25df0f"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DatabaseInterface, MinorUnitsPreflightResult, MinorUnitsRescaleResult, MoneyColumnTarget } from '@happyvertical/smrt-core/migrations';
|
|
2
|
+
/** Marker recorded in `_smrt_backfills` once the rescale has run. */
|
|
3
|
+
export declare const SUBSCRIPTIONS_MONEY_MINOR_UNITS_BACKFILL = "@happyvertical/smrt-subscriptions:money-minor-units:v1";
|
|
4
|
+
/**
|
|
5
|
+
* Every subscriptions money column that held major units before #2401.
|
|
6
|
+
*
|
|
7
|
+
* `quantity` columns are absent on purpose: metered quantities are genuinely
|
|
8
|
+
* fractional and stay DECIMAL.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SUBSCRIPTIONS_MONEY_COLUMNS: MoneyColumnTarget[];
|
|
11
|
+
/**
|
|
12
|
+
* Report what {@link migrateSubscriptionsMoneyToMinorUnits} would do, without
|
|
13
|
+
* writing anything.
|
|
14
|
+
*/
|
|
15
|
+
export declare function preflightSubscriptionsMoneyMinorUnits(db: DatabaseInterface, options?: {
|
|
16
|
+
scale?: number;
|
|
17
|
+
engineHint?: string;
|
|
18
|
+
}): Promise<MinorUnitsPreflightResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Convert every subscriptions money column from floating-point major units to
|
|
21
|
+
* integer minor units. Idempotent via a `_smrt_backfills` marker.
|
|
22
|
+
*
|
|
23
|
+
* @throws `MinorUnitsPreflightError` when a row would be rounded or would
|
|
24
|
+
* overflow `int4` and `force` was not set.
|
|
25
|
+
*/
|
|
26
|
+
export declare function migrateSubscriptionsMoneyToMinorUnits(db: DatabaseInterface, options?: {
|
|
27
|
+
scale?: number;
|
|
28
|
+
engineHint?: string;
|
|
29
|
+
force?: boolean;
|
|
30
|
+
}): Promise<MinorUnitsRescaleResult>;
|
|
31
|
+
//# sourceMappingURL=moneyMinorUnits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moneyMinorUnits.d.ts","sourceRoot":"","sources":["../../src/migrations/moneyMinorUnits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EAGvB,MAAM,qCAAqC,CAAC;AAE7C,qEAAqE;AACrE,eAAO,MAAM,wCAAwC,2DACK,CAAC;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,iBAAiB,EAK1D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qCAAqC,CACnD,EAAE,EAAE,iBAAiB,EACrB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACpD,OAAO,CAAC,yBAAyB,CAAC,CAEpC;AAED;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CACnD,EAAE,EAAE,iBAAiB,EACrB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACrE,OAAO,CAAC,uBAAuB,CAAC,CAMlC"}
|
|
@@ -7,6 +7,11 @@ export declare class SubscriptionPlan extends SmrtObject {
|
|
|
7
7
|
description: string;
|
|
8
8
|
status: SubscriptionPlanStatus;
|
|
9
9
|
sortOrder: number;
|
|
10
|
+
/**
|
|
11
|
+
* Plan price in **integer minor units** of {@link currency} — `$19.99` is
|
|
12
|
+
* `1999`. The `= 0` initializer is load-bearing: SMRT maps an integer literal
|
|
13
|
+
* to INTEGER and a decimal literal to DECIMAL, and money is exact (#2401).
|
|
14
|
+
*/
|
|
10
15
|
priceAmount: number;
|
|
11
16
|
currency: string;
|
|
12
17
|
billingInterval: BillingInterval;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionPlan.d.ts","sourceRoot":"","sources":["../../src/models/SubscriptionPlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAE5D,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAQrB,qBAQa,gBAAiB,SAAQ,UAAU;IAE9C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B,OAAO,EAAE,MAAM,CAAM;IACrB,IAAI,EAAE,MAAM,CAAM;IAClB,WAAW,EAAE,MAAM,CAAM;IACzB,MAAM,EAAE,sBAAsB,CAAY;IAC1C,SAAS,EAAE,MAAM,CAAK;IACtB,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SubscriptionPlan.d.ts","sourceRoot":"","sources":["../../src/models/SubscriptionPlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAE5D,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAQrB,qBAQa,gBAAiB,SAAQ,UAAU;IAE9C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B,OAAO,EAAE,MAAM,CAAM;IACrB,IAAI,EAAE,MAAM,CAAM;IAClB,WAAW,EAAE,MAAM,CAAM;IACzB,MAAM,EAAE,sBAAsB,CAAY;IAC1C,SAAS,EAAE,MAAM,CAAK;IACtB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAK;IACxB,QAAQ,EAAE,MAAM,CAAS;IACzB,eAAe,EAAE,eAAe,CAAW;IAC3C,gBAAgB,EAAE,MAAM,CAAY;IACpC,eAAe,EAAE,MAAM,CAAM;IAC7B,aAAa,EAAE,MAAM,CAAM;IAC3B,QAAQ,EAAE,MAAM,CAAQ;IACxB,UAAU,EAAE,MAAM,CAAQ;IAC1B,QAAQ,EAAE,MAAM,CAAQ;gBAEZ,OAAO,GAAE,uBAA4B;IA6BjD,QAAQ,IAAI,OAAO;IAInB,gBAAgB,IAAI,gBAAgB,EAAE;IAMtC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAC,GAAG,IAAI;IAIhE,cAAc,IAAI,MAAM,EAAE;IAM1B,aAAa,IAAI,aAAa,EAAE;IAMhC,aAAa,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,IAAI;IAIhD,WAAW,IAAI,UAAU;IAIzB,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI;CAGxC;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -28,7 +28,19 @@ export declare class ClientCharge extends SmrtObject {
|
|
|
28
28
|
provider: string;
|
|
29
29
|
serviceKey: string;
|
|
30
30
|
metricKey: string;
|
|
31
|
+
/**
|
|
32
|
+
* Metered quantity — genuinely fractional (`duration.seconds`, token counts
|
|
33
|
+
* scaled by a rate), so it stays DECIMAL.
|
|
34
|
+
*/
|
|
31
35
|
quantity: number;
|
|
36
|
+
/**
|
|
37
|
+
* Charge in **integer minor units** of {@link currency} (#2401).
|
|
38
|
+
*
|
|
39
|
+
* Summed against {@link BillingAdjustment.amount} and compared against
|
|
40
|
+
* {@link SpendingPolicy.limitAmount}, so all three carry the same unit —
|
|
41
|
+
* `CommercialService.calculateAmount()` rounds to a whole minor unit at the
|
|
42
|
+
* one boundary where the fractional pricing terms meet money.
|
|
43
|
+
*/
|
|
32
44
|
amount: number;
|
|
33
45
|
currency: string;
|
|
34
46
|
pricingRuleId: string;
|
|
@@ -41,6 +53,12 @@ export declare class ClientCharge extends SmrtObject {
|
|
|
41
53
|
export declare class BillingAdjustment extends SmrtObject {
|
|
42
54
|
tenantId?: string;
|
|
43
55
|
clientChargeId: string;
|
|
56
|
+
/**
|
|
57
|
+
* Signed correction in **integer minor units**, same unit as
|
|
58
|
+
* {@link ClientCharge.amount} it adjusts. Negative values are legitimate
|
|
59
|
+
* (a credit) — that is why the non-negative guard in
|
|
60
|
+
* `CommercialService.calculateAmount()` does not apply here (#2401).
|
|
61
|
+
*/
|
|
44
62
|
amount: number;
|
|
45
63
|
currency: string;
|
|
46
64
|
reason: string;
|
|
@@ -59,6 +77,11 @@ export declare class SpendingPolicy extends SmrtObject {
|
|
|
59
77
|
metricKey: string;
|
|
60
78
|
period: SpendingPeriod;
|
|
61
79
|
rollingSeconds: number;
|
|
80
|
+
/**
|
|
81
|
+
* Spending cap in **integer minor units** of {@link currency}. Compared
|
|
82
|
+
* directly against the sum of `ClientCharge.amount` + `BillingAdjustment`s
|
|
83
|
+
* plus the caller's estimate, so it must carry the same unit (#2401).
|
|
84
|
+
*/
|
|
62
85
|
limitAmount: number;
|
|
63
86
|
currency: string;
|
|
64
87
|
behavior: SpendingPolicyBehavior;
|