@happyvertical/smrt-subscriptions 0.40.70 → 0.42.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 +36 -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 +155 -114
- 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.42.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,12 +708,6 @@
|
|
|
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": [
|
|
@@ -722,13 +716,21 @@
|
|
|
722
716
|
"unique": true
|
|
723
717
|
},
|
|
724
718
|
{
|
|
725
|
-
"name": "
|
|
719
|
+
"name": "_smrt_subscription_plans_slug_context_idx",
|
|
726
720
|
"columns": [
|
|
727
|
-
"
|
|
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"
|
|
728
730
|
]
|
|
729
731
|
}
|
|
730
732
|
],
|
|
731
|
-
"version": "
|
|
733
|
+
"version": "65765fd0"
|
|
732
734
|
}
|
|
733
735
|
},
|
|
734
736
|
"@happyvertical/smrt-subscriptions:TenantSubscription": {
|
|
@@ -1031,12 +1033,6 @@
|
|
|
1031
1033
|
}
|
|
1032
1034
|
},
|
|
1033
1035
|
"indexes": [
|
|
1034
|
-
{
|
|
1035
|
-
"name": "_smrt_tenant_subscriptions_id_idx",
|
|
1036
|
-
"columns": [
|
|
1037
|
-
"id"
|
|
1038
|
-
]
|
|
1039
|
-
},
|
|
1040
1036
|
{
|
|
1041
1037
|
"name": "_smrt_tenant_subscriptions_tenant_id_subscriber_kind_idx",
|
|
1042
1038
|
"columns": [
|
|
@@ -1045,6 +1041,26 @@
|
|
|
1045
1041
|
"subscriber_external_id"
|
|
1046
1042
|
],
|
|
1047
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
|
+
]
|
|
1048
1064
|
}
|
|
1049
1065
|
],
|
|
1050
1066
|
"version": "ef3d8be5"
|
|
@@ -1195,7 +1211,12 @@
|
|
|
1195
1211
|
},
|
|
1196
1212
|
"tenantScoped": {
|
|
1197
1213
|
"mode": "required"
|
|
1198
|
-
}
|
|
1214
|
+
},
|
|
1215
|
+
"conflictColumns": [
|
|
1216
|
+
"tenant_id",
|
|
1217
|
+
"slug",
|
|
1218
|
+
"context"
|
|
1219
|
+
]
|
|
1199
1220
|
},
|
|
1200
1221
|
"extends": "SmrtObject",
|
|
1201
1222
|
"exportName": "TenantUsageMetric",
|
|
@@ -1320,24 +1341,20 @@
|
|
|
1320
1341
|
}
|
|
1321
1342
|
},
|
|
1322
1343
|
"indexes": [
|
|
1323
|
-
{
|
|
1324
|
-
"name": "_smrt_tenant_usage_metrics_id_idx",
|
|
1325
|
-
"columns": [
|
|
1326
|
-
"id"
|
|
1327
|
-
]
|
|
1328
|
-
},
|
|
1329
1344
|
{
|
|
1330
1345
|
"name": "_smrt_tenant_usage_metrics_slug_context_idx",
|
|
1331
1346
|
"columns": [
|
|
1347
|
+
"tenant_id",
|
|
1332
1348
|
"slug",
|
|
1333
1349
|
"context"
|
|
1334
1350
|
],
|
|
1335
1351
|
"unique": true
|
|
1336
1352
|
},
|
|
1337
1353
|
{
|
|
1338
|
-
"name": "
|
|
1354
|
+
"name": "_smrt_tenant_usage_metrics_tenant_id_created_at_idx",
|
|
1339
1355
|
"columns": [
|
|
1340
|
-
"tenant_id"
|
|
1356
|
+
"tenant_id",
|
|
1357
|
+
"created_at"
|
|
1341
1358
|
]
|
|
1342
1359
|
}
|
|
1343
1360
|
],
|
|
@@ -1449,7 +1466,12 @@
|
|
|
1449
1466
|
"mcp": true,
|
|
1450
1467
|
"tenantScoped": {
|
|
1451
1468
|
"mode": "required"
|
|
1452
|
-
}
|
|
1469
|
+
},
|
|
1470
|
+
"conflictColumns": [
|
|
1471
|
+
"tenant_id",
|
|
1472
|
+
"slug",
|
|
1473
|
+
"context"
|
|
1474
|
+
]
|
|
1453
1475
|
},
|
|
1454
1476
|
"extends": "SmrtObject",
|
|
1455
1477
|
"exportName": "PricingRule",
|
|
@@ -1556,24 +1578,20 @@
|
|
|
1556
1578
|
}
|
|
1557
1579
|
},
|
|
1558
1580
|
"indexes": [
|
|
1559
|
-
{
|
|
1560
|
-
"name": "_smrt_pricing_rules_id_idx",
|
|
1561
|
-
"columns": [
|
|
1562
|
-
"id"
|
|
1563
|
-
]
|
|
1564
|
-
},
|
|
1565
1581
|
{
|
|
1566
1582
|
"name": "_smrt_pricing_rules_slug_context_idx",
|
|
1567
1583
|
"columns": [
|
|
1584
|
+
"tenant_id",
|
|
1568
1585
|
"slug",
|
|
1569
1586
|
"context"
|
|
1570
1587
|
],
|
|
1571
1588
|
"unique": true
|
|
1572
1589
|
},
|
|
1573
1590
|
{
|
|
1574
|
-
"name": "
|
|
1591
|
+
"name": "_smrt_pricing_rules_tenant_id_created_at_idx",
|
|
1575
1592
|
"columns": [
|
|
1576
|
-
"tenant_id"
|
|
1593
|
+
"tenant_id",
|
|
1594
|
+
"created_at"
|
|
1577
1595
|
]
|
|
1578
1596
|
}
|
|
1579
1597
|
],
|
|
@@ -1656,7 +1674,7 @@
|
|
|
1656
1674
|
"default": 0
|
|
1657
1675
|
},
|
|
1658
1676
|
"amount": {
|
|
1659
|
-
"type": "
|
|
1677
|
+
"type": "integer",
|
|
1660
1678
|
"required": false,
|
|
1661
1679
|
"default": 0
|
|
1662
1680
|
},
|
|
@@ -1734,7 +1752,7 @@
|
|
|
1734
1752
|
],
|
|
1735
1753
|
"schema": {
|
|
1736
1754
|
"tableName": "_smrt_client_charges",
|
|
1737
|
-
"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);",
|
|
1738
1756
|
"columns": {
|
|
1739
1757
|
"id": {
|
|
1740
1758
|
"type": "UUID",
|
|
@@ -1828,7 +1846,7 @@
|
|
|
1828
1846
|
"default": 0
|
|
1829
1847
|
},
|
|
1830
1848
|
"amount": {
|
|
1831
|
-
"type": "
|
|
1849
|
+
"type": "INTEGER",
|
|
1832
1850
|
"notNull": false,
|
|
1833
1851
|
"unique": false,
|
|
1834
1852
|
"default": 0
|
|
@@ -1864,12 +1882,6 @@
|
|
|
1864
1882
|
}
|
|
1865
1883
|
},
|
|
1866
1884
|
"indexes": [
|
|
1867
|
-
{
|
|
1868
|
-
"name": "_smrt_client_charges_id_idx",
|
|
1869
|
-
"columns": [
|
|
1870
|
-
"id"
|
|
1871
|
-
]
|
|
1872
|
-
},
|
|
1873
1885
|
{
|
|
1874
1886
|
"name": "_smrt_client_charges_usage_event_id_idx",
|
|
1875
1887
|
"columns": [
|
|
@@ -1878,13 +1890,27 @@
|
|
|
1878
1890
|
"unique": true
|
|
1879
1891
|
},
|
|
1880
1892
|
{
|
|
1881
|
-
"name": "
|
|
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",
|
|
1882
1908
|
"columns": [
|
|
1883
|
-
"
|
|
1909
|
+
"pricing_rule_id"
|
|
1884
1910
|
]
|
|
1885
1911
|
}
|
|
1886
1912
|
],
|
|
1887
|
-
"version": "
|
|
1913
|
+
"version": "eeee66e0"
|
|
1888
1914
|
}
|
|
1889
1915
|
},
|
|
1890
1916
|
"@happyvertical/smrt-subscriptions:BillingAdjustment": {
|
|
@@ -1918,7 +1944,7 @@
|
|
|
1918
1944
|
"related": "ClientCharge"
|
|
1919
1945
|
},
|
|
1920
1946
|
"amount": {
|
|
1921
|
-
"type": "
|
|
1947
|
+
"type": "integer",
|
|
1922
1948
|
"required": false,
|
|
1923
1949
|
"default": 0
|
|
1924
1950
|
},
|
|
@@ -1971,7 +1997,12 @@
|
|
|
1971
1997
|
},
|
|
1972
1998
|
"tenantScoped": {
|
|
1973
1999
|
"mode": "required"
|
|
1974
|
-
}
|
|
2000
|
+
},
|
|
2001
|
+
"conflictColumns": [
|
|
2002
|
+
"tenant_id",
|
|
2003
|
+
"slug",
|
|
2004
|
+
"context"
|
|
2005
|
+
]
|
|
1975
2006
|
},
|
|
1976
2007
|
"extends": "SmrtObject",
|
|
1977
2008
|
"exportName": "BillingAdjustment",
|
|
@@ -1985,7 +2016,7 @@
|
|
|
1985
2016
|
],
|
|
1986
2017
|
"schema": {
|
|
1987
2018
|
"tableName": "_smrt_billing_adjustments",
|
|
1988
|
-
"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);",
|
|
1989
2020
|
"columns": {
|
|
1990
2021
|
"id": {
|
|
1991
2022
|
"type": "UUID",
|
|
@@ -2025,7 +2056,7 @@
|
|
|
2025
2056
|
"unique": false
|
|
2026
2057
|
},
|
|
2027
2058
|
"amount": {
|
|
2028
|
-
"type": "
|
|
2059
|
+
"type": "INTEGER",
|
|
2029
2060
|
"notNull": false,
|
|
2030
2061
|
"unique": false,
|
|
2031
2062
|
"default": 0
|
|
@@ -2062,28 +2093,30 @@
|
|
|
2062
2093
|
}
|
|
2063
2094
|
},
|
|
2064
2095
|
"indexes": [
|
|
2065
|
-
{
|
|
2066
|
-
"name": "_smrt_billing_adjustments_id_idx",
|
|
2067
|
-
"columns": [
|
|
2068
|
-
"id"
|
|
2069
|
-
]
|
|
2070
|
-
},
|
|
2071
2096
|
{
|
|
2072
2097
|
"name": "_smrt_billing_adjustments_slug_context_idx",
|
|
2073
2098
|
"columns": [
|
|
2099
|
+
"tenant_id",
|
|
2074
2100
|
"slug",
|
|
2075
2101
|
"context"
|
|
2076
2102
|
],
|
|
2077
2103
|
"unique": true
|
|
2078
2104
|
},
|
|
2079
2105
|
{
|
|
2080
|
-
"name": "
|
|
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",
|
|
2081
2114
|
"columns": [
|
|
2082
|
-
"
|
|
2115
|
+
"client_charge_id"
|
|
2083
2116
|
]
|
|
2084
2117
|
}
|
|
2085
2118
|
],
|
|
2086
|
-
"version": "
|
|
2119
|
+
"version": "1c7ec461"
|
|
2087
2120
|
}
|
|
2088
2121
|
},
|
|
2089
2122
|
"@happyvertical/smrt-subscriptions:SpendingPolicy": {
|
|
@@ -2152,7 +2185,7 @@
|
|
|
2152
2185
|
"default": 0
|
|
2153
2186
|
},
|
|
2154
2187
|
"limitAmount": {
|
|
2155
|
-
"type": "
|
|
2188
|
+
"type": "integer",
|
|
2156
2189
|
"required": false,
|
|
2157
2190
|
"default": 0
|
|
2158
2191
|
},
|
|
@@ -2209,7 +2242,7 @@
|
|
|
2209
2242
|
],
|
|
2210
2243
|
"schema": {
|
|
2211
2244
|
"tableName": "_smrt_spending_policies",
|
|
2212
|
-
"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);",
|
|
2213
2246
|
"columns": {
|
|
2214
2247
|
"id": {
|
|
2215
2248
|
"type": "UUID",
|
|
@@ -2291,7 +2324,7 @@
|
|
|
2291
2324
|
"default": 0
|
|
2292
2325
|
},
|
|
2293
2326
|
"limit_amount": {
|
|
2294
|
-
"type": "
|
|
2327
|
+
"type": "INTEGER",
|
|
2295
2328
|
"notNull": false,
|
|
2296
2329
|
"unique": false,
|
|
2297
2330
|
"default": 0
|
|
@@ -2322,12 +2355,6 @@
|
|
|
2322
2355
|
}
|
|
2323
2356
|
},
|
|
2324
2357
|
"indexes": [
|
|
2325
|
-
{
|
|
2326
|
-
"name": "_smrt_spending_policies_id_idx",
|
|
2327
|
-
"columns": [
|
|
2328
|
-
"id"
|
|
2329
|
-
]
|
|
2330
|
-
},
|
|
2331
2358
|
{
|
|
2332
2359
|
"name": "_smrt_spending_policies_tenant_id_subscriber_kind_idx",
|
|
2333
2360
|
"columns": [
|
|
@@ -2341,9 +2368,23 @@
|
|
|
2341
2368
|
"name"
|
|
2342
2369
|
],
|
|
2343
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
|
+
]
|
|
2344
2385
|
}
|
|
2345
2386
|
],
|
|
2346
|
-
"version": "
|
|
2387
|
+
"version": "6a413cf4"
|
|
2347
2388
|
}
|
|
2348
2389
|
},
|
|
2349
2390
|
"@happyvertical/smrt-subscriptions:PricingRuleCollection": {
|
|
@@ -2393,12 +2434,6 @@
|
|
|
2393
2434
|
}
|
|
2394
2435
|
},
|
|
2395
2436
|
"indexes": [
|
|
2396
|
-
{
|
|
2397
|
-
"name": "_smrt_pricing_rules_id_idx",
|
|
2398
|
-
"columns": [
|
|
2399
|
-
"id"
|
|
2400
|
-
]
|
|
2401
|
-
},
|
|
2402
2437
|
{
|
|
2403
2438
|
"name": "_smrt_pricing_rules_slug_context_idx",
|
|
2404
2439
|
"columns": [
|
|
@@ -2406,6 +2441,12 @@
|
|
|
2406
2441
|
"context"
|
|
2407
2442
|
],
|
|
2408
2443
|
"unique": true
|
|
2444
|
+
},
|
|
2445
|
+
{
|
|
2446
|
+
"name": "_smrt_pricing_rules_created_at_idx",
|
|
2447
|
+
"columns": [
|
|
2448
|
+
"created_at"
|
|
2449
|
+
]
|
|
2409
2450
|
}
|
|
2410
2451
|
],
|
|
2411
2452
|
"version": "3fb55a6a"
|
|
@@ -2458,12 +2499,6 @@
|
|
|
2458
2499
|
}
|
|
2459
2500
|
},
|
|
2460
2501
|
"indexes": [
|
|
2461
|
-
{
|
|
2462
|
-
"name": "_smrt_client_charges_id_idx",
|
|
2463
|
-
"columns": [
|
|
2464
|
-
"id"
|
|
2465
|
-
]
|
|
2466
|
-
},
|
|
2467
2502
|
{
|
|
2468
2503
|
"name": "_smrt_client_charges_slug_context_idx",
|
|
2469
2504
|
"columns": [
|
|
@@ -2471,6 +2506,12 @@
|
|
|
2471
2506
|
"context"
|
|
2472
2507
|
],
|
|
2473
2508
|
"unique": true
|
|
2509
|
+
},
|
|
2510
|
+
{
|
|
2511
|
+
"name": "_smrt_client_charges_created_at_idx",
|
|
2512
|
+
"columns": [
|
|
2513
|
+
"created_at"
|
|
2514
|
+
]
|
|
2474
2515
|
}
|
|
2475
2516
|
],
|
|
2476
2517
|
"version": "96756a5d"
|
|
@@ -2523,12 +2564,6 @@
|
|
|
2523
2564
|
}
|
|
2524
2565
|
},
|
|
2525
2566
|
"indexes": [
|
|
2526
|
-
{
|
|
2527
|
-
"name": "_smrt_billing_adjustments_id_idx",
|
|
2528
|
-
"columns": [
|
|
2529
|
-
"id"
|
|
2530
|
-
]
|
|
2531
|
-
},
|
|
2532
2567
|
{
|
|
2533
2568
|
"name": "_smrt_billing_adjustments_slug_context_idx",
|
|
2534
2569
|
"columns": [
|
|
@@ -2536,6 +2571,12 @@
|
|
|
2536
2571
|
"context"
|
|
2537
2572
|
],
|
|
2538
2573
|
"unique": true
|
|
2574
|
+
},
|
|
2575
|
+
{
|
|
2576
|
+
"name": "_smrt_billing_adjustments_created_at_idx",
|
|
2577
|
+
"columns": [
|
|
2578
|
+
"created_at"
|
|
2579
|
+
]
|
|
2539
2580
|
}
|
|
2540
2581
|
],
|
|
2541
2582
|
"version": "5ca89c74"
|
|
@@ -2588,12 +2629,6 @@
|
|
|
2588
2629
|
}
|
|
2589
2630
|
},
|
|
2590
2631
|
"indexes": [
|
|
2591
|
-
{
|
|
2592
|
-
"name": "_smrt_spending_policies_id_idx",
|
|
2593
|
-
"columns": [
|
|
2594
|
-
"id"
|
|
2595
|
-
]
|
|
2596
|
-
},
|
|
2597
2632
|
{
|
|
2598
2633
|
"name": "_smrt_spending_policies_slug_context_idx",
|
|
2599
2634
|
"columns": [
|
|
@@ -2601,6 +2636,12 @@
|
|
|
2601
2636
|
"context"
|
|
2602
2637
|
],
|
|
2603
2638
|
"unique": true
|
|
2639
|
+
},
|
|
2640
|
+
{
|
|
2641
|
+
"name": "_smrt_spending_policies_created_at_idx",
|
|
2642
|
+
"columns": [
|
|
2643
|
+
"created_at"
|
|
2644
|
+
]
|
|
2604
2645
|
}
|
|
2605
2646
|
],
|
|
2606
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"}
|