@happyvertical/smrt-subscriptions 0.51.21 → 0.51.24
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 +29 -1
- package/README.md +126 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1067 -94
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1758 -13
- package/dist/models/commercial.d.ts +61 -1
- package/dist/models/commercial.d.ts.map +1 -1
- package/dist/models/index.d.ts +3 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/reseller.d.ts +107 -0
- package/dist/models/reseller.d.ts.map +1 -0
- package/dist/services/commercial.d.ts +147 -6
- package/dist/services/commercial.d.ts.map +1 -1
- package/dist/services/index.d.ts +3 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/reseller-errors.d.ts +7 -0
- package/dist/services/reseller-errors.d.ts.map +1 -0
- package/dist/services/reseller.d.ts +154 -0
- package/dist/services/reseller.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +962 -183
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-subscriptions",
|
|
6
|
-
"packageVersion": "0.51.
|
|
6
|
+
"packageVersion": "0.51.24",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
12
|
-
"agents": "
|
|
10
|
+
"manifest": "8ff906be519d9c5ef124675c0b671342369c6e3d326bb49747de6aeb4ae67b04",
|
|
11
|
+
"packageJson": "1c2be76b491ab95393c56fe66863c69afd9d1f21d91118da73b4041d6fe217ca",
|
|
12
|
+
"agents": "debf4259aee01e1df2ce90f22dec0321a0589cd5a3453541c15221dc437878b0"
|
|
13
13
|
},
|
|
14
14
|
"exports": [
|
|
15
15
|
".",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"subscriptions"
|
|
50
50
|
],
|
|
51
51
|
"risks": [
|
|
52
|
+
"cross-package-refs:6",
|
|
52
53
|
"sensitive-fields-excluded"
|
|
53
54
|
],
|
|
54
55
|
"objects": [
|
|
@@ -1430,9 +1431,24 @@
|
|
|
1430
1431
|
"required": false,
|
|
1431
1432
|
"columnType": "BOOLEAN",
|
|
1432
1433
|
"default": true
|
|
1434
|
+
},
|
|
1435
|
+
{
|
|
1436
|
+
"name": "priceBookId",
|
|
1437
|
+
"type": "foreignKey",
|
|
1438
|
+
"required": false,
|
|
1439
|
+
"related": "PriceBook",
|
|
1440
|
+
"columnType": "UUID"
|
|
1441
|
+
}
|
|
1442
|
+
],
|
|
1443
|
+
"relationships": [
|
|
1444
|
+
{
|
|
1445
|
+
"name": "priceBookId",
|
|
1446
|
+
"type": "foreignKey",
|
|
1447
|
+
"required": false,
|
|
1448
|
+
"related": "PriceBook",
|
|
1449
|
+
"columnType": "UUID"
|
|
1433
1450
|
}
|
|
1434
1451
|
],
|
|
1435
|
-
"relationships": [],
|
|
1436
1452
|
"methods": [
|
|
1437
1453
|
"getTerms",
|
|
1438
1454
|
"setTerms"
|
|
@@ -1603,6 +1619,7 @@
|
|
|
1603
1619
|
}
|
|
1604
1620
|
],
|
|
1605
1621
|
"relationshipFeatures": [
|
|
1622
|
+
"foreignKey",
|
|
1606
1623
|
"uuidColumns"
|
|
1607
1624
|
],
|
|
1608
1625
|
"tags": [],
|
|
@@ -1629,6 +1646,13 @@
|
|
|
1629
1646
|
"related": "TenantUsageMetric",
|
|
1630
1647
|
"columnType": "UUID"
|
|
1631
1648
|
},
|
|
1649
|
+
{
|
|
1650
|
+
"name": "usageTenantId",
|
|
1651
|
+
"type": "crossPackageRef",
|
|
1652
|
+
"required": false,
|
|
1653
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
1654
|
+
"columnType": "UUID"
|
|
1655
|
+
},
|
|
1632
1656
|
{
|
|
1633
1657
|
"name": "subscriberKind",
|
|
1634
1658
|
"type": "text",
|
|
@@ -1713,6 +1737,13 @@
|
|
|
1713
1737
|
"related": "PricingRule",
|
|
1714
1738
|
"columnType": "UUID"
|
|
1715
1739
|
},
|
|
1740
|
+
{
|
|
1741
|
+
"name": "priceBookId",
|
|
1742
|
+
"type": "foreignKey",
|
|
1743
|
+
"required": false,
|
|
1744
|
+
"related": "PriceBook",
|
|
1745
|
+
"columnType": "UUID"
|
|
1746
|
+
},
|
|
1716
1747
|
{
|
|
1717
1748
|
"name": "pricingSnapshot",
|
|
1718
1749
|
"type": "text",
|
|
@@ -1742,12 +1773,26 @@
|
|
|
1742
1773
|
"related": "TenantUsageMetric",
|
|
1743
1774
|
"columnType": "UUID"
|
|
1744
1775
|
},
|
|
1776
|
+
{
|
|
1777
|
+
"name": "usageTenantId",
|
|
1778
|
+
"type": "crossPackageRef",
|
|
1779
|
+
"required": false,
|
|
1780
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
1781
|
+
"columnType": "UUID"
|
|
1782
|
+
},
|
|
1745
1783
|
{
|
|
1746
1784
|
"name": "pricingRuleId",
|
|
1747
1785
|
"type": "foreignKey",
|
|
1748
1786
|
"required": false,
|
|
1749
1787
|
"related": "PricingRule",
|
|
1750
1788
|
"columnType": "UUID"
|
|
1789
|
+
},
|
|
1790
|
+
{
|
|
1791
|
+
"name": "priceBookId",
|
|
1792
|
+
"type": "foreignKey",
|
|
1793
|
+
"required": false,
|
|
1794
|
+
"related": "PriceBook",
|
|
1795
|
+
"columnType": "UUID"
|
|
1751
1796
|
}
|
|
1752
1797
|
],
|
|
1753
1798
|
"methods": [
|
|
@@ -1819,6 +1864,7 @@
|
|
|
1819
1864
|
}
|
|
1820
1865
|
],
|
|
1821
1866
|
"relationshipFeatures": [
|
|
1867
|
+
"crossPackageRef",
|
|
1822
1868
|
"foreignKey",
|
|
1823
1869
|
"uuidColumns"
|
|
1824
1870
|
],
|
|
@@ -1898,60 +1944,803 @@
|
|
|
1898
1944
|
"columnType": "UUID"
|
|
1899
1945
|
}
|
|
1900
1946
|
],
|
|
1901
|
-
"methods": [],
|
|
1947
|
+
"methods": [],
|
|
1948
|
+
"tenant": {
|
|
1949
|
+
"scoped": true,
|
|
1950
|
+
"mode": "required",
|
|
1951
|
+
"field": "tenantId"
|
|
1952
|
+
},
|
|
1953
|
+
"conflictColumns": [
|
|
1954
|
+
"tenant_id",
|
|
1955
|
+
"slug",
|
|
1956
|
+
"context"
|
|
1957
|
+
],
|
|
1958
|
+
"surfaces": [
|
|
1959
|
+
{
|
|
1960
|
+
"kind": "api",
|
|
1961
|
+
"name": "billingadjustments.list",
|
|
1962
|
+
"operation": "list",
|
|
1963
|
+
"objectName": "@happyvertical/smrt-subscriptions:BillingAdjustment",
|
|
1964
|
+
"path": "/billingadjustments",
|
|
1965
|
+
"method": "GET"
|
|
1966
|
+
},
|
|
1967
|
+
{
|
|
1968
|
+
"kind": "api",
|
|
1969
|
+
"name": "billingadjustments.get",
|
|
1970
|
+
"operation": "get",
|
|
1971
|
+
"objectName": "@happyvertical/smrt-subscriptions:BillingAdjustment",
|
|
1972
|
+
"path": "/billingadjustments/[id]",
|
|
1973
|
+
"method": "GET"
|
|
1974
|
+
},
|
|
1975
|
+
{
|
|
1976
|
+
"kind": "cli",
|
|
1977
|
+
"name": "billingadjustment_list",
|
|
1978
|
+
"operation": "list",
|
|
1979
|
+
"objectName": "@happyvertical/smrt-subscriptions:BillingAdjustment"
|
|
1980
|
+
},
|
|
1981
|
+
{
|
|
1982
|
+
"kind": "cli",
|
|
1983
|
+
"name": "billingadjustment_get",
|
|
1984
|
+
"operation": "get",
|
|
1985
|
+
"objectName": "@happyvertical/smrt-subscriptions:BillingAdjustment"
|
|
1986
|
+
},
|
|
1987
|
+
{
|
|
1988
|
+
"kind": "mcp",
|
|
1989
|
+
"name": "billingadjustment_list",
|
|
1990
|
+
"operation": "list",
|
|
1991
|
+
"objectName": "@happyvertical/smrt-subscriptions:BillingAdjustment"
|
|
1992
|
+
},
|
|
1993
|
+
{
|
|
1994
|
+
"kind": "mcp",
|
|
1995
|
+
"name": "billingadjustment_get",
|
|
1996
|
+
"operation": "get",
|
|
1997
|
+
"objectName": "@happyvertical/smrt-subscriptions:BillingAdjustment"
|
|
1998
|
+
}
|
|
1999
|
+
],
|
|
2000
|
+
"relationshipFeatures": [
|
|
2001
|
+
"foreignKey",
|
|
2002
|
+
"uuidColumns"
|
|
2003
|
+
],
|
|
2004
|
+
"tags": [],
|
|
2005
|
+
"risks": []
|
|
2006
|
+
},
|
|
2007
|
+
{
|
|
2008
|
+
"name": "SpendingPolicy",
|
|
2009
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:SpendingPolicy",
|
|
2010
|
+
"collection": "spendingpolicies",
|
|
2011
|
+
"tableName": "_smrt_spending_policies",
|
|
2012
|
+
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2013
|
+
"extends": "SmrtObject",
|
|
2014
|
+
"fields": [
|
|
2015
|
+
{
|
|
2016
|
+
"name": "tenantId",
|
|
2017
|
+
"type": "text",
|
|
2018
|
+
"required": true,
|
|
2019
|
+
"columnType": "UUID"
|
|
2020
|
+
},
|
|
2021
|
+
{
|
|
2022
|
+
"name": "name",
|
|
2023
|
+
"type": "text",
|
|
2024
|
+
"required": false,
|
|
2025
|
+
"columnType": "TEXT",
|
|
2026
|
+
"default": ""
|
|
2027
|
+
},
|
|
2028
|
+
{
|
|
2029
|
+
"name": "subscriberKind",
|
|
2030
|
+
"type": "text",
|
|
2031
|
+
"required": false,
|
|
2032
|
+
"columnType": "TEXT",
|
|
2033
|
+
"default": ""
|
|
2034
|
+
},
|
|
2035
|
+
{
|
|
2036
|
+
"name": "subscriberExternalId",
|
|
2037
|
+
"type": "text",
|
|
2038
|
+
"required": false,
|
|
2039
|
+
"columnType": "TEXT",
|
|
2040
|
+
"default": ""
|
|
2041
|
+
},
|
|
2042
|
+
{
|
|
2043
|
+
"name": "projectId",
|
|
2044
|
+
"type": "text",
|
|
2045
|
+
"required": false,
|
|
2046
|
+
"columnType": "TEXT",
|
|
2047
|
+
"default": ""
|
|
2048
|
+
},
|
|
2049
|
+
{
|
|
2050
|
+
"name": "serviceKey",
|
|
2051
|
+
"type": "text",
|
|
2052
|
+
"required": false,
|
|
2053
|
+
"columnType": "TEXT",
|
|
2054
|
+
"default": ""
|
|
2055
|
+
},
|
|
2056
|
+
{
|
|
2057
|
+
"name": "metricKey",
|
|
2058
|
+
"type": "text",
|
|
2059
|
+
"required": false,
|
|
2060
|
+
"columnType": "TEXT",
|
|
2061
|
+
"default": ""
|
|
2062
|
+
},
|
|
2063
|
+
{
|
|
2064
|
+
"name": "period",
|
|
2065
|
+
"type": "text",
|
|
2066
|
+
"required": false,
|
|
2067
|
+
"columnType": "TEXT",
|
|
2068
|
+
"default": "month"
|
|
2069
|
+
},
|
|
2070
|
+
{
|
|
2071
|
+
"name": "rollingSeconds",
|
|
2072
|
+
"type": "integer",
|
|
2073
|
+
"required": false,
|
|
2074
|
+
"columnType": "INTEGER",
|
|
2075
|
+
"default": 0
|
|
2076
|
+
},
|
|
2077
|
+
{
|
|
2078
|
+
"name": "limitAmount",
|
|
2079
|
+
"type": "integer",
|
|
2080
|
+
"required": false,
|
|
2081
|
+
"columnType": "INTEGER",
|
|
2082
|
+
"default": 0
|
|
2083
|
+
},
|
|
2084
|
+
{
|
|
2085
|
+
"name": "currency",
|
|
2086
|
+
"type": "text",
|
|
2087
|
+
"required": false,
|
|
2088
|
+
"columnType": "TEXT",
|
|
2089
|
+
"default": "USD"
|
|
2090
|
+
},
|
|
2091
|
+
{
|
|
2092
|
+
"name": "behavior",
|
|
2093
|
+
"type": "text",
|
|
2094
|
+
"required": false,
|
|
2095
|
+
"columnType": "TEXT",
|
|
2096
|
+
"default": "observe"
|
|
2097
|
+
},
|
|
2098
|
+
{
|
|
2099
|
+
"name": "priority",
|
|
2100
|
+
"type": "integer",
|
|
2101
|
+
"required": false,
|
|
2102
|
+
"columnType": "INTEGER",
|
|
2103
|
+
"default": 0
|
|
2104
|
+
},
|
|
2105
|
+
{
|
|
2106
|
+
"name": "active",
|
|
2107
|
+
"type": "boolean",
|
|
2108
|
+
"required": false,
|
|
2109
|
+
"columnType": "BOOLEAN",
|
|
2110
|
+
"default": true
|
|
2111
|
+
},
|
|
2112
|
+
{
|
|
2113
|
+
"name": "basis",
|
|
2114
|
+
"type": "text",
|
|
2115
|
+
"required": false,
|
|
2116
|
+
"columnType": "TEXT",
|
|
2117
|
+
"default": "billed"
|
|
2118
|
+
},
|
|
2119
|
+
{
|
|
2120
|
+
"name": "setByTenantId",
|
|
2121
|
+
"type": "crossPackageRef",
|
|
2122
|
+
"required": false,
|
|
2123
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
2124
|
+
"columnType": "UUID"
|
|
2125
|
+
},
|
|
2126
|
+
{
|
|
2127
|
+
"name": "balanceFrom",
|
|
2128
|
+
"type": "datetime",
|
|
2129
|
+
"required": false,
|
|
2130
|
+
"columnType": "TIMESTAMP"
|
|
2131
|
+
}
|
|
2132
|
+
],
|
|
2133
|
+
"relationships": [
|
|
2134
|
+
{
|
|
2135
|
+
"name": "setByTenantId",
|
|
2136
|
+
"type": "crossPackageRef",
|
|
2137
|
+
"required": false,
|
|
2138
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
2139
|
+
"columnType": "UUID"
|
|
2140
|
+
}
|
|
2141
|
+
],
|
|
2142
|
+
"methods": [],
|
|
2143
|
+
"tenant": {
|
|
2144
|
+
"scoped": true,
|
|
2145
|
+
"mode": "required",
|
|
2146
|
+
"field": "tenantId"
|
|
2147
|
+
},
|
|
2148
|
+
"conflictColumns": [
|
|
2149
|
+
"tenant_id",
|
|
2150
|
+
"subscriber_kind",
|
|
2151
|
+
"subscriber_external_id",
|
|
2152
|
+
"project_id",
|
|
2153
|
+
"service_key",
|
|
2154
|
+
"metric_key",
|
|
2155
|
+
"period",
|
|
2156
|
+
"name"
|
|
2157
|
+
],
|
|
2158
|
+
"surfaces": [
|
|
2159
|
+
{
|
|
2160
|
+
"kind": "api",
|
|
2161
|
+
"name": "spendingpolicies.list",
|
|
2162
|
+
"operation": "list",
|
|
2163
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy",
|
|
2164
|
+
"path": "/spendingpolicies",
|
|
2165
|
+
"method": "GET"
|
|
2166
|
+
},
|
|
2167
|
+
{
|
|
2168
|
+
"kind": "api",
|
|
2169
|
+
"name": "spendingpolicies.get",
|
|
2170
|
+
"operation": "get",
|
|
2171
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy",
|
|
2172
|
+
"path": "/spendingpolicies/[id]",
|
|
2173
|
+
"method": "GET"
|
|
2174
|
+
},
|
|
2175
|
+
{
|
|
2176
|
+
"kind": "api",
|
|
2177
|
+
"name": "spendingpolicies.create",
|
|
2178
|
+
"operation": "create",
|
|
2179
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy",
|
|
2180
|
+
"path": "/spendingpolicies",
|
|
2181
|
+
"method": "POST"
|
|
2182
|
+
},
|
|
2183
|
+
{
|
|
2184
|
+
"kind": "api",
|
|
2185
|
+
"name": "spendingpolicies.update",
|
|
2186
|
+
"operation": "update",
|
|
2187
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy",
|
|
2188
|
+
"path": "/spendingpolicies/[id]",
|
|
2189
|
+
"method": "PATCH"
|
|
2190
|
+
},
|
|
2191
|
+
{
|
|
2192
|
+
"kind": "api",
|
|
2193
|
+
"name": "spendingpolicies.delete",
|
|
2194
|
+
"operation": "delete",
|
|
2195
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy",
|
|
2196
|
+
"path": "/spendingpolicies/[id]",
|
|
2197
|
+
"method": "DELETE"
|
|
2198
|
+
},
|
|
2199
|
+
{
|
|
2200
|
+
"kind": "cli",
|
|
2201
|
+
"name": "spendingpolicy_list",
|
|
2202
|
+
"operation": "list",
|
|
2203
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2204
|
+
},
|
|
2205
|
+
{
|
|
2206
|
+
"kind": "cli",
|
|
2207
|
+
"name": "spendingpolicy_get",
|
|
2208
|
+
"operation": "get",
|
|
2209
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2210
|
+
},
|
|
2211
|
+
{
|
|
2212
|
+
"kind": "cli",
|
|
2213
|
+
"name": "spendingpolicy_create",
|
|
2214
|
+
"operation": "create",
|
|
2215
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2216
|
+
},
|
|
2217
|
+
{
|
|
2218
|
+
"kind": "cli",
|
|
2219
|
+
"name": "spendingpolicy_update",
|
|
2220
|
+
"operation": "update",
|
|
2221
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2222
|
+
},
|
|
2223
|
+
{
|
|
2224
|
+
"kind": "cli",
|
|
2225
|
+
"name": "spendingpolicy_delete",
|
|
2226
|
+
"operation": "delete",
|
|
2227
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2228
|
+
},
|
|
2229
|
+
{
|
|
2230
|
+
"kind": "mcp",
|
|
2231
|
+
"name": "spendingpolicy_list",
|
|
2232
|
+
"operation": "list",
|
|
2233
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2234
|
+
},
|
|
2235
|
+
{
|
|
2236
|
+
"kind": "mcp",
|
|
2237
|
+
"name": "spendingpolicy_get",
|
|
2238
|
+
"operation": "get",
|
|
2239
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2240
|
+
},
|
|
2241
|
+
{
|
|
2242
|
+
"kind": "mcp",
|
|
2243
|
+
"name": "spendingpolicy_create",
|
|
2244
|
+
"operation": "create",
|
|
2245
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2246
|
+
},
|
|
2247
|
+
{
|
|
2248
|
+
"kind": "mcp",
|
|
2249
|
+
"name": "spendingpolicy_update",
|
|
2250
|
+
"operation": "update",
|
|
2251
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2252
|
+
},
|
|
2253
|
+
{
|
|
2254
|
+
"kind": "mcp",
|
|
2255
|
+
"name": "spendingpolicy_delete",
|
|
2256
|
+
"operation": "delete",
|
|
2257
|
+
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2258
|
+
}
|
|
2259
|
+
],
|
|
2260
|
+
"relationshipFeatures": [
|
|
2261
|
+
"crossPackageRef",
|
|
2262
|
+
"uuidColumns"
|
|
2263
|
+
],
|
|
2264
|
+
"tags": [],
|
|
2265
|
+
"risks": []
|
|
2266
|
+
},
|
|
2267
|
+
{
|
|
2268
|
+
"name": "PricingRuleCollection",
|
|
2269
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:PricingRuleCollection",
|
|
2270
|
+
"collection": "pricingrules",
|
|
2271
|
+
"tableName": "_smrt_pricing_rules",
|
|
2272
|
+
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2273
|
+
"extends": "SmrtCollection",
|
|
2274
|
+
"fields": [],
|
|
2275
|
+
"relationships": [],
|
|
2276
|
+
"methods": [],
|
|
2277
|
+
"surfaces": [],
|
|
2278
|
+
"relationshipFeatures": [
|
|
2279
|
+
"uuidColumns"
|
|
2280
|
+
],
|
|
2281
|
+
"tags": [],
|
|
2282
|
+
"risks": []
|
|
2283
|
+
},
|
|
2284
|
+
{
|
|
2285
|
+
"name": "ClientChargeCollection",
|
|
2286
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:ClientChargeCollection",
|
|
2287
|
+
"collection": "clientcharges",
|
|
2288
|
+
"tableName": "_smrt_client_charges",
|
|
2289
|
+
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2290
|
+
"extends": "SmrtCollection",
|
|
2291
|
+
"fields": [],
|
|
2292
|
+
"relationships": [],
|
|
2293
|
+
"methods": [],
|
|
2294
|
+
"surfaces": [],
|
|
2295
|
+
"relationshipFeatures": [
|
|
2296
|
+
"uuidColumns"
|
|
2297
|
+
],
|
|
2298
|
+
"tags": [],
|
|
2299
|
+
"risks": []
|
|
2300
|
+
},
|
|
2301
|
+
{
|
|
2302
|
+
"name": "BillingAdjustmentCollection",
|
|
2303
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:BillingAdjustmentCollection",
|
|
2304
|
+
"collection": "billingadjustments",
|
|
2305
|
+
"tableName": "_smrt_billing_adjustments",
|
|
2306
|
+
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2307
|
+
"extends": "SmrtCollection",
|
|
2308
|
+
"fields": [],
|
|
2309
|
+
"relationships": [],
|
|
2310
|
+
"methods": [],
|
|
2311
|
+
"surfaces": [],
|
|
2312
|
+
"relationshipFeatures": [
|
|
2313
|
+
"uuidColumns"
|
|
2314
|
+
],
|
|
2315
|
+
"tags": [],
|
|
2316
|
+
"risks": []
|
|
2317
|
+
},
|
|
2318
|
+
{
|
|
2319
|
+
"name": "SpendingPolicyCollection",
|
|
2320
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:SpendingPolicyCollection",
|
|
2321
|
+
"collection": "spendingpolicies",
|
|
2322
|
+
"tableName": "_smrt_spending_policies",
|
|
2323
|
+
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2324
|
+
"extends": "SmrtCollection",
|
|
2325
|
+
"fields": [],
|
|
2326
|
+
"relationships": [],
|
|
2327
|
+
"methods": [],
|
|
2328
|
+
"surfaces": [],
|
|
2329
|
+
"relationshipFeatures": [
|
|
2330
|
+
"uuidColumns"
|
|
2331
|
+
],
|
|
2332
|
+
"tags": [],
|
|
2333
|
+
"risks": []
|
|
2334
|
+
},
|
|
2335
|
+
{
|
|
2336
|
+
"name": "PriceBook",
|
|
2337
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:PriceBook",
|
|
2338
|
+
"collection": "pricebooks",
|
|
2339
|
+
"tableName": "_smrt_price_books",
|
|
2340
|
+
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2341
|
+
"extends": "SmrtObject",
|
|
2342
|
+
"fields": [
|
|
2343
|
+
{
|
|
2344
|
+
"name": "tenantId",
|
|
2345
|
+
"type": "text",
|
|
2346
|
+
"required": true,
|
|
2347
|
+
"columnType": "UUID"
|
|
2348
|
+
},
|
|
2349
|
+
{
|
|
2350
|
+
"name": "bookKey",
|
|
2351
|
+
"type": "text",
|
|
2352
|
+
"required": false,
|
|
2353
|
+
"columnType": "TEXT",
|
|
2354
|
+
"default": ""
|
|
2355
|
+
},
|
|
2356
|
+
{
|
|
2357
|
+
"name": "name",
|
|
2358
|
+
"type": "text",
|
|
2359
|
+
"required": false,
|
|
2360
|
+
"columnType": "TEXT",
|
|
2361
|
+
"default": ""
|
|
2362
|
+
},
|
|
2363
|
+
{
|
|
2364
|
+
"name": "kind",
|
|
2365
|
+
"type": "text",
|
|
2366
|
+
"required": false,
|
|
2367
|
+
"columnType": "TEXT",
|
|
2368
|
+
"default": "retail"
|
|
2369
|
+
},
|
|
2370
|
+
{
|
|
2371
|
+
"name": "active",
|
|
2372
|
+
"type": "boolean",
|
|
2373
|
+
"required": false,
|
|
2374
|
+
"columnType": "BOOLEAN",
|
|
2375
|
+
"default": true
|
|
2376
|
+
}
|
|
2377
|
+
],
|
|
2378
|
+
"relationships": [],
|
|
2379
|
+
"methods": [],
|
|
2380
|
+
"tenant": {
|
|
2381
|
+
"scoped": true,
|
|
2382
|
+
"mode": "required",
|
|
2383
|
+
"field": "tenantId"
|
|
2384
|
+
},
|
|
2385
|
+
"conflictColumns": [
|
|
2386
|
+
"tenant_id",
|
|
2387
|
+
"book_key"
|
|
2388
|
+
],
|
|
2389
|
+
"surfaces": [],
|
|
2390
|
+
"relationshipFeatures": [
|
|
2391
|
+
"uuidColumns"
|
|
2392
|
+
],
|
|
2393
|
+
"tags": [],
|
|
2394
|
+
"risks": []
|
|
2395
|
+
},
|
|
2396
|
+
{
|
|
2397
|
+
"name": "PriceBookAssignment",
|
|
2398
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:PriceBookAssignment",
|
|
2399
|
+
"collection": "pricebookassignments",
|
|
2400
|
+
"tableName": "_smrt_price_book_assignments",
|
|
2401
|
+
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2402
|
+
"extends": "SmrtObject",
|
|
2403
|
+
"fields": [
|
|
2404
|
+
{
|
|
2405
|
+
"name": "childTenantId",
|
|
2406
|
+
"type": "crossPackageRef",
|
|
2407
|
+
"required": true,
|
|
2408
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
2409
|
+
"columnType": "UUID"
|
|
2410
|
+
},
|
|
2411
|
+
{
|
|
2412
|
+
"name": "resellerTenantId",
|
|
2413
|
+
"type": "crossPackageRef",
|
|
2414
|
+
"required": true,
|
|
2415
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
2416
|
+
"columnType": "UUID"
|
|
2417
|
+
},
|
|
2418
|
+
{
|
|
2419
|
+
"name": "wholesalePriceBookId",
|
|
2420
|
+
"type": "foreignKey",
|
|
2421
|
+
"required": false,
|
|
2422
|
+
"related": "PriceBook",
|
|
2423
|
+
"columnType": "UUID"
|
|
2424
|
+
},
|
|
2425
|
+
{
|
|
2426
|
+
"name": "wholesaleCurrency",
|
|
2427
|
+
"type": "text",
|
|
2428
|
+
"required": false,
|
|
2429
|
+
"columnType": "TEXT",
|
|
2430
|
+
"default": ""
|
|
2431
|
+
},
|
|
2432
|
+
{
|
|
2433
|
+
"name": "retailPriceBookId",
|
|
2434
|
+
"type": "foreignKey",
|
|
2435
|
+
"required": false,
|
|
2436
|
+
"related": "PriceBook",
|
|
2437
|
+
"columnType": "UUID"
|
|
2438
|
+
},
|
|
2439
|
+
{
|
|
2440
|
+
"name": "retailCurrency",
|
|
2441
|
+
"type": "text",
|
|
2442
|
+
"required": false,
|
|
2443
|
+
"columnType": "TEXT",
|
|
2444
|
+
"default": ""
|
|
2445
|
+
}
|
|
2446
|
+
],
|
|
2447
|
+
"relationships": [
|
|
2448
|
+
{
|
|
2449
|
+
"name": "childTenantId",
|
|
2450
|
+
"type": "crossPackageRef",
|
|
2451
|
+
"required": true,
|
|
2452
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
2453
|
+
"columnType": "UUID"
|
|
2454
|
+
},
|
|
2455
|
+
{
|
|
2456
|
+
"name": "resellerTenantId",
|
|
2457
|
+
"type": "crossPackageRef",
|
|
2458
|
+
"required": true,
|
|
2459
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
2460
|
+
"columnType": "UUID"
|
|
2461
|
+
},
|
|
2462
|
+
{
|
|
2463
|
+
"name": "wholesalePriceBookId",
|
|
2464
|
+
"type": "foreignKey",
|
|
2465
|
+
"required": false,
|
|
2466
|
+
"related": "PriceBook",
|
|
2467
|
+
"columnType": "UUID"
|
|
2468
|
+
},
|
|
2469
|
+
{
|
|
2470
|
+
"name": "retailPriceBookId",
|
|
2471
|
+
"type": "foreignKey",
|
|
2472
|
+
"required": false,
|
|
2473
|
+
"related": "PriceBook",
|
|
2474
|
+
"columnType": "UUID"
|
|
2475
|
+
}
|
|
2476
|
+
],
|
|
2477
|
+
"methods": [],
|
|
2478
|
+
"conflictColumns": [
|
|
2479
|
+
"child_tenant_id"
|
|
2480
|
+
],
|
|
2481
|
+
"surfaces": [],
|
|
2482
|
+
"relationshipFeatures": [
|
|
2483
|
+
"crossPackageRef",
|
|
2484
|
+
"foreignKey",
|
|
2485
|
+
"uuidColumns"
|
|
2486
|
+
],
|
|
2487
|
+
"tags": [],
|
|
2488
|
+
"risks": []
|
|
2489
|
+
},
|
|
2490
|
+
{
|
|
2491
|
+
"name": "RetailCharge",
|
|
2492
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:RetailCharge",
|
|
2493
|
+
"collection": "retailcharges",
|
|
2494
|
+
"tableName": "_smrt_retail_charges",
|
|
2495
|
+
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2496
|
+
"extends": "SmrtObject",
|
|
2497
|
+
"fields": [
|
|
2498
|
+
{
|
|
2499
|
+
"name": "tenantId",
|
|
2500
|
+
"type": "text",
|
|
2501
|
+
"required": true,
|
|
2502
|
+
"columnType": "UUID"
|
|
2503
|
+
},
|
|
2504
|
+
{
|
|
2505
|
+
"name": "resellerTenantId",
|
|
2506
|
+
"type": "crossPackageRef",
|
|
2507
|
+
"required": false,
|
|
2508
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
2509
|
+
"columnType": "UUID"
|
|
2510
|
+
},
|
|
2511
|
+
{
|
|
2512
|
+
"name": "usageEventId",
|
|
2513
|
+
"type": "foreignKey",
|
|
2514
|
+
"required": false,
|
|
2515
|
+
"related": "TenantUsageMetric",
|
|
2516
|
+
"columnType": "UUID"
|
|
2517
|
+
},
|
|
2518
|
+
{
|
|
2519
|
+
"name": "clientChargeId",
|
|
2520
|
+
"type": "foreignKey",
|
|
2521
|
+
"required": false,
|
|
2522
|
+
"related": "ClientCharge",
|
|
2523
|
+
"columnType": "UUID"
|
|
2524
|
+
},
|
|
2525
|
+
{
|
|
2526
|
+
"name": "subscriberKind",
|
|
2527
|
+
"type": "text",
|
|
2528
|
+
"required": false,
|
|
2529
|
+
"columnType": "TEXT",
|
|
2530
|
+
"default": "tenant"
|
|
2531
|
+
},
|
|
2532
|
+
{
|
|
2533
|
+
"name": "subscriberExternalId",
|
|
2534
|
+
"type": "text",
|
|
2535
|
+
"required": false,
|
|
2536
|
+
"columnType": "TEXT",
|
|
2537
|
+
"default": ""
|
|
2538
|
+
},
|
|
2539
|
+
{
|
|
2540
|
+
"name": "projectId",
|
|
2541
|
+
"type": "text",
|
|
2542
|
+
"required": false,
|
|
2543
|
+
"columnType": "TEXT",
|
|
2544
|
+
"default": ""
|
|
2545
|
+
},
|
|
2546
|
+
{
|
|
2547
|
+
"name": "workRefType",
|
|
2548
|
+
"type": "text",
|
|
2549
|
+
"required": false,
|
|
2550
|
+
"columnType": "TEXT",
|
|
2551
|
+
"default": ""
|
|
2552
|
+
},
|
|
2553
|
+
{
|
|
2554
|
+
"name": "workRefId",
|
|
2555
|
+
"type": "text",
|
|
2556
|
+
"required": false,
|
|
2557
|
+
"columnType": "TEXT",
|
|
2558
|
+
"default": ""
|
|
2559
|
+
},
|
|
2560
|
+
{
|
|
2561
|
+
"name": "provider",
|
|
2562
|
+
"type": "text",
|
|
2563
|
+
"required": false,
|
|
2564
|
+
"columnType": "TEXT",
|
|
2565
|
+
"default": ""
|
|
2566
|
+
},
|
|
2567
|
+
{
|
|
2568
|
+
"name": "serviceKey",
|
|
2569
|
+
"type": "text",
|
|
2570
|
+
"required": false,
|
|
2571
|
+
"columnType": "TEXT",
|
|
2572
|
+
"default": ""
|
|
2573
|
+
},
|
|
2574
|
+
{
|
|
2575
|
+
"name": "metricKey",
|
|
2576
|
+
"type": "text",
|
|
2577
|
+
"required": false,
|
|
2578
|
+
"columnType": "TEXT",
|
|
2579
|
+
"default": ""
|
|
2580
|
+
},
|
|
2581
|
+
{
|
|
2582
|
+
"name": "quantity",
|
|
2583
|
+
"type": "decimal",
|
|
2584
|
+
"required": false,
|
|
2585
|
+
"columnType": "REAL",
|
|
2586
|
+
"default": 0
|
|
2587
|
+
},
|
|
2588
|
+
{
|
|
2589
|
+
"name": "amount",
|
|
2590
|
+
"type": "integer",
|
|
2591
|
+
"required": false,
|
|
2592
|
+
"columnType": "INTEGER",
|
|
2593
|
+
"default": 0
|
|
2594
|
+
},
|
|
2595
|
+
{
|
|
2596
|
+
"name": "currency",
|
|
2597
|
+
"type": "text",
|
|
2598
|
+
"required": false,
|
|
2599
|
+
"columnType": "TEXT",
|
|
2600
|
+
"default": "USD"
|
|
2601
|
+
},
|
|
2602
|
+
{
|
|
2603
|
+
"name": "priceBookId",
|
|
2604
|
+
"type": "foreignKey",
|
|
2605
|
+
"required": false,
|
|
2606
|
+
"related": "PriceBook",
|
|
2607
|
+
"columnType": "UUID"
|
|
2608
|
+
},
|
|
2609
|
+
{
|
|
2610
|
+
"name": "pricingRuleId",
|
|
2611
|
+
"type": "foreignKey",
|
|
2612
|
+
"required": false,
|
|
2613
|
+
"related": "PricingRule",
|
|
2614
|
+
"columnType": "UUID"
|
|
2615
|
+
},
|
|
2616
|
+
{
|
|
2617
|
+
"name": "pricingSnapshot",
|
|
2618
|
+
"type": "text",
|
|
2619
|
+
"required": false,
|
|
2620
|
+
"columnType": "TEXT",
|
|
2621
|
+
"default": "{}"
|
|
2622
|
+
},
|
|
2623
|
+
{
|
|
2624
|
+
"name": "status",
|
|
2625
|
+
"type": "text",
|
|
2626
|
+
"required": false,
|
|
2627
|
+
"columnType": "TEXT",
|
|
2628
|
+
"default": "draft"
|
|
2629
|
+
},
|
|
2630
|
+
{
|
|
2631
|
+
"name": "approvedAt",
|
|
2632
|
+
"type": "datetime",
|
|
2633
|
+
"required": false,
|
|
2634
|
+
"columnType": "TIMESTAMP"
|
|
2635
|
+
}
|
|
2636
|
+
],
|
|
2637
|
+
"relationships": [
|
|
2638
|
+
{
|
|
2639
|
+
"name": "resellerTenantId",
|
|
2640
|
+
"type": "crossPackageRef",
|
|
2641
|
+
"required": false,
|
|
2642
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
2643
|
+
"columnType": "UUID"
|
|
2644
|
+
},
|
|
2645
|
+
{
|
|
2646
|
+
"name": "usageEventId",
|
|
2647
|
+
"type": "foreignKey",
|
|
2648
|
+
"required": false,
|
|
2649
|
+
"related": "TenantUsageMetric",
|
|
2650
|
+
"columnType": "UUID"
|
|
2651
|
+
},
|
|
2652
|
+
{
|
|
2653
|
+
"name": "clientChargeId",
|
|
2654
|
+
"type": "foreignKey",
|
|
2655
|
+
"required": false,
|
|
2656
|
+
"related": "ClientCharge",
|
|
2657
|
+
"columnType": "UUID"
|
|
2658
|
+
},
|
|
2659
|
+
{
|
|
2660
|
+
"name": "priceBookId",
|
|
2661
|
+
"type": "foreignKey",
|
|
2662
|
+
"required": false,
|
|
2663
|
+
"related": "PriceBook",
|
|
2664
|
+
"columnType": "UUID"
|
|
2665
|
+
},
|
|
2666
|
+
{
|
|
2667
|
+
"name": "pricingRuleId",
|
|
2668
|
+
"type": "foreignKey",
|
|
2669
|
+
"required": false,
|
|
2670
|
+
"related": "PricingRule",
|
|
2671
|
+
"columnType": "UUID"
|
|
2672
|
+
}
|
|
2673
|
+
],
|
|
2674
|
+
"methods": [
|
|
2675
|
+
"getPricingSnapshot"
|
|
2676
|
+
],
|
|
2677
|
+
"methodSignatures": [
|
|
2678
|
+
{
|
|
2679
|
+
"name": "getPricingSnapshot",
|
|
2680
|
+
"returns": "Record<string, unknown>"
|
|
2681
|
+
}
|
|
2682
|
+
],
|
|
1902
2683
|
"tenant": {
|
|
1903
2684
|
"scoped": true,
|
|
1904
2685
|
"mode": "required",
|
|
1905
2686
|
"field": "tenantId"
|
|
1906
2687
|
},
|
|
1907
2688
|
"conflictColumns": [
|
|
1908
|
-
"
|
|
1909
|
-
"slug",
|
|
1910
|
-
"context"
|
|
2689
|
+
"usage_event_id"
|
|
1911
2690
|
],
|
|
1912
2691
|
"surfaces": [
|
|
1913
2692
|
{
|
|
1914
2693
|
"kind": "api",
|
|
1915
|
-
"name": "
|
|
2694
|
+
"name": "retailcharges.list",
|
|
1916
2695
|
"operation": "list",
|
|
1917
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
1918
|
-
"path": "/
|
|
2696
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge",
|
|
2697
|
+
"path": "/retailcharges",
|
|
1919
2698
|
"method": "GET"
|
|
1920
2699
|
},
|
|
1921
2700
|
{
|
|
1922
2701
|
"kind": "api",
|
|
1923
|
-
"name": "
|
|
2702
|
+
"name": "retailcharges.get",
|
|
1924
2703
|
"operation": "get",
|
|
1925
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
1926
|
-
"path": "/
|
|
2704
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge",
|
|
2705
|
+
"path": "/retailcharges/[id]",
|
|
1927
2706
|
"method": "GET"
|
|
1928
2707
|
},
|
|
1929
2708
|
{
|
|
1930
2709
|
"kind": "cli",
|
|
1931
|
-
"name": "
|
|
2710
|
+
"name": "retailcharge_list",
|
|
1932
2711
|
"operation": "list",
|
|
1933
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
2712
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge"
|
|
1934
2713
|
},
|
|
1935
2714
|
{
|
|
1936
2715
|
"kind": "cli",
|
|
1937
|
-
"name": "
|
|
2716
|
+
"name": "retailcharge_get",
|
|
1938
2717
|
"operation": "get",
|
|
1939
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
2718
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge"
|
|
1940
2719
|
},
|
|
1941
2720
|
{
|
|
1942
2721
|
"kind": "mcp",
|
|
1943
|
-
"name": "
|
|
2722
|
+
"name": "retailcharge_list",
|
|
1944
2723
|
"operation": "list",
|
|
1945
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
2724
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge"
|
|
1946
2725
|
},
|
|
1947
2726
|
{
|
|
1948
2727
|
"kind": "mcp",
|
|
1949
|
-
"name": "
|
|
2728
|
+
"name": "retailcharge_get",
|
|
1950
2729
|
"operation": "get",
|
|
1951
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
2730
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge"
|
|
2731
|
+
}
|
|
2732
|
+
],
|
|
2733
|
+
"withheldSurfaces": [
|
|
2734
|
+
{
|
|
2735
|
+
"kind": "api",
|
|
2736
|
+
"operation": "getPricingSnapshot",
|
|
2737
|
+
"code": "not-included",
|
|
2738
|
+
"reason": "not listed in api.include",
|
|
2739
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge"
|
|
1952
2740
|
}
|
|
1953
2741
|
],
|
|
1954
2742
|
"relationshipFeatures": [
|
|
2743
|
+
"crossPackageRef",
|
|
1955
2744
|
"foreignKey",
|
|
1956
2745
|
"uuidColumns"
|
|
1957
2746
|
],
|
|
@@ -1959,10 +2748,10 @@
|
|
|
1959
2748
|
"risks": []
|
|
1960
2749
|
},
|
|
1961
2750
|
{
|
|
1962
|
-
"name": "
|
|
1963
|
-
"qualifiedName": "@happyvertical/smrt-subscriptions:
|
|
1964
|
-
"collection": "
|
|
1965
|
-
"tableName": "
|
|
2751
|
+
"name": "CreditGrant",
|
|
2752
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:CreditGrant",
|
|
2753
|
+
"collection": "creditgrants",
|
|
2754
|
+
"tableName": "_smrt_credit_grants",
|
|
1966
2755
|
"packageName": "@happyvertical/smrt-subscriptions",
|
|
1967
2756
|
"extends": "SmrtObject",
|
|
1968
2757
|
"fields": [
|
|
@@ -1973,98 +2762,71 @@
|
|
|
1973
2762
|
"columnType": "UUID"
|
|
1974
2763
|
},
|
|
1975
2764
|
{
|
|
1976
|
-
"name": "
|
|
1977
|
-
"type": "
|
|
2765
|
+
"name": "spendingPolicyId",
|
|
2766
|
+
"type": "foreignKey",
|
|
1978
2767
|
"required": false,
|
|
1979
|
-
"
|
|
1980
|
-
"
|
|
2768
|
+
"related": "SpendingPolicy",
|
|
2769
|
+
"columnType": "UUID"
|
|
1981
2770
|
},
|
|
1982
2771
|
{
|
|
1983
|
-
"name": "
|
|
1984
|
-
"type": "
|
|
2772
|
+
"name": "amount",
|
|
2773
|
+
"type": "integer",
|
|
1985
2774
|
"required": false,
|
|
1986
|
-
"columnType": "
|
|
1987
|
-
"default":
|
|
2775
|
+
"columnType": "INTEGER",
|
|
2776
|
+
"default": 0
|
|
1988
2777
|
},
|
|
1989
2778
|
{
|
|
1990
|
-
"name": "
|
|
2779
|
+
"name": "currency",
|
|
1991
2780
|
"type": "text",
|
|
1992
2781
|
"required": false,
|
|
1993
2782
|
"columnType": "TEXT",
|
|
1994
|
-
"default": ""
|
|
2783
|
+
"default": "USD"
|
|
1995
2784
|
},
|
|
1996
2785
|
{
|
|
1997
|
-
"name": "
|
|
2786
|
+
"name": "reason",
|
|
1998
2787
|
"type": "text",
|
|
1999
2788
|
"required": false,
|
|
2000
2789
|
"columnType": "TEXT",
|
|
2001
2790
|
"default": ""
|
|
2002
2791
|
},
|
|
2003
2792
|
{
|
|
2004
|
-
"name": "
|
|
2793
|
+
"name": "source",
|
|
2005
2794
|
"type": "text",
|
|
2006
2795
|
"required": false,
|
|
2007
2796
|
"columnType": "TEXT",
|
|
2008
2797
|
"default": ""
|
|
2009
2798
|
},
|
|
2010
2799
|
{
|
|
2011
|
-
"name": "
|
|
2800
|
+
"name": "sourceId",
|
|
2012
2801
|
"type": "text",
|
|
2013
2802
|
"required": false,
|
|
2014
2803
|
"columnType": "TEXT",
|
|
2015
2804
|
"default": ""
|
|
2016
2805
|
},
|
|
2017
2806
|
{
|
|
2018
|
-
"name": "
|
|
2019
|
-
"type": "
|
|
2020
|
-
"required": false,
|
|
2021
|
-
"columnType": "TEXT",
|
|
2022
|
-
"default": "month"
|
|
2023
|
-
},
|
|
2024
|
-
{
|
|
2025
|
-
"name": "rollingSeconds",
|
|
2026
|
-
"type": "integer",
|
|
2027
|
-
"required": false,
|
|
2028
|
-
"columnType": "INTEGER",
|
|
2029
|
-
"default": 0
|
|
2030
|
-
},
|
|
2031
|
-
{
|
|
2032
|
-
"name": "limitAmount",
|
|
2033
|
-
"type": "integer",
|
|
2034
|
-
"required": false,
|
|
2035
|
-
"columnType": "INTEGER",
|
|
2036
|
-
"default": 0
|
|
2037
|
-
},
|
|
2038
|
-
{
|
|
2039
|
-
"name": "currency",
|
|
2040
|
-
"type": "text",
|
|
2041
|
-
"required": false,
|
|
2042
|
-
"columnType": "TEXT",
|
|
2043
|
-
"default": "USD"
|
|
2044
|
-
},
|
|
2045
|
-
{
|
|
2046
|
-
"name": "behavior",
|
|
2047
|
-
"type": "text",
|
|
2807
|
+
"name": "grantedByTenantId",
|
|
2808
|
+
"type": "crossPackageRef",
|
|
2048
2809
|
"required": false,
|
|
2049
|
-
"
|
|
2050
|
-
"
|
|
2051
|
-
}
|
|
2810
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
2811
|
+
"columnType": "UUID"
|
|
2812
|
+
}
|
|
2813
|
+
],
|
|
2814
|
+
"relationships": [
|
|
2052
2815
|
{
|
|
2053
|
-
"name": "
|
|
2054
|
-
"type": "
|
|
2816
|
+
"name": "spendingPolicyId",
|
|
2817
|
+
"type": "foreignKey",
|
|
2055
2818
|
"required": false,
|
|
2056
|
-
"
|
|
2057
|
-
"
|
|
2819
|
+
"related": "SpendingPolicy",
|
|
2820
|
+
"columnType": "UUID"
|
|
2058
2821
|
},
|
|
2059
2822
|
{
|
|
2060
|
-
"name": "
|
|
2061
|
-
"type": "
|
|
2823
|
+
"name": "grantedByTenantId",
|
|
2824
|
+
"type": "crossPackageRef",
|
|
2062
2825
|
"required": false,
|
|
2063
|
-
"
|
|
2064
|
-
"
|
|
2826
|
+
"related": "@happyvertical/smrt-users:Tenant",
|
|
2827
|
+
"columnType": "UUID"
|
|
2065
2828
|
}
|
|
2066
2829
|
],
|
|
2067
|
-
"relationships": [],
|
|
2068
2830
|
"methods": [],
|
|
2069
2831
|
"tenant": {
|
|
2070
2832
|
"scoped": true,
|
|
@@ -2073,127 +2835,64 @@
|
|
|
2073
2835
|
},
|
|
2074
2836
|
"conflictColumns": [
|
|
2075
2837
|
"tenant_id",
|
|
2076
|
-
"
|
|
2077
|
-
"
|
|
2078
|
-
"project_id",
|
|
2079
|
-
"service_key",
|
|
2080
|
-
"metric_key",
|
|
2081
|
-
"period",
|
|
2082
|
-
"name"
|
|
2838
|
+
"slug",
|
|
2839
|
+
"context"
|
|
2083
2840
|
],
|
|
2084
2841
|
"surfaces": [
|
|
2085
2842
|
{
|
|
2086
2843
|
"kind": "api",
|
|
2087
|
-
"name": "
|
|
2844
|
+
"name": "creditgrants.list",
|
|
2088
2845
|
"operation": "list",
|
|
2089
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
2090
|
-
"path": "/
|
|
2846
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant",
|
|
2847
|
+
"path": "/creditgrants",
|
|
2091
2848
|
"method": "GET"
|
|
2092
2849
|
},
|
|
2093
2850
|
{
|
|
2094
2851
|
"kind": "api",
|
|
2095
|
-
"name": "
|
|
2852
|
+
"name": "creditgrants.get",
|
|
2096
2853
|
"operation": "get",
|
|
2097
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
2098
|
-
"path": "/
|
|
2854
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant",
|
|
2855
|
+
"path": "/creditgrants/[id]",
|
|
2099
2856
|
"method": "GET"
|
|
2100
2857
|
},
|
|
2101
|
-
{
|
|
2102
|
-
"kind": "api",
|
|
2103
|
-
"name": "spendingpolicies.create",
|
|
2104
|
-
"operation": "create",
|
|
2105
|
-
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy",
|
|
2106
|
-
"path": "/spendingpolicies",
|
|
2107
|
-
"method": "POST"
|
|
2108
|
-
},
|
|
2109
|
-
{
|
|
2110
|
-
"kind": "api",
|
|
2111
|
-
"name": "spendingpolicies.update",
|
|
2112
|
-
"operation": "update",
|
|
2113
|
-
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy",
|
|
2114
|
-
"path": "/spendingpolicies/[id]",
|
|
2115
|
-
"method": "PATCH"
|
|
2116
|
-
},
|
|
2117
|
-
{
|
|
2118
|
-
"kind": "api",
|
|
2119
|
-
"name": "spendingpolicies.delete",
|
|
2120
|
-
"operation": "delete",
|
|
2121
|
-
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy",
|
|
2122
|
-
"path": "/spendingpolicies/[id]",
|
|
2123
|
-
"method": "DELETE"
|
|
2124
|
-
},
|
|
2125
2858
|
{
|
|
2126
2859
|
"kind": "cli",
|
|
2127
|
-
"name": "
|
|
2860
|
+
"name": "creditgrant_list",
|
|
2128
2861
|
"operation": "list",
|
|
2129
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
2862
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant"
|
|
2130
2863
|
},
|
|
2131
2864
|
{
|
|
2132
2865
|
"kind": "cli",
|
|
2133
|
-
"name": "
|
|
2866
|
+
"name": "creditgrant_get",
|
|
2134
2867
|
"operation": "get",
|
|
2135
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
2136
|
-
},
|
|
2137
|
-
{
|
|
2138
|
-
"kind": "cli",
|
|
2139
|
-
"name": "spendingpolicy_create",
|
|
2140
|
-
"operation": "create",
|
|
2141
|
-
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2142
|
-
},
|
|
2143
|
-
{
|
|
2144
|
-
"kind": "cli",
|
|
2145
|
-
"name": "spendingpolicy_update",
|
|
2146
|
-
"operation": "update",
|
|
2147
|
-
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2148
|
-
},
|
|
2149
|
-
{
|
|
2150
|
-
"kind": "cli",
|
|
2151
|
-
"name": "spendingpolicy_delete",
|
|
2152
|
-
"operation": "delete",
|
|
2153
|
-
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2868
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant"
|
|
2154
2869
|
},
|
|
2155
2870
|
{
|
|
2156
2871
|
"kind": "mcp",
|
|
2157
|
-
"name": "
|
|
2872
|
+
"name": "creditgrant_list",
|
|
2158
2873
|
"operation": "list",
|
|
2159
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
2874
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant"
|
|
2160
2875
|
},
|
|
2161
2876
|
{
|
|
2162
2877
|
"kind": "mcp",
|
|
2163
|
-
"name": "
|
|
2878
|
+
"name": "creditgrant_get",
|
|
2164
2879
|
"operation": "get",
|
|
2165
|
-
"objectName": "@happyvertical/smrt-subscriptions:
|
|
2166
|
-
},
|
|
2167
|
-
{
|
|
2168
|
-
"kind": "mcp",
|
|
2169
|
-
"name": "spendingpolicy_create",
|
|
2170
|
-
"operation": "create",
|
|
2171
|
-
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2172
|
-
},
|
|
2173
|
-
{
|
|
2174
|
-
"kind": "mcp",
|
|
2175
|
-
"name": "spendingpolicy_update",
|
|
2176
|
-
"operation": "update",
|
|
2177
|
-
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2178
|
-
},
|
|
2179
|
-
{
|
|
2180
|
-
"kind": "mcp",
|
|
2181
|
-
"name": "spendingpolicy_delete",
|
|
2182
|
-
"operation": "delete",
|
|
2183
|
-
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
2880
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant"
|
|
2184
2881
|
}
|
|
2185
2882
|
],
|
|
2186
2883
|
"relationshipFeatures": [
|
|
2884
|
+
"crossPackageRef",
|
|
2885
|
+
"foreignKey",
|
|
2187
2886
|
"uuidColumns"
|
|
2188
2887
|
],
|
|
2189
2888
|
"tags": [],
|
|
2190
2889
|
"risks": []
|
|
2191
2890
|
},
|
|
2192
2891
|
{
|
|
2193
|
-
"name": "
|
|
2194
|
-
"qualifiedName": "@happyvertical/smrt-subscriptions:
|
|
2195
|
-
"collection": "
|
|
2196
|
-
"tableName": "
|
|
2892
|
+
"name": "PriceBookCollection",
|
|
2893
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:PriceBookCollection",
|
|
2894
|
+
"collection": "pricebooks",
|
|
2895
|
+
"tableName": "_smrt_price_books",
|
|
2197
2896
|
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2198
2897
|
"extends": "SmrtCollection",
|
|
2199
2898
|
"fields": [],
|
|
@@ -2207,10 +2906,10 @@
|
|
|
2207
2906
|
"risks": []
|
|
2208
2907
|
},
|
|
2209
2908
|
{
|
|
2210
|
-
"name": "
|
|
2211
|
-
"qualifiedName": "@happyvertical/smrt-subscriptions:
|
|
2212
|
-
"collection": "
|
|
2213
|
-
"tableName": "
|
|
2909
|
+
"name": "PriceBookAssignmentCollection",
|
|
2910
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:PriceBookAssignmentCollection",
|
|
2911
|
+
"collection": "pricebookassignments",
|
|
2912
|
+
"tableName": "_smrt_price_book_assignments",
|
|
2214
2913
|
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2215
2914
|
"extends": "SmrtCollection",
|
|
2216
2915
|
"fields": [],
|
|
@@ -2224,10 +2923,10 @@
|
|
|
2224
2923
|
"risks": []
|
|
2225
2924
|
},
|
|
2226
2925
|
{
|
|
2227
|
-
"name": "
|
|
2228
|
-
"qualifiedName": "@happyvertical/smrt-subscriptions:
|
|
2229
|
-
"collection": "
|
|
2230
|
-
"tableName": "
|
|
2926
|
+
"name": "RetailChargeCollection",
|
|
2927
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:RetailChargeCollection",
|
|
2928
|
+
"collection": "retailcharges",
|
|
2929
|
+
"tableName": "_smrt_retail_charges",
|
|
2231
2930
|
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2232
2931
|
"extends": "SmrtCollection",
|
|
2233
2932
|
"fields": [],
|
|
@@ -2241,10 +2940,10 @@
|
|
|
2241
2940
|
"risks": []
|
|
2242
2941
|
},
|
|
2243
2942
|
{
|
|
2244
|
-
"name": "
|
|
2245
|
-
"qualifiedName": "@happyvertical/smrt-subscriptions:
|
|
2246
|
-
"collection": "
|
|
2247
|
-
"tableName": "
|
|
2943
|
+
"name": "CreditGrantCollection",
|
|
2944
|
+
"qualifiedName": "@happyvertical/smrt-subscriptions:CreditGrantCollection",
|
|
2945
|
+
"collection": "creditgrants",
|
|
2946
|
+
"tableName": "_smrt_credit_grants",
|
|
2248
2947
|
"packageName": "@happyvertical/smrt-subscriptions",
|
|
2249
2948
|
"extends": "SmrtCollection",
|
|
2250
2949
|
"fields": [],
|
|
@@ -3092,16 +3791,96 @@
|
|
|
3092
3791
|
"name": "spendingpolicy_delete",
|
|
3093
3792
|
"operation": "delete",
|
|
3094
3793
|
"objectName": "@happyvertical/smrt-subscriptions:SpendingPolicy"
|
|
3794
|
+
},
|
|
3795
|
+
{
|
|
3796
|
+
"kind": "api",
|
|
3797
|
+
"name": "retailcharges.list",
|
|
3798
|
+
"operation": "list",
|
|
3799
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge",
|
|
3800
|
+
"path": "/retailcharges",
|
|
3801
|
+
"method": "GET"
|
|
3802
|
+
},
|
|
3803
|
+
{
|
|
3804
|
+
"kind": "api",
|
|
3805
|
+
"name": "retailcharges.get",
|
|
3806
|
+
"operation": "get",
|
|
3807
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge",
|
|
3808
|
+
"path": "/retailcharges/[id]",
|
|
3809
|
+
"method": "GET"
|
|
3810
|
+
},
|
|
3811
|
+
{
|
|
3812
|
+
"kind": "cli",
|
|
3813
|
+
"name": "retailcharge_list",
|
|
3814
|
+
"operation": "list",
|
|
3815
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge"
|
|
3816
|
+
},
|
|
3817
|
+
{
|
|
3818
|
+
"kind": "cli",
|
|
3819
|
+
"name": "retailcharge_get",
|
|
3820
|
+
"operation": "get",
|
|
3821
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge"
|
|
3822
|
+
},
|
|
3823
|
+
{
|
|
3824
|
+
"kind": "mcp",
|
|
3825
|
+
"name": "retailcharge_list",
|
|
3826
|
+
"operation": "list",
|
|
3827
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge"
|
|
3828
|
+
},
|
|
3829
|
+
{
|
|
3830
|
+
"kind": "mcp",
|
|
3831
|
+
"name": "retailcharge_get",
|
|
3832
|
+
"operation": "get",
|
|
3833
|
+
"objectName": "@happyvertical/smrt-subscriptions:RetailCharge"
|
|
3834
|
+
},
|
|
3835
|
+
{
|
|
3836
|
+
"kind": "api",
|
|
3837
|
+
"name": "creditgrants.list",
|
|
3838
|
+
"operation": "list",
|
|
3839
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant",
|
|
3840
|
+
"path": "/creditgrants",
|
|
3841
|
+
"method": "GET"
|
|
3842
|
+
},
|
|
3843
|
+
{
|
|
3844
|
+
"kind": "api",
|
|
3845
|
+
"name": "creditgrants.get",
|
|
3846
|
+
"operation": "get",
|
|
3847
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant",
|
|
3848
|
+
"path": "/creditgrants/[id]",
|
|
3849
|
+
"method": "GET"
|
|
3850
|
+
},
|
|
3851
|
+
{
|
|
3852
|
+
"kind": "cli",
|
|
3853
|
+
"name": "creditgrant_list",
|
|
3854
|
+
"operation": "list",
|
|
3855
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant"
|
|
3856
|
+
},
|
|
3857
|
+
{
|
|
3858
|
+
"kind": "cli",
|
|
3859
|
+
"name": "creditgrant_get",
|
|
3860
|
+
"operation": "get",
|
|
3861
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant"
|
|
3862
|
+
},
|
|
3863
|
+
{
|
|
3864
|
+
"kind": "mcp",
|
|
3865
|
+
"name": "creditgrant_list",
|
|
3866
|
+
"operation": "list",
|
|
3867
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant"
|
|
3868
|
+
},
|
|
3869
|
+
{
|
|
3870
|
+
"kind": "mcp",
|
|
3871
|
+
"name": "creditgrant_get",
|
|
3872
|
+
"operation": "get",
|
|
3873
|
+
"objectName": "@happyvertical/smrt-subscriptions:CreditGrant"
|
|
3095
3874
|
}
|
|
3096
3875
|
],
|
|
3097
3876
|
"prompts": [],
|
|
3098
3877
|
"relationshipsV2": {
|
|
3099
|
-
"foreignKeyFields":
|
|
3100
|
-
"crossPackageRefFields":
|
|
3878
|
+
"foreignKeyFields": 13,
|
|
3879
|
+
"crossPackageRefFields": 6,
|
|
3101
3880
|
"junctionCollections": 0,
|
|
3102
3881
|
"hierarchicalObjects": 0,
|
|
3103
3882
|
"polymorphicAssociations": 0,
|
|
3104
|
-
"uuidColumns":
|
|
3883
|
+
"uuidColumns": 80
|
|
3105
3884
|
},
|
|
3106
|
-
"agentDoc": "# @happyvertical/smrt-subscriptions\n\nTenant subscriptions, plan features, immutable/idempotent usage evidence,\neffective-dated client pricing, scoped spending policies, and entitlement\nresolution for SMRT applications.\n\n## Validation\n\n```bash\npnpm --filter @happyvertical/smrt-subscriptions test\npnpm --filter @happyvertical/smrt-subscriptions test:postgres\npnpm --filter @happyvertical/smrt-subscriptions typecheck\npnpm --filter @happyvertical/smrt-subscriptions build\n```\n\n`test:postgres` is the lane that holds the money-column line — SQLite's type\naffinity stores a REAL in an INTEGER column without complaint, so a money field\nthat reverted to DECIMAL passes every SQLite suite.\n\n## Money\n\n- **Money is integer minor units** (cents) — `$19.99` is `1999`.\n `SubscriptionPlan.priceAmount`, `ClientCharge.amount`,\n `BillingAdjustment.amount` and `SpendingPolicy.limitAmount` all initialize\n `= 0`, never `= 0.0`: the integer literal is what maps them to INTEGER\n columns (BIGINT on fresh PostgreSQL/DuckDB databases; #2401, #2373). `ClientCharge.quantity` and `TenantUsageMetric.quantity` are\n the opposite case — metered quantities are genuinely fractional and stay\n DECIMAL.\n- **`PricingRule.terms` are minor units *per unit of usage*, and stay\n fractional.** A per-token rate is routinely a fraction of a cent, so an\n integer `unitPrice` would truncate it to zero. `calculateAmount()` rounds the\n computed result to a whole minor unit — that is the single boundary in the\n package where a rate meets money, and it is what lets `evaluateSpending()`\n compare charge sums against `limitAmount` exactly.\n- **`adjust()` rejects a fractional amount.** Negative amounts are legitimate\n (a credit); fractional ones almost always mean the caller passed major units.\n- **Billing rejects immediate JSON write-back.** The JSON adapter's default\n `writeStrategy: 'immediate'` and DuckDB with that write-back strategy export\n files before transaction commit, while adapter rollback restores only the\n database transaction. `CommercialUsageService` therefore fails before setup\n on those configurations. PostgreSQL, SQLite, ordinary DuckDB, and explicit\n non-immediate write strategies remain supported. When supplying an already\n resolved database handle, also pass `billingStorage` so this capability\n decision is explicit rather than inferred from private adapter state.\n- **Embedded sourced adjustments serialize per database.** SQLite, DuckDB, and\n supported non-immediate JSON handles multiplex local writes; the complete\n deterministic adjustment flow, including recovery reads, runs under one\n database-scoped lock. Every supported embedded adjustment transaction,\n sourced or unsourced, also holds the core embedded write queue for its full\n lifetime; transaction-bound model saves re-enter that hold so adjustments\n cannot absorb, roll back, or deadlock with unrelated ordinary writes.\n- **UI formats by dividing, never by `toFixed`.** `PlanPicker` and\n `CommercialOverview` scale back to major units using the currency's own\n minor-unit exponent, so zero-decimal currencies (JPY, KRW) are not divided.\n- **Migrating an existing database**: `preflightSubscriptionsMoneyMinorUnits(db)`\n reports which columns still hold major units and which rows would be rounded\n or exceed JavaScript's safe-integer range; `migrateSubscriptionsMoneyToMinorUnits(db)` converts them\n (idempotent via `_smrt_backfills`). On SQLite the values are rescaled but the\n declared type needs the table-rebuild path (#2370). Existing\n `PricingRule.terms` are **not** migrated automatically — only the operator\n knows which keys in a given rule are prices rather than quantities or ratios.\n- **Range and existing deployments**: fresh PostgreSQL/DuckDB INTEGER columns\n are BIGINT, and hydration rejects values outside JavaScript's safe-integer\n range. Existing PostgreSQL `int4` columns require the explicit widening in #2424.\n\n## Notes\n\n- Keep Stripe-specific fields as provider binding metadata. Runtime Stripe API\n calls belong in the HappyVertical SDK accounting provider.\n- Thresholds are evaluated from tenant usage metrics and optional AI usage\n summaries. Resolve multiple thresholds with the batch usage path where\n available; do not bypass tenant context in application code.\n- Use `SubscriptionResolver.create()` or an explicitly injected\n `SubscriptionResolver` once per request when resolving entitlements multiple\n times. Load and pass `EntitlementResolutionContext` to avoid re-reading the\n current subscription and plan.\n- Subscription UI components should stay provider-neutral and receive actions\n from the host app.\n"
|
|
3885
|
+
"agentDoc": "# @happyvertical/smrt-subscriptions\n\nTenant subscriptions, plan features, immutable/idempotent usage evidence,\neffective-dated client pricing, scoped spending policies, and entitlement\nresolution for SMRT applications.\n\n## Validation\n\n```bash\npnpm --filter @happyvertical/smrt-subscriptions test\npnpm --filter @happyvertical/smrt-subscriptions test:postgres\npnpm --filter @happyvertical/smrt-subscriptions typecheck\npnpm --filter @happyvertical/smrt-subscriptions build\n```\n\n`test:postgres` is the lane that holds the money-column line — SQLite's type\naffinity stores a REAL in an INTEGER column without complaint, so a money field\nthat reverted to DECIMAL passes every SQLite suite.\n\n## Money\n\n- **Money is integer minor units** (cents) — `$19.99` is `1999`.\n `SubscriptionPlan.priceAmount`, `ClientCharge.amount`, `RetailCharge.amount`,\n `CreditGrant.amount`,\n `BillingAdjustment.amount` and `SpendingPolicy.limitAmount` all initialize\n `= 0`, never `= 0.0`: the integer literal is what maps them to INTEGER\n columns (BIGINT on fresh PostgreSQL/DuckDB databases; #2401, #2373). `ClientCharge.quantity` and `TenantUsageMetric.quantity` are\n the opposite case — metered quantities are genuinely fractional and stay\n DECIMAL.\n- **`PricingRule.terms` are minor units *per unit of usage*, and stay\n fractional.** A per-token rate is routinely a fraction of a cent, so an\n integer `unitPrice` would truncate it to zero. `calculateAmount()` rounds the\n computed result to a whole minor unit — that is the single boundary in the\n package where a rate meets money, and it is what lets `evaluateSpending()`\n compare charge sums against `limitAmount` exactly.\n- **`adjust()` rejects a fractional amount.** Negative amounts are legitimate\n (a credit); fractional ones almost always mean the caller passed major units.\n- **Billing rejects immediate JSON write-back.** The JSON adapter's default\n `writeStrategy: 'immediate'` and DuckDB with that write-back strategy export\n files before transaction commit, while adapter rollback restores only the\n database transaction. `CommercialUsageService` therefore fails before setup\n on those configurations. PostgreSQL, SQLite, ordinary DuckDB, and explicit\n non-immediate write strategies remain supported. When supplying an already\n resolved database handle, also pass `billingStorage` so this capability\n decision is explicit rather than inferred from private adapter state.\n- **Embedded sourced adjustments serialize per database.** SQLite, DuckDB, and\n supported non-immediate JSON handles multiplex local writes; the complete\n deterministic adjustment flow, including recovery reads, runs under one\n database-scoped lock. Every supported embedded adjustment transaction,\n sourced or unsourced, also holds the core embedded write queue for its full\n lifetime; transaction-bound model saves re-enter that hold so adjustments\n cannot absorb, roll back, or deadlock with unrelated ordinary writes.\n- **UI formats by dividing, never by `toFixed`.** `PlanPicker` and\n `CommercialOverview` scale back to major units using the currency's own\n minor-unit exponent, so zero-decimal currencies (JPY, KRW) are not divided.\n- **Migrating an existing database**: `preflightSubscriptionsMoneyMinorUnits(db)`\n reports which columns still hold major units and which rows would be rounded\n or exceed JavaScript's safe-integer range; `migrateSubscriptionsMoneyToMinorUnits(db)` converts them\n (idempotent via `_smrt_backfills`). On SQLite the values are rescaled but the\n declared type needs the table-rebuild path (#2370). Existing\n `PricingRule.terms` are **not** migrated automatically — only the operator\n knows which keys in a given rule are prices rather than quantities or ratios.\n- **Range and existing deployments**: fresh PostgreSQL/DuckDB INTEGER columns\n are BIGINT, and hydration rejects values outside JavaScript's safe-integer\n range. Existing PostgreSQL `int4` columns require the explicit widening in #2424.\n\n## Reseller billing (#3059)\n\n- Billing ownership is consumed from `smrt-tenancy`'s\n `BillingRelationshipService` (`BillingRelationshipReader`); never re-derive\n parentage or owners here.\n- `ClientCharge` stays one row per usage event (`usage_event_id` unique) and\n `tenantId` is always the payer. That uniqueness is the double-billing guard\n across owner changes; do not widen its conflict key. The retail leg lives in\n `RetailCharge` (also one per event), written in the same transaction.\n- Price-book rules are `PricingRule` rows with `priceBookId`; `price()` must\n keep ignoring them, and `rateUsage()` only trusts rules whose tenant owns the\n book.\n- Delegated `SpendingPolicy` rows (`setByTenantId`) are guarded in\n `validateBeforeSave` and a `beforeDelete` hook, by id and by conflict key;\n `CreditGrant` applies the same parent-only rule to delegated balances.\n `PriceBookAssignmentCollection` is deliberately not a root export.\n- `ResellerBillingService` authorizes first, then writes in a system context\n (parent writes land on child-owned rows). The wholesale leg is authorized by\n the book's publisher and may never be published by the payer; whether a\n publisher is a legitimate provider for the reseller is a host obligation\n (the model records no upstream seller). Relationship reads precede\n authorization and stay under smrt-tenancy's own read rules. The only\n cross-tenant read in evaluation is the bounded `wholesale`-basis sum.\n- `balance` policies take their limit from `CreditGrant`s; `limitAmount` must\n be 0, and currency and period are fixed once saved (the ledger is scoped to\n them). Auto top-up is a host hook only — no payment provider calls.\n\n## Notes\n\n- Keep Stripe-specific fields as provider binding metadata. Runtime Stripe API\n calls belong in the HappyVertical SDK accounting provider.\n- Thresholds are evaluated from tenant usage metrics and optional AI usage\n summaries. Resolve multiple thresholds with the batch usage path where\n available; do not bypass tenant context in application code.\n- Use `SubscriptionResolver.create()` or an explicitly injected\n `SubscriptionResolver` once per request when resolving entitlements multiple\n times. Load and pass `EntitlementResolutionContext` to avoid re-reading the\n current subscription and plan.\n- Subscription UI components should stay provider-neutral and receive actions\n from the host app.\n"
|
|
3107
3886
|
}
|