From cfbbc3b2b55e24c7d8805cb0d009e7f570757fa3 Mon Sep 17 00:00:00 2001 From: Krisztian Gacsal Date: Tue, 5 Nov 2024 15:31:16 +0100 Subject: [PATCH 1/2] feat(api): add ordering to Plan API spec --- api/api.gen.go | 1369 +++++++++++---------- api/openapi.yaml | 42 +- api/spec/src/productcatalog/plan.tsp | 18 +- api/spec/src/productcatalog/ratecards.tsp | 2 +- 4 files changed, 725 insertions(+), 706 deletions(-) diff --git a/api/api.gen.go b/api/api.gen.go index 32a3c2583..89dfb4fe1 100644 --- a/api/api.gen.go +++ b/api/api.gen.go @@ -381,20 +381,25 @@ const ( // Defines values for PhasesOrderBy. const ( - PhasesOrderByKey PhasesOrderBy = "key" + PhasesOrderByKey PhasesOrderBy = "key" + PhasesOrderByStartAfter PhasesOrderBy = "start_after" ) // Defines values for PlanOrderBy. const ( - PlanOrderById PlanOrderBy = "id" - PlanOrderByKey PlanOrderBy = "key" + PlanOrderByCreateAt PlanOrderBy = "create_at" + PlanOrderById PlanOrderBy = "id" + PlanOrderByKey PlanOrderBy = "key" + PlanOrderByUpdatedAt PlanOrderBy = "updated_at" + PlanOrderByVersion PlanOrderBy = "version" ) // Defines values for PlanStatus. const ( - PlanStatusActive PlanStatus = "active" - PlanStatusArchived PlanStatus = "archived" - PlanStatusDraft PlanStatus = "draft" + PlanStatusActive PlanStatus = "active" + PlanStatusArchived PlanStatus = "archived" + PlanStatusDraft PlanStatus = "draft" + PlanStatusScheduled PlanStatus = "scheduled" ) // Defines values for PricePaymentTerm. @@ -2790,9 +2795,10 @@ type Plan struct { // Status The status of the plan. // Computed based on the effective start and end dates: - // - draft = no effectiveStartDate - // - active = effectiveStartDate <= now < effectiveEndDate - // - archived / inactive = effectiveEndDate <= now + // - draft = no effectiveFrom + // - active = effectiveFrom <= now < effectiveTo + // - archived / inactive = effectiveTo <= now + // - scheduled = now < effectiveFrom < effectiveTo Status PlanStatus `json:"status"` // UpdatedAt Timestamp of when the resource was last updated. @@ -2944,7 +2950,7 @@ type PlanPhaseUpdate struct { StartAfter *string `json:"startAfter"` } -// PlanReference Referebces an exact plan. +// PlanReference References an exact plan. type PlanReference struct { // Key The plan key. Key string `json:"key"` @@ -3075,6 +3081,7 @@ type RateCardEntitlement struct { // RateCardFlatFee A flat fee rate card defines a one-time purchase or a recurring fee. type RateCardFlatFee struct { // BillingCadence The billing cadence of the rate card. + // When null it means it is a one time fee. BillingCadence *string `json:"billingCadence"` // CreatedAt Timestamp of when the resource was created. @@ -3123,6 +3130,7 @@ type RateCardFlatFeeType string // RateCardFlatFeeUpdateItem A flat fee rate card defines a one-time purchase or a recurring fee. type RateCardFlatFeeUpdateItem struct { // BillingCadence The billing cadence of the rate card. + // When null it means it is a one time fee. BillingCadence *string `json:"billingCadence"` // Description Optional description of the resource. Maximum 1024 characters. @@ -3206,7 +3214,6 @@ type RateCardUpdateItem struct { // RateCardUsageBased A usage-based rate card defines a price based on usage. type RateCardUsageBased struct { // BillingCadence The billing cadence of the rate card. - // When null, the rate card is a one-time purchase. BillingCadence string `json:"billingCadence"` // CreatedAt Timestamp of when the resource was created. @@ -3270,7 +3277,6 @@ type RateCardUsageBasedType string // RateCardUsageBasedUpdateItem A usage-based rate card defines a price based on usage. type RateCardUsageBasedUpdateItem struct { // BillingCadence The billing cadence of the rate card. - // When null, the rate card is a one-time purchase. BillingCadence string `json:"billingCadence"` // Description Optional description of the resource. Maximum 1024 characters. @@ -11448,675 +11454,676 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+y9C3fbNtYo+lewdOesJvPJiu082viuWbMU22k8zcPjRzPTKteFSUjCFwpkCdC22pv/", - "fhb2BkCQBCXKj8RJddacr7FIAhvAxn4//uxF6SxLBRNK9nb+7GU0pzOmWA5/veBJwsXkQFykPGKvuVSH", - "+rkcsKuMili/wq6yJI1Zb2dME8n6PS56O73fC5bPe/2eoDPW2+mZt/s9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G6FtjKOCtbY6/7dYikBAK/GjSlSktu1UZa", - "geUa9tLa9yvaTmsb2cWO+mNO21w4kMscSC2YtXt98JmmNfgxOXZVgyjJUskVv/C9qlUvU8lt0+IcusM4", - "v2jpJsKP1yXu7odSxMZjBhHZoZXs24eQOQJXD9BCQogWFdE0xeC43FJG83xADm026AVNCuZKv0aMG14G", - "NwtKonARp5fH/A9GHsy4KBR7eMsJKR65aBMxjCjtexhAJ3Gly7EuAJd1Mr6CILFU52BXGcdciRVsJu6b", - "hbIlgl9OgMImx2AmMzOTw7b4BGhcUx2G3bBtzdLd+Er1Rnp1lCZJesHyoUdnTfmdzfrZ/GiuU85Inib6", - "augvCYXqC0z16yWT5qWjmpKYjyFNWJFzmlARYc0HagKwLg3qzsmUagI+To1wCSMPRuKF+aisVgVPCBTq", - "cw0XqNwh5s0zyP09O4K3/kHeHLx98Ka+3D55M/zPA/vBC5gVv+iTN1xUX374sAMLabCNWxUuy8thh61l", - "TGDQnCmyA9kPGT978i4ffpy+vpjzKU+fZ0+3ps85fyleAHOe1Ze5RoHbRgHBrhRK48yVbmsEcLErVadc", - "wIaQWd0yj8lynoZ7I5iY4tTv1GCEK3P0oA5M+URrde5NiAExhdLHPJf6uA7tQ8glc+JYzCI+cwFkckDe", - "6wGT9JLl9jfCRQwNisTEzsRnWZpDCaIBNjQzu9HXQ3vwbunZZhpzinyCTReoqL2zPRgJ2zpNw52bZg80", - "cQKDa/HhOrbRmVN0sWCJnEvFZkSyxITClMdm9CUAXSo392AkDgSJqMQ6njmz08kptaq0nsbBmrALlvS9", - "oaMklabAP1fS55BWZMFOruYEDkw8FJXow7pM7YxwIZEVRTSxM3KGspLPealisrJgmKmQPqKC3OFJuQaA", - "WsCYQ82CC/WDH5W4/fTpsqDEvHJ/btOQVY5cs2IZheQbMQViE4WOMpMGGz+4VcLT0bNnVL6quF8ROI2d", - "sCoqLzE+APla2IW45K7VNOJ7rJT+JRSiL6ZorMXjtXi8Fo/vGgXWwuhaGP3LCaP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9tSTorCQUrlZvzfcT", - "+SXXwsJvaBe9qb+Camt+Nal1hbXPUWGtWbwpUAQSc5iWVFQA/h9e57+O370lGc0leNzxzZDuR6BHPIZH", - "cYml9VEi0DcSWphNWfRR83KfNhvfJ1T7tt0UrDfViiX6G80mNiY5BV+n+cjJL8a+YIhtv3SjokAzT4uc", - "pJfCuFAH5BWVps8yFaFK+70/yQiPyzS/GPV2yK+j3oSraXE+6n0gn3wG/L8yXD977fdcF6pY+znXfs51", - "oYpbN+KazNy1Dfez16lAUeHuC1YEUqo71KtoSjtrYefzCDtrs/a6CsjtVwFZROe/HhuDITlLKN6JWXsN", - "iPaCi3VLTN+Za/qtG9fvXW1M0o1FtoafNVkLZM/U415B8U1zgK5sNGvI1YwKOnHEks1tLeYy1nVsCy8D", - "3TYVtAekMk1EhSZcZoF9W46oTxypbyqzxiYdsNJoSbAaPB7w18kBaY30PS94ogjN00LELTG1GDpejcGF", - "QN24iCqVpSsxtQObgkByBmY9YYLWczajXHh+hAAq9NGsj9xIsAuWE82JJBFsQhW/YF2yqlokVa/cRwvb", - "DOxqkwlLQILO7LXGnj6y+Q4Z9WCBox6wo6WCtfOHNSF+P2VAfH0iPaXSQ02fKhFTzJpGUZ5KdCBUSlnP", - "s1oxBYSoBULPoGqsrjdAVGNJriONKZlv4v7Fd4pEei50xSHC9QkbTAbWrVjugkZr7GdRReF0TLY2N10b", - "DSSH54VJwLnUOA+KFozOYvLDZt8kcDjn2PamtTNXdut62AhQ3WDnsPWz8TsE1lu367nwbM+ydw3Aa+yh", - "RNIga7hgIePjbpIWMTyT5BgdIRHSHrhex8Dpqmle0NvxabS1OaYx29iKnrONJ/GzaOOH7e+fbkRPt6PH", - "z75/vBU/jjTjAF1I3yWWX/CIbZjuIDJjkes62tsabJZivq8BYhVaPlsSsWUWm+XpLFO9Rq9HK3c0+TG7", - "QDvrPEkpHIgoEjhsu+OpYEYOqG9oo93Ch099mClKoXO0CvLfXXxYKXwM4guQowF5U0hFaAy4rlJy9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uH45Jm9IWfmYtoxQb7v9XtYnuEMINArNiIwT+ZnhXBVzIM319DRIKI3jsTr", - "W52V33U4h/8TPIhD19WqUSQYW1TZvstQehV792PjjKbMEK49hDOYAeyHd1w8yMzpg1qfcfuW6pWYyrkq", - "DV61wymVTK7GH7KECpLBhz4SV9tReyeY0ECohf5V2qgIo5JBfXg9gyzO3bvyW8tQ1hQ1mneXNHbNF5r+", - "1BqUnh7vBTuT2kmQ9NgIuISKarqUgeRbcnMsKrTqLCGBeqvOXEDeYF1tsrW5/aRWc9JT8/VTHy6/JHqz", - "Eut4zKDTYrjSdbPlj9tmuGrnLEpnTBI3zIC81y+IVFkBm8X98n0wccQ5Hd8wEsZptXZeQyPjUKCHv8yT", - "dPVFQtUfkqRiwvJVVupeJVygXUuxZH7bC9eEum3ZqwZYBytIf55SrmZdB3uhdUDviVBL3hnf6LaaWym9", - "amD8ic2Dli6/LnjXCs34RVMHG5alvu24wXVZmMqh2kxor6q1b8F+1hiRvDCtiLfgMmw/fdZOZ7afPmtU", - "QbVEh8ssoWikC2brAIduaU3gWDjRDD3nEbQt0VTedAOB1sj6RwovfydJrm9vRPNYkvSC5XiJqaY1PrvW", - "LH2SM6mFg5EYmknkJVfRlKRRVOSmn0216y4l56beF4p1fcKELEojLyWSiwkYhry5TL8WqBUGRIKLKCli", - "rBU8sbWhYz4eM1RjABhoz929i4iWVEBMarW0HpYCUcDGJ10obse+rAkVNhkt3ImsEtwDbH0kdtNZVmhN", - "+ZxKFtsUXFYj3VY+1rRM7ozEBvIJ8g9NfN3LUNRujyqmXzA9gv8ReExGxebm40h/fGn+Xb61L2I3RB5N", - "+QWLySPCRXM886Y/2pLwWMzT+xYKGLgOjJ4Daat+6D/jS5UTJwciwgYTLG6yUm9dfmOQNkjNBMv7fYDl", - "xzpLW/yqH4FyX7ghncTrroKjTUGNJKECjWcht6k5QJybaKUAxW3X66peneB+SttrKXUtpX5eKXUt3a2l", - "u7V0d9vSXY09msNCDujxvSXsbnXzW9Mds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2LW4VH1iGb0nCccRZpf/2xccQAJzFQ0iQos7KDoFVTK9LipqQsKlApi", - "AGD5GTtzn50pemXReqe3a3/WY5eH4d7Wv37qt4BjJ3M2eom2Ao07Jgq8Dob55Mx9UYJyYEqa7nqPXCww", - "PCqftIJkquNJEqVJwiIlSVooqagA6T5nF0wUJjXBfGEh8UR9W2JvxtQ0jZtbiUOf2bm83cQn5LB8YjcU", - "n7gHISpu9lTZktimHu08LfRNNCOUK/QWAXWRolSc5klvp/eIz+iEyUcI7iAD6mQgxPerlA/j7hJ+wWZp", - "7EzO9Q8sxwLyir2q4TZF0P/gQCM7jSJ1trX9+MnTZ9//8LwxSYVDtN+cT+vOh2vxfi3e3z/xvqQQ9T1/", - "bZ70wXxgM63MmBwqY8dF5Or8h80ea+3h69AeGnQ/JKRZGQrfIgd7g2B9366KiONyZUA+sJS1GrJEDWke", - "l3ePgzoKvL47ZdHHtFDHTEqeijfBW2/OuPbuAIb2ToqpIlsgjhuR6EArEaqtV0lVugMhSSjTvcRHi0ir", - "IQmL0bweaYhgU8x2yjMaGV7ifgG3rz6+2u9mrjMUAvVGFlHEWNySQ4UQHuvF4lJaFwEbYpYQaniC4mhL", - "vxbvWye5DrqyxsYIPB4sDXRxhPSwAudiCaE5lR0zqPHV9no54E0JvekuqIx5pp/LlUcGClRtmLC0/P6q", - "xLn9GrSp8h649goEaYYjBQ6pvLNtv/wnfpDHwoANzf9K2lxPhwvRjEOUBMwgMYPmDpUeDXEayYFRXaJ0", - "9kjRK/3/N/TbskKQ1VUUn21t4v+rimrwaDSK//zh098aYR7xcpIbLSaP79n5NE0/7l8suueX+BIkn6vW", - "fu4tCfUXcMFN+rWybKsS38iFerwdzJe1d7dtXHsPqwClrjz/cmz16Vx979L2Cvd84XJbhITFYucCgbJd", - "usD59PNBN+5reKkDxTHintntpbjSXiu5hi62YHLzgGiWHXyNnSGauWOGHH0bq9GSmcxoxL6F5QRC0eza", - "+gYBg6he9vZopByZuhwQsR1WzSkpJMtJmq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IUshSyFLIUstTqWcsyzpsMy", - "mGLL2jbbl+ZbNu/bzOfYNYMHeGIauaF5zAgX5Phgjzx69OiZWQtiqltnAqyGFb+Ay/VVlr1wu7wazbY6", - "W482Opsbnc3TzuY2/NfqdDY/NZoNm39ju5EXX33LvVzjfRFeu75a3lRtD+CeuYtpGGeR5knESI9RnaWM", - "8FCZT+ycjVTZztol+Nn93dg8yzqdraeTj7f+qhsQm6DUyoWvYi3YCHc/rr4RLsHP7q9vxOTj2kb4m/3r", - "bESaRTAM5Zqbpz93Nn/56Zet337/tPX2ycfd3191nu0//3Swe/LpjW3HONHj48cfPr3c/Knz6vjVr08f", - "vd3d+rDzpK5V5rXqJk1st14fPicP3gt+wVJFo2hE3gv+d8bIa3bJA9lPaTLgAfxwIlMNC/whwFWPs/Rh", - "C4zyb3CDdNURyI/wJwfB/eC7+LeXP/7402+7nSdPfznp/PTTu73fT+04lNOdbB5vvni2/+Ht063jF1uP", - "dp69efpL3VCM1/F7MRrf5f0JEFMruT1Rn9NN3p2AWuDNCdxC4xYazS1xB4k3J6ZuTjC/MVvF5rH9Bf46", - "K8tFTQ/gnQUND0CgLaS1dzWZqbP/VmYBthUohVEKoxRGRTYqshFD7rlRAHNi/XoQkmYRW1aBDe/M118f", - "Q9bXccsBBd12nxwLNuKbOORYUtXdvmE992o1eGdih5yzkVmPKMnsqxZjc8LKlIUrbl8b2Qu0FgZMs0+P", - "nh9t2xs2kMt4nVIyyuyaLYnKkkSmmnSlHhCoNRUheWWKFrDeKRozohIWgJALZMj6TJgP6tv6iruqAthO", - "dxqUL3TVa4N3jj89evt8/9XpyYfHx8cHB78+ffbiycHOhwpt8NbvT357/Pbti19PHm3tHfy0+fHZk/1H", - "V9IG31b1qllFV6Jdrc3oJpWrphKoW8VdHe7qULeKmxrUrU7pVlO3aViXSxqT/yL+aI7tIf+6DYZNMd+N", - "JxpoM7qhQdmNshtlN8pulN1XcEPjjONWoJRsfzF/rup9BswCZ7uesZaDq/A742Bh/gGrbR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uGdej9sCmZMG+HmHVvuoAqQU14osqCCzljqYtPUUmm2", + "GJEDamYh54wsZIqWccAWJ/9aq/8fENRZCJodpoNHg9297/e+2U+SHbq793Dnb98/pDvf7e092Nmj33+z", + "P2VJuv8wjTrKxnkOaxHLV9PBo1/WkHVd8JyZT94P17xJRXour+DVt80NGef5aCJeCUbk9BFoL+C3TLl5", + "aWEERrT3LGiem8N49MdA4Xg9phsO7IA91uCwefkycKC+x115TFVMPz5XujDKHNjuFzJlGei+1jHLUkLz", + "XIHkesycomiUrzwP3tESjlwWMyqsxgiaIlfgVjN6tC7BbqA0FQkbogLNtSLy0qjlYspnZWENCiIlScHA", + "wkEz4DaNS1owo92MI4TplC+Y0nSRGwQF3c8qfLIsEgbarv26hnyD/d39bzZxORWMpq9EtnQuaReeeeBi", + "TE+jrimDOMAMrwl7zooFNcefLR1bvp11AM9evY4+Fr3gZ+dScusZkReosJC93f1vSDKnBg2tdLGgV8+Z", + "mOm50Wb2vwnhCi1uLah4RIwZkxKMEM5mxq1fvwZMbRN39354+O1///btt+Nnb8Y//fh0b//lf3YP/vX9", + "sx8NKlJtyNTg0eD/+2V3529vf9nd+X688+M/f3rx8mjn9Oed/9Kd+f++W4h8R1/s/P72j/1v3/9lxUYf", + "PomtwwbTAyHLsh6ELIjOeG6/bZMpI4YuqhddyD7aWTRc1vDWm6trqEJKUKquL+H9cLBgmqZU0w3AdF9E", + "aGhlXXTjRo/JbVw1lJMPmgf/Y90qCn7N1ojkMdOXjAmyB3Rn/9uH3ai4/+1D0Ks9agZ4yVWeURQ8Ywdq", + "A7R7b9Q4z13sd2un8EEYSJNIISrtp3VOZZ5+AL3MqNLEDnE7xOa5meE1zNBBb96HQUC/mGs+dGJ5xQzC", + "hVZXyO/927iwcEBzes4zK/e1+DpJ/HNggv51zhSRIlsSdsUV2E6RixEFvHBJUim+0jZbBHb12O0qcNmG", + "8NM8YsPTSU6XC4MWJJFZxhLDLUvtXRgFu2CiRCs/sV84ifwrcNeDockOYm7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JnEx2JVrqwf15IaiENyFwQD", + "/WuSHVyPyggiy/MsagFpknwcaq3THN96PxyA022V9I5eOQvoFNNUvdJwU3C377UBz0E3bG527LK7DHCw", + "5jzngh2DWhcLasM7AKY8LOkAMZA5Q6tIMqcFqh+18864aGiF/TMmDTghfQWVHM1OxIyLilGs+kK4KwhB", + "r7UrSznaq2+/49I23D2qbcuCipJmAZCjG98YhAgpaX2LYFYt7VbdxPakXL+Umr0q+IwLmlkojg24fWmq", + "HewHJljBkycyKc31NkMYmtpQ/7DwSuQYfjl+dvDgwYPv30Kyi3p0/76WMlMjzvQU8l3mepHdL6aJeeme", + "jVYz6FJFs1l5gQvy+vSgZVe9VsmTQwPvGBRgtBb6FB5g43atYNTFpUVNWMK7njfaUXsY1nH9PhA7vz5h", + "BafZPVLFxSHCWjU99aCNQqnXybIJnPuZkCk7k/bkz6w5KaoOlgVEXPitwiBjb2zm4p3zV1p7bDV9T+HY", + "zLAKUxtlLCLX2L7hZNKEXMri3TSTl0TajyJX9bwW3NPB//Adw/HNS+jWcWOCwKqUTDjGxnI9xxDKqZMS", + "Lnjq5WNrP26OyBVJ5lIxQfiU0AvKM3qesY9u1xhu3cB3wA38+buWhgN39TYsUvPGfuZveZNYdHmm/Hwb", + "kJBXXaGFr1xYoYRfFPL/WqSepaM8bpVbt6pHfzSjL9Bsb307G/EIN/iBH+KEaawaFzIMkK/8K0TZd6zz", + "litPLLdU4G5QgS8l7AKlio0CLxqYfehG6ERsP8cavPbvuYC2vgaPFTPSPEfDVHRG5wG+7tqtI69z5c4R", + "vXrd9q0PXrWbbfWaNb364Jk0vVozyxcXgNHF2iAww+5pA4VrJ9uD8zUZEeqZd54d3SUSchcu9Pvukw6V", + "701BXGkMCOEMJgnN8ngJwbjZdBdDPI/ZXK8wf221zQ7bZGs1px+qwbohS/YkivNodu6/aS/LBSt4UtuY", + "H+UlWZTJHJzfypp6c8p9/La51aCQQ2a0SJb95zuwX2AYfDDp4ZSkfAr7rat80ZzC326/v8Kw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Ln+vchPageIXMCeUIWumpS4AUdK4DFLviF5OmGYiZ+", + "4lSj+NMh8l48CSccKqadPLNq4NuV+KpJVubKX+fGudSyWk5Ze1O9PNyoVlGjhrC7oKjS7JIuoQCooLma", + "S68FteRqV7/JaU9NzXdkhO2J8NdDOkOEEYTDRBR2lWc84Tpbuso7DkR2lRveIivHcLjhEYhaS+SqEixi", + "la+7IuWsIdxT5cBQ1Q6cU2FUXZ2p1EQQ3J+GJ9zp1iLs9LHe6Dj2eZrOI0DTCyoSAzUaDrBwccY02pY0", + "tH8x+LgqT86ObgP4RF7qtnVzrF5NV1xgqpCsOrt+YD1wls3OQimOPzqrhjNA31hD86FrxXSEQvNzp3bF", + "qvehWF2JXVCE0HZyqofHDgmvLwe0WcP1wq+N9D6nF/6rM6rJpNzdfZAQql5NK7UW50jdGFh4DLXcYLzm", + "66TMsXfrq+mQCHaJ3+10fqc09JgJ9C09Efa2u0o1yTLJWHftxs/PD98qnLXmnoWVcG8+c3RsM/MkWDCX", + "ofxjMMrmHbquoigSndNNCh/GZn1sFMqADGnft76q/wxpowY1HAwOMnB/caE0o2lDqP5KuZhtsDiMbil1", + "0u+W5e4AKiinARSjuGfslF3pmiW8pqNUxSoN77ZG5bVB15EkTDdMndZ7g3Wnvdp7prhAvb6W3MtFyi94", + "6srQ9fFNPQUOGmtIFzxuGDtyWui27U46bmwpXwZGplLnZa1c7l8HzpYV6qSBtFP9c0TzPFKqfji42jGj", + "7VzQQtCFuWy/GNzpP/AYxo3shTY7mnZV546+5j2IuDfMPgy0yoqJV0FvgTbgukEvZOHUQciuiHV9jquq", + "5LVi0xJ6SU2ELmR5zjI1l1KjLbwudVvpPDwSb00dWK/HAO29+AuamtyjM8ui/d/oizhzvogzrO/uHzuN", + "oxr8zNYs9X+rpUjC5+bvsylsg//tknIzxhkttfRz+adQFv1MyzOAtYI+GDr8xQ2+Xsxxmcz9OpxFsqDX", + "tTqzn7yATfQfvV3dz8yHdvSHYziw57T+swYsHX3OKlr2WnB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iCoUwZAEiO6oT3r4pC3uxd9zt6PZwkGGKUze", + "CHtJg37fTmkNuj4457pGCarpOh9a3MORuRe7aKZZAffReweypffZ+fG1Ytn042oJ19iWeNu1BftdippE", + "dWp/azubIBYG88tuNsIiGloRDT1wiiTg4vmyFnEQIQ9xFKw5MfwWrBDsgsz2G3VL1i/CM37F0qC336a+", + "yqabE6RAmdYO9xg8dJA/dyuVVzu7JvIpmcL67LKE1KHDr+51vDFf4ugazsTqsJvuRCt0QxkFKzRgoSzD", + "wxyVdK7GczaVBUNWtopr1BL3t9j1Z8CuLnc1wp6ytExqiUs3g2SVPcBJJt5viNl0g+FA5Rlvgev0/Lo1", + "s+47beRRt0SauhesqyRK7a3rF0VB+3+2tFd1yti2OvG2OvE2WXRbZ2ZbZ+bzrTOzLfzyGRd+AVPWh5mK", + "wNUe5lA2KwP9VlLIvvmwaf5lR1k107b48bb4caxIUBB4si1//IHlj5FiBLd6hX2mK0TrT69nbGspbqsb", + "b6XDrXS4lQ4/onT4+RY5XCm/fFD55A/k5muLKW85+pajb61WW6vVVi7ZyiVbuWQrl2xUfnkT4QTL/0Ri", + "e9OCKbWBWDDGL4BGoNFM1W7LMZuVGS1ILhXEHODwsHmXUDs4DLuuiJGCbOYpwbzRL4eD+WqKDsNzcxDx", + "3AhL6ep1aoG0waW3siENxZawKFs8UopeHW5Om07NV1gTqsUq8eevFMkAvsMnEDcRtOKnVyQvC6RG5HTO", + "llDrGqIisaI25muoITkvNblkXxUM695xoVmBZV3AsCoV1BvgkXEbaTsFVPINhOecFQrL1J2XikMCGMK9", + "KtoAxulqev8Z3ZQtIn1yRPIJZp0N5TEiMBLJY372deAM6ML3NIckt9W1dDcq6Wdhew+STxtB1/dUr1Cu", + "2VL9SVvFSqRAMRBx3A66sm68Y6Rpyc5Aj46VgjebUnfQrA9wshwUt+1tKwMwODmSsinURQWhAOYKoG8k", + "wa7rjB4MfyiUprHQuZtFjFs+GG5XcaPnEj8Pu2HrzwNKuudhZdueR6I2zjiPnGfPVPMIiXgfX7daveIw", + "1/rIayJ1lGKx0i53U219Krz+g6JvFA2VpsVno4mfaNswYuWimiHgsMIhHF1bQ6yxKIC7oGK2Gs8xjLy9", + "afZBfcxGnH7LmHjLGRwZT2weSy1gvgnVZx6SmLIpLTPdSgu1KST2sVttPLl0G254m4bbL6Vs/9aa19ua", + "d8MFlmEtEH8jhaaJjmaduzmjVC4gzGuCcd5cp0Sxr4e7KJVu1MMNPrW25B5Vix9cu2pxOFPjdt9K2lbr", + "sNzOtyvGetufZz2xKrFr4oqCKrFBIhew0ooZvF3Lwsd57pmn6uTnhstWNS4aVRx9MwJFvubpkJgZ77lT", + "hwxKx3fXiwK+8k7/cwhX0OGKsZV8AmuA2X2/bdep/r9yVqc/rJ5zo4TulfNperVyrqZeBJnB1VZXy++F", + "L6vRpIkdUQHsthDho57/Rzr2T33aoXS9sUobIE1fXTZGl96/bYGGplUzsq8YHcXJxntN9OTwo9lFzIM2", + "mNJEzq/AM65uAkcbTGOc54fpq6LdmfA2UXcDGG4BozeY/SMieqP2+ApMujYWdaq9/S9FE+dvTO27i+rS", + "Vs34SGqGdVLdurJxp0Rsu5VxKdpdKitP9yUf3QF61zKLba/29mpvLQhbC8IHkLf1BoP+loKuqv61x742", + "zeWcetJky+VU5fyDWpVWsP5r35L8+DrNskFbJeisSFt/3qcirYVchZVoOwwxFbOATV9R0uqUXj1mc3rB", + "sd5z5fZMslJx6J3Drty/V4/j4o5QsT6wJUgCkvNgv0lxQtvweOe/dOf33Z3v3/7P179MJqPJZGcyuU/O", + "3v4jfHTvr38Z9IAiFgrmiqJcL76jtq7wVrw0lzbjv7PUhtSlUDj3UriSoLLgM25YAbegBV3sw+AMBzlR", + "WhbMMVREXd/zX0tnll9CK3f8ohn1gZU7vdceQqmLlREdLj+0tWvnAXZsunMes2qV95QPP4RgSI9qRBbE", + "45qjbtDTBAuwYPVMDHm8ZpRkGBVp+1EU9SDI2+jVUvNv51VxHMNGfGKDLIBvFAsuwhIzBdVsIt6xViEg", + "qPLmqwCRMRE889WB+MLG02KfVCOdAWouzuVEcEX++ld2xRa5/utf7Uy2fqAqixspTyoXzCIdZx55oZRO", + "JRj5uVavbGVvomafvhaVbbxAEprrsoCKnktyEWnlh1A0Kk9Cmy58A4qaK3bBCnPvJoOk4JonNJsMsAZQ", + "DrHLupY1DVuMMb9V4+M4bapys5M5REcLS3xA6gPa4gsfmqGg35YvhRsNJfBnFo5/4H603QtdR0wYNDoM", + "8Mta0M7cMtGqGy98jV3a3T7WATR06Z8nr16SnOq5DU/oiM5Xis5qWzLG5sOVDBzRELrB/0DxPiaoOyzY", + "mDI2kPLEjdNq2OrQrL66ViSF+z4862oL3/a+PifBglZeI/diswZ4AC9t3a5buUWVIIQDGEGSFsIc+gph", + "5WfJ01b7wGitc/MmvhKsFcrkSzKnIs2w0iZ2twx6y7VvOPUTbYYrFajPufCVyRuFk9dAM3SK+SPXzC/g", + "cnQTat/B6HzxZoupWDe23jDw3AH2D/I1G81GZG939/9AB3yF1V1dxl3hXrzXQvUA5KHb0VX4XW1ehxn1", + "GPtsGvjMnEHx+ls4wODw2l0WcXjgPPQdc7JjFLHaRelXfIYJMzLML2lV6wsycapcEcdncIawVaXTVWyv", + "yl/xjV9bRfC0bHR+HIUNFDdHfpckg30WGvkujXjdqo5ge6vxGSzQbJTnfUEsZbDDq99eX2kwsRYnC1F4", + "Fv1QN7j3YcQwVwkWL3ZX2v/rTLArfYYdK4NLGh1yLVnjIfo16sGsKizYdXZt3hJ/sROwQK/pgguDwexp", + "jW73Jq+/jB5Kszvmj8PPvRVKte+HT6DwtDvcdZfBrr4P7X4TmK4aNjxneopargM7UlPEzjJ2vZN3Mx74", + "IToLIlezRCxjoYPy847r/DJiMr+U6McPd/ofuhE6Ebty/a/G6w91/dvEgE44nPt/NRRfXEWvFaW8ehDR", + "MKKhjfHVQ1df33UU8GF0YLvJc5KWYJZ29fkhG63q9mq/ZhyS16gg4zzHbBm8P8DksEUUzfNV0kOb4o4z", + "Ph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VR+Jk70FEs/j5mHbaOFxuyYv0uLtjWTmLuF7fpTNzo2MtPUL/QVe3sn5VzYL84TNdm47hXYy2n", + "cGfMHXB1Q9E0XSqwXbArbONOKgLku7hPBAbXNQfAywAKEZ4mJYJdVt+BXy33faZ7Vv1ci0yv7JDtRdon", + "VskwgNmjBxOHz/LA8il1jLPdEWDWasO7eEawhyPv9XPIF24hLEbZjWl+LIuJKJWNDWjv+1eqicHhtOsN", + "Yg4ZqkOI0ure+73pHXaztiR9w/Wz18fPIwx+OEBm6NPIsO/myl5O/WvIuutnhLi1X/aX/prRMz6E66i2", + "7o5SOsFZWEkV9ZbTZd4oNdY1QODT1WUhunZWlUnClOp6XHInJm2wLVa2iothqzBL2SSJVRjlPiInniug", + "FDBajVONMeGREYFGqwhy7LafRu+lvX0fmXEsNgrOje76CxeZW1+l+XkixtklXSryq2K6zH8FycG1E6+h", + "VVOYNY86N9eSgq69bZGMKF0zw+gyPxSaCd17KPgGrIlCd467lt6boXsR3+b1arANfNa5T1HB3Qntzo7d", + "Zll9WcAhtjNpLDY8nuYeI0gW61awjcBmbLnFY5kuOy92aGP2Qvu5TJfxGIQL9qyQiztf5elmmVMcET+/", + "St24GqtbRqSHx1QncyM0mZsBPjO5WFCRon3Gfe3kNVWqc/fxCLtkv2NLe7RGrP/1fj6niqn7f8B/f2LL", + "9/eBc97/w/zH/P0rOOLGaUoMotnqBlwoVmgroS2Mql/4ztN47ZwrD/OFXUd56LDtoPPSMw6gYKJjtpAX", + "LJyrwF/MF3YmbwOoMh6CCLB+CkJ4CZ+mXI/T1Hay2uw7hBc/fVsvWbq72xY28oyKtu3mHVvGQgbMWXEj", + "B9vYAXv9XF8D506tMjdqynegpD78ZlWKjM+P+cejs1/WZMSYi2TNsfaZYRYzoz01yKhZU/X+25gNqpPq", + "wi7V6jkHhK11SaKUNqQSEQZVMObsAb8cnrz6Zn/vb902B/N0xwFTMzr4hgoNa0M4fu2d6xgcntQP80Ht", + "LB9ELA4POiwOgRbdRL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A", + "rxGz4xscjcP+5Us0+AHevK/jy2Oq2Kndj4jHcE7N1bVFuKx2FNvKiEzy+VvNNFC8ow3bagb9NCMOYkvB", + "kRi6JixfkAFsirewS6uxj60zDck4Vw6lnMbSFNPHx/998PLJ059OT37+5vj42bN/Pfz+h2+fjX++QT+h", + "BeynmOPouoDbf+3Yb3fQg3MrbqSYrnTMaArs0VrSQHeqzGm3v8ktJPpkBjN7ArZ4lmOmHRJXZXB8x/zm", + "WeZvP65tnRMIdvZu63Rdt7N+exRQd18bO6LsuPZodYpeM3nB11+QeWtTUn7MDL2u90hu76QTHEKaHtnZ", + "TXKFfWvdAFlrNCoktGskQid1XAd/atJBP8ENZTIrFDUxayshbCWErYSwlRC2EsItSQjOHOiU0rdfsrfq", + "brFzy7FXcvWbY+dBR5HunAiIFUSjcYQht/jxzVDmiXiKhUWq9RHp/zpMsfAo7tvnS8avv8qPSPM/CfXc", + "iBTdwDUO++/Eb3TtJlOlZMLBmeHTL2tSamcr6BWXsnkbr2uBrY2zsTX2ul/HSEok8KtFU+q05EZtpDVY", + "rmEvbXy/oe20sZF97Kg/FLTLhQO5zJHUgkW31wefGVqDH5MTXzWIklwqrvlF6FWte5kqbivLc+gO4/2i", + "lZsIP96WuLsbShGbThlEZMdW8tQ9hMwRuHqAFgpCtKhI5hKD4wpHGe3zETly2aAXNCuZL/2aMG55Gdws", + "KInCRSovT/jvjHy94KLU7N4NJ6QE5KJLxLCidOhhAJ3Ely7HugBcNcn4BoLEWp2DXeUccyU2sJn4b1bK", + "lgh+NQEKmxyDmezMTI274hOgcU19GPaBbWvW7sZnqjfSq2OZZfKCFeOAztryO7vNs/nBXqeCkUJm5mqY", + "LwmF6gtMD5slk5aVo5qSlE8hTViTc5pRkWDNB2oDsC4t6i7JnBoCPpVWuISRRxPx2H5UVauCJwQK9fmG", + "C1Q9IvbNM8j9PTuGt/5OXhy+/PpFc7lD8mL876/dB49hVvxiSF5wUX/53r0eLKTFNm5UuKwuhxu2kTGB", + "QX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nJfiiCAoP0Lk4rfyCuihFApEZ1mm34KLUjKQlM7/M5SWZc6VlwROUYVlBQIo1aoCW", + "RURL/rA21A1neXuXnhgYFqB0Xs6ZnrOi2z8uwYQ54xdMDOGNgqcuACPQgr5SXpg4Z3N6wWUxmogdstYB", + "794KXO/Ba27qUdStXjBNuRh3EMGOVaJj3xI+SxwBrW2yuSwql3+tleLY9gxvLWvNiJEVdn6xat7IFsQq", + "RZ1QkZ7Lq3Gemy3ZtkjZepb62E2+lGbGGVeOz/W0PNDiHdN5RhP23H4bFy4W1YvEzoJBcVC9ggulaZax", + "lNA8N3fZWfFGrSVsDSSbGEg27aI7zvPOJrontQa65qASKQSKPtFz6tZvaZ5/pVDL5YpYmhvKRAp/iod4", + "fWn29T59X93NDNq8doaJnaC55bXwNtSjQp5nbBEWTulrJ2NXOUs0S5tDdDRZNlIJcGNbCyRbklLAPTDC", + "HBVp5pSo30qmtBPzKNhtZUGLJQgwmaQgS1QdjhfUiP+CioQNrXAKcbIZf8eypa1nyC44BvlCOKaSC2bY", + "FV2OYkH7J7LQ0AMwjqMS2gN64T7EzvHJwWA4ePL05CCKoCe64DmzIkSTKVSkDl+DixQJOauJG6tw0/Ce", + "1awjoOoJzek5zziKNL/80briABKYqWiWlFjIQdMrqIwZcFNbBxQoFXj0Yfk5O/OfnWl65dD60eDA/WzG", + "rg7Dv21+fT/sAMdN5m30Cm0FBndshHYTDPvJmf+iAuXQljA9CB75OF14VD3pBMlWw1MkkVnGEq2ILLXS", + "VIB0X7ALJkqbNmC/cJAEor4rqbdgei7T9lbi0GdurmA38Qk5qp64DcUn/kGMits91a4Etq0/u5SluYl2", + "hGqFwSKgDlIixesiGzwa3OcLOmPqPoI7yoE6WQjx/Trlw5i4jF+whUy9ybn5geNYQF6xrTXcpgT6Hxwa", + "ZKdJos/29h988+3Dv333fWuSGofovjnvtx0Qt+L9Vry/e+J9RSGae/7cPhmC+cBlQdkxOVTCTsvE1/WP", + "mz222sPnoT206H5MSHMyFL5F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c2TXgk2gneUFh0wB+Gz62UJmwHeJqyUl7159Vvxgl+CWVN", + "6XqWO5AU8a+5yEarnmOWX8OzzE0aFk631/0hO0OiD6IPOowj4UvCd1r4tj/ZUSrmxwviZVHL/JusO4K4", + "irUG+tOSaKlDFovRE2efsMzrxr00xeCJtyxjSb6SfCX5SvKV5CvJ15nytS2VsTxJXNJzMZqtqT/EdG7+", + "lYXuheRs790hey1G0wK3JJP20nTv3eFrMfL5rLzfreQlxxl54dICEY0S9npnAWnmKm8limYOZdRaRUB7", + "z8WoWAm9ZXs2afjifkNtfXilNR2aIzDGVIAOPhQlpUKouJvzfshCWBm3phtRjSUEnqNKwyStGH5jWKmI", + "Vl2UkBLh/Bm64GORTqNd+I0deK/2leyl6XNu6FYi0QzRDNEM0QzRzBI0o92nsDNTeVCCGZ6mADFHe7kd", + "tM7UMdw0M4yz98e/wGIMMcTcYEESttPqsF6iL+fiDiTd8cW8Evb98S/3RdGwD4JnL00huNoqyzWJZxLP", + "JJ5JPJN4JvHsxGO7+CBmCuq94pNBicoiHYvWmfpNZLInhSnJZfcL3qq/igZc9QXcxYGr88zqc7cMKbfC", + "9jJhBvhkaQleVGNltQVmE96HkvZ1LOB+x4mTh8a8c6lNC6yKlznCXz5L1yU3zRFXEMwPJsLaM/xnecjX", + "nnmeyWUyXTjyNXqmEmA9weWtOnmPRSwzEfl2EfAQ8BDwEPAQ8Nw34PEwMM9YENPMsAYUPjDW5mNiQ1EU", + "oZIkGUkykmQkyR62JPNyp0aWtT/B38P4CIIiLTTCEz7e4+EL6NIk79cb34H0WUYNXil+rj58yK9+Eapv", + "B43d775tNoZShX9uu4Ks+6Iau43//pNv/d3ZevbxPx/91+4/i388/n/+4//97z87W99//LOz9Wxv66ef", + "X795+27r9LetD3xr8K/zoUq37MXW3x8/7Tz9/B81J+YbtehDYU3CmYQzCWe6okdX9IhOiE5q6KSNvkNn", + "MQpcdPOM4r4wcMXUYvWPp7AFkt1DcFlCI+7+4C1B9w02VnvF6hVf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MpwMZwQ8nOrOwwB8CXPWkyB63wCj/FjdI", + "1x2B4gh/chD8D6GL//HT99//8I/nnaff/XzS+eGHd/t/nOI4VNOdbB9vv3r28re33+0cv9p5svfszXc/", + "zxqK8Tr+IEbjq7w/AWJqLbcnZud0m3cnoBZ0c4K20LSFJnNL2kHSzYmpmxMibMzWsXlsf4K/3spyWdMD", + "eGdJwwMQaEtp7X1N5ursv5RZALaCpDBJYZLCpMgmRTZhyAM3ChBerN8MQrI8EasqsOGdxfrrY8j6Jm45", + "oKC77pNjyUZ8EYccK6q627es516vBu9M7bFzMXLrEWc5vooYWxBWbhCuJL42wgu0CAOu2adHL4528YYN", + "5DJep4xOclyzNTN5murMsq62Awa15ipmr13RCtY7w4eCmVREIOQiHYu+UO6D+rK+4q6rAMbpzqPqha7Z", + "2uC94w9P3r54+fr05Ldvj48PDn797tmrpwd7v9Vog3f+ePqPb9++ffXryZOd/YMftn9/9vTlk2tpg++q", + "etWtomvRrs7M6DaVq64SpFulXR3t6ki3Spsa0q1O6VYzv2nYlEsal/8y/miO8ZB/0wbDrpivxhMNtJnc", + "0JDsJtlNsptkN8nua7ih8cZxa1BKtj+5P9f1PgNmgfNdz6Dl4Dr8znhYWHzAii0ijzOEAIQAdChLh7LE", + "QMRA98/jzEoMtLy7mRLSLDL5uk9A0vk6dB2kuyBwIXAhcCFwIXC5h9ZkKzLL0v5l6s9bpp3L3HFi+SpP", + "iYiciJyInIiciJyInIicNupQZgPHXm0r0LSl3sTl1A3UDA2RESp2s9INoLH+suCltAOWcRXrIYu55dNU", + "5rK8r1qk7a/kUiKZzBA8ETwRPBE8ETw9tGDh16OiS9EdaH3eNhfyajYO7fMk6fLonAkVp1oqi3e5uiN2", + "ciGv3IBApiPGuzq3rAAfnsz0x3csQFC594/GyYM3hU3ofCaK+h1bvpLOh8x3CEcIR8iCl6QxSeNFqgwv", + "4FBCTkvE6+gz0oSrJdwJQLJ6DwLvIIcVvQZAfl+/owC8Pu2gxFW45RZQazPZza2YcaVZxg/Z02jRU+di", + "tLCrzsVomb66kQ+AdVzRX1d3KJz2LTfm7rMs+sfM7qDfMG2ln3iMooEn7zL3OVopyhfm3arYh9vm4YlG", + "p75uKbEjmDKxEOlRePoV3aN3a8m1787PfHnT9+VdwXRHniidKJ0onSid7sg7aE49FQcgdzLimtfhARpm", + "3IB32W5It+WyxkJu+4o7NIrO6EjckrglcUvilsTtctfaU5SF8yXupOqr/cn9OYyPstdi9LmtxNUcE56K", + "WI4z3rMsbOZh/oGkPlOH7quzeaaMr7rsudHEMx2eZILHI19fJpXPSGcMa8JiLXDtykRPZEJFOBcSDrZB", + "ad5NpBmIOBQ9jQZvxeULl6eHg8XmQKUumGsTxNXoqFej3btz6qw7oGP62GxcbfX11pTqqe7pR6IxojGi", + "MbKYIospwlHC0S+Jo28LNLwRjy7tRAkocnxAWXaehIB5XX9JK9Ij+UgigiGCIYIhgiGCIYK5Bz6SlsKX", + "uc6QAprI2EerbrHTOYosBgLX5plyM7Dn0lkc1NyIehdK62QUUm7dGeVW58spt0hZRahHqEeoR6hHqHc/", + "vEotyXnzHEiNQW+W56g7rkzajHUVds1tu4Yi5CHkIeQh5CHkIeR5yO6gbnY8104H3CwTiBnTMalm2HGH", + "K5TvML87yUjzrr+5Zj3A64Bfz5U6mFfXv1Q3+/VbuVbniqe7dYSvhK9k7E/0Rnfr4G5dBalueskOrti5", + "HGcz2viu3V2mtA1qsqBbvtxlQSiebNQJIggiCCIIIggilroxOCX4b6wNwn+DNHotRnNNuIORVQU8yrbb", + "+MNNjLfvuEZpRjVD786t7AaUPGRVTsxBzEHnbnTuRtBF0HV9q3Lgmp73dnAT+/IFOhtvHU4QtGEI6nxh", + "TQ5pZoiSiJKIkoiSiJLuiUH2qog01zR7PiWNrbMJlNYPShs8bPtytuOEaIRohGiEaIRohGgP2IB8bSeH", + "6AZhttPRd5hgrjNwn4ZcNtHhGjEJMQkxCTEJMckDYpLACDdkkVwtpJH3IclcHilSEZEQkRCREJEQkRCR", + "EJE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UwwYA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/api/openapi.yaml b/api/openapi.yaml index 46d8aea28..c82883bb0 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -12354,6 +12354,7 @@ components: type: string enum: - key + - start_after description: Order by options for plan phases. Plan: type: object @@ -12450,9 +12451,10 @@ components: description: |- The status of the plan. Computed based on the effective start and end dates: - - draft = no effectiveStartDate - - active = effectiveStartDate <= now < effectiveEndDate - - archived / inactive = effectiveEndDate <= now + - draft = no effectiveFrom + - active = effectiveFrom <= now < effectiveTo + - archived / inactive = effectiveTo <= now + - scheduled = now < effectiveFrom < effectiveTo title: Status readOnly: true phases: @@ -12529,6 +12531,9 @@ components: enum: - id - key + - version + - create_at + - updated_at description: Order by options for plans. PlanPaginatedResponse: type: object @@ -12621,13 +12626,13 @@ components: nullable: true example: P1Y1D description: The time after which the plan starts compared to subscription start - title: Duration + title: Start after discounts: type: array items: $ref: '#/components/schemas/AppliedDiscount' description: The discounts on the plan. - title: Discount + title: Discounts description: The plan phase or pricing ramp allows changing a plan's rate cards over time as a subscription progresses. PlanPhaseCreate: type: object @@ -12671,13 +12676,13 @@ components: nullable: true example: P1Y1D description: The time after which the plan starts compared to subscription start - title: Duration + title: Start after discounts: type: array items: $ref: '#/components/schemas/AppliedDiscount' description: The discounts on the plan. - title: Discount + title: Discounts description: Resource create operation model. PlanPhasePaginatedResponse: type: object @@ -12742,13 +12747,13 @@ components: nullable: true example: P1Y1D description: The time after which the plan starts compared to subscription start - title: Duration + title: Start after discounts: type: array items: $ref: '#/components/schemas/AppliedDiscount' description: The discounts on the plan. - title: Discount + title: Discounts description: Resource create or update operation model. PlanReference: type: object @@ -12765,13 +12770,14 @@ components: version: type: integer description: The plan version. - description: Referebces an exact plan. + description: References an exact plan. PlanStatus: type: string enum: - draft - active - archived + - scheduled description: The status of a plan. PlanUpdate: type: object @@ -13168,7 +13174,9 @@ components: type: string format: duration nullable: true - description: The billing cadence of the rate card. + description: |- + The billing cadence of the rate card. + When null it means it is a one time fee. title: Billing cadence price: type: object @@ -13236,7 +13244,9 @@ components: type: string format: duration nullable: true - description: The billing cadence of the rate card. + description: |- + The billing cadence of the rate card. + When null it means it is a one time fee. title: Billing cadence price: type: object @@ -13484,9 +13494,7 @@ components: billingCadence: type: string format: duration - description: |- - The billing cadence of the rate card. - When null, the rate card is a one-time purchase. + description: The billing cadence of the rate card. title: Billing cadence price: anyOf: @@ -13562,9 +13570,7 @@ components: billingCadence: type: string format: duration - description: |- - The billing cadence of the rate card. - When null, the rate card is a one-time purchase. + description: The billing cadence of the rate card. title: Billing cadence price: anyOf: diff --git a/api/spec/src/productcatalog/plan.tsp b/api/spec/src/productcatalog/plan.tsp index c85610948..75e73fd24 100644 --- a/api/spec/src/productcatalog/plan.tsp +++ b/api/spec/src/productcatalog/plan.tsp @@ -15,10 +15,11 @@ enum PlanStatus { draft: "draft", active: "active", archived: "archived", + scheduled: "scheduled", } /** - * Referebces an exact plan. + * References an exact plan. */ @friendlyName("PlanReference") model PlanReference { @@ -69,9 +70,10 @@ model Plan { /** * The status of the plan. * Computed based on the effective start and end dates: - * - draft = no effectiveStartDate - * - active = effectiveStartDate <= now < effectiveEndDate - * - archived / inactive = effectiveEndDate <= now + * - draft = no effectiveFrom + * - active = effectiveFrom <= now < effectiveTo + * - archived / inactive = effectiveTo <= now + * - scheduled = now < effectiveFrom < effectiveTo */ @summary("Status") @visibility("read") @@ -107,7 +109,7 @@ model PlanPhase { /** * The time after which the plan starts compared to subscription start */ - @summary("Duration") + @summary("Start after") @encode(DurationKnownEncoding.ISO8601) @example(duration.fromISO("P1Y1D")) startAfter: duration | null; @@ -115,7 +117,7 @@ model PlanPhase { /** * The discounts on the plan. */ - @summary("Discount") + @summary("Discounts") discounts?: AppliedDiscount[]; // /** @@ -193,6 +195,9 @@ model PlanVariantOverridePreset { enum PlanOrderBy { id: "id", key: "key", + version: "version", + createdAt: "create_at", + updatedAt: "updated_at", } /** @@ -201,4 +206,5 @@ enum PlanOrderBy { @friendlyName("PhasesOrderBy") enum PhasesOrderBy { key: "key", + startAfter: "start_after", } diff --git a/api/spec/src/productcatalog/ratecards.tsp b/api/spec/src/productcatalog/ratecards.tsp index b3b36ea27..56a48a65c 100644 --- a/api/spec/src/productcatalog/ratecards.tsp +++ b/api/spec/src/productcatalog/ratecards.tsp @@ -70,6 +70,7 @@ model RateCardFlatFee { /** * The billing cadence of the rate card. + * When null it means it is a one time fee. */ @visibility("read", "create", "update") @summary("Billing cadence") @@ -103,7 +104,6 @@ model RateCardUsageBased { /** * The billing cadence of the rate card. - * When null, the rate card is a one-time purchase. */ @visibility("read", "create", "update") @summary("Billing cadence") From a71553c246acde7d9e350a49413eacdf7c2f2fa7 Mon Sep 17 00:00:00 2001 From: Krisztian Gacsal Date: Tue, 5 Nov 2024 16:20:56 +0100 Subject: [PATCH 2/2] feat: add db schema and types for Plan API --- openmeter/ent/db/client.go | 529 ++- openmeter/ent/db/ent.go | 7 + openmeter/ent/db/expose.go | 6 + openmeter/ent/db/feature.go | 18 +- openmeter/ent/db/feature/feature.go | 30 + openmeter/ent/db/feature/where.go | 23 + openmeter/ent/db/feature_create.go | 32 + openmeter/ent/db/feature_query.go | 79 +- openmeter/ent/db/feature_update.go | 163 + openmeter/ent/db/hook/hook.go | 36 + openmeter/ent/db/migrate/schema.go | 188 + openmeter/ent/db/mutation.go | 3768 ++++++++++++++++- openmeter/ent/db/paginate.go | 144 + openmeter/ent/db/plan.go | 270 ++ openmeter/ent/db/plan/plan.go | 184 + openmeter/ent/db/plan/where.go | 774 ++++ openmeter/ent/db/plan_create.go | 1180 ++++++ openmeter/ent/db/plan_delete.go | 89 + openmeter/ent/db/plan_query.go | 643 +++ openmeter/ent/db/plan_update.go | 733 ++++ openmeter/ent/db/planphase.go | 274 ++ openmeter/ent/db/planphase/planphase.go | 204 + openmeter/ent/db/planphase/where.go | 743 ++++ openmeter/ent/db/planphase_create.go | 1137 +++++ openmeter/ent/db/planphase_delete.go | 88 + openmeter/ent/db/planphase_query.go | 718 ++++ openmeter/ent/db/planphase_update.go | 770 ++++ openmeter/ent/db/planratecard.go | 351 ++ openmeter/ent/db/planratecard/planratecard.go | 247 ++ openmeter/ent/db/planratecard/where.go | 964 +++++ openmeter/ent/db/planratecard_create.go | 1494 +++++++ openmeter/ent/db/planratecard_delete.go | 88 + openmeter/ent/db/planratecard_query.go | 721 ++++ openmeter/ent/db/planratecard_update.go | 944 +++++ openmeter/ent/db/predicate/predicate.go | 31 + openmeter/ent/db/runtime.go | 120 + openmeter/ent/db/setorclear.go | 253 ++ openmeter/ent/db/tx.go | 9 + openmeter/ent/schema/feature.go | 1 + openmeter/ent/schema/productcatalog.go | 196 + openmeter/productcatalog/plan/discount.go | 154 + openmeter/productcatalog/plan/entitlement.go | 230 + openmeter/productcatalog/plan/phase.go | 99 + openmeter/productcatalog/plan/phase_test.go | 60 + openmeter/productcatalog/plan/plan.go | 146 + openmeter/productcatalog/plan/plan_test.go | 91 + openmeter/productcatalog/plan/price.go | 439 ++ openmeter/productcatalog/plan/price_test.go | 362 ++ openmeter/productcatalog/plan/ratecard.go | 348 ++ .../productcatalog/plan/ratecard_test.go | 339 ++ openmeter/productcatalog/plan/tax.go | 45 + openmeter/productcatalog/plan/tax_test.go | 36 + openmeter/productcatalog/plan/utils.go | 24 + openmeter/productcatalog/plan/utils_test.go | 81 + openmeter/productcatalog/plan/validator.go | 6 + pkg/framework/entutils/valuescanner.go | 30 + .../migrations/20241105171821_plan.down.sql | 40 + .../migrations/20241105171821_plan.up.sql | 91 + tools/migrate/migrations/atlas.sum | 4 +- 59 files changed, 20864 insertions(+), 10 deletions(-) create mode 100644 openmeter/ent/db/plan.go create mode 100644 openmeter/ent/db/plan/plan.go create mode 100644 openmeter/ent/db/plan/where.go create mode 100644 openmeter/ent/db/plan_create.go create mode 100644 openmeter/ent/db/plan_delete.go create mode 100644 openmeter/ent/db/plan_query.go create mode 100644 openmeter/ent/db/plan_update.go create mode 100644 openmeter/ent/db/planphase.go create mode 100644 openmeter/ent/db/planphase/planphase.go create mode 100644 openmeter/ent/db/planphase/where.go create mode 100644 openmeter/ent/db/planphase_create.go create mode 100644 openmeter/ent/db/planphase_delete.go create mode 100644 openmeter/ent/db/planphase_query.go create mode 100644 openmeter/ent/db/planphase_update.go create mode 100644 openmeter/ent/db/planratecard.go create mode 100644 openmeter/ent/db/planratecard/planratecard.go create mode 100644 openmeter/ent/db/planratecard/where.go create mode 100644 openmeter/ent/db/planratecard_create.go create mode 100644 openmeter/ent/db/planratecard_delete.go create mode 100644 openmeter/ent/db/planratecard_query.go create mode 100644 openmeter/ent/db/planratecard_update.go create mode 100644 openmeter/ent/schema/productcatalog.go create mode 100644 openmeter/productcatalog/plan/discount.go create mode 100644 openmeter/productcatalog/plan/entitlement.go create mode 100644 openmeter/productcatalog/plan/phase.go create mode 100644 openmeter/productcatalog/plan/phase_test.go create mode 100644 openmeter/productcatalog/plan/plan.go create mode 100644 openmeter/productcatalog/plan/plan_test.go create mode 100644 openmeter/productcatalog/plan/price.go create mode 100644 openmeter/productcatalog/plan/price_test.go create mode 100644 openmeter/productcatalog/plan/ratecard.go create mode 100644 openmeter/productcatalog/plan/ratecard_test.go create mode 100644 openmeter/productcatalog/plan/tax.go create mode 100644 openmeter/productcatalog/plan/tax_test.go create mode 100644 openmeter/productcatalog/plan/utils.go create mode 100644 openmeter/productcatalog/plan/utils_test.go create mode 100644 openmeter/productcatalog/plan/validator.go create mode 100644 pkg/framework/entutils/valuescanner.go create mode 100644 tools/migrate/migrations/20241105171821_plan.down.sql create mode 100644 tools/migrate/migrations/20241105171821_plan.up.sql diff --git a/openmeter/ent/db/client.go b/openmeter/ent/db/client.go index 13e0b702f..aa0274b37 100644 --- a/openmeter/ent/db/client.go +++ b/openmeter/ent/db/client.go @@ -36,6 +36,9 @@ import ( "github.com/openmeterio/openmeter/openmeter/ent/db/notificationevent" "github.com/openmeterio/openmeter/openmeter/ent/db/notificationeventdeliverystatus" "github.com/openmeterio/openmeter/openmeter/ent/db/notificationrule" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" "github.com/openmeterio/openmeter/openmeter/ent/db/usagereset" stdsql "database/sql" @@ -88,6 +91,12 @@ type Client struct { NotificationEventDeliveryStatus *NotificationEventDeliveryStatusClient // NotificationRule is the client for interacting with the NotificationRule builders. NotificationRule *NotificationRuleClient + // Plan is the client for interacting with the Plan builders. + Plan *PlanClient + // PlanPhase is the client for interacting with the PlanPhase builders. + PlanPhase *PlanPhaseClient + // PlanRateCard is the client for interacting with the PlanRateCard builders. + PlanRateCard *PlanRateCardClient // UsageReset is the client for interacting with the UsageReset builders. UsageReset *UsageResetClient } @@ -122,6 +131,9 @@ func (c *Client) init() { c.NotificationEvent = NewNotificationEventClient(c.config) c.NotificationEventDeliveryStatus = NewNotificationEventDeliveryStatusClient(c.config) c.NotificationRule = NewNotificationRuleClient(c.config) + c.Plan = NewPlanClient(c.config) + c.PlanPhase = NewPlanPhaseClient(c.config) + c.PlanRateCard = NewPlanRateCardClient(c.config) c.UsageReset = NewUsageResetClient(c.config) } @@ -236,6 +248,9 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { NotificationEvent: NewNotificationEventClient(cfg), NotificationEventDeliveryStatus: NewNotificationEventDeliveryStatusClient(cfg), NotificationRule: NewNotificationRuleClient(cfg), + Plan: NewPlanClient(cfg), + PlanPhase: NewPlanPhaseClient(cfg), + PlanRateCard: NewPlanRateCardClient(cfg), UsageReset: NewUsageResetClient(cfg), }, nil } @@ -277,6 +292,9 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) NotificationEvent: NewNotificationEventClient(cfg), NotificationEventDeliveryStatus: NewNotificationEventDeliveryStatusClient(cfg), NotificationRule: NewNotificationRuleClient(cfg), + Plan: NewPlanClient(cfg), + PlanPhase: NewPlanPhaseClient(cfg), + PlanRateCard: NewPlanRateCardClient(cfg), UsageReset: NewUsageResetClient(cfg), }, nil } @@ -312,7 +330,8 @@ func (c *Client) Use(hooks ...Hook) { c.BillingInvoiceManualLineConfig, c.BillingInvoiceValidationIssue, c.BillingProfile, c.BillingWorkflowConfig, c.Customer, c.CustomerSubjects, c.Entitlement, c.Feature, c.Grant, c.NotificationChannel, c.NotificationEvent, - c.NotificationEventDeliveryStatus, c.NotificationRule, c.UsageReset, + c.NotificationEventDeliveryStatus, c.NotificationRule, c.Plan, c.PlanPhase, + c.PlanRateCard, c.UsageReset, } { n.Use(hooks...) } @@ -327,7 +346,8 @@ func (c *Client) Intercept(interceptors ...Interceptor) { c.BillingInvoiceManualLineConfig, c.BillingInvoiceValidationIssue, c.BillingProfile, c.BillingWorkflowConfig, c.Customer, c.CustomerSubjects, c.Entitlement, c.Feature, c.Grant, c.NotificationChannel, c.NotificationEvent, - c.NotificationEventDeliveryStatus, c.NotificationRule, c.UsageReset, + c.NotificationEventDeliveryStatus, c.NotificationRule, c.Plan, c.PlanPhase, + c.PlanRateCard, c.UsageReset, } { n.Intercept(interceptors...) } @@ -378,6 +398,12 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.NotificationEventDeliveryStatus.mutate(ctx, m) case *NotificationRuleMutation: return c.NotificationRule.mutate(ctx, m) + case *PlanMutation: + return c.Plan.mutate(ctx, m) + case *PlanPhaseMutation: + return c.PlanPhase.mutate(ctx, m) + case *PlanRateCardMutation: + return c.PlanRateCard.mutate(ctx, m) case *UsageResetMutation: return c.UsageReset.mutate(ctx, m) default: @@ -3208,6 +3234,22 @@ func (c *FeatureClient) QueryEntitlement(f *Feature) *EntitlementQuery { return query } +// QueryRatecard queries the ratecard edge of a Feature. +func (c *FeatureClient) QueryRatecard(f *Feature) *PlanRateCardQuery { + query := (&PlanRateCardClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := f.ID + step := sqlgraph.NewStep( + sqlgraph.From(feature.Table, feature.FieldID, id), + sqlgraph.To(planratecard.Table, planratecard.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, feature.RatecardTable, feature.RatecardColumn), + ) + fromV = sqlgraph.Neighbors(f.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *FeatureClient) Hooks() []Hook { return c.hooks.Feature @@ -4010,6 +4052,485 @@ func (c *NotificationRuleClient) mutate(ctx context.Context, m *NotificationRule } } +// PlanClient is a client for the Plan schema. +type PlanClient struct { + config +} + +// NewPlanClient returns a client for the Plan from the given config. +func NewPlanClient(c config) *PlanClient { + return &PlanClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `dbplan.Hooks(f(g(h())))`. +func (c *PlanClient) Use(hooks ...Hook) { + c.hooks.Plan = append(c.hooks.Plan, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `dbplan.Intercept(f(g(h())))`. +func (c *PlanClient) Intercept(interceptors ...Interceptor) { + c.inters.Plan = append(c.inters.Plan, interceptors...) +} + +// Create returns a builder for creating a Plan entity. +func (c *PlanClient) Create() *PlanCreate { + mutation := newPlanMutation(c.config, OpCreate) + return &PlanCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Plan entities. +func (c *PlanClient) CreateBulk(builders ...*PlanCreate) *PlanCreateBulk { + return &PlanCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PlanClient) MapCreateBulk(slice any, setFunc func(*PlanCreate, int)) *PlanCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PlanCreateBulk{err: fmt.Errorf("calling to PlanClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PlanCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PlanCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Plan. +func (c *PlanClient) Update() *PlanUpdate { + mutation := newPlanMutation(c.config, OpUpdate) + return &PlanUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PlanClient) UpdateOne(pl *Plan) *PlanUpdateOne { + mutation := newPlanMutation(c.config, OpUpdateOne, withPlan(pl)) + return &PlanUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PlanClient) UpdateOneID(id string) *PlanUpdateOne { + mutation := newPlanMutation(c.config, OpUpdateOne, withPlanID(id)) + return &PlanUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Plan. +func (c *PlanClient) Delete() *PlanDelete { + mutation := newPlanMutation(c.config, OpDelete) + return &PlanDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PlanClient) DeleteOne(pl *Plan) *PlanDeleteOne { + return c.DeleteOneID(pl.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PlanClient) DeleteOneID(id string) *PlanDeleteOne { + builder := c.Delete().Where(dbplan.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PlanDeleteOne{builder} +} + +// Query returns a query builder for Plan. +func (c *PlanClient) Query() *PlanQuery { + return &PlanQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePlan}, + inters: c.Interceptors(), + } +} + +// Get returns a Plan entity by its id. +func (c *PlanClient) Get(ctx context.Context, id string) (*Plan, error) { + return c.Query().Where(dbplan.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PlanClient) GetX(ctx context.Context, id string) *Plan { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryPhases queries the phases edge of a Plan. +func (c *PlanClient) QueryPhases(pl *Plan) *PlanPhaseQuery { + query := (&PlanPhaseClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := pl.ID + step := sqlgraph.NewStep( + sqlgraph.From(dbplan.Table, dbplan.FieldID, id), + sqlgraph.To(planphase.Table, planphase.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, dbplan.PhasesTable, dbplan.PhasesColumn), + ) + fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PlanClient) Hooks() []Hook { + return c.hooks.Plan +} + +// Interceptors returns the client interceptors. +func (c *PlanClient) Interceptors() []Interceptor { + return c.inters.Plan +} + +func (c *PlanClient) mutate(ctx context.Context, m *PlanMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PlanCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PlanUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PlanUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PlanDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown Plan mutation op: %q", m.Op()) + } +} + +// PlanPhaseClient is a client for the PlanPhase schema. +type PlanPhaseClient struct { + config +} + +// NewPlanPhaseClient returns a client for the PlanPhase from the given config. +func NewPlanPhaseClient(c config) *PlanPhaseClient { + return &PlanPhaseClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `planphase.Hooks(f(g(h())))`. +func (c *PlanPhaseClient) Use(hooks ...Hook) { + c.hooks.PlanPhase = append(c.hooks.PlanPhase, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `planphase.Intercept(f(g(h())))`. +func (c *PlanPhaseClient) Intercept(interceptors ...Interceptor) { + c.inters.PlanPhase = append(c.inters.PlanPhase, interceptors...) +} + +// Create returns a builder for creating a PlanPhase entity. +func (c *PlanPhaseClient) Create() *PlanPhaseCreate { + mutation := newPlanPhaseMutation(c.config, OpCreate) + return &PlanPhaseCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of PlanPhase entities. +func (c *PlanPhaseClient) CreateBulk(builders ...*PlanPhaseCreate) *PlanPhaseCreateBulk { + return &PlanPhaseCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PlanPhaseClient) MapCreateBulk(slice any, setFunc func(*PlanPhaseCreate, int)) *PlanPhaseCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PlanPhaseCreateBulk{err: fmt.Errorf("calling to PlanPhaseClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PlanPhaseCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PlanPhaseCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for PlanPhase. +func (c *PlanPhaseClient) Update() *PlanPhaseUpdate { + mutation := newPlanPhaseMutation(c.config, OpUpdate) + return &PlanPhaseUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PlanPhaseClient) UpdateOne(pp *PlanPhase) *PlanPhaseUpdateOne { + mutation := newPlanPhaseMutation(c.config, OpUpdateOne, withPlanPhase(pp)) + return &PlanPhaseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PlanPhaseClient) UpdateOneID(id string) *PlanPhaseUpdateOne { + mutation := newPlanPhaseMutation(c.config, OpUpdateOne, withPlanPhaseID(id)) + return &PlanPhaseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for PlanPhase. +func (c *PlanPhaseClient) Delete() *PlanPhaseDelete { + mutation := newPlanPhaseMutation(c.config, OpDelete) + return &PlanPhaseDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PlanPhaseClient) DeleteOne(pp *PlanPhase) *PlanPhaseDeleteOne { + return c.DeleteOneID(pp.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PlanPhaseClient) DeleteOneID(id string) *PlanPhaseDeleteOne { + builder := c.Delete().Where(planphase.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PlanPhaseDeleteOne{builder} +} + +// Query returns a query builder for PlanPhase. +func (c *PlanPhaseClient) Query() *PlanPhaseQuery { + return &PlanPhaseQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePlanPhase}, + inters: c.Interceptors(), + } +} + +// Get returns a PlanPhase entity by its id. +func (c *PlanPhaseClient) Get(ctx context.Context, id string) (*PlanPhase, error) { + return c.Query().Where(planphase.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PlanPhaseClient) GetX(ctx context.Context, id string) *PlanPhase { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryPlan queries the plan edge of a PlanPhase. +func (c *PlanPhaseClient) QueryPlan(pp *PlanPhase) *PlanQuery { + query := (&PlanClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := pp.ID + step := sqlgraph.NewStep( + sqlgraph.From(planphase.Table, planphase.FieldID, id), + sqlgraph.To(dbplan.Table, dbplan.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, planphase.PlanTable, planphase.PlanColumn), + ) + fromV = sqlgraph.Neighbors(pp.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryRatecards queries the ratecards edge of a PlanPhase. +func (c *PlanPhaseClient) QueryRatecards(pp *PlanPhase) *PlanRateCardQuery { + query := (&PlanRateCardClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := pp.ID + step := sqlgraph.NewStep( + sqlgraph.From(planphase.Table, planphase.FieldID, id), + sqlgraph.To(planratecard.Table, planratecard.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, planphase.RatecardsTable, planphase.RatecardsColumn), + ) + fromV = sqlgraph.Neighbors(pp.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PlanPhaseClient) Hooks() []Hook { + return c.hooks.PlanPhase +} + +// Interceptors returns the client interceptors. +func (c *PlanPhaseClient) Interceptors() []Interceptor { + return c.inters.PlanPhase +} + +func (c *PlanPhaseClient) mutate(ctx context.Context, m *PlanPhaseMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PlanPhaseCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PlanPhaseUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PlanPhaseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PlanPhaseDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown PlanPhase mutation op: %q", m.Op()) + } +} + +// PlanRateCardClient is a client for the PlanRateCard schema. +type PlanRateCardClient struct { + config +} + +// NewPlanRateCardClient returns a client for the PlanRateCard from the given config. +func NewPlanRateCardClient(c config) *PlanRateCardClient { + return &PlanRateCardClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `planratecard.Hooks(f(g(h())))`. +func (c *PlanRateCardClient) Use(hooks ...Hook) { + c.hooks.PlanRateCard = append(c.hooks.PlanRateCard, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `planratecard.Intercept(f(g(h())))`. +func (c *PlanRateCardClient) Intercept(interceptors ...Interceptor) { + c.inters.PlanRateCard = append(c.inters.PlanRateCard, interceptors...) +} + +// Create returns a builder for creating a PlanRateCard entity. +func (c *PlanRateCardClient) Create() *PlanRateCardCreate { + mutation := newPlanRateCardMutation(c.config, OpCreate) + return &PlanRateCardCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of PlanRateCard entities. +func (c *PlanRateCardClient) CreateBulk(builders ...*PlanRateCardCreate) *PlanRateCardCreateBulk { + return &PlanRateCardCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PlanRateCardClient) MapCreateBulk(slice any, setFunc func(*PlanRateCardCreate, int)) *PlanRateCardCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PlanRateCardCreateBulk{err: fmt.Errorf("calling to PlanRateCardClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PlanRateCardCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PlanRateCardCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for PlanRateCard. +func (c *PlanRateCardClient) Update() *PlanRateCardUpdate { + mutation := newPlanRateCardMutation(c.config, OpUpdate) + return &PlanRateCardUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PlanRateCardClient) UpdateOne(prc *PlanRateCard) *PlanRateCardUpdateOne { + mutation := newPlanRateCardMutation(c.config, OpUpdateOne, withPlanRateCard(prc)) + return &PlanRateCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PlanRateCardClient) UpdateOneID(id string) *PlanRateCardUpdateOne { + mutation := newPlanRateCardMutation(c.config, OpUpdateOne, withPlanRateCardID(id)) + return &PlanRateCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for PlanRateCard. +func (c *PlanRateCardClient) Delete() *PlanRateCardDelete { + mutation := newPlanRateCardMutation(c.config, OpDelete) + return &PlanRateCardDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PlanRateCardClient) DeleteOne(prc *PlanRateCard) *PlanRateCardDeleteOne { + return c.DeleteOneID(prc.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PlanRateCardClient) DeleteOneID(id string) *PlanRateCardDeleteOne { + builder := c.Delete().Where(planratecard.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PlanRateCardDeleteOne{builder} +} + +// Query returns a query builder for PlanRateCard. +func (c *PlanRateCardClient) Query() *PlanRateCardQuery { + return &PlanRateCardQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePlanRateCard}, + inters: c.Interceptors(), + } +} + +// Get returns a PlanRateCard entity by its id. +func (c *PlanRateCardClient) Get(ctx context.Context, id string) (*PlanRateCard, error) { + return c.Query().Where(planratecard.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PlanRateCardClient) GetX(ctx context.Context, id string) *PlanRateCard { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryPhase queries the phase edge of a PlanRateCard. +func (c *PlanRateCardClient) QueryPhase(prc *PlanRateCard) *PlanPhaseQuery { + query := (&PlanPhaseClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := prc.ID + step := sqlgraph.NewStep( + sqlgraph.From(planratecard.Table, planratecard.FieldID, id), + sqlgraph.To(planphase.Table, planphase.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, planratecard.PhaseTable, planratecard.PhaseColumn), + ) + fromV = sqlgraph.Neighbors(prc.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryFeatures queries the features edge of a PlanRateCard. +func (c *PlanRateCardClient) QueryFeatures(prc *PlanRateCard) *FeatureQuery { + query := (&FeatureClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := prc.ID + step := sqlgraph.NewStep( + sqlgraph.From(planratecard.Table, planratecard.FieldID, id), + sqlgraph.To(feature.Table, feature.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, planratecard.FeaturesTable, planratecard.FeaturesColumn), + ) + fromV = sqlgraph.Neighbors(prc.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PlanRateCardClient) Hooks() []Hook { + return c.hooks.PlanRateCard +} + +// Interceptors returns the client interceptors. +func (c *PlanRateCardClient) Interceptors() []Interceptor { + return c.inters.PlanRateCard +} + +func (c *PlanRateCardClient) mutate(ctx context.Context, m *PlanRateCardMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PlanRateCardCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PlanRateCardUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PlanRateCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PlanRateCardDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("db: unknown PlanRateCard mutation op: %q", m.Op()) + } +} + // UsageResetClient is a client for the UsageReset schema. type UsageResetClient struct { config @@ -4167,7 +4688,7 @@ type ( BillingInvoiceManualLineConfig, BillingInvoiceValidationIssue, BillingProfile, BillingWorkflowConfig, Customer, CustomerSubjects, Entitlement, Feature, Grant, NotificationChannel, NotificationEvent, NotificationEventDeliveryStatus, - NotificationRule, UsageReset []ent.Hook + NotificationRule, Plan, PlanPhase, PlanRateCard, UsageReset []ent.Hook } inters struct { App, AppCustomer, AppStripe, AppStripeCustomer, BalanceSnapshot, @@ -4175,7 +4696,7 @@ type ( BillingInvoiceManualLineConfig, BillingInvoiceValidationIssue, BillingProfile, BillingWorkflowConfig, Customer, CustomerSubjects, Entitlement, Feature, Grant, NotificationChannel, NotificationEvent, NotificationEventDeliveryStatus, - NotificationRule, UsageReset []ent.Interceptor + NotificationRule, Plan, PlanPhase, PlanRateCard, UsageReset []ent.Interceptor } ) diff --git a/openmeter/ent/db/ent.go b/openmeter/ent/db/ent.go index 7cf38ca14..2292943d2 100644 --- a/openmeter/ent/db/ent.go +++ b/openmeter/ent/db/ent.go @@ -34,6 +34,10 @@ import ( "github.com/openmeterio/openmeter/openmeter/ent/db/notificationevent" "github.com/openmeterio/openmeter/openmeter/ent/db/notificationeventdeliverystatus" "github.com/openmeterio/openmeter/openmeter/ent/db/notificationrule" + + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" "github.com/openmeterio/openmeter/openmeter/ent/db/usagereset" ) @@ -116,6 +120,9 @@ func checkColumn(table, column string) error { notificationevent.Table: notificationevent.ValidColumn, notificationeventdeliverystatus.Table: notificationeventdeliverystatus.ValidColumn, notificationrule.Table: notificationrule.ValidColumn, + dbplan.Table: dbplan.ValidColumn, + planphase.Table: planphase.ValidColumn, + planratecard.Table: planratecard.ValidColumn, usagereset.Table: usagereset.ValidColumn, }) }) diff --git a/openmeter/ent/db/expose.go b/openmeter/ent/db/expose.go index 6794d3ebc..eea6fc7c2 100644 --- a/openmeter/ent/db/expose.go +++ b/openmeter/ent/db/expose.go @@ -131,6 +131,12 @@ func NewTxClientFromRawConfig(ctx context.Context, cfg entutils.RawEntConfig) *T NotificationRule: NewNotificationRuleClient(config), + Plan: NewPlanClient(config), + + PlanPhase: NewPlanPhaseClient(config), + + PlanRateCard: NewPlanRateCardClient(config), + UsageReset: NewUsageResetClient(config), } } diff --git a/openmeter/ent/db/feature.go b/openmeter/ent/db/feature.go index fc2ec50a1..6106f0fcd 100644 --- a/openmeter/ent/db/feature.go +++ b/openmeter/ent/db/feature.go @@ -48,9 +48,11 @@ type Feature struct { type FeatureEdges struct { // Entitlement holds the value of the entitlement edge. Entitlement []*Entitlement `json:"entitlement,omitempty"` + // Ratecard holds the value of the ratecard edge. + Ratecard []*PlanRateCard `json:"ratecard,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool + loadedTypes [2]bool } // EntitlementOrErr returns the Entitlement value or an error if the edge @@ -62,6 +64,15 @@ func (e FeatureEdges) EntitlementOrErr() ([]*Entitlement, error) { return nil, &NotLoadedError{edge: "entitlement"} } +// RatecardOrErr returns the Ratecard value or an error if the edge +// was not loaded in eager-loading. +func (e FeatureEdges) RatecardOrErr() ([]*PlanRateCard, error) { + if e.loadedTypes[1] { + return e.Ratecard, nil + } + return nil, &NotLoadedError{edge: "ratecard"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Feature) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -179,6 +190,11 @@ func (f *Feature) QueryEntitlement() *EntitlementQuery { return NewFeatureClient(f.config).QueryEntitlement(f) } +// QueryRatecard queries the "ratecard" edge of the Feature entity. +func (f *Feature) QueryRatecard() *PlanRateCardQuery { + return NewFeatureClient(f.config).QueryRatecard(f) +} + // Update returns a builder for updating this Feature. // Note that you need to call Feature.Unwrap() before calling this method if this Feature // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/openmeter/ent/db/feature/feature.go b/openmeter/ent/db/feature/feature.go index 56c729bb5..0ed92d0ed 100644 --- a/openmeter/ent/db/feature/feature.go +++ b/openmeter/ent/db/feature/feature.go @@ -36,6 +36,8 @@ const ( FieldArchivedAt = "archived_at" // EdgeEntitlement holds the string denoting the entitlement edge name in mutations. EdgeEntitlement = "entitlement" + // EdgeRatecard holds the string denoting the ratecard edge name in mutations. + EdgeRatecard = "ratecard" // Table holds the table name of the feature in the database. Table = "features" // EntitlementTable is the table that holds the entitlement relation/edge. @@ -45,6 +47,13 @@ const ( EntitlementInverseTable = "entitlements" // EntitlementColumn is the table column denoting the entitlement relation/edge. EntitlementColumn = "feature_id" + // RatecardTable is the table that holds the ratecard relation/edge. + RatecardTable = "plan_rate_cards" + // RatecardInverseTable is the table name for the PlanRateCard entity. + // It exists in this package in order to avoid circular dependency with the "planratecard" package. + RatecardInverseTable = "plan_rate_cards" + // RatecardColumn is the table column denoting the ratecard relation/edge. + RatecardColumn = "feature_id" ) // Columns holds all SQL columns for feature fields. @@ -150,6 +159,20 @@ func ByEntitlement(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newEntitlementStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByRatecardCount orders the results by ratecard count. +func ByRatecardCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRatecardStep(), opts...) + } +} + +// ByRatecard orders the results by ratecard terms. +func ByRatecard(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRatecardStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newEntitlementStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -157,3 +180,10 @@ func newEntitlementStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, EntitlementTable, EntitlementColumn), ) } +func newRatecardStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RatecardInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, RatecardTable, RatecardColumn), + ) +} diff --git a/openmeter/ent/db/feature/where.go b/openmeter/ent/db/feature/where.go index c2d71fdfd..8d5e9e48c 100644 --- a/openmeter/ent/db/feature/where.go +++ b/openmeter/ent/db/feature/where.go @@ -598,6 +598,29 @@ func HasEntitlementWith(preds ...predicate.Entitlement) predicate.Feature { }) } +// HasRatecard applies the HasEdge predicate on the "ratecard" edge. +func HasRatecard() predicate.Feature { + return predicate.Feature(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, RatecardTable, RatecardColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRatecardWith applies the HasEdge predicate on the "ratecard" edge with a given conditions (other predicates). +func HasRatecardWith(preds ...predicate.PlanRateCard) predicate.Feature { + return predicate.Feature(func(s *sql.Selector) { + step := newRatecardStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Feature) predicate.Feature { return predicate.Feature(sql.AndPredicates(predicates...)) diff --git a/openmeter/ent/db/feature_create.go b/openmeter/ent/db/feature_create.go index 793f34a4c..1d8368c09 100644 --- a/openmeter/ent/db/feature_create.go +++ b/openmeter/ent/db/feature_create.go @@ -14,6 +14,7 @@ import ( "entgo.io/ent/schema/field" "github.com/openmeterio/openmeter/openmeter/ent/db/entitlement" "github.com/openmeterio/openmeter/openmeter/ent/db/feature" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" ) // FeatureCreate is the builder for creating a Feature entity. @@ -153,6 +154,21 @@ func (fc *FeatureCreate) AddEntitlement(e ...*Entitlement) *FeatureCreate { return fc.AddEntitlementIDs(ids...) } +// AddRatecardIDs adds the "ratecard" edge to the PlanRateCard entity by IDs. +func (fc *FeatureCreate) AddRatecardIDs(ids ...string) *FeatureCreate { + fc.mutation.AddRatecardIDs(ids...) + return fc +} + +// AddRatecard adds the "ratecard" edges to the PlanRateCard entity. +func (fc *FeatureCreate) AddRatecard(p ...*PlanRateCard) *FeatureCreate { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return fc.AddRatecardIDs(ids...) +} + // Mutation returns the FeatureMutation object of the builder. func (fc *FeatureCreate) Mutation() *FeatureMutation { return fc.mutation @@ -326,6 +342,22 @@ func (fc *FeatureCreate) createSpec() (*Feature, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := fc.mutation.RatecardIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: feature.RatecardTable, + Columns: []string{feature.RatecardColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/openmeter/ent/db/feature_query.go b/openmeter/ent/db/feature_query.go index 31b8cd424..b2d34e4fd 100644 --- a/openmeter/ent/db/feature_query.go +++ b/openmeter/ent/db/feature_query.go @@ -15,6 +15,7 @@ import ( "entgo.io/ent/schema/field" "github.com/openmeterio/openmeter/openmeter/ent/db/entitlement" "github.com/openmeterio/openmeter/openmeter/ent/db/feature" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" ) @@ -26,6 +27,7 @@ type FeatureQuery struct { inters []Interceptor predicates []predicate.Feature withEntitlement *EntitlementQuery + withRatecard *PlanRateCardQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -85,6 +87,28 @@ func (fq *FeatureQuery) QueryEntitlement() *EntitlementQuery { return query } +// QueryRatecard chains the current query on the "ratecard" edge. +func (fq *FeatureQuery) QueryRatecard() *PlanRateCardQuery { + query := (&PlanRateCardClient{config: fq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := fq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := fq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(feature.Table, feature.FieldID, selector), + sqlgraph.To(planratecard.Table, planratecard.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, feature.RatecardTable, feature.RatecardColumn), + ) + fromU = sqlgraph.SetNeighbors(fq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Feature entity from the query. // Returns a *NotFoundError when no Feature was found. func (fq *FeatureQuery) First(ctx context.Context) (*Feature, error) { @@ -278,6 +302,7 @@ func (fq *FeatureQuery) Clone() *FeatureQuery { inters: append([]Interceptor{}, fq.inters...), predicates: append([]predicate.Feature{}, fq.predicates...), withEntitlement: fq.withEntitlement.Clone(), + withRatecard: fq.withRatecard.Clone(), // clone intermediate query. sql: fq.sql.Clone(), path: fq.path, @@ -295,6 +320,17 @@ func (fq *FeatureQuery) WithEntitlement(opts ...func(*EntitlementQuery)) *Featur return fq } +// WithRatecard tells the query-builder to eager-load the nodes that are connected to +// the "ratecard" edge. The optional arguments are used to configure the query builder of the edge. +func (fq *FeatureQuery) WithRatecard(opts ...func(*PlanRateCardQuery)) *FeatureQuery { + query := (&PlanRateCardClient{config: fq.config}).Query() + for _, opt := range opts { + opt(query) + } + fq.withRatecard = query + return fq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -373,8 +409,9 @@ func (fq *FeatureQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Feat var ( nodes = []*Feature{} _spec = fq.querySpec() - loadedTypes = [1]bool{ + loadedTypes = [2]bool{ fq.withEntitlement != nil, + fq.withRatecard != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -405,6 +442,13 @@ func (fq *FeatureQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Feat return nil, err } } + if query := fq.withRatecard; query != nil { + if err := fq.loadRatecard(ctx, query, nodes, + func(n *Feature) { n.Edges.Ratecard = []*PlanRateCard{} }, + func(n *Feature, e *PlanRateCard) { n.Edges.Ratecard = append(n.Edges.Ratecard, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -438,6 +482,39 @@ func (fq *FeatureQuery) loadEntitlement(ctx context.Context, query *EntitlementQ } return nil } +func (fq *FeatureQuery) loadRatecard(ctx context.Context, query *PlanRateCardQuery, nodes []*Feature, init func(*Feature), assign func(*Feature, *PlanRateCard)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Feature) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(planratecard.FieldFeatureID) + } + query.Where(predicate.PlanRateCard(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(feature.RatecardColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.FeatureID + if fk == nil { + return fmt.Errorf(`foreign-key "feature_id" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "feature_id" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} func (fq *FeatureQuery) sqlCount(ctx context.Context) (int, error) { _spec := fq.querySpec() diff --git a/openmeter/ent/db/feature_update.go b/openmeter/ent/db/feature_update.go index b7030733f..3ecd0767f 100644 --- a/openmeter/ent/db/feature_update.go +++ b/openmeter/ent/db/feature_update.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/schema/field" "github.com/openmeterio/openmeter/openmeter/ent/db/entitlement" "github.com/openmeterio/openmeter/openmeter/ent/db/feature" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" ) @@ -128,6 +129,21 @@ func (fu *FeatureUpdate) AddEntitlement(e ...*Entitlement) *FeatureUpdate { return fu.AddEntitlementIDs(ids...) } +// AddRatecardIDs adds the "ratecard" edge to the PlanRateCard entity by IDs. +func (fu *FeatureUpdate) AddRatecardIDs(ids ...string) *FeatureUpdate { + fu.mutation.AddRatecardIDs(ids...) + return fu +} + +// AddRatecard adds the "ratecard" edges to the PlanRateCard entity. +func (fu *FeatureUpdate) AddRatecard(p ...*PlanRateCard) *FeatureUpdate { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return fu.AddRatecardIDs(ids...) +} + // Mutation returns the FeatureMutation object of the builder. func (fu *FeatureUpdate) Mutation() *FeatureMutation { return fu.mutation @@ -154,6 +170,27 @@ func (fu *FeatureUpdate) RemoveEntitlement(e ...*Entitlement) *FeatureUpdate { return fu.RemoveEntitlementIDs(ids...) } +// ClearRatecard clears all "ratecard" edges to the PlanRateCard entity. +func (fu *FeatureUpdate) ClearRatecard() *FeatureUpdate { + fu.mutation.ClearRatecard() + return fu +} + +// RemoveRatecardIDs removes the "ratecard" edge to PlanRateCard entities by IDs. +func (fu *FeatureUpdate) RemoveRatecardIDs(ids ...string) *FeatureUpdate { + fu.mutation.RemoveRatecardIDs(ids...) + return fu +} + +// RemoveRatecard removes "ratecard" edges to PlanRateCard entities. +func (fu *FeatureUpdate) RemoveRatecard(p ...*PlanRateCard) *FeatureUpdate { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return fu.RemoveRatecardIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (fu *FeatureUpdate) Save(ctx context.Context) (int, error) { fu.defaults() @@ -290,6 +327,51 @@ func (fu *FeatureUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if fu.mutation.RatecardCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: feature.RatecardTable, + Columns: []string{feature.RatecardColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := fu.mutation.RemovedRatecardIDs(); len(nodes) > 0 && !fu.mutation.RatecardCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: feature.RatecardTable, + Columns: []string{feature.RatecardColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := fu.mutation.RatecardIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: feature.RatecardTable, + Columns: []string{feature.RatecardColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, fu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{feature.Label} @@ -409,6 +491,21 @@ func (fuo *FeatureUpdateOne) AddEntitlement(e ...*Entitlement) *FeatureUpdateOne return fuo.AddEntitlementIDs(ids...) } +// AddRatecardIDs adds the "ratecard" edge to the PlanRateCard entity by IDs. +func (fuo *FeatureUpdateOne) AddRatecardIDs(ids ...string) *FeatureUpdateOne { + fuo.mutation.AddRatecardIDs(ids...) + return fuo +} + +// AddRatecard adds the "ratecard" edges to the PlanRateCard entity. +func (fuo *FeatureUpdateOne) AddRatecard(p ...*PlanRateCard) *FeatureUpdateOne { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return fuo.AddRatecardIDs(ids...) +} + // Mutation returns the FeatureMutation object of the builder. func (fuo *FeatureUpdateOne) Mutation() *FeatureMutation { return fuo.mutation @@ -435,6 +532,27 @@ func (fuo *FeatureUpdateOne) RemoveEntitlement(e ...*Entitlement) *FeatureUpdate return fuo.RemoveEntitlementIDs(ids...) } +// ClearRatecard clears all "ratecard" edges to the PlanRateCard entity. +func (fuo *FeatureUpdateOne) ClearRatecard() *FeatureUpdateOne { + fuo.mutation.ClearRatecard() + return fuo +} + +// RemoveRatecardIDs removes the "ratecard" edge to PlanRateCard entities by IDs. +func (fuo *FeatureUpdateOne) RemoveRatecardIDs(ids ...string) *FeatureUpdateOne { + fuo.mutation.RemoveRatecardIDs(ids...) + return fuo +} + +// RemoveRatecard removes "ratecard" edges to PlanRateCard entities. +func (fuo *FeatureUpdateOne) RemoveRatecard(p ...*PlanRateCard) *FeatureUpdateOne { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return fuo.RemoveRatecardIDs(ids...) +} + // Where appends a list predicates to the FeatureUpdate builder. func (fuo *FeatureUpdateOne) Where(ps ...predicate.Feature) *FeatureUpdateOne { fuo.mutation.Where(ps...) @@ -601,6 +719,51 @@ func (fuo *FeatureUpdateOne) sqlSave(ctx context.Context) (_node *Feature, err e } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if fuo.mutation.RatecardCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: feature.RatecardTable, + Columns: []string{feature.RatecardColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := fuo.mutation.RemovedRatecardIDs(); len(nodes) > 0 && !fuo.mutation.RatecardCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: feature.RatecardTable, + Columns: []string{feature.RatecardColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := fuo.mutation.RatecardIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: feature.RatecardTable, + Columns: []string{feature.RatecardColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &Feature{config: fuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/openmeter/ent/db/hook/hook.go b/openmeter/ent/db/hook/hook.go index 7ce2c2731..5a81df8af 100644 --- a/openmeter/ent/db/hook/hook.go +++ b/openmeter/ent/db/hook/hook.go @@ -261,6 +261,42 @@ func (f NotificationRuleFunc) Mutate(ctx context.Context, m db.Mutation) (db.Val return nil, fmt.Errorf("unexpected mutation type %T. expect *db.NotificationRuleMutation", m) } +// The PlanFunc type is an adapter to allow the use of ordinary +// function as Plan mutator. +type PlanFunc func(context.Context, *db.PlanMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f PlanFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.PlanMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.PlanMutation", m) +} + +// The PlanPhaseFunc type is an adapter to allow the use of ordinary +// function as PlanPhase mutator. +type PlanPhaseFunc func(context.Context, *db.PlanPhaseMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f PlanPhaseFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.PlanPhaseMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.PlanPhaseMutation", m) +} + +// The PlanRateCardFunc type is an adapter to allow the use of ordinary +// function as PlanRateCard mutator. +type PlanRateCardFunc func(context.Context, *db.PlanRateCardMutation) (db.Value, error) + +// Mutate calls f(ctx, m). +func (f PlanRateCardFunc) Mutate(ctx context.Context, m db.Mutation) (db.Value, error) { + if mv, ok := m.(*db.PlanRateCardMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *db.PlanRateCardMutation", m) +} + // The UsageResetFunc type is an adapter to allow the use of ordinary // function as UsageReset mutator. type UsageResetFunc func(context.Context, *db.UsageResetMutation) (db.Value, error) diff --git a/openmeter/ent/db/migrate/schema.go b/openmeter/ent/db/migrate/schema.go index 6bc987915..a4453419f 100644 --- a/openmeter/ent/db/migrate/schema.go +++ b/openmeter/ent/db/migrate/schema.go @@ -1107,6 +1107,188 @@ var ( }, }, } + // PlansColumns holds the columns for the "plans" table. + PlansColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "char(26)"}}, + {Name: "namespace", Type: field.TypeString}, + {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "name", Type: field.TypeString}, + {Name: "description", Type: field.TypeString, Nullable: true}, + {Name: "key", Type: field.TypeString}, + {Name: "version", Type: field.TypeInt}, + {Name: "currency", Type: field.TypeString, Default: "USD"}, + {Name: "effective_from", Type: field.TypeTime, Nullable: true}, + {Name: "effective_to", Type: field.TypeTime, Nullable: true}, + } + // PlansTable holds the schema information for the "plans" table. + PlansTable = &schema.Table{ + Name: "plans", + Columns: PlansColumns, + PrimaryKey: []*schema.Column{PlansColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "plan_id", + Unique: true, + Columns: []*schema.Column{PlansColumns[0]}, + }, + { + Name: "plan_namespace", + Unique: false, + Columns: []*schema.Column{PlansColumns[1]}, + }, + { + Name: "plan_namespace_id", + Unique: true, + Columns: []*schema.Column{PlansColumns[1], PlansColumns[0]}, + }, + { + Name: "plan_namespace_key_deleted_at", + Unique: true, + Columns: []*schema.Column{PlansColumns[1], PlansColumns[8], PlansColumns[5]}, + }, + { + Name: "plan_namespace_key_version", + Unique: true, + Columns: []*schema.Column{PlansColumns[1], PlansColumns[8], PlansColumns[9]}, + }, + }, + } + // PlanPhasesColumns holds the columns for the "plan_phases" table. + PlanPhasesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "char(26)"}}, + {Name: "namespace", Type: field.TypeString}, + {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "name", Type: field.TypeString}, + {Name: "description", Type: field.TypeString, Nullable: true}, + {Name: "key", Type: field.TypeString}, + {Name: "start_after", Type: field.TypeString, Default: "P0D"}, + {Name: "discounts", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, + {Name: "plan_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "char(26)"}}, + } + // PlanPhasesTable holds the schema information for the "plan_phases" table. + PlanPhasesTable = &schema.Table{ + Name: "plan_phases", + Columns: PlanPhasesColumns, + PrimaryKey: []*schema.Column{PlanPhasesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "plan_phases_plans_phases", + Columns: []*schema.Column{PlanPhasesColumns[11]}, + RefColumns: []*schema.Column{PlansColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + Indexes: []*schema.Index{ + { + Name: "planphase_id", + Unique: true, + Columns: []*schema.Column{PlanPhasesColumns[0]}, + }, + { + Name: "planphase_namespace", + Unique: false, + Columns: []*schema.Column{PlanPhasesColumns[1]}, + }, + { + Name: "planphase_namespace_id", + Unique: true, + Columns: []*schema.Column{PlanPhasesColumns[1], PlanPhasesColumns[0]}, + }, + { + Name: "planphase_namespace_key_deleted_at", + Unique: true, + Columns: []*schema.Column{PlanPhasesColumns[1], PlanPhasesColumns[8], PlanPhasesColumns[5]}, + }, + { + Name: "planphase_namespace_key", + Unique: false, + Columns: []*schema.Column{PlanPhasesColumns[1], PlanPhasesColumns[8]}, + }, + { + Name: "planphase_plan_id_key", + Unique: true, + Columns: []*schema.Column{PlanPhasesColumns[11], PlanPhasesColumns[8]}, + }, + }, + } + // PlanRateCardsColumns holds the columns for the "plan_rate_cards" table. + PlanRateCardsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "char(26)"}}, + {Name: "namespace", Type: field.TypeString}, + {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "updated_at", Type: field.TypeTime}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, + {Name: "name", Type: field.TypeString}, + {Name: "description", Type: field.TypeString, Nullable: true}, + {Name: "key", Type: field.TypeString}, + {Name: "type", Type: field.TypeEnum, Enums: []string{"flat_fee", "usage_based"}}, + {Name: "feature_key", Type: field.TypeString, Nullable: true}, + {Name: "entitlement_template", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, + {Name: "tax_config", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, + {Name: "billing_cadence", Type: field.TypeString, Nullable: true}, + {Name: "price", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, + {Name: "feature_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "char(26)"}}, + {Name: "phase_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "char(26)"}}, + } + // PlanRateCardsTable holds the schema information for the "plan_rate_cards" table. + PlanRateCardsTable = &schema.Table{ + Name: "plan_rate_cards", + Columns: PlanRateCardsColumns, + PrimaryKey: []*schema.Column{PlanRateCardsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "plan_rate_cards_features_ratecard", + Columns: []*schema.Column{PlanRateCardsColumns[15]}, + RefColumns: []*schema.Column{FeaturesColumns[0]}, + OnDelete: schema.SetNull, + }, + { + Symbol: "plan_rate_cards_plan_phases_ratecards", + Columns: []*schema.Column{PlanRateCardsColumns[16]}, + RefColumns: []*schema.Column{PlanPhasesColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + Indexes: []*schema.Index{ + { + Name: "planratecard_id", + Unique: true, + Columns: []*schema.Column{PlanRateCardsColumns[0]}, + }, + { + Name: "planratecard_namespace", + Unique: false, + Columns: []*schema.Column{PlanRateCardsColumns[1]}, + }, + { + Name: "planratecard_namespace_id", + Unique: true, + Columns: []*schema.Column{PlanRateCardsColumns[1], PlanRateCardsColumns[0]}, + }, + { + Name: "planratecard_namespace_key_deleted_at", + Unique: true, + Columns: []*schema.Column{PlanRateCardsColumns[1], PlanRateCardsColumns[8], PlanRateCardsColumns[5]}, + }, + { + Name: "planratecard_phase_id_key", + Unique: true, + Columns: []*schema.Column{PlanRateCardsColumns[16], PlanRateCardsColumns[8]}, + }, + { + Name: "planratecard_phase_id_feature_key", + Unique: true, + Columns: []*schema.Column{PlanRateCardsColumns[16], PlanRateCardsColumns[10]}, + }, + }, + } // UsageResetsColumns holds the columns for the "usage_resets" table. UsageResetsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "char(26)"}}, @@ -1226,6 +1408,9 @@ var ( NotificationEventsTable, NotificationEventDeliveryStatusTable, NotificationRulesTable, + PlansTable, + PlanPhasesTable, + PlanRateCardsTable, UsageResetsTable, NotificationChannelRulesTable, NotificationEventDeliveryStatusEventsTable, @@ -1258,6 +1443,9 @@ func init() { EntitlementsTable.ForeignKeys[0].RefTable = FeaturesTable GrantsTable.ForeignKeys[0].RefTable = EntitlementsTable NotificationEventsTable.ForeignKeys[0].RefTable = NotificationRulesTable + PlanPhasesTable.ForeignKeys[0].RefTable = PlansTable + PlanRateCardsTable.ForeignKeys[0].RefTable = FeaturesTable + PlanRateCardsTable.ForeignKeys[1].RefTable = PlanPhasesTable UsageResetsTable.ForeignKeys[0].RefTable = EntitlementsTable NotificationChannelRulesTable.ForeignKeys[0].RefTable = NotificationChannelsTable NotificationChannelRulesTable.ForeignKeys[1].RefTable = NotificationRulesTable diff --git a/openmeter/ent/db/mutation.go b/openmeter/ent/db/mutation.go index 07fe6a8c8..ed312ff3e 100644 --- a/openmeter/ent/db/mutation.go +++ b/openmeter/ent/db/mutation.go @@ -37,9 +37,13 @@ import ( "github.com/openmeterio/openmeter/openmeter/ent/db/notificationevent" "github.com/openmeterio/openmeter/openmeter/ent/db/notificationeventdeliverystatus" "github.com/openmeterio/openmeter/openmeter/ent/db/notificationrule" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" "github.com/openmeterio/openmeter/openmeter/ent/db/usagereset" "github.com/openmeterio/openmeter/openmeter/notification" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" "github.com/openmeterio/openmeter/pkg/currencyx" "github.com/openmeterio/openmeter/pkg/datex" "github.com/openmeterio/openmeter/pkg/models" @@ -77,6 +81,9 @@ const ( TypeNotificationEvent = "NotificationEvent" TypeNotificationEventDeliveryStatus = "NotificationEventDeliveryStatus" TypeNotificationRule = "NotificationRule" + TypePlan = "Plan" + TypePlanPhase = "PlanPhase" + TypePlanRateCard = "PlanRateCard" TypeUsageReset = "UsageReset" ) @@ -19674,6 +19681,9 @@ type FeatureMutation struct { entitlement map[string]struct{} removedentitlement map[string]struct{} clearedentitlement bool + ratecard map[string]struct{} + removedratecard map[string]struct{} + clearedratecard bool done bool oldValue func(context.Context) (*Feature, error) predicates []predicate.Feature @@ -20262,6 +20272,60 @@ func (m *FeatureMutation) ResetEntitlement() { m.removedentitlement = nil } +// AddRatecardIDs adds the "ratecard" edge to the PlanRateCard entity by ids. +func (m *FeatureMutation) AddRatecardIDs(ids ...string) { + if m.ratecard == nil { + m.ratecard = make(map[string]struct{}) + } + for i := range ids { + m.ratecard[ids[i]] = struct{}{} + } +} + +// ClearRatecard clears the "ratecard" edge to the PlanRateCard entity. +func (m *FeatureMutation) ClearRatecard() { + m.clearedratecard = true +} + +// RatecardCleared reports if the "ratecard" edge to the PlanRateCard entity was cleared. +func (m *FeatureMutation) RatecardCleared() bool { + return m.clearedratecard +} + +// RemoveRatecardIDs removes the "ratecard" edge to the PlanRateCard entity by IDs. +func (m *FeatureMutation) RemoveRatecardIDs(ids ...string) { + if m.removedratecard == nil { + m.removedratecard = make(map[string]struct{}) + } + for i := range ids { + delete(m.ratecard, ids[i]) + m.removedratecard[ids[i]] = struct{}{} + } +} + +// RemovedRatecard returns the removed IDs of the "ratecard" edge to the PlanRateCard entity. +func (m *FeatureMutation) RemovedRatecardIDs() (ids []string) { + for id := range m.removedratecard { + ids = append(ids, id) + } + return +} + +// RatecardIDs returns the "ratecard" edge IDs in the mutation. +func (m *FeatureMutation) RatecardIDs() (ids []string) { + for id := range m.ratecard { + ids = append(ids, id) + } + return +} + +// ResetRatecard resets all changes to the "ratecard" edge. +func (m *FeatureMutation) ResetRatecard() { + m.ratecard = nil + m.clearedratecard = false + m.removedratecard = nil +} + // Where appends a list predicates to the FeatureMutation builder. func (m *FeatureMutation) Where(ps ...predicate.Feature) { m.predicates = append(m.predicates, ps...) @@ -20581,10 +20645,13 @@ func (m *FeatureMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *FeatureMutation) AddedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.entitlement != nil { edges = append(edges, feature.EdgeEntitlement) } + if m.ratecard != nil { + edges = append(edges, feature.EdgeRatecard) + } return edges } @@ -20598,16 +20665,25 @@ func (m *FeatureMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case feature.EdgeRatecard: + ids := make([]ent.Value, 0, len(m.ratecard)) + for id := range m.ratecard { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *FeatureMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.removedentitlement != nil { edges = append(edges, feature.EdgeEntitlement) } + if m.removedratecard != nil { + edges = append(edges, feature.EdgeRatecard) + } return edges } @@ -20621,16 +20697,25 @@ func (m *FeatureMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case feature.EdgeRatecard: + ids := make([]ent.Value, 0, len(m.removedratecard)) + for id := range m.removedratecard { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *FeatureMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) + edges := make([]string, 0, 2) if m.clearedentitlement { edges = append(edges, feature.EdgeEntitlement) } + if m.clearedratecard { + edges = append(edges, feature.EdgeRatecard) + } return edges } @@ -20640,6 +20725,8 @@ func (m *FeatureMutation) EdgeCleared(name string) bool { switch name { case feature.EdgeEntitlement: return m.clearedentitlement + case feature.EdgeRatecard: + return m.clearedratecard } return false } @@ -20659,6 +20746,9 @@ func (m *FeatureMutation) ResetEdge(name string) error { case feature.EdgeEntitlement: m.ResetEntitlement() return nil + case feature.EdgeRatecard: + m.ResetRatecard() + return nil } return fmt.Errorf("unknown Feature edge %s", name) } @@ -25423,6 +25513,3678 @@ func (m *NotificationRuleMutation) ResetEdge(name string) error { return fmt.Errorf("unknown NotificationRule edge %s", name) } +// PlanMutation represents an operation that mutates the Plan nodes in the graph. +type PlanMutation struct { + config + op Op + typ string + id *string + namespace *string + metadata *map[string]string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + name *string + description *string + key *string + version *int + addversion *int + currency *string + effective_from *time.Time + effective_to *time.Time + clearedFields map[string]struct{} + phases map[string]struct{} + removedphases map[string]struct{} + clearedphases bool + done bool + oldValue func(context.Context) (*Plan, error) + predicates []predicate.Plan +} + +var _ ent.Mutation = (*PlanMutation)(nil) + +// planOption allows management of the mutation configuration using functional options. +type planOption func(*PlanMutation) + +// newPlanMutation creates new mutation for the Plan entity. +func newPlanMutation(c config, op Op, opts ...planOption) *PlanMutation { + m := &PlanMutation{ + config: c, + op: op, + typ: TypePlan, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPlanID sets the ID field of the mutation. +func withPlanID(id string) planOption { + return func(m *PlanMutation) { + var ( + err error + once sync.Once + value *Plan + ) + m.oldValue = func(ctx context.Context) (*Plan, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Plan.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPlan sets the old Plan of the mutation. +func withPlan(node *Plan) planOption { + return func(m *PlanMutation) { + m.oldValue = func(context.Context) (*Plan, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PlanMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PlanMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Plan entities. +func (m *PlanMutation) SetID(id string) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PlanMutation) ID() (id string, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PlanMutation) IDs(ctx context.Context) ([]string, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []string{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Plan.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetNamespace sets the "namespace" field. +func (m *PlanMutation) SetNamespace(s string) { + m.namespace = &s +} + +// Namespace returns the value of the "namespace" field in the mutation. +func (m *PlanMutation) Namespace() (r string, exists bool) { + v := m.namespace + if v == nil { + return + } + return *v, true +} + +// OldNamespace returns the old "namespace" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldNamespace(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNamespace is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNamespace requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNamespace: %w", err) + } + return oldValue.Namespace, nil +} + +// ResetNamespace resets all changes to the "namespace" field. +func (m *PlanMutation) ResetNamespace() { + m.namespace = nil +} + +// SetMetadata sets the "metadata" field. +func (m *PlanMutation) SetMetadata(value map[string]string) { + m.metadata = &value +} + +// Metadata returns the value of the "metadata" field in the mutation. +func (m *PlanMutation) Metadata() (r map[string]string, exists bool) { + v := m.metadata + if v == nil { + return + } + return *v, true +} + +// OldMetadata returns the old "metadata" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldMetadata(ctx context.Context) (v map[string]string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMetadata is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMetadata requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMetadata: %w", err) + } + return oldValue.Metadata, nil +} + +// ClearMetadata clears the value of the "metadata" field. +func (m *PlanMutation) ClearMetadata() { + m.metadata = nil + m.clearedFields[dbplan.FieldMetadata] = struct{}{} +} + +// MetadataCleared returns if the "metadata" field was cleared in this mutation. +func (m *PlanMutation) MetadataCleared() bool { + _, ok := m.clearedFields[dbplan.FieldMetadata] + return ok +} + +// ResetMetadata resets all changes to the "metadata" field. +func (m *PlanMutation) ResetMetadata() { + m.metadata = nil + delete(m.clearedFields, dbplan.FieldMetadata) +} + +// SetCreatedAt sets the "created_at" field. +func (m *PlanMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *PlanMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *PlanMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *PlanMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *PlanMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *PlanMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *PlanMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *PlanMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *PlanMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[dbplan.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *PlanMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[dbplan.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *PlanMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, dbplan.FieldDeletedAt) +} + +// SetName sets the "name" field. +func (m *PlanMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *PlanMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *PlanMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *PlanMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *PlanMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldDescription(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *PlanMutation) ClearDescription() { + m.description = nil + m.clearedFields[dbplan.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *PlanMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[dbplan.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *PlanMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, dbplan.FieldDescription) +} + +// SetKey sets the "key" field. +func (m *PlanMutation) SetKey(s string) { + m.key = &s +} + +// Key returns the value of the "key" field in the mutation. +func (m *PlanMutation) Key() (r string, exists bool) { + v := m.key + if v == nil { + return + } + return *v, true +} + +// OldKey returns the old "key" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKey: %w", err) + } + return oldValue.Key, nil +} + +// ResetKey resets all changes to the "key" field. +func (m *PlanMutation) ResetKey() { + m.key = nil +} + +// SetVersion sets the "version" field. +func (m *PlanMutation) SetVersion(i int) { + m.version = &i + m.addversion = nil +} + +// Version returns the value of the "version" field in the mutation. +func (m *PlanMutation) Version() (r int, exists bool) { + v := m.version + if v == nil { + return + } + return *v, true +} + +// OldVersion returns the old "version" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldVersion(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersion: %w", err) + } + return oldValue.Version, nil +} + +// AddVersion adds i to the "version" field. +func (m *PlanMutation) AddVersion(i int) { + if m.addversion != nil { + *m.addversion += i + } else { + m.addversion = &i + } +} + +// AddedVersion returns the value that was added to the "version" field in this mutation. +func (m *PlanMutation) AddedVersion() (r int, exists bool) { + v := m.addversion + if v == nil { + return + } + return *v, true +} + +// ResetVersion resets all changes to the "version" field. +func (m *PlanMutation) ResetVersion() { + m.version = nil + m.addversion = nil +} + +// SetCurrency sets the "currency" field. +func (m *PlanMutation) SetCurrency(s string) { + m.currency = &s +} + +// Currency returns the value of the "currency" field in the mutation. +func (m *PlanMutation) Currency() (r string, exists bool) { + v := m.currency + if v == nil { + return + } + return *v, true +} + +// OldCurrency returns the old "currency" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldCurrency(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCurrency is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCurrency requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCurrency: %w", err) + } + return oldValue.Currency, nil +} + +// ResetCurrency resets all changes to the "currency" field. +func (m *PlanMutation) ResetCurrency() { + m.currency = nil +} + +// SetEffectiveFrom sets the "effective_from" field. +func (m *PlanMutation) SetEffectiveFrom(t time.Time) { + m.effective_from = &t +} + +// EffectiveFrom returns the value of the "effective_from" field in the mutation. +func (m *PlanMutation) EffectiveFrom() (r time.Time, exists bool) { + v := m.effective_from + if v == nil { + return + } + return *v, true +} + +// OldEffectiveFrom returns the old "effective_from" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldEffectiveFrom(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEffectiveFrom is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEffectiveFrom requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEffectiveFrom: %w", err) + } + return oldValue.EffectiveFrom, nil +} + +// ClearEffectiveFrom clears the value of the "effective_from" field. +func (m *PlanMutation) ClearEffectiveFrom() { + m.effective_from = nil + m.clearedFields[dbplan.FieldEffectiveFrom] = struct{}{} +} + +// EffectiveFromCleared returns if the "effective_from" field was cleared in this mutation. +func (m *PlanMutation) EffectiveFromCleared() bool { + _, ok := m.clearedFields[dbplan.FieldEffectiveFrom] + return ok +} + +// ResetEffectiveFrom resets all changes to the "effective_from" field. +func (m *PlanMutation) ResetEffectiveFrom() { + m.effective_from = nil + delete(m.clearedFields, dbplan.FieldEffectiveFrom) +} + +// SetEffectiveTo sets the "effective_to" field. +func (m *PlanMutation) SetEffectiveTo(t time.Time) { + m.effective_to = &t +} + +// EffectiveTo returns the value of the "effective_to" field in the mutation. +func (m *PlanMutation) EffectiveTo() (r time.Time, exists bool) { + v := m.effective_to + if v == nil { + return + } + return *v, true +} + +// OldEffectiveTo returns the old "effective_to" field's value of the Plan entity. +// If the Plan object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanMutation) OldEffectiveTo(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEffectiveTo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEffectiveTo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEffectiveTo: %w", err) + } + return oldValue.EffectiveTo, nil +} + +// ClearEffectiveTo clears the value of the "effective_to" field. +func (m *PlanMutation) ClearEffectiveTo() { + m.effective_to = nil + m.clearedFields[dbplan.FieldEffectiveTo] = struct{}{} +} + +// EffectiveToCleared returns if the "effective_to" field was cleared in this mutation. +func (m *PlanMutation) EffectiveToCleared() bool { + _, ok := m.clearedFields[dbplan.FieldEffectiveTo] + return ok +} + +// ResetEffectiveTo resets all changes to the "effective_to" field. +func (m *PlanMutation) ResetEffectiveTo() { + m.effective_to = nil + delete(m.clearedFields, dbplan.FieldEffectiveTo) +} + +// AddPhaseIDs adds the "phases" edge to the PlanPhase entity by ids. +func (m *PlanMutation) AddPhaseIDs(ids ...string) { + if m.phases == nil { + m.phases = make(map[string]struct{}) + } + for i := range ids { + m.phases[ids[i]] = struct{}{} + } +} + +// ClearPhases clears the "phases" edge to the PlanPhase entity. +func (m *PlanMutation) ClearPhases() { + m.clearedphases = true +} + +// PhasesCleared reports if the "phases" edge to the PlanPhase entity was cleared. +func (m *PlanMutation) PhasesCleared() bool { + return m.clearedphases +} + +// RemovePhaseIDs removes the "phases" edge to the PlanPhase entity by IDs. +func (m *PlanMutation) RemovePhaseIDs(ids ...string) { + if m.removedphases == nil { + m.removedphases = make(map[string]struct{}) + } + for i := range ids { + delete(m.phases, ids[i]) + m.removedphases[ids[i]] = struct{}{} + } +} + +// RemovedPhases returns the removed IDs of the "phases" edge to the PlanPhase entity. +func (m *PlanMutation) RemovedPhasesIDs() (ids []string) { + for id := range m.removedphases { + ids = append(ids, id) + } + return +} + +// PhasesIDs returns the "phases" edge IDs in the mutation. +func (m *PlanMutation) PhasesIDs() (ids []string) { + for id := range m.phases { + ids = append(ids, id) + } + return +} + +// ResetPhases resets all changes to the "phases" edge. +func (m *PlanMutation) ResetPhases() { + m.phases = nil + m.clearedphases = false + m.removedphases = nil +} + +// Where appends a list predicates to the PlanMutation builder. +func (m *PlanMutation) Where(ps ...predicate.Plan) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PlanMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PlanMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Plan, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PlanMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PlanMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Plan). +func (m *PlanMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PlanMutation) Fields() []string { + fields := make([]string, 0, 12) + if m.namespace != nil { + fields = append(fields, dbplan.FieldNamespace) + } + if m.metadata != nil { + fields = append(fields, dbplan.FieldMetadata) + } + if m.created_at != nil { + fields = append(fields, dbplan.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, dbplan.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, dbplan.FieldDeletedAt) + } + if m.name != nil { + fields = append(fields, dbplan.FieldName) + } + if m.description != nil { + fields = append(fields, dbplan.FieldDescription) + } + if m.key != nil { + fields = append(fields, dbplan.FieldKey) + } + if m.version != nil { + fields = append(fields, dbplan.FieldVersion) + } + if m.currency != nil { + fields = append(fields, dbplan.FieldCurrency) + } + if m.effective_from != nil { + fields = append(fields, dbplan.FieldEffectiveFrom) + } + if m.effective_to != nil { + fields = append(fields, dbplan.FieldEffectiveTo) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PlanMutation) Field(name string) (ent.Value, bool) { + switch name { + case dbplan.FieldNamespace: + return m.Namespace() + case dbplan.FieldMetadata: + return m.Metadata() + case dbplan.FieldCreatedAt: + return m.CreatedAt() + case dbplan.FieldUpdatedAt: + return m.UpdatedAt() + case dbplan.FieldDeletedAt: + return m.DeletedAt() + case dbplan.FieldName: + return m.Name() + case dbplan.FieldDescription: + return m.Description() + case dbplan.FieldKey: + return m.Key() + case dbplan.FieldVersion: + return m.Version() + case dbplan.FieldCurrency: + return m.Currency() + case dbplan.FieldEffectiveFrom: + return m.EffectiveFrom() + case dbplan.FieldEffectiveTo: + return m.EffectiveTo() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PlanMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case dbplan.FieldNamespace: + return m.OldNamespace(ctx) + case dbplan.FieldMetadata: + return m.OldMetadata(ctx) + case dbplan.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case dbplan.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case dbplan.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case dbplan.FieldName: + return m.OldName(ctx) + case dbplan.FieldDescription: + return m.OldDescription(ctx) + case dbplan.FieldKey: + return m.OldKey(ctx) + case dbplan.FieldVersion: + return m.OldVersion(ctx) + case dbplan.FieldCurrency: + return m.OldCurrency(ctx) + case dbplan.FieldEffectiveFrom: + return m.OldEffectiveFrom(ctx) + case dbplan.FieldEffectiveTo: + return m.OldEffectiveTo(ctx) + } + return nil, fmt.Errorf("unknown Plan field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PlanMutation) SetField(name string, value ent.Value) error { + switch name { + case dbplan.FieldNamespace: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNamespace(v) + return nil + case dbplan.FieldMetadata: + v, ok := value.(map[string]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMetadata(v) + return nil + case dbplan.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case dbplan.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case dbplan.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case dbplan.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case dbplan.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case dbplan.FieldKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKey(v) + return nil + case dbplan.FieldVersion: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersion(v) + return nil + case dbplan.FieldCurrency: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCurrency(v) + return nil + case dbplan.FieldEffectiveFrom: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEffectiveFrom(v) + return nil + case dbplan.FieldEffectiveTo: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEffectiveTo(v) + return nil + } + return fmt.Errorf("unknown Plan field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PlanMutation) AddedFields() []string { + var fields []string + if m.addversion != nil { + fields = append(fields, dbplan.FieldVersion) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PlanMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case dbplan.FieldVersion: + return m.AddedVersion() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PlanMutation) AddField(name string, value ent.Value) error { + switch name { + case dbplan.FieldVersion: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVersion(v) + return nil + } + return fmt.Errorf("unknown Plan numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PlanMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(dbplan.FieldMetadata) { + fields = append(fields, dbplan.FieldMetadata) + } + if m.FieldCleared(dbplan.FieldDeletedAt) { + fields = append(fields, dbplan.FieldDeletedAt) + } + if m.FieldCleared(dbplan.FieldDescription) { + fields = append(fields, dbplan.FieldDescription) + } + if m.FieldCleared(dbplan.FieldEffectiveFrom) { + fields = append(fields, dbplan.FieldEffectiveFrom) + } + if m.FieldCleared(dbplan.FieldEffectiveTo) { + fields = append(fields, dbplan.FieldEffectiveTo) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PlanMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PlanMutation) ClearField(name string) error { + switch name { + case dbplan.FieldMetadata: + m.ClearMetadata() + return nil + case dbplan.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case dbplan.FieldDescription: + m.ClearDescription() + return nil + case dbplan.FieldEffectiveFrom: + m.ClearEffectiveFrom() + return nil + case dbplan.FieldEffectiveTo: + m.ClearEffectiveTo() + return nil + } + return fmt.Errorf("unknown Plan nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PlanMutation) ResetField(name string) error { + switch name { + case dbplan.FieldNamespace: + m.ResetNamespace() + return nil + case dbplan.FieldMetadata: + m.ResetMetadata() + return nil + case dbplan.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case dbplan.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case dbplan.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case dbplan.FieldName: + m.ResetName() + return nil + case dbplan.FieldDescription: + m.ResetDescription() + return nil + case dbplan.FieldKey: + m.ResetKey() + return nil + case dbplan.FieldVersion: + m.ResetVersion() + return nil + case dbplan.FieldCurrency: + m.ResetCurrency() + return nil + case dbplan.FieldEffectiveFrom: + m.ResetEffectiveFrom() + return nil + case dbplan.FieldEffectiveTo: + m.ResetEffectiveTo() + return nil + } + return fmt.Errorf("unknown Plan field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PlanMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.phases != nil { + edges = append(edges, dbplan.EdgePhases) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PlanMutation) AddedIDs(name string) []ent.Value { + switch name { + case dbplan.EdgePhases: + ids := make([]ent.Value, 0, len(m.phases)) + for id := range m.phases { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PlanMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + if m.removedphases != nil { + edges = append(edges, dbplan.EdgePhases) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PlanMutation) RemovedIDs(name string) []ent.Value { + switch name { + case dbplan.EdgePhases: + ids := make([]ent.Value, 0, len(m.removedphases)) + for id := range m.removedphases { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PlanMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedphases { + edges = append(edges, dbplan.EdgePhases) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PlanMutation) EdgeCleared(name string) bool { + switch name { + case dbplan.EdgePhases: + return m.clearedphases + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PlanMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Plan unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PlanMutation) ResetEdge(name string) error { + switch name { + case dbplan.EdgePhases: + m.ResetPhases() + return nil + } + return fmt.Errorf("unknown Plan edge %s", name) +} + +// PlanPhaseMutation represents an operation that mutates the PlanPhase nodes in the graph. +type PlanPhaseMutation struct { + config + op Op + typ string + id *string + namespace *string + metadata *map[string]string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + name *string + description *string + key *string + start_after *datex.ISOString + discounts *[]plan.Discount + clearedFields map[string]struct{} + plan *string + clearedplan bool + ratecards map[string]struct{} + removedratecards map[string]struct{} + clearedratecards bool + done bool + oldValue func(context.Context) (*PlanPhase, error) + predicates []predicate.PlanPhase +} + +var _ ent.Mutation = (*PlanPhaseMutation)(nil) + +// planphaseOption allows management of the mutation configuration using functional options. +type planphaseOption func(*PlanPhaseMutation) + +// newPlanPhaseMutation creates new mutation for the PlanPhase entity. +func newPlanPhaseMutation(c config, op Op, opts ...planphaseOption) *PlanPhaseMutation { + m := &PlanPhaseMutation{ + config: c, + op: op, + typ: TypePlanPhase, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPlanPhaseID sets the ID field of the mutation. +func withPlanPhaseID(id string) planphaseOption { + return func(m *PlanPhaseMutation) { + var ( + err error + once sync.Once + value *PlanPhase + ) + m.oldValue = func(ctx context.Context) (*PlanPhase, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().PlanPhase.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPlanPhase sets the old PlanPhase of the mutation. +func withPlanPhase(node *PlanPhase) planphaseOption { + return func(m *PlanPhaseMutation) { + m.oldValue = func(context.Context) (*PlanPhase, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PlanPhaseMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PlanPhaseMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of PlanPhase entities. +func (m *PlanPhaseMutation) SetID(id string) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PlanPhaseMutation) ID() (id string, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PlanPhaseMutation) IDs(ctx context.Context) ([]string, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []string{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().PlanPhase.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetNamespace sets the "namespace" field. +func (m *PlanPhaseMutation) SetNamespace(s string) { + m.namespace = &s +} + +// Namespace returns the value of the "namespace" field in the mutation. +func (m *PlanPhaseMutation) Namespace() (r string, exists bool) { + v := m.namespace + if v == nil { + return + } + return *v, true +} + +// OldNamespace returns the old "namespace" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldNamespace(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNamespace is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNamespace requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNamespace: %w", err) + } + return oldValue.Namespace, nil +} + +// ResetNamespace resets all changes to the "namespace" field. +func (m *PlanPhaseMutation) ResetNamespace() { + m.namespace = nil +} + +// SetMetadata sets the "metadata" field. +func (m *PlanPhaseMutation) SetMetadata(value map[string]string) { + m.metadata = &value +} + +// Metadata returns the value of the "metadata" field in the mutation. +func (m *PlanPhaseMutation) Metadata() (r map[string]string, exists bool) { + v := m.metadata + if v == nil { + return + } + return *v, true +} + +// OldMetadata returns the old "metadata" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldMetadata(ctx context.Context) (v map[string]string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMetadata is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMetadata requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMetadata: %w", err) + } + return oldValue.Metadata, nil +} + +// ClearMetadata clears the value of the "metadata" field. +func (m *PlanPhaseMutation) ClearMetadata() { + m.metadata = nil + m.clearedFields[planphase.FieldMetadata] = struct{}{} +} + +// MetadataCleared returns if the "metadata" field was cleared in this mutation. +func (m *PlanPhaseMutation) MetadataCleared() bool { + _, ok := m.clearedFields[planphase.FieldMetadata] + return ok +} + +// ResetMetadata resets all changes to the "metadata" field. +func (m *PlanPhaseMutation) ResetMetadata() { + m.metadata = nil + delete(m.clearedFields, planphase.FieldMetadata) +} + +// SetCreatedAt sets the "created_at" field. +func (m *PlanPhaseMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *PlanPhaseMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *PlanPhaseMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *PlanPhaseMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *PlanPhaseMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *PlanPhaseMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *PlanPhaseMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *PlanPhaseMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *PlanPhaseMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[planphase.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *PlanPhaseMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[planphase.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *PlanPhaseMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, planphase.FieldDeletedAt) +} + +// SetName sets the "name" field. +func (m *PlanPhaseMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *PlanPhaseMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *PlanPhaseMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *PlanPhaseMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *PlanPhaseMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldDescription(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *PlanPhaseMutation) ClearDescription() { + m.description = nil + m.clearedFields[planphase.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *PlanPhaseMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[planphase.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *PlanPhaseMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, planphase.FieldDescription) +} + +// SetKey sets the "key" field. +func (m *PlanPhaseMutation) SetKey(s string) { + m.key = &s +} + +// Key returns the value of the "key" field in the mutation. +func (m *PlanPhaseMutation) Key() (r string, exists bool) { + v := m.key + if v == nil { + return + } + return *v, true +} + +// OldKey returns the old "key" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKey: %w", err) + } + return oldValue.Key, nil +} + +// ResetKey resets all changes to the "key" field. +func (m *PlanPhaseMutation) ResetKey() { + m.key = nil +} + +// SetStartAfter sets the "start_after" field. +func (m *PlanPhaseMutation) SetStartAfter(ds datex.ISOString) { + m.start_after = &ds +} + +// StartAfter returns the value of the "start_after" field in the mutation. +func (m *PlanPhaseMutation) StartAfter() (r datex.ISOString, exists bool) { + v := m.start_after + if v == nil { + return + } + return *v, true +} + +// OldStartAfter returns the old "start_after" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldStartAfter(ctx context.Context) (v datex.ISOString, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStartAfter is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStartAfter requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStartAfter: %w", err) + } + return oldValue.StartAfter, nil +} + +// ResetStartAfter resets all changes to the "start_after" field. +func (m *PlanPhaseMutation) ResetStartAfter() { + m.start_after = nil +} + +// SetDiscounts sets the "discounts" field. +func (m *PlanPhaseMutation) SetDiscounts(pl []plan.Discount) { + m.discounts = &pl +} + +// Discounts returns the value of the "discounts" field in the mutation. +func (m *PlanPhaseMutation) Discounts() (r []plan.Discount, exists bool) { + v := m.discounts + if v == nil { + return + } + return *v, true +} + +// OldDiscounts returns the old "discounts" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldDiscounts(ctx context.Context) (v []plan.Discount, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDiscounts is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDiscounts requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDiscounts: %w", err) + } + return oldValue.Discounts, nil +} + +// ClearDiscounts clears the value of the "discounts" field. +func (m *PlanPhaseMutation) ClearDiscounts() { + m.discounts = nil + m.clearedFields[planphase.FieldDiscounts] = struct{}{} +} + +// DiscountsCleared returns if the "discounts" field was cleared in this mutation. +func (m *PlanPhaseMutation) DiscountsCleared() bool { + _, ok := m.clearedFields[planphase.FieldDiscounts] + return ok +} + +// ResetDiscounts resets all changes to the "discounts" field. +func (m *PlanPhaseMutation) ResetDiscounts() { + m.discounts = nil + delete(m.clearedFields, planphase.FieldDiscounts) +} + +// SetPlanID sets the "plan_id" field. +func (m *PlanPhaseMutation) SetPlanID(s string) { + m.plan = &s +} + +// PlanID returns the value of the "plan_id" field in the mutation. +func (m *PlanPhaseMutation) PlanID() (r string, exists bool) { + v := m.plan + if v == nil { + return + } + return *v, true +} + +// OldPlanID returns the old "plan_id" field's value of the PlanPhase entity. +// If the PlanPhase object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanPhaseMutation) OldPlanID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPlanID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPlanID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPlanID: %w", err) + } + return oldValue.PlanID, nil +} + +// ResetPlanID resets all changes to the "plan_id" field. +func (m *PlanPhaseMutation) ResetPlanID() { + m.plan = nil +} + +// ClearPlan clears the "plan" edge to the Plan entity. +func (m *PlanPhaseMutation) ClearPlan() { + m.clearedplan = true + m.clearedFields[planphase.FieldPlanID] = struct{}{} +} + +// PlanCleared reports if the "plan" edge to the Plan entity was cleared. +func (m *PlanPhaseMutation) PlanCleared() bool { + return m.clearedplan +} + +// PlanIDs returns the "plan" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PlanID instead. It exists only for internal usage by the builders. +func (m *PlanPhaseMutation) PlanIDs() (ids []string) { + if id := m.plan; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetPlan resets all changes to the "plan" edge. +func (m *PlanPhaseMutation) ResetPlan() { + m.plan = nil + m.clearedplan = false +} + +// AddRatecardIDs adds the "ratecards" edge to the PlanRateCard entity by ids. +func (m *PlanPhaseMutation) AddRatecardIDs(ids ...string) { + if m.ratecards == nil { + m.ratecards = make(map[string]struct{}) + } + for i := range ids { + m.ratecards[ids[i]] = struct{}{} + } +} + +// ClearRatecards clears the "ratecards" edge to the PlanRateCard entity. +func (m *PlanPhaseMutation) ClearRatecards() { + m.clearedratecards = true +} + +// RatecardsCleared reports if the "ratecards" edge to the PlanRateCard entity was cleared. +func (m *PlanPhaseMutation) RatecardsCleared() bool { + return m.clearedratecards +} + +// RemoveRatecardIDs removes the "ratecards" edge to the PlanRateCard entity by IDs. +func (m *PlanPhaseMutation) RemoveRatecardIDs(ids ...string) { + if m.removedratecards == nil { + m.removedratecards = make(map[string]struct{}) + } + for i := range ids { + delete(m.ratecards, ids[i]) + m.removedratecards[ids[i]] = struct{}{} + } +} + +// RemovedRatecards returns the removed IDs of the "ratecards" edge to the PlanRateCard entity. +func (m *PlanPhaseMutation) RemovedRatecardsIDs() (ids []string) { + for id := range m.removedratecards { + ids = append(ids, id) + } + return +} + +// RatecardsIDs returns the "ratecards" edge IDs in the mutation. +func (m *PlanPhaseMutation) RatecardsIDs() (ids []string) { + for id := range m.ratecards { + ids = append(ids, id) + } + return +} + +// ResetRatecards resets all changes to the "ratecards" edge. +func (m *PlanPhaseMutation) ResetRatecards() { + m.ratecards = nil + m.clearedratecards = false + m.removedratecards = nil +} + +// Where appends a list predicates to the PlanPhaseMutation builder. +func (m *PlanPhaseMutation) Where(ps ...predicate.PlanPhase) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PlanPhaseMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PlanPhaseMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PlanPhase, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PlanPhaseMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PlanPhaseMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (PlanPhase). +func (m *PlanPhaseMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PlanPhaseMutation) Fields() []string { + fields := make([]string, 0, 11) + if m.namespace != nil { + fields = append(fields, planphase.FieldNamespace) + } + if m.metadata != nil { + fields = append(fields, planphase.FieldMetadata) + } + if m.created_at != nil { + fields = append(fields, planphase.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, planphase.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, planphase.FieldDeletedAt) + } + if m.name != nil { + fields = append(fields, planphase.FieldName) + } + if m.description != nil { + fields = append(fields, planphase.FieldDescription) + } + if m.key != nil { + fields = append(fields, planphase.FieldKey) + } + if m.start_after != nil { + fields = append(fields, planphase.FieldStartAfter) + } + if m.discounts != nil { + fields = append(fields, planphase.FieldDiscounts) + } + if m.plan != nil { + fields = append(fields, planphase.FieldPlanID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PlanPhaseMutation) Field(name string) (ent.Value, bool) { + switch name { + case planphase.FieldNamespace: + return m.Namespace() + case planphase.FieldMetadata: + return m.Metadata() + case planphase.FieldCreatedAt: + return m.CreatedAt() + case planphase.FieldUpdatedAt: + return m.UpdatedAt() + case planphase.FieldDeletedAt: + return m.DeletedAt() + case planphase.FieldName: + return m.Name() + case planphase.FieldDescription: + return m.Description() + case planphase.FieldKey: + return m.Key() + case planphase.FieldStartAfter: + return m.StartAfter() + case planphase.FieldDiscounts: + return m.Discounts() + case planphase.FieldPlanID: + return m.PlanID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PlanPhaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case planphase.FieldNamespace: + return m.OldNamespace(ctx) + case planphase.FieldMetadata: + return m.OldMetadata(ctx) + case planphase.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case planphase.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case planphase.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case planphase.FieldName: + return m.OldName(ctx) + case planphase.FieldDescription: + return m.OldDescription(ctx) + case planphase.FieldKey: + return m.OldKey(ctx) + case planphase.FieldStartAfter: + return m.OldStartAfter(ctx) + case planphase.FieldDiscounts: + return m.OldDiscounts(ctx) + case planphase.FieldPlanID: + return m.OldPlanID(ctx) + } + return nil, fmt.Errorf("unknown PlanPhase field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PlanPhaseMutation) SetField(name string, value ent.Value) error { + switch name { + case planphase.FieldNamespace: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNamespace(v) + return nil + case planphase.FieldMetadata: + v, ok := value.(map[string]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMetadata(v) + return nil + case planphase.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case planphase.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case planphase.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case planphase.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case planphase.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case planphase.FieldKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKey(v) + return nil + case planphase.FieldStartAfter: + v, ok := value.(datex.ISOString) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStartAfter(v) + return nil + case planphase.FieldDiscounts: + v, ok := value.([]plan.Discount) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDiscounts(v) + return nil + case planphase.FieldPlanID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPlanID(v) + return nil + } + return fmt.Errorf("unknown PlanPhase field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PlanPhaseMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PlanPhaseMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PlanPhaseMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown PlanPhase numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PlanPhaseMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(planphase.FieldMetadata) { + fields = append(fields, planphase.FieldMetadata) + } + if m.FieldCleared(planphase.FieldDeletedAt) { + fields = append(fields, planphase.FieldDeletedAt) + } + if m.FieldCleared(planphase.FieldDescription) { + fields = append(fields, planphase.FieldDescription) + } + if m.FieldCleared(planphase.FieldDiscounts) { + fields = append(fields, planphase.FieldDiscounts) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PlanPhaseMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PlanPhaseMutation) ClearField(name string) error { + switch name { + case planphase.FieldMetadata: + m.ClearMetadata() + return nil + case planphase.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case planphase.FieldDescription: + m.ClearDescription() + return nil + case planphase.FieldDiscounts: + m.ClearDiscounts() + return nil + } + return fmt.Errorf("unknown PlanPhase nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PlanPhaseMutation) ResetField(name string) error { + switch name { + case planphase.FieldNamespace: + m.ResetNamespace() + return nil + case planphase.FieldMetadata: + m.ResetMetadata() + return nil + case planphase.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case planphase.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case planphase.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case planphase.FieldName: + m.ResetName() + return nil + case planphase.FieldDescription: + m.ResetDescription() + return nil + case planphase.FieldKey: + m.ResetKey() + return nil + case planphase.FieldStartAfter: + m.ResetStartAfter() + return nil + case planphase.FieldDiscounts: + m.ResetDiscounts() + return nil + case planphase.FieldPlanID: + m.ResetPlanID() + return nil + } + return fmt.Errorf("unknown PlanPhase field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PlanPhaseMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.plan != nil { + edges = append(edges, planphase.EdgePlan) + } + if m.ratecards != nil { + edges = append(edges, planphase.EdgeRatecards) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PlanPhaseMutation) AddedIDs(name string) []ent.Value { + switch name { + case planphase.EdgePlan: + if id := m.plan; id != nil { + return []ent.Value{*id} + } + case planphase.EdgeRatecards: + ids := make([]ent.Value, 0, len(m.ratecards)) + for id := range m.ratecards { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PlanPhaseMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedratecards != nil { + edges = append(edges, planphase.EdgeRatecards) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PlanPhaseMutation) RemovedIDs(name string) []ent.Value { + switch name { + case planphase.EdgeRatecards: + ids := make([]ent.Value, 0, len(m.removedratecards)) + for id := range m.removedratecards { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PlanPhaseMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedplan { + edges = append(edges, planphase.EdgePlan) + } + if m.clearedratecards { + edges = append(edges, planphase.EdgeRatecards) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PlanPhaseMutation) EdgeCleared(name string) bool { + switch name { + case planphase.EdgePlan: + return m.clearedplan + case planphase.EdgeRatecards: + return m.clearedratecards + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PlanPhaseMutation) ClearEdge(name string) error { + switch name { + case planphase.EdgePlan: + m.ClearPlan() + return nil + } + return fmt.Errorf("unknown PlanPhase unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PlanPhaseMutation) ResetEdge(name string) error { + switch name { + case planphase.EdgePlan: + m.ResetPlan() + return nil + case planphase.EdgeRatecards: + m.ResetRatecards() + return nil + } + return fmt.Errorf("unknown PlanPhase edge %s", name) +} + +// PlanRateCardMutation represents an operation that mutates the PlanRateCard nodes in the graph. +type PlanRateCardMutation struct { + config + op Op + typ string + id *string + namespace *string + metadata *map[string]string + created_at *time.Time + updated_at *time.Time + deleted_at *time.Time + name *string + description *string + key *string + _type *plan.RateCardType + feature_key *string + entitlement_template **plan.EntitlementTemplate + tax_config **plan.TaxConfig + billing_cadence *datex.ISOString + price **plan.Price + clearedFields map[string]struct{} + phase *string + clearedphase bool + features *string + clearedfeatures bool + done bool + oldValue func(context.Context) (*PlanRateCard, error) + predicates []predicate.PlanRateCard +} + +var _ ent.Mutation = (*PlanRateCardMutation)(nil) + +// planratecardOption allows management of the mutation configuration using functional options. +type planratecardOption func(*PlanRateCardMutation) + +// newPlanRateCardMutation creates new mutation for the PlanRateCard entity. +func newPlanRateCardMutation(c config, op Op, opts ...planratecardOption) *PlanRateCardMutation { + m := &PlanRateCardMutation{ + config: c, + op: op, + typ: TypePlanRateCard, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPlanRateCardID sets the ID field of the mutation. +func withPlanRateCardID(id string) planratecardOption { + return func(m *PlanRateCardMutation) { + var ( + err error + once sync.Once + value *PlanRateCard + ) + m.oldValue = func(ctx context.Context) (*PlanRateCard, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().PlanRateCard.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPlanRateCard sets the old PlanRateCard of the mutation. +func withPlanRateCard(node *PlanRateCard) planratecardOption { + return func(m *PlanRateCardMutation) { + m.oldValue = func(context.Context) (*PlanRateCard, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PlanRateCardMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PlanRateCardMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("db: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of PlanRateCard entities. +func (m *PlanRateCardMutation) SetID(id string) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PlanRateCardMutation) ID() (id string, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PlanRateCardMutation) IDs(ctx context.Context) ([]string, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []string{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().PlanRateCard.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetNamespace sets the "namespace" field. +func (m *PlanRateCardMutation) SetNamespace(s string) { + m.namespace = &s +} + +// Namespace returns the value of the "namespace" field in the mutation. +func (m *PlanRateCardMutation) Namespace() (r string, exists bool) { + v := m.namespace + if v == nil { + return + } + return *v, true +} + +// OldNamespace returns the old "namespace" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldNamespace(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNamespace is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNamespace requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNamespace: %w", err) + } + return oldValue.Namespace, nil +} + +// ResetNamespace resets all changes to the "namespace" field. +func (m *PlanRateCardMutation) ResetNamespace() { + m.namespace = nil +} + +// SetMetadata sets the "metadata" field. +func (m *PlanRateCardMutation) SetMetadata(value map[string]string) { + m.metadata = &value +} + +// Metadata returns the value of the "metadata" field in the mutation. +func (m *PlanRateCardMutation) Metadata() (r map[string]string, exists bool) { + v := m.metadata + if v == nil { + return + } + return *v, true +} + +// OldMetadata returns the old "metadata" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldMetadata(ctx context.Context) (v map[string]string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMetadata is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMetadata requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMetadata: %w", err) + } + return oldValue.Metadata, nil +} + +// ClearMetadata clears the value of the "metadata" field. +func (m *PlanRateCardMutation) ClearMetadata() { + m.metadata = nil + m.clearedFields[planratecard.FieldMetadata] = struct{}{} +} + +// MetadataCleared returns if the "metadata" field was cleared in this mutation. +func (m *PlanRateCardMutation) MetadataCleared() bool { + _, ok := m.clearedFields[planratecard.FieldMetadata] + return ok +} + +// ResetMetadata resets all changes to the "metadata" field. +func (m *PlanRateCardMutation) ResetMetadata() { + m.metadata = nil + delete(m.clearedFields, planratecard.FieldMetadata) +} + +// SetCreatedAt sets the "created_at" field. +func (m *PlanRateCardMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *PlanRateCardMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *PlanRateCardMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *PlanRateCardMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *PlanRateCardMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *PlanRateCardMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *PlanRateCardMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *PlanRateCardMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *PlanRateCardMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[planratecard.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *PlanRateCardMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[planratecard.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *PlanRateCardMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, planratecard.FieldDeletedAt) +} + +// SetName sets the "name" field. +func (m *PlanRateCardMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *PlanRateCardMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *PlanRateCardMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *PlanRateCardMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *PlanRateCardMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldDescription(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *PlanRateCardMutation) ClearDescription() { + m.description = nil + m.clearedFields[planratecard.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *PlanRateCardMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[planratecard.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *PlanRateCardMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, planratecard.FieldDescription) +} + +// SetKey sets the "key" field. +func (m *PlanRateCardMutation) SetKey(s string) { + m.key = &s +} + +// Key returns the value of the "key" field in the mutation. +func (m *PlanRateCardMutation) Key() (r string, exists bool) { + v := m.key + if v == nil { + return + } + return *v, true +} + +// OldKey returns the old "key" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKey: %w", err) + } + return oldValue.Key, nil +} + +// ResetKey resets all changes to the "key" field. +func (m *PlanRateCardMutation) ResetKey() { + m.key = nil +} + +// SetType sets the "type" field. +func (m *PlanRateCardMutation) SetType(pct plan.RateCardType) { + m._type = &pct +} + +// GetType returns the value of the "type" field in the mutation. +func (m *PlanRateCardMutation) GetType() (r plan.RateCardType, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldType(ctx context.Context) (v plan.RateCardType, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *PlanRateCardMutation) ResetType() { + m._type = nil +} + +// SetFeatureKey sets the "feature_key" field. +func (m *PlanRateCardMutation) SetFeatureKey(s string) { + m.feature_key = &s +} + +// FeatureKey returns the value of the "feature_key" field in the mutation. +func (m *PlanRateCardMutation) FeatureKey() (r string, exists bool) { + v := m.feature_key + if v == nil { + return + } + return *v, true +} + +// OldFeatureKey returns the old "feature_key" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldFeatureKey(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFeatureKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFeatureKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFeatureKey: %w", err) + } + return oldValue.FeatureKey, nil +} + +// ClearFeatureKey clears the value of the "feature_key" field. +func (m *PlanRateCardMutation) ClearFeatureKey() { + m.feature_key = nil + m.clearedFields[planratecard.FieldFeatureKey] = struct{}{} +} + +// FeatureKeyCleared returns if the "feature_key" field was cleared in this mutation. +func (m *PlanRateCardMutation) FeatureKeyCleared() bool { + _, ok := m.clearedFields[planratecard.FieldFeatureKey] + return ok +} + +// ResetFeatureKey resets all changes to the "feature_key" field. +func (m *PlanRateCardMutation) ResetFeatureKey() { + m.feature_key = nil + delete(m.clearedFields, planratecard.FieldFeatureKey) +} + +// SetEntitlementTemplate sets the "entitlement_template" field. +func (m *PlanRateCardMutation) SetEntitlementTemplate(pt *plan.EntitlementTemplate) { + m.entitlement_template = &pt +} + +// EntitlementTemplate returns the value of the "entitlement_template" field in the mutation. +func (m *PlanRateCardMutation) EntitlementTemplate() (r *plan.EntitlementTemplate, exists bool) { + v := m.entitlement_template + if v == nil { + return + } + return *v, true +} + +// OldEntitlementTemplate returns the old "entitlement_template" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldEntitlementTemplate(ctx context.Context) (v *plan.EntitlementTemplate, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEntitlementTemplate is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEntitlementTemplate requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEntitlementTemplate: %w", err) + } + return oldValue.EntitlementTemplate, nil +} + +// ClearEntitlementTemplate clears the value of the "entitlement_template" field. +func (m *PlanRateCardMutation) ClearEntitlementTemplate() { + m.entitlement_template = nil + m.clearedFields[planratecard.FieldEntitlementTemplate] = struct{}{} +} + +// EntitlementTemplateCleared returns if the "entitlement_template" field was cleared in this mutation. +func (m *PlanRateCardMutation) EntitlementTemplateCleared() bool { + _, ok := m.clearedFields[planratecard.FieldEntitlementTemplate] + return ok +} + +// ResetEntitlementTemplate resets all changes to the "entitlement_template" field. +func (m *PlanRateCardMutation) ResetEntitlementTemplate() { + m.entitlement_template = nil + delete(m.clearedFields, planratecard.FieldEntitlementTemplate) +} + +// SetTaxConfig sets the "tax_config" field. +func (m *PlanRateCardMutation) SetTaxConfig(pc *plan.TaxConfig) { + m.tax_config = &pc +} + +// TaxConfig returns the value of the "tax_config" field in the mutation. +func (m *PlanRateCardMutation) TaxConfig() (r *plan.TaxConfig, exists bool) { + v := m.tax_config + if v == nil { + return + } + return *v, true +} + +// OldTaxConfig returns the old "tax_config" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldTaxConfig(ctx context.Context) (v *plan.TaxConfig, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTaxConfig is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTaxConfig requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTaxConfig: %w", err) + } + return oldValue.TaxConfig, nil +} + +// ClearTaxConfig clears the value of the "tax_config" field. +func (m *PlanRateCardMutation) ClearTaxConfig() { + m.tax_config = nil + m.clearedFields[planratecard.FieldTaxConfig] = struct{}{} +} + +// TaxConfigCleared returns if the "tax_config" field was cleared in this mutation. +func (m *PlanRateCardMutation) TaxConfigCleared() bool { + _, ok := m.clearedFields[planratecard.FieldTaxConfig] + return ok +} + +// ResetTaxConfig resets all changes to the "tax_config" field. +func (m *PlanRateCardMutation) ResetTaxConfig() { + m.tax_config = nil + delete(m.clearedFields, planratecard.FieldTaxConfig) +} + +// SetBillingCadence sets the "billing_cadence" field. +func (m *PlanRateCardMutation) SetBillingCadence(ds datex.ISOString) { + m.billing_cadence = &ds +} + +// BillingCadence returns the value of the "billing_cadence" field in the mutation. +func (m *PlanRateCardMutation) BillingCadence() (r datex.ISOString, exists bool) { + v := m.billing_cadence + if v == nil { + return + } + return *v, true +} + +// OldBillingCadence returns the old "billing_cadence" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldBillingCadence(ctx context.Context) (v *datex.ISOString, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBillingCadence is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBillingCadence requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBillingCadence: %w", err) + } + return oldValue.BillingCadence, nil +} + +// ClearBillingCadence clears the value of the "billing_cadence" field. +func (m *PlanRateCardMutation) ClearBillingCadence() { + m.billing_cadence = nil + m.clearedFields[planratecard.FieldBillingCadence] = struct{}{} +} + +// BillingCadenceCleared returns if the "billing_cadence" field was cleared in this mutation. +func (m *PlanRateCardMutation) BillingCadenceCleared() bool { + _, ok := m.clearedFields[planratecard.FieldBillingCadence] + return ok +} + +// ResetBillingCadence resets all changes to the "billing_cadence" field. +func (m *PlanRateCardMutation) ResetBillingCadence() { + m.billing_cadence = nil + delete(m.clearedFields, planratecard.FieldBillingCadence) +} + +// SetPrice sets the "price" field. +func (m *PlanRateCardMutation) SetPrice(pl *plan.Price) { + m.price = &pl +} + +// Price returns the value of the "price" field in the mutation. +func (m *PlanRateCardMutation) Price() (r *plan.Price, exists bool) { + v := m.price + if v == nil { + return + } + return *v, true +} + +// OldPrice returns the old "price" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldPrice(ctx context.Context) (v *plan.Price, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPrice is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPrice requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPrice: %w", err) + } + return oldValue.Price, nil +} + +// ClearPrice clears the value of the "price" field. +func (m *PlanRateCardMutation) ClearPrice() { + m.price = nil + m.clearedFields[planratecard.FieldPrice] = struct{}{} +} + +// PriceCleared returns if the "price" field was cleared in this mutation. +func (m *PlanRateCardMutation) PriceCleared() bool { + _, ok := m.clearedFields[planratecard.FieldPrice] + return ok +} + +// ResetPrice resets all changes to the "price" field. +func (m *PlanRateCardMutation) ResetPrice() { + m.price = nil + delete(m.clearedFields, planratecard.FieldPrice) +} + +// SetPhaseID sets the "phase_id" field. +func (m *PlanRateCardMutation) SetPhaseID(s string) { + m.phase = &s +} + +// PhaseID returns the value of the "phase_id" field in the mutation. +func (m *PlanRateCardMutation) PhaseID() (r string, exists bool) { + v := m.phase + if v == nil { + return + } + return *v, true +} + +// OldPhaseID returns the old "phase_id" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldPhaseID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPhaseID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPhaseID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPhaseID: %w", err) + } + return oldValue.PhaseID, nil +} + +// ResetPhaseID resets all changes to the "phase_id" field. +func (m *PlanRateCardMutation) ResetPhaseID() { + m.phase = nil +} + +// SetFeatureID sets the "feature_id" field. +func (m *PlanRateCardMutation) SetFeatureID(s string) { + m.features = &s +} + +// FeatureID returns the value of the "feature_id" field in the mutation. +func (m *PlanRateCardMutation) FeatureID() (r string, exists bool) { + v := m.features + if v == nil { + return + } + return *v, true +} + +// OldFeatureID returns the old "feature_id" field's value of the PlanRateCard entity. +// If the PlanRateCard object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PlanRateCardMutation) OldFeatureID(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFeatureID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFeatureID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFeatureID: %w", err) + } + return oldValue.FeatureID, nil +} + +// ClearFeatureID clears the value of the "feature_id" field. +func (m *PlanRateCardMutation) ClearFeatureID() { + m.features = nil + m.clearedFields[planratecard.FieldFeatureID] = struct{}{} +} + +// FeatureIDCleared returns if the "feature_id" field was cleared in this mutation. +func (m *PlanRateCardMutation) FeatureIDCleared() bool { + _, ok := m.clearedFields[planratecard.FieldFeatureID] + return ok +} + +// ResetFeatureID resets all changes to the "feature_id" field. +func (m *PlanRateCardMutation) ResetFeatureID() { + m.features = nil + delete(m.clearedFields, planratecard.FieldFeatureID) +} + +// ClearPhase clears the "phase" edge to the PlanPhase entity. +func (m *PlanRateCardMutation) ClearPhase() { + m.clearedphase = true + m.clearedFields[planratecard.FieldPhaseID] = struct{}{} +} + +// PhaseCleared reports if the "phase" edge to the PlanPhase entity was cleared. +func (m *PlanRateCardMutation) PhaseCleared() bool { + return m.clearedphase +} + +// PhaseIDs returns the "phase" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PhaseID instead. It exists only for internal usage by the builders. +func (m *PlanRateCardMutation) PhaseIDs() (ids []string) { + if id := m.phase; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetPhase resets all changes to the "phase" edge. +func (m *PlanRateCardMutation) ResetPhase() { + m.phase = nil + m.clearedphase = false +} + +// SetFeaturesID sets the "features" edge to the Feature entity by id. +func (m *PlanRateCardMutation) SetFeaturesID(id string) { + m.features = &id +} + +// ClearFeatures clears the "features" edge to the Feature entity. +func (m *PlanRateCardMutation) ClearFeatures() { + m.clearedfeatures = true + m.clearedFields[planratecard.FieldFeatureID] = struct{}{} +} + +// FeaturesCleared reports if the "features" edge to the Feature entity was cleared. +func (m *PlanRateCardMutation) FeaturesCleared() bool { + return m.FeatureIDCleared() || m.clearedfeatures +} + +// FeaturesID returns the "features" edge ID in the mutation. +func (m *PlanRateCardMutation) FeaturesID() (id string, exists bool) { + if m.features != nil { + return *m.features, true + } + return +} + +// FeaturesIDs returns the "features" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// FeaturesID instead. It exists only for internal usage by the builders. +func (m *PlanRateCardMutation) FeaturesIDs() (ids []string) { + if id := m.features; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetFeatures resets all changes to the "features" edge. +func (m *PlanRateCardMutation) ResetFeatures() { + m.features = nil + m.clearedfeatures = false +} + +// Where appends a list predicates to the PlanRateCardMutation builder. +func (m *PlanRateCardMutation) Where(ps ...predicate.PlanRateCard) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PlanRateCardMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PlanRateCardMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PlanRateCard, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PlanRateCardMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PlanRateCardMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (PlanRateCard). +func (m *PlanRateCardMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PlanRateCardMutation) Fields() []string { + fields := make([]string, 0, 16) + if m.namespace != nil { + fields = append(fields, planratecard.FieldNamespace) + } + if m.metadata != nil { + fields = append(fields, planratecard.FieldMetadata) + } + if m.created_at != nil { + fields = append(fields, planratecard.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, planratecard.FieldUpdatedAt) + } + if m.deleted_at != nil { + fields = append(fields, planratecard.FieldDeletedAt) + } + if m.name != nil { + fields = append(fields, planratecard.FieldName) + } + if m.description != nil { + fields = append(fields, planratecard.FieldDescription) + } + if m.key != nil { + fields = append(fields, planratecard.FieldKey) + } + if m._type != nil { + fields = append(fields, planratecard.FieldType) + } + if m.feature_key != nil { + fields = append(fields, planratecard.FieldFeatureKey) + } + if m.entitlement_template != nil { + fields = append(fields, planratecard.FieldEntitlementTemplate) + } + if m.tax_config != nil { + fields = append(fields, planratecard.FieldTaxConfig) + } + if m.billing_cadence != nil { + fields = append(fields, planratecard.FieldBillingCadence) + } + if m.price != nil { + fields = append(fields, planratecard.FieldPrice) + } + if m.phase != nil { + fields = append(fields, planratecard.FieldPhaseID) + } + if m.features != nil { + fields = append(fields, planratecard.FieldFeatureID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PlanRateCardMutation) Field(name string) (ent.Value, bool) { + switch name { + case planratecard.FieldNamespace: + return m.Namespace() + case planratecard.FieldMetadata: + return m.Metadata() + case planratecard.FieldCreatedAt: + return m.CreatedAt() + case planratecard.FieldUpdatedAt: + return m.UpdatedAt() + case planratecard.FieldDeletedAt: + return m.DeletedAt() + case planratecard.FieldName: + return m.Name() + case planratecard.FieldDescription: + return m.Description() + case planratecard.FieldKey: + return m.Key() + case planratecard.FieldType: + return m.GetType() + case planratecard.FieldFeatureKey: + return m.FeatureKey() + case planratecard.FieldEntitlementTemplate: + return m.EntitlementTemplate() + case planratecard.FieldTaxConfig: + return m.TaxConfig() + case planratecard.FieldBillingCadence: + return m.BillingCadence() + case planratecard.FieldPrice: + return m.Price() + case planratecard.FieldPhaseID: + return m.PhaseID() + case planratecard.FieldFeatureID: + return m.FeatureID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PlanRateCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case planratecard.FieldNamespace: + return m.OldNamespace(ctx) + case planratecard.FieldMetadata: + return m.OldMetadata(ctx) + case planratecard.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case planratecard.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case planratecard.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case planratecard.FieldName: + return m.OldName(ctx) + case planratecard.FieldDescription: + return m.OldDescription(ctx) + case planratecard.FieldKey: + return m.OldKey(ctx) + case planratecard.FieldType: + return m.OldType(ctx) + case planratecard.FieldFeatureKey: + return m.OldFeatureKey(ctx) + case planratecard.FieldEntitlementTemplate: + return m.OldEntitlementTemplate(ctx) + case planratecard.FieldTaxConfig: + return m.OldTaxConfig(ctx) + case planratecard.FieldBillingCadence: + return m.OldBillingCadence(ctx) + case planratecard.FieldPrice: + return m.OldPrice(ctx) + case planratecard.FieldPhaseID: + return m.OldPhaseID(ctx) + case planratecard.FieldFeatureID: + return m.OldFeatureID(ctx) + } + return nil, fmt.Errorf("unknown PlanRateCard field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PlanRateCardMutation) SetField(name string, value ent.Value) error { + switch name { + case planratecard.FieldNamespace: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNamespace(v) + return nil + case planratecard.FieldMetadata: + v, ok := value.(map[string]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMetadata(v) + return nil + case planratecard.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case planratecard.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case planratecard.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case planratecard.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case planratecard.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case planratecard.FieldKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKey(v) + return nil + case planratecard.FieldType: + v, ok := value.(plan.RateCardType) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case planratecard.FieldFeatureKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFeatureKey(v) + return nil + case planratecard.FieldEntitlementTemplate: + v, ok := value.(*plan.EntitlementTemplate) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEntitlementTemplate(v) + return nil + case planratecard.FieldTaxConfig: + v, ok := value.(*plan.TaxConfig) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTaxConfig(v) + return nil + case planratecard.FieldBillingCadence: + v, ok := value.(datex.ISOString) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBillingCadence(v) + return nil + case planratecard.FieldPrice: + v, ok := value.(*plan.Price) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPrice(v) + return nil + case planratecard.FieldPhaseID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPhaseID(v) + return nil + case planratecard.FieldFeatureID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFeatureID(v) + return nil + } + return fmt.Errorf("unknown PlanRateCard field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PlanRateCardMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PlanRateCardMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PlanRateCardMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown PlanRateCard numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PlanRateCardMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(planratecard.FieldMetadata) { + fields = append(fields, planratecard.FieldMetadata) + } + if m.FieldCleared(planratecard.FieldDeletedAt) { + fields = append(fields, planratecard.FieldDeletedAt) + } + if m.FieldCleared(planratecard.FieldDescription) { + fields = append(fields, planratecard.FieldDescription) + } + if m.FieldCleared(planratecard.FieldFeatureKey) { + fields = append(fields, planratecard.FieldFeatureKey) + } + if m.FieldCleared(planratecard.FieldEntitlementTemplate) { + fields = append(fields, planratecard.FieldEntitlementTemplate) + } + if m.FieldCleared(planratecard.FieldTaxConfig) { + fields = append(fields, planratecard.FieldTaxConfig) + } + if m.FieldCleared(planratecard.FieldBillingCadence) { + fields = append(fields, planratecard.FieldBillingCadence) + } + if m.FieldCleared(planratecard.FieldPrice) { + fields = append(fields, planratecard.FieldPrice) + } + if m.FieldCleared(planratecard.FieldFeatureID) { + fields = append(fields, planratecard.FieldFeatureID) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PlanRateCardMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PlanRateCardMutation) ClearField(name string) error { + switch name { + case planratecard.FieldMetadata: + m.ClearMetadata() + return nil + case planratecard.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case planratecard.FieldDescription: + m.ClearDescription() + return nil + case planratecard.FieldFeatureKey: + m.ClearFeatureKey() + return nil + case planratecard.FieldEntitlementTemplate: + m.ClearEntitlementTemplate() + return nil + case planratecard.FieldTaxConfig: + m.ClearTaxConfig() + return nil + case planratecard.FieldBillingCadence: + m.ClearBillingCadence() + return nil + case planratecard.FieldPrice: + m.ClearPrice() + return nil + case planratecard.FieldFeatureID: + m.ClearFeatureID() + return nil + } + return fmt.Errorf("unknown PlanRateCard nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PlanRateCardMutation) ResetField(name string) error { + switch name { + case planratecard.FieldNamespace: + m.ResetNamespace() + return nil + case planratecard.FieldMetadata: + m.ResetMetadata() + return nil + case planratecard.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case planratecard.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case planratecard.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case planratecard.FieldName: + m.ResetName() + return nil + case planratecard.FieldDescription: + m.ResetDescription() + return nil + case planratecard.FieldKey: + m.ResetKey() + return nil + case planratecard.FieldType: + m.ResetType() + return nil + case planratecard.FieldFeatureKey: + m.ResetFeatureKey() + return nil + case planratecard.FieldEntitlementTemplate: + m.ResetEntitlementTemplate() + return nil + case planratecard.FieldTaxConfig: + m.ResetTaxConfig() + return nil + case planratecard.FieldBillingCadence: + m.ResetBillingCadence() + return nil + case planratecard.FieldPrice: + m.ResetPrice() + return nil + case planratecard.FieldPhaseID: + m.ResetPhaseID() + return nil + case planratecard.FieldFeatureID: + m.ResetFeatureID() + return nil + } + return fmt.Errorf("unknown PlanRateCard field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PlanRateCardMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.phase != nil { + edges = append(edges, planratecard.EdgePhase) + } + if m.features != nil { + edges = append(edges, planratecard.EdgeFeatures) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PlanRateCardMutation) AddedIDs(name string) []ent.Value { + switch name { + case planratecard.EdgePhase: + if id := m.phase; id != nil { + return []ent.Value{*id} + } + case planratecard.EdgeFeatures: + if id := m.features; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PlanRateCardMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PlanRateCardMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PlanRateCardMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedphase { + edges = append(edges, planratecard.EdgePhase) + } + if m.clearedfeatures { + edges = append(edges, planratecard.EdgeFeatures) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PlanRateCardMutation) EdgeCleared(name string) bool { + switch name { + case planratecard.EdgePhase: + return m.clearedphase + case planratecard.EdgeFeatures: + return m.clearedfeatures + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PlanRateCardMutation) ClearEdge(name string) error { + switch name { + case planratecard.EdgePhase: + m.ClearPhase() + return nil + case planratecard.EdgeFeatures: + m.ClearFeatures() + return nil + } + return fmt.Errorf("unknown PlanRateCard unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PlanRateCardMutation) ResetEdge(name string) error { + switch name { + case planratecard.EdgePhase: + m.ResetPhase() + return nil + case planratecard.EdgeFeatures: + m.ResetFeatures() + return nil + } + return fmt.Errorf("unknown PlanRateCard edge %s", name) +} + // UsageResetMutation represents an operation that mutates the UsageReset nodes in the graph. type UsageResetMutation struct { config diff --git a/openmeter/ent/db/paginate.go b/openmeter/ent/db/paginate.go index e04fd60fc..cba1e85ec 100644 --- a/openmeter/ent/db/paginate.go +++ b/openmeter/ent/db/paginate.go @@ -1017,6 +1017,150 @@ func (nr *NotificationRuleQuery) Paginate(ctx context.Context, page pagination.P // type check var _ pagination.Paginator[*NotificationRule] = (*NotificationRuleQuery)(nil) +// Paginate runs the query and returns a paginated response. +// If page is its 0 value then it will return all the items and populate the response page accordingly. +func (pl *PlanQuery) Paginate(ctx context.Context, page pagination.Page) (pagination.PagedResponse[*Plan], error) { + // Get the limit and offset + limit, offset := page.Limit(), page.Offset() + + // Unset previous pagination settings + zero := 0 + pl.ctx.Offset = &zero + pl.ctx.Limit = &zero + + // Create duplicate of the query to run for + countQuery := pl.Clone() + pagedQuery := pl + + // Unset ordering for count query + countQuery.order = nil + + pagedResponse := pagination.PagedResponse[*Plan]{ + Page: page, + } + + // Get the total count + count, err := countQuery.Count(ctx) + if err != nil { + return pagedResponse, fmt.Errorf("failed to get count: %w", err) + } + pagedResponse.TotalCount = count + + // If page is its 0 value then return all the items + if page.IsZero() { + offset = 0 + limit = count + } + + // Set the limit and offset + pagedQuery.ctx.Limit = &limit + pagedQuery.ctx.Offset = &offset + + // Get the paged items + items, err := pagedQuery.All(ctx) + pagedResponse.Items = items + return pagedResponse, err +} + +// type check +var _ pagination.Paginator[*Plan] = (*PlanQuery)(nil) + +// Paginate runs the query and returns a paginated response. +// If page is its 0 value then it will return all the items and populate the response page accordingly. +func (pp *PlanPhaseQuery) Paginate(ctx context.Context, page pagination.Page) (pagination.PagedResponse[*PlanPhase], error) { + // Get the limit and offset + limit, offset := page.Limit(), page.Offset() + + // Unset previous pagination settings + zero := 0 + pp.ctx.Offset = &zero + pp.ctx.Limit = &zero + + // Create duplicate of the query to run for + countQuery := pp.Clone() + pagedQuery := pp + + // Unset ordering for count query + countQuery.order = nil + + pagedResponse := pagination.PagedResponse[*PlanPhase]{ + Page: page, + } + + // Get the total count + count, err := countQuery.Count(ctx) + if err != nil { + return pagedResponse, fmt.Errorf("failed to get count: %w", err) + } + pagedResponse.TotalCount = count + + // If page is its 0 value then return all the items + if page.IsZero() { + offset = 0 + limit = count + } + + // Set the limit and offset + pagedQuery.ctx.Limit = &limit + pagedQuery.ctx.Offset = &offset + + // Get the paged items + items, err := pagedQuery.All(ctx) + pagedResponse.Items = items + return pagedResponse, err +} + +// type check +var _ pagination.Paginator[*PlanPhase] = (*PlanPhaseQuery)(nil) + +// Paginate runs the query and returns a paginated response. +// If page is its 0 value then it will return all the items and populate the response page accordingly. +func (prc *PlanRateCardQuery) Paginate(ctx context.Context, page pagination.Page) (pagination.PagedResponse[*PlanRateCard], error) { + // Get the limit and offset + limit, offset := page.Limit(), page.Offset() + + // Unset previous pagination settings + zero := 0 + prc.ctx.Offset = &zero + prc.ctx.Limit = &zero + + // Create duplicate of the query to run for + countQuery := prc.Clone() + pagedQuery := prc + + // Unset ordering for count query + countQuery.order = nil + + pagedResponse := pagination.PagedResponse[*PlanRateCard]{ + Page: page, + } + + // Get the total count + count, err := countQuery.Count(ctx) + if err != nil { + return pagedResponse, fmt.Errorf("failed to get count: %w", err) + } + pagedResponse.TotalCount = count + + // If page is its 0 value then return all the items + if page.IsZero() { + offset = 0 + limit = count + } + + // Set the limit and offset + pagedQuery.ctx.Limit = &limit + pagedQuery.ctx.Offset = &offset + + // Get the paged items + items, err := pagedQuery.All(ctx) + pagedResponse.Items = items + return pagedResponse, err +} + +// type check +var _ pagination.Paginator[*PlanRateCard] = (*PlanRateCardQuery)(nil) + // Paginate runs the query and returns a paginated response. // If page is its 0 value then it will return all the items and populate the response page accordingly. func (ur *UsageResetQuery) Paginate(ctx context.Context, page pagination.Page) (pagination.PagedResponse[*UsageReset], error) { diff --git a/openmeter/ent/db/plan.go b/openmeter/ent/db/plan.go new file mode 100644 index 000000000..253096cf5 --- /dev/null +++ b/openmeter/ent/db/plan.go @@ -0,0 +1,270 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" +) + +// Plan is the model entity for the Plan schema. +type Plan struct { + config `json:"-"` + // ID of the ent. + ID string `json:"id,omitempty"` + // Namespace holds the value of the "namespace" field. + Namespace string `json:"namespace,omitempty"` + // Metadata holds the value of the "metadata" field. + Metadata map[string]string `json:"metadata,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt *time.Time `json:"deleted_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description *string `json:"description,omitempty"` + // Key holds the value of the "key" field. + Key string `json:"key,omitempty"` + // Version holds the value of the "version" field. + Version int `json:"version,omitempty"` + // Currency holds the value of the "currency" field. + Currency string `json:"currency,omitempty"` + // EffectiveFrom holds the value of the "effective_from" field. + EffectiveFrom *time.Time `json:"effective_from,omitempty"` + // EffectiveTo holds the value of the "effective_to" field. + EffectiveTo *time.Time `json:"effective_to,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PlanQuery when eager-loading is set. + Edges PlanEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PlanEdges holds the relations/edges for other nodes in the graph. +type PlanEdges struct { + // Phases holds the value of the phases edge. + Phases []*PlanPhase `json:"phases,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// PhasesOrErr returns the Phases value or an error if the edge +// was not loaded in eager-loading. +func (e PlanEdges) PhasesOrErr() ([]*PlanPhase, error) { + if e.loadedTypes[0] { + return e.Phases, nil + } + return nil, &NotLoadedError{edge: "phases"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Plan) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case dbplan.FieldMetadata: + values[i] = new([]byte) + case dbplan.FieldVersion: + values[i] = new(sql.NullInt64) + case dbplan.FieldID, dbplan.FieldNamespace, dbplan.FieldName, dbplan.FieldDescription, dbplan.FieldKey, dbplan.FieldCurrency: + values[i] = new(sql.NullString) + case dbplan.FieldCreatedAt, dbplan.FieldUpdatedAt, dbplan.FieldDeletedAt, dbplan.FieldEffectiveFrom, dbplan.FieldEffectiveTo: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Plan fields. +func (pl *Plan) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case dbplan.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + pl.ID = value.String + } + case dbplan.FieldNamespace: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field namespace", values[i]) + } else if value.Valid { + pl.Namespace = value.String + } + case dbplan.FieldMetadata: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field metadata", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &pl.Metadata); err != nil { + return fmt.Errorf("unmarshal field metadata: %w", err) + } + } + case dbplan.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + pl.CreatedAt = value.Time + } + case dbplan.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + pl.UpdatedAt = value.Time + } + case dbplan.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + pl.DeletedAt = new(time.Time) + *pl.DeletedAt = value.Time + } + case dbplan.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + pl.Name = value.String + } + case dbplan.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + pl.Description = new(string) + *pl.Description = value.String + } + case dbplan.FieldKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field key", values[i]) + } else if value.Valid { + pl.Key = value.String + } + case dbplan.FieldVersion: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field version", values[i]) + } else if value.Valid { + pl.Version = int(value.Int64) + } + case dbplan.FieldCurrency: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field currency", values[i]) + } else if value.Valid { + pl.Currency = value.String + } + case dbplan.FieldEffectiveFrom: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field effective_from", values[i]) + } else if value.Valid { + pl.EffectiveFrom = new(time.Time) + *pl.EffectiveFrom = value.Time + } + case dbplan.FieldEffectiveTo: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field effective_to", values[i]) + } else if value.Valid { + pl.EffectiveTo = new(time.Time) + *pl.EffectiveTo = value.Time + } + default: + pl.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Plan. +// This includes values selected through modifiers, order, etc. +func (pl *Plan) Value(name string) (ent.Value, error) { + return pl.selectValues.Get(name) +} + +// QueryPhases queries the "phases" edge of the Plan entity. +func (pl *Plan) QueryPhases() *PlanPhaseQuery { + return NewPlanClient(pl.config).QueryPhases(pl) +} + +// Update returns a builder for updating this Plan. +// Note that you need to call Plan.Unwrap() before calling this method if this Plan +// was returned from a transaction, and the transaction was committed or rolled back. +func (pl *Plan) Update() *PlanUpdateOne { + return NewPlanClient(pl.config).UpdateOne(pl) +} + +// Unwrap unwraps the Plan entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (pl *Plan) Unwrap() *Plan { + _tx, ok := pl.config.driver.(*txDriver) + if !ok { + panic("db: Plan is not a transactional entity") + } + pl.config.driver = _tx.drv + return pl +} + +// String implements the fmt.Stringer. +func (pl *Plan) String() string { + var builder strings.Builder + builder.WriteString("Plan(") + builder.WriteString(fmt.Sprintf("id=%v, ", pl.ID)) + builder.WriteString("namespace=") + builder.WriteString(pl.Namespace) + builder.WriteString(", ") + builder.WriteString("metadata=") + builder.WriteString(fmt.Sprintf("%v", pl.Metadata)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(pl.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(pl.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + if v := pl.DeletedAt; v != nil { + builder.WriteString("deleted_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(pl.Name) + builder.WriteString(", ") + if v := pl.Description; v != nil { + builder.WriteString("description=") + builder.WriteString(*v) + } + builder.WriteString(", ") + builder.WriteString("key=") + builder.WriteString(pl.Key) + builder.WriteString(", ") + builder.WriteString("version=") + builder.WriteString(fmt.Sprintf("%v", pl.Version)) + builder.WriteString(", ") + builder.WriteString("currency=") + builder.WriteString(pl.Currency) + builder.WriteString(", ") + if v := pl.EffectiveFrom; v != nil { + builder.WriteString("effective_from=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + if v := pl.EffectiveTo; v != nil { + builder.WriteString("effective_to=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteByte(')') + return builder.String() +} + +// Plans is a parsable slice of Plan. +type Plans []*Plan diff --git a/openmeter/ent/db/plan/plan.go b/openmeter/ent/db/plan/plan.go new file mode 100644 index 000000000..4683a9ab6 --- /dev/null +++ b/openmeter/ent/db/plan/plan.go @@ -0,0 +1,184 @@ +// Code generated by ent, DO NOT EDIT. + +package dbplan + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the plan type in the database. + Label = "plan" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldNamespace holds the string denoting the namespace field in the database. + FieldNamespace = "namespace" + // FieldMetadata holds the string denoting the metadata field in the database. + FieldMetadata = "metadata" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldKey holds the string denoting the key field in the database. + FieldKey = "key" + // FieldVersion holds the string denoting the version field in the database. + FieldVersion = "version" + // FieldCurrency holds the string denoting the currency field in the database. + FieldCurrency = "currency" + // FieldEffectiveFrom holds the string denoting the effective_from field in the database. + FieldEffectiveFrom = "effective_from" + // FieldEffectiveTo holds the string denoting the effective_to field in the database. + FieldEffectiveTo = "effective_to" + // EdgePhases holds the string denoting the phases edge name in mutations. + EdgePhases = "phases" + // Table holds the table name of the plan in the database. + Table = "plans" + // PhasesTable is the table that holds the phases relation/edge. + PhasesTable = "plan_phases" + // PhasesInverseTable is the table name for the PlanPhase entity. + // It exists in this package in order to avoid circular dependency with the "planphase" package. + PhasesInverseTable = "plan_phases" + // PhasesColumn is the table column denoting the phases relation/edge. + PhasesColumn = "plan_id" +) + +// Columns holds all SQL columns for plan fields. +var Columns = []string{ + FieldID, + FieldNamespace, + FieldMetadata, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldName, + FieldDescription, + FieldKey, + FieldVersion, + FieldCurrency, + FieldEffectiveFrom, + FieldEffectiveTo, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // NamespaceValidator is a validator for the "namespace" field. It is called by the builders before save. + NamespaceValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // KeyValidator is a validator for the "key" field. It is called by the builders before save. + KeyValidator func(string) error + // VersionValidator is a validator for the "version" field. It is called by the builders before save. + VersionValidator func(int) error + // DefaultCurrency holds the default value on creation for the "currency" field. + DefaultCurrency string + // CurrencyValidator is a validator for the "currency" field. It is called by the builders before save. + CurrencyValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string +) + +// OrderOption defines the ordering options for the Plan queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByNamespace orders the results by the namespace field. +func ByNamespace(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNamespace, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByKey orders the results by the key field. +func ByKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKey, opts...).ToFunc() +} + +// ByVersion orders the results by the version field. +func ByVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersion, opts...).ToFunc() +} + +// ByCurrency orders the results by the currency field. +func ByCurrency(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCurrency, opts...).ToFunc() +} + +// ByEffectiveFrom orders the results by the effective_from field. +func ByEffectiveFrom(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEffectiveFrom, opts...).ToFunc() +} + +// ByEffectiveTo orders the results by the effective_to field. +func ByEffectiveTo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEffectiveTo, opts...).ToFunc() +} + +// ByPhasesCount orders the results by phases count. +func ByPhasesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPhasesStep(), opts...) + } +} + +// ByPhases orders the results by phases terms. +func ByPhases(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPhasesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newPhasesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PhasesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, PhasesTable, PhasesColumn), + ) +} diff --git a/openmeter/ent/db/plan/where.go b/openmeter/ent/db/plan/where.go new file mode 100644 index 000000000..7a48c0b74 --- /dev/null +++ b/openmeter/ent/db/plan/where.go @@ -0,0 +1,774 @@ +// Code generated by ent, DO NOT EDIT. + +package dbplan + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.Plan { + return predicate.Plan(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.Plan { + return predicate.Plan(sql.FieldContainsFold(FieldID, id)) +} + +// Namespace applies equality check predicate on the "namespace" field. It's identical to NamespaceEQ. +func Namespace(v string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldNamespace, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldName, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldDescription, v)) +} + +// Key applies equality check predicate on the "key" field. It's identical to KeyEQ. +func Key(v string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldKey, v)) +} + +// Version applies equality check predicate on the "version" field. It's identical to VersionEQ. +func Version(v int) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldVersion, v)) +} + +// Currency applies equality check predicate on the "currency" field. It's identical to CurrencyEQ. +func Currency(v string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldCurrency, v)) +} + +// EffectiveFrom applies equality check predicate on the "effective_from" field. It's identical to EffectiveFromEQ. +func EffectiveFrom(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldEffectiveFrom, v)) +} + +// EffectiveTo applies equality check predicate on the "effective_to" field. It's identical to EffectiveToEQ. +func EffectiveTo(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldEffectiveTo, v)) +} + +// NamespaceEQ applies the EQ predicate on the "namespace" field. +func NamespaceEQ(v string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldNamespace, v)) +} + +// NamespaceNEQ applies the NEQ predicate on the "namespace" field. +func NamespaceNEQ(v string) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldNamespace, v)) +} + +// NamespaceIn applies the In predicate on the "namespace" field. +func NamespaceIn(vs ...string) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldNamespace, vs...)) +} + +// NamespaceNotIn applies the NotIn predicate on the "namespace" field. +func NamespaceNotIn(vs ...string) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldNamespace, vs...)) +} + +// NamespaceGT applies the GT predicate on the "namespace" field. +func NamespaceGT(v string) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldNamespace, v)) +} + +// NamespaceGTE applies the GTE predicate on the "namespace" field. +func NamespaceGTE(v string) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldNamespace, v)) +} + +// NamespaceLT applies the LT predicate on the "namespace" field. +func NamespaceLT(v string) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldNamespace, v)) +} + +// NamespaceLTE applies the LTE predicate on the "namespace" field. +func NamespaceLTE(v string) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldNamespace, v)) +} + +// NamespaceContains applies the Contains predicate on the "namespace" field. +func NamespaceContains(v string) predicate.Plan { + return predicate.Plan(sql.FieldContains(FieldNamespace, v)) +} + +// NamespaceHasPrefix applies the HasPrefix predicate on the "namespace" field. +func NamespaceHasPrefix(v string) predicate.Plan { + return predicate.Plan(sql.FieldHasPrefix(FieldNamespace, v)) +} + +// NamespaceHasSuffix applies the HasSuffix predicate on the "namespace" field. +func NamespaceHasSuffix(v string) predicate.Plan { + return predicate.Plan(sql.FieldHasSuffix(FieldNamespace, v)) +} + +// NamespaceEqualFold applies the EqualFold predicate on the "namespace" field. +func NamespaceEqualFold(v string) predicate.Plan { + return predicate.Plan(sql.FieldEqualFold(FieldNamespace, v)) +} + +// NamespaceContainsFold applies the ContainsFold predicate on the "namespace" field. +func NamespaceContainsFold(v string) predicate.Plan { + return predicate.Plan(sql.FieldContainsFold(FieldNamespace, v)) +} + +// MetadataIsNil applies the IsNil predicate on the "metadata" field. +func MetadataIsNil() predicate.Plan { + return predicate.Plan(sql.FieldIsNull(FieldMetadata)) +} + +// MetadataNotNil applies the NotNil predicate on the "metadata" field. +func MetadataNotNil() predicate.Plan { + return predicate.Plan(sql.FieldNotNull(FieldMetadata)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.Plan { + return predicate.Plan(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.Plan { + return predicate.Plan(sql.FieldNotNull(FieldDeletedAt)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Plan { + return predicate.Plan(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Plan { + return predicate.Plan(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Plan { + return predicate.Plan(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Plan { + return predicate.Plan(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Plan { + return predicate.Plan(sql.FieldContainsFold(FieldName, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Plan { + return predicate.Plan(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Plan { + return predicate.Plan(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Plan { + return predicate.Plan(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.Plan { + return predicate.Plan(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.Plan { + return predicate.Plan(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Plan { + return predicate.Plan(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Plan { + return predicate.Plan(sql.FieldContainsFold(FieldDescription, v)) +} + +// KeyEQ applies the EQ predicate on the "key" field. +func KeyEQ(v string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldKey, v)) +} + +// KeyNEQ applies the NEQ predicate on the "key" field. +func KeyNEQ(v string) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldKey, v)) +} + +// KeyIn applies the In predicate on the "key" field. +func KeyIn(vs ...string) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldKey, vs...)) +} + +// KeyNotIn applies the NotIn predicate on the "key" field. +func KeyNotIn(vs ...string) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldKey, vs...)) +} + +// KeyGT applies the GT predicate on the "key" field. +func KeyGT(v string) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldKey, v)) +} + +// KeyGTE applies the GTE predicate on the "key" field. +func KeyGTE(v string) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldKey, v)) +} + +// KeyLT applies the LT predicate on the "key" field. +func KeyLT(v string) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldKey, v)) +} + +// KeyLTE applies the LTE predicate on the "key" field. +func KeyLTE(v string) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldKey, v)) +} + +// KeyContains applies the Contains predicate on the "key" field. +func KeyContains(v string) predicate.Plan { + return predicate.Plan(sql.FieldContains(FieldKey, v)) +} + +// KeyHasPrefix applies the HasPrefix predicate on the "key" field. +func KeyHasPrefix(v string) predicate.Plan { + return predicate.Plan(sql.FieldHasPrefix(FieldKey, v)) +} + +// KeyHasSuffix applies the HasSuffix predicate on the "key" field. +func KeyHasSuffix(v string) predicate.Plan { + return predicate.Plan(sql.FieldHasSuffix(FieldKey, v)) +} + +// KeyEqualFold applies the EqualFold predicate on the "key" field. +func KeyEqualFold(v string) predicate.Plan { + return predicate.Plan(sql.FieldEqualFold(FieldKey, v)) +} + +// KeyContainsFold applies the ContainsFold predicate on the "key" field. +func KeyContainsFold(v string) predicate.Plan { + return predicate.Plan(sql.FieldContainsFold(FieldKey, v)) +} + +// VersionEQ applies the EQ predicate on the "version" field. +func VersionEQ(v int) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldVersion, v)) +} + +// VersionNEQ applies the NEQ predicate on the "version" field. +func VersionNEQ(v int) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldVersion, v)) +} + +// VersionIn applies the In predicate on the "version" field. +func VersionIn(vs ...int) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldVersion, vs...)) +} + +// VersionNotIn applies the NotIn predicate on the "version" field. +func VersionNotIn(vs ...int) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldVersion, vs...)) +} + +// VersionGT applies the GT predicate on the "version" field. +func VersionGT(v int) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldVersion, v)) +} + +// VersionGTE applies the GTE predicate on the "version" field. +func VersionGTE(v int) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldVersion, v)) +} + +// VersionLT applies the LT predicate on the "version" field. +func VersionLT(v int) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldVersion, v)) +} + +// VersionLTE applies the LTE predicate on the "version" field. +func VersionLTE(v int) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldVersion, v)) +} + +// CurrencyEQ applies the EQ predicate on the "currency" field. +func CurrencyEQ(v string) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldCurrency, v)) +} + +// CurrencyNEQ applies the NEQ predicate on the "currency" field. +func CurrencyNEQ(v string) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldCurrency, v)) +} + +// CurrencyIn applies the In predicate on the "currency" field. +func CurrencyIn(vs ...string) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldCurrency, vs...)) +} + +// CurrencyNotIn applies the NotIn predicate on the "currency" field. +func CurrencyNotIn(vs ...string) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldCurrency, vs...)) +} + +// CurrencyGT applies the GT predicate on the "currency" field. +func CurrencyGT(v string) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldCurrency, v)) +} + +// CurrencyGTE applies the GTE predicate on the "currency" field. +func CurrencyGTE(v string) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldCurrency, v)) +} + +// CurrencyLT applies the LT predicate on the "currency" field. +func CurrencyLT(v string) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldCurrency, v)) +} + +// CurrencyLTE applies the LTE predicate on the "currency" field. +func CurrencyLTE(v string) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldCurrency, v)) +} + +// CurrencyContains applies the Contains predicate on the "currency" field. +func CurrencyContains(v string) predicate.Plan { + return predicate.Plan(sql.FieldContains(FieldCurrency, v)) +} + +// CurrencyHasPrefix applies the HasPrefix predicate on the "currency" field. +func CurrencyHasPrefix(v string) predicate.Plan { + return predicate.Plan(sql.FieldHasPrefix(FieldCurrency, v)) +} + +// CurrencyHasSuffix applies the HasSuffix predicate on the "currency" field. +func CurrencyHasSuffix(v string) predicate.Plan { + return predicate.Plan(sql.FieldHasSuffix(FieldCurrency, v)) +} + +// CurrencyEqualFold applies the EqualFold predicate on the "currency" field. +func CurrencyEqualFold(v string) predicate.Plan { + return predicate.Plan(sql.FieldEqualFold(FieldCurrency, v)) +} + +// CurrencyContainsFold applies the ContainsFold predicate on the "currency" field. +func CurrencyContainsFold(v string) predicate.Plan { + return predicate.Plan(sql.FieldContainsFold(FieldCurrency, v)) +} + +// EffectiveFromEQ applies the EQ predicate on the "effective_from" field. +func EffectiveFromEQ(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldEffectiveFrom, v)) +} + +// EffectiveFromNEQ applies the NEQ predicate on the "effective_from" field. +func EffectiveFromNEQ(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldEffectiveFrom, v)) +} + +// EffectiveFromIn applies the In predicate on the "effective_from" field. +func EffectiveFromIn(vs ...time.Time) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldEffectiveFrom, vs...)) +} + +// EffectiveFromNotIn applies the NotIn predicate on the "effective_from" field. +func EffectiveFromNotIn(vs ...time.Time) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldEffectiveFrom, vs...)) +} + +// EffectiveFromGT applies the GT predicate on the "effective_from" field. +func EffectiveFromGT(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldEffectiveFrom, v)) +} + +// EffectiveFromGTE applies the GTE predicate on the "effective_from" field. +func EffectiveFromGTE(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldEffectiveFrom, v)) +} + +// EffectiveFromLT applies the LT predicate on the "effective_from" field. +func EffectiveFromLT(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldEffectiveFrom, v)) +} + +// EffectiveFromLTE applies the LTE predicate on the "effective_from" field. +func EffectiveFromLTE(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldEffectiveFrom, v)) +} + +// EffectiveFromIsNil applies the IsNil predicate on the "effective_from" field. +func EffectiveFromIsNil() predicate.Plan { + return predicate.Plan(sql.FieldIsNull(FieldEffectiveFrom)) +} + +// EffectiveFromNotNil applies the NotNil predicate on the "effective_from" field. +func EffectiveFromNotNil() predicate.Plan { + return predicate.Plan(sql.FieldNotNull(FieldEffectiveFrom)) +} + +// EffectiveToEQ applies the EQ predicate on the "effective_to" field. +func EffectiveToEQ(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldEQ(FieldEffectiveTo, v)) +} + +// EffectiveToNEQ applies the NEQ predicate on the "effective_to" field. +func EffectiveToNEQ(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldNEQ(FieldEffectiveTo, v)) +} + +// EffectiveToIn applies the In predicate on the "effective_to" field. +func EffectiveToIn(vs ...time.Time) predicate.Plan { + return predicate.Plan(sql.FieldIn(FieldEffectiveTo, vs...)) +} + +// EffectiveToNotIn applies the NotIn predicate on the "effective_to" field. +func EffectiveToNotIn(vs ...time.Time) predicate.Plan { + return predicate.Plan(sql.FieldNotIn(FieldEffectiveTo, vs...)) +} + +// EffectiveToGT applies the GT predicate on the "effective_to" field. +func EffectiveToGT(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldGT(FieldEffectiveTo, v)) +} + +// EffectiveToGTE applies the GTE predicate on the "effective_to" field. +func EffectiveToGTE(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldGTE(FieldEffectiveTo, v)) +} + +// EffectiveToLT applies the LT predicate on the "effective_to" field. +func EffectiveToLT(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldLT(FieldEffectiveTo, v)) +} + +// EffectiveToLTE applies the LTE predicate on the "effective_to" field. +func EffectiveToLTE(v time.Time) predicate.Plan { + return predicate.Plan(sql.FieldLTE(FieldEffectiveTo, v)) +} + +// EffectiveToIsNil applies the IsNil predicate on the "effective_to" field. +func EffectiveToIsNil() predicate.Plan { + return predicate.Plan(sql.FieldIsNull(FieldEffectiveTo)) +} + +// EffectiveToNotNil applies the NotNil predicate on the "effective_to" field. +func EffectiveToNotNil() predicate.Plan { + return predicate.Plan(sql.FieldNotNull(FieldEffectiveTo)) +} + +// HasPhases applies the HasEdge predicate on the "phases" edge. +func HasPhases() predicate.Plan { + return predicate.Plan(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, PhasesTable, PhasesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPhasesWith applies the HasEdge predicate on the "phases" edge with a given conditions (other predicates). +func HasPhasesWith(preds ...predicate.PlanPhase) predicate.Plan { + return predicate.Plan(func(s *sql.Selector) { + step := newPhasesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Plan) predicate.Plan { + return predicate.Plan(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Plan) predicate.Plan { + return predicate.Plan(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Plan) predicate.Plan { + return predicate.Plan(sql.NotPredicates(p)) +} diff --git a/openmeter/ent/db/plan_create.go b/openmeter/ent/db/plan_create.go new file mode 100644 index 000000000..a8a50b1d7 --- /dev/null +++ b/openmeter/ent/db/plan_create.go @@ -0,0 +1,1180 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" +) + +// PlanCreate is the builder for creating a Plan entity. +type PlanCreate struct { + config + mutation *PlanMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetNamespace sets the "namespace" field. +func (pc *PlanCreate) SetNamespace(s string) *PlanCreate { + pc.mutation.SetNamespace(s) + return pc +} + +// SetMetadata sets the "metadata" field. +func (pc *PlanCreate) SetMetadata(m map[string]string) *PlanCreate { + pc.mutation.SetMetadata(m) + return pc +} + +// SetCreatedAt sets the "created_at" field. +func (pc *PlanCreate) SetCreatedAt(t time.Time) *PlanCreate { + pc.mutation.SetCreatedAt(t) + return pc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (pc *PlanCreate) SetNillableCreatedAt(t *time.Time) *PlanCreate { + if t != nil { + pc.SetCreatedAt(*t) + } + return pc +} + +// SetUpdatedAt sets the "updated_at" field. +func (pc *PlanCreate) SetUpdatedAt(t time.Time) *PlanCreate { + pc.mutation.SetUpdatedAt(t) + return pc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (pc *PlanCreate) SetNillableUpdatedAt(t *time.Time) *PlanCreate { + if t != nil { + pc.SetUpdatedAt(*t) + } + return pc +} + +// SetDeletedAt sets the "deleted_at" field. +func (pc *PlanCreate) SetDeletedAt(t time.Time) *PlanCreate { + pc.mutation.SetDeletedAt(t) + return pc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (pc *PlanCreate) SetNillableDeletedAt(t *time.Time) *PlanCreate { + if t != nil { + pc.SetDeletedAt(*t) + } + return pc +} + +// SetName sets the "name" field. +func (pc *PlanCreate) SetName(s string) *PlanCreate { + pc.mutation.SetName(s) + return pc +} + +// SetDescription sets the "description" field. +func (pc *PlanCreate) SetDescription(s string) *PlanCreate { + pc.mutation.SetDescription(s) + return pc +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (pc *PlanCreate) SetNillableDescription(s *string) *PlanCreate { + if s != nil { + pc.SetDescription(*s) + } + return pc +} + +// SetKey sets the "key" field. +func (pc *PlanCreate) SetKey(s string) *PlanCreate { + pc.mutation.SetKey(s) + return pc +} + +// SetVersion sets the "version" field. +func (pc *PlanCreate) SetVersion(i int) *PlanCreate { + pc.mutation.SetVersion(i) + return pc +} + +// SetCurrency sets the "currency" field. +func (pc *PlanCreate) SetCurrency(s string) *PlanCreate { + pc.mutation.SetCurrency(s) + return pc +} + +// SetNillableCurrency sets the "currency" field if the given value is not nil. +func (pc *PlanCreate) SetNillableCurrency(s *string) *PlanCreate { + if s != nil { + pc.SetCurrency(*s) + } + return pc +} + +// SetEffectiveFrom sets the "effective_from" field. +func (pc *PlanCreate) SetEffectiveFrom(t time.Time) *PlanCreate { + pc.mutation.SetEffectiveFrom(t) + return pc +} + +// SetNillableEffectiveFrom sets the "effective_from" field if the given value is not nil. +func (pc *PlanCreate) SetNillableEffectiveFrom(t *time.Time) *PlanCreate { + if t != nil { + pc.SetEffectiveFrom(*t) + } + return pc +} + +// SetEffectiveTo sets the "effective_to" field. +func (pc *PlanCreate) SetEffectiveTo(t time.Time) *PlanCreate { + pc.mutation.SetEffectiveTo(t) + return pc +} + +// SetNillableEffectiveTo sets the "effective_to" field if the given value is not nil. +func (pc *PlanCreate) SetNillableEffectiveTo(t *time.Time) *PlanCreate { + if t != nil { + pc.SetEffectiveTo(*t) + } + return pc +} + +// SetID sets the "id" field. +func (pc *PlanCreate) SetID(s string) *PlanCreate { + pc.mutation.SetID(s) + return pc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (pc *PlanCreate) SetNillableID(s *string) *PlanCreate { + if s != nil { + pc.SetID(*s) + } + return pc +} + +// AddPhaseIDs adds the "phases" edge to the PlanPhase entity by IDs. +func (pc *PlanCreate) AddPhaseIDs(ids ...string) *PlanCreate { + pc.mutation.AddPhaseIDs(ids...) + return pc +} + +// AddPhases adds the "phases" edges to the PlanPhase entity. +func (pc *PlanCreate) AddPhases(p ...*PlanPhase) *PlanCreate { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return pc.AddPhaseIDs(ids...) +} + +// Mutation returns the PlanMutation object of the builder. +func (pc *PlanCreate) Mutation() *PlanMutation { + return pc.mutation +} + +// Save creates the Plan in the database. +func (pc *PlanCreate) Save(ctx context.Context) (*Plan, error) { + pc.defaults() + return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (pc *PlanCreate) SaveX(ctx context.Context) *Plan { + v, err := pc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (pc *PlanCreate) Exec(ctx context.Context) error { + _, err := pc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (pc *PlanCreate) ExecX(ctx context.Context) { + if err := pc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (pc *PlanCreate) defaults() { + if _, ok := pc.mutation.CreatedAt(); !ok { + v := dbplan.DefaultCreatedAt() + pc.mutation.SetCreatedAt(v) + } + if _, ok := pc.mutation.UpdatedAt(); !ok { + v := dbplan.DefaultUpdatedAt() + pc.mutation.SetUpdatedAt(v) + } + if _, ok := pc.mutation.Currency(); !ok { + v := dbplan.DefaultCurrency + pc.mutation.SetCurrency(v) + } + if _, ok := pc.mutation.ID(); !ok { + v := dbplan.DefaultID() + pc.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (pc *PlanCreate) check() error { + if _, ok := pc.mutation.Namespace(); !ok { + return &ValidationError{Name: "namespace", err: errors.New(`db: missing required field "Plan.namespace"`)} + } + if v, ok := pc.mutation.Namespace(); ok { + if err := dbplan.NamespaceValidator(v); err != nil { + return &ValidationError{Name: "namespace", err: fmt.Errorf(`db: validator failed for field "Plan.namespace": %w`, err)} + } + } + if _, ok := pc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "Plan.created_at"`)} + } + if _, ok := pc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "Plan.updated_at"`)} + } + if _, ok := pc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`db: missing required field "Plan.name"`)} + } + if _, ok := pc.mutation.Key(); !ok { + return &ValidationError{Name: "key", err: errors.New(`db: missing required field "Plan.key"`)} + } + if v, ok := pc.mutation.Key(); ok { + if err := dbplan.KeyValidator(v); err != nil { + return &ValidationError{Name: "key", err: fmt.Errorf(`db: validator failed for field "Plan.key": %w`, err)} + } + } + if _, ok := pc.mutation.Version(); !ok { + return &ValidationError{Name: "version", err: errors.New(`db: missing required field "Plan.version"`)} + } + if v, ok := pc.mutation.Version(); ok { + if err := dbplan.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "Plan.version": %w`, err)} + } + } + if _, ok := pc.mutation.Currency(); !ok { + return &ValidationError{Name: "currency", err: errors.New(`db: missing required field "Plan.currency"`)} + } + if v, ok := pc.mutation.Currency(); ok { + if err := dbplan.CurrencyValidator(v); err != nil { + return &ValidationError{Name: "currency", err: fmt.Errorf(`db: validator failed for field "Plan.currency": %w`, err)} + } + } + return nil +} + +func (pc *PlanCreate) sqlSave(ctx context.Context) (*Plan, error) { + if err := pc.check(); err != nil { + return nil, err + } + _node, _spec := pc.createSpec() + if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(string); ok { + _node.ID = id + } else { + return nil, fmt.Errorf("unexpected Plan.ID type: %T", _spec.ID.Value) + } + } + pc.mutation.id = &_node.ID + pc.mutation.done = true + return _node, nil +} + +func (pc *PlanCreate) createSpec() (*Plan, *sqlgraph.CreateSpec) { + var ( + _node = &Plan{config: pc.config} + _spec = sqlgraph.NewCreateSpec(dbplan.Table, sqlgraph.NewFieldSpec(dbplan.FieldID, field.TypeString)) + ) + _spec.OnConflict = pc.conflict + if id, ok := pc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := pc.mutation.Namespace(); ok { + _spec.SetField(dbplan.FieldNamespace, field.TypeString, value) + _node.Namespace = value + } + if value, ok := pc.mutation.Metadata(); ok { + _spec.SetField(dbplan.FieldMetadata, field.TypeJSON, value) + _node.Metadata = value + } + if value, ok := pc.mutation.CreatedAt(); ok { + _spec.SetField(dbplan.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := pc.mutation.UpdatedAt(); ok { + _spec.SetField(dbplan.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := pc.mutation.DeletedAt(); ok { + _spec.SetField(dbplan.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = &value + } + if value, ok := pc.mutation.Name(); ok { + _spec.SetField(dbplan.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := pc.mutation.Description(); ok { + _spec.SetField(dbplan.FieldDescription, field.TypeString, value) + _node.Description = &value + } + if value, ok := pc.mutation.Key(); ok { + _spec.SetField(dbplan.FieldKey, field.TypeString, value) + _node.Key = value + } + if value, ok := pc.mutation.Version(); ok { + _spec.SetField(dbplan.FieldVersion, field.TypeInt, value) + _node.Version = value + } + if value, ok := pc.mutation.Currency(); ok { + _spec.SetField(dbplan.FieldCurrency, field.TypeString, value) + _node.Currency = value + } + if value, ok := pc.mutation.EffectiveFrom(); ok { + _spec.SetField(dbplan.FieldEffectiveFrom, field.TypeTime, value) + _node.EffectiveFrom = &value + } + if value, ok := pc.mutation.EffectiveTo(); ok { + _spec.SetField(dbplan.FieldEffectiveTo, field.TypeTime, value) + _node.EffectiveTo = &value + } + if nodes := pc.mutation.PhasesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: dbplan.PhasesTable, + Columns: []string{dbplan.PhasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Plan.Create(). +// SetNamespace(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.PlanUpsert) { +// SetNamespace(v+v). +// }). +// Exec(ctx) +func (pc *PlanCreate) OnConflict(opts ...sql.ConflictOption) *PlanUpsertOne { + pc.conflict = opts + return &PlanUpsertOne{ + create: pc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Plan.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (pc *PlanCreate) OnConflictColumns(columns ...string) *PlanUpsertOne { + pc.conflict = append(pc.conflict, sql.ConflictColumns(columns...)) + return &PlanUpsertOne{ + create: pc, + } +} + +type ( + // PlanUpsertOne is the builder for "upsert"-ing + // one Plan node. + PlanUpsertOne struct { + create *PlanCreate + } + + // PlanUpsert is the "OnConflict" setter. + PlanUpsert struct { + *sql.UpdateSet + } +) + +// SetMetadata sets the "metadata" field. +func (u *PlanUpsert) SetMetadata(v map[string]string) *PlanUpsert { + u.Set(dbplan.FieldMetadata, v) + return u +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *PlanUpsert) UpdateMetadata() *PlanUpsert { + u.SetExcluded(dbplan.FieldMetadata) + return u +} + +// ClearMetadata clears the value of the "metadata" field. +func (u *PlanUpsert) ClearMetadata() *PlanUpsert { + u.SetNull(dbplan.FieldMetadata) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *PlanUpsert) SetUpdatedAt(v time.Time) *PlanUpsert { + u.Set(dbplan.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *PlanUpsert) UpdateUpdatedAt() *PlanUpsert { + u.SetExcluded(dbplan.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *PlanUpsert) SetDeletedAt(v time.Time) *PlanUpsert { + u.Set(dbplan.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *PlanUpsert) UpdateDeletedAt() *PlanUpsert { + u.SetExcluded(dbplan.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *PlanUpsert) ClearDeletedAt() *PlanUpsert { + u.SetNull(dbplan.FieldDeletedAt) + return u +} + +// SetName sets the "name" field. +func (u *PlanUpsert) SetName(v string) *PlanUpsert { + u.Set(dbplan.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *PlanUpsert) UpdateName() *PlanUpsert { + u.SetExcluded(dbplan.FieldName) + return u +} + +// SetDescription sets the "description" field. +func (u *PlanUpsert) SetDescription(v string) *PlanUpsert { + u.Set(dbplan.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PlanUpsert) UpdateDescription() *PlanUpsert { + u.SetExcluded(dbplan.FieldDescription) + return u +} + +// ClearDescription clears the value of the "description" field. +func (u *PlanUpsert) ClearDescription() *PlanUpsert { + u.SetNull(dbplan.FieldDescription) + return u +} + +// SetVersion sets the "version" field. +func (u *PlanUpsert) SetVersion(v int) *PlanUpsert { + u.Set(dbplan.FieldVersion, v) + return u +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *PlanUpsert) UpdateVersion() *PlanUpsert { + u.SetExcluded(dbplan.FieldVersion) + return u +} + +// AddVersion adds v to the "version" field. +func (u *PlanUpsert) AddVersion(v int) *PlanUpsert { + u.Add(dbplan.FieldVersion, v) + return u +} + +// SetEffectiveFrom sets the "effective_from" field. +func (u *PlanUpsert) SetEffectiveFrom(v time.Time) *PlanUpsert { + u.Set(dbplan.FieldEffectiveFrom, v) + return u +} + +// UpdateEffectiveFrom sets the "effective_from" field to the value that was provided on create. +func (u *PlanUpsert) UpdateEffectiveFrom() *PlanUpsert { + u.SetExcluded(dbplan.FieldEffectiveFrom) + return u +} + +// ClearEffectiveFrom clears the value of the "effective_from" field. +func (u *PlanUpsert) ClearEffectiveFrom() *PlanUpsert { + u.SetNull(dbplan.FieldEffectiveFrom) + return u +} + +// SetEffectiveTo sets the "effective_to" field. +func (u *PlanUpsert) SetEffectiveTo(v time.Time) *PlanUpsert { + u.Set(dbplan.FieldEffectiveTo, v) + return u +} + +// UpdateEffectiveTo sets the "effective_to" field to the value that was provided on create. +func (u *PlanUpsert) UpdateEffectiveTo() *PlanUpsert { + u.SetExcluded(dbplan.FieldEffectiveTo) + return u +} + +// ClearEffectiveTo clears the value of the "effective_to" field. +func (u *PlanUpsert) ClearEffectiveTo() *PlanUpsert { + u.SetNull(dbplan.FieldEffectiveTo) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.Plan.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(dbplan.FieldID) +// }), +// ). +// Exec(ctx) +func (u *PlanUpsertOne) UpdateNewValues() *PlanUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(dbplan.FieldID) + } + if _, exists := u.create.mutation.Namespace(); exists { + s.SetIgnore(dbplan.FieldNamespace) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(dbplan.FieldCreatedAt) + } + if _, exists := u.create.mutation.Key(); exists { + s.SetIgnore(dbplan.FieldKey) + } + if _, exists := u.create.mutation.Currency(); exists { + s.SetIgnore(dbplan.FieldCurrency) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Plan.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *PlanUpsertOne) Ignore() *PlanUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *PlanUpsertOne) DoNothing() *PlanUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the PlanCreate.OnConflict +// documentation for more info. +func (u *PlanUpsertOne) Update(set func(*PlanUpsert)) *PlanUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&PlanUpsert{UpdateSet: update}) + })) + return u +} + +// SetMetadata sets the "metadata" field. +func (u *PlanUpsertOne) SetMetadata(v map[string]string) *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.SetMetadata(v) + }) +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *PlanUpsertOne) UpdateMetadata() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.UpdateMetadata() + }) +} + +// ClearMetadata clears the value of the "metadata" field. +func (u *PlanUpsertOne) ClearMetadata() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.ClearMetadata() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *PlanUpsertOne) SetUpdatedAt(v time.Time) *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *PlanUpsertOne) UpdateUpdatedAt() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *PlanUpsertOne) SetDeletedAt(v time.Time) *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *PlanUpsertOne) UpdateDeletedAt() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *PlanUpsertOne) ClearDeletedAt() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.ClearDeletedAt() + }) +} + +// SetName sets the "name" field. +func (u *PlanUpsertOne) SetName(v string) *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *PlanUpsertOne) UpdateName() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *PlanUpsertOne) SetDescription(v string) *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PlanUpsertOne) UpdateDescription() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *PlanUpsertOne) ClearDescription() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.ClearDescription() + }) +} + +// SetVersion sets the "version" field. +func (u *PlanUpsertOne) SetVersion(v int) *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.SetVersion(v) + }) +} + +// AddVersion adds v to the "version" field. +func (u *PlanUpsertOne) AddVersion(v int) *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.AddVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *PlanUpsertOne) UpdateVersion() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.UpdateVersion() + }) +} + +// SetEffectiveFrom sets the "effective_from" field. +func (u *PlanUpsertOne) SetEffectiveFrom(v time.Time) *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.SetEffectiveFrom(v) + }) +} + +// UpdateEffectiveFrom sets the "effective_from" field to the value that was provided on create. +func (u *PlanUpsertOne) UpdateEffectiveFrom() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.UpdateEffectiveFrom() + }) +} + +// ClearEffectiveFrom clears the value of the "effective_from" field. +func (u *PlanUpsertOne) ClearEffectiveFrom() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.ClearEffectiveFrom() + }) +} + +// SetEffectiveTo sets the "effective_to" field. +func (u *PlanUpsertOne) SetEffectiveTo(v time.Time) *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.SetEffectiveTo(v) + }) +} + +// UpdateEffectiveTo sets the "effective_to" field to the value that was provided on create. +func (u *PlanUpsertOne) UpdateEffectiveTo() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.UpdateEffectiveTo() + }) +} + +// ClearEffectiveTo clears the value of the "effective_to" field. +func (u *PlanUpsertOne) ClearEffectiveTo() *PlanUpsertOne { + return u.Update(func(s *PlanUpsert) { + s.ClearEffectiveTo() + }) +} + +// Exec executes the query. +func (u *PlanUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for PlanCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *PlanUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *PlanUpsertOne) ID(ctx context.Context) (id string, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: PlanUpsertOne.ID is not supported by MySQL driver. Use PlanUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *PlanUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// PlanCreateBulk is the builder for creating many Plan entities in bulk. +type PlanCreateBulk struct { + config + err error + builders []*PlanCreate + conflict []sql.ConflictOption +} + +// Save creates the Plan entities in the database. +func (pcb *PlanCreateBulk) Save(ctx context.Context) ([]*Plan, error) { + if pcb.err != nil { + return nil, pcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) + nodes := make([]*Plan, len(pcb.builders)) + mutators := make([]Mutator, len(pcb.builders)) + for i := range pcb.builders { + func(i int, root context.Context) { + builder := pcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PlanMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = pcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, pcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (pcb *PlanCreateBulk) SaveX(ctx context.Context) []*Plan { + v, err := pcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (pcb *PlanCreateBulk) Exec(ctx context.Context) error { + _, err := pcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (pcb *PlanCreateBulk) ExecX(ctx context.Context) { + if err := pcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Plan.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.PlanUpsert) { +// SetNamespace(v+v). +// }). +// Exec(ctx) +func (pcb *PlanCreateBulk) OnConflict(opts ...sql.ConflictOption) *PlanUpsertBulk { + pcb.conflict = opts + return &PlanUpsertBulk{ + create: pcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Plan.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (pcb *PlanCreateBulk) OnConflictColumns(columns ...string) *PlanUpsertBulk { + pcb.conflict = append(pcb.conflict, sql.ConflictColumns(columns...)) + return &PlanUpsertBulk{ + create: pcb, + } +} + +// PlanUpsertBulk is the builder for "upsert"-ing +// a bulk of Plan nodes. +type PlanUpsertBulk struct { + create *PlanCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Plan.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(dbplan.FieldID) +// }), +// ). +// Exec(ctx) +func (u *PlanUpsertBulk) UpdateNewValues() *PlanUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(dbplan.FieldID) + } + if _, exists := b.mutation.Namespace(); exists { + s.SetIgnore(dbplan.FieldNamespace) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(dbplan.FieldCreatedAt) + } + if _, exists := b.mutation.Key(); exists { + s.SetIgnore(dbplan.FieldKey) + } + if _, exists := b.mutation.Currency(); exists { + s.SetIgnore(dbplan.FieldCurrency) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Plan.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *PlanUpsertBulk) Ignore() *PlanUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *PlanUpsertBulk) DoNothing() *PlanUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the PlanCreateBulk.OnConflict +// documentation for more info. +func (u *PlanUpsertBulk) Update(set func(*PlanUpsert)) *PlanUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&PlanUpsert{UpdateSet: update}) + })) + return u +} + +// SetMetadata sets the "metadata" field. +func (u *PlanUpsertBulk) SetMetadata(v map[string]string) *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.SetMetadata(v) + }) +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *PlanUpsertBulk) UpdateMetadata() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.UpdateMetadata() + }) +} + +// ClearMetadata clears the value of the "metadata" field. +func (u *PlanUpsertBulk) ClearMetadata() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.ClearMetadata() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *PlanUpsertBulk) SetUpdatedAt(v time.Time) *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *PlanUpsertBulk) UpdateUpdatedAt() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *PlanUpsertBulk) SetDeletedAt(v time.Time) *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *PlanUpsertBulk) UpdateDeletedAt() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *PlanUpsertBulk) ClearDeletedAt() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.ClearDeletedAt() + }) +} + +// SetName sets the "name" field. +func (u *PlanUpsertBulk) SetName(v string) *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *PlanUpsertBulk) UpdateName() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *PlanUpsertBulk) SetDescription(v string) *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PlanUpsertBulk) UpdateDescription() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *PlanUpsertBulk) ClearDescription() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.ClearDescription() + }) +} + +// SetVersion sets the "version" field. +func (u *PlanUpsertBulk) SetVersion(v int) *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.SetVersion(v) + }) +} + +// AddVersion adds v to the "version" field. +func (u *PlanUpsertBulk) AddVersion(v int) *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.AddVersion(v) + }) +} + +// UpdateVersion sets the "version" field to the value that was provided on create. +func (u *PlanUpsertBulk) UpdateVersion() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.UpdateVersion() + }) +} + +// SetEffectiveFrom sets the "effective_from" field. +func (u *PlanUpsertBulk) SetEffectiveFrom(v time.Time) *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.SetEffectiveFrom(v) + }) +} + +// UpdateEffectiveFrom sets the "effective_from" field to the value that was provided on create. +func (u *PlanUpsertBulk) UpdateEffectiveFrom() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.UpdateEffectiveFrom() + }) +} + +// ClearEffectiveFrom clears the value of the "effective_from" field. +func (u *PlanUpsertBulk) ClearEffectiveFrom() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.ClearEffectiveFrom() + }) +} + +// SetEffectiveTo sets the "effective_to" field. +func (u *PlanUpsertBulk) SetEffectiveTo(v time.Time) *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.SetEffectiveTo(v) + }) +} + +// UpdateEffectiveTo sets the "effective_to" field to the value that was provided on create. +func (u *PlanUpsertBulk) UpdateEffectiveTo() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.UpdateEffectiveTo() + }) +} + +// ClearEffectiveTo clears the value of the "effective_to" field. +func (u *PlanUpsertBulk) ClearEffectiveTo() *PlanUpsertBulk { + return u.Update(func(s *PlanUpsert) { + s.ClearEffectiveTo() + }) +} + +// Exec executes the query. +func (u *PlanUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the PlanCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for PlanCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *PlanUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/openmeter/ent/db/plan_delete.go b/openmeter/ent/db/plan_delete.go new file mode 100644 index 000000000..d95164484 --- /dev/null +++ b/openmeter/ent/db/plan_delete.go @@ -0,0 +1,89 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" + + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" +) + +// PlanDelete is the builder for deleting a Plan entity. +type PlanDelete struct { + config + hooks []Hook + mutation *PlanMutation +} + +// Where appends a list predicates to the PlanDelete builder. +func (pd *PlanDelete) Where(ps ...predicate.Plan) *PlanDelete { + pd.mutation.Where(ps...) + return pd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (pd *PlanDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (pd *PlanDelete) ExecX(ctx context.Context) int { + n, err := pd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (pd *PlanDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(dbplan.Table, sqlgraph.NewFieldSpec(dbplan.FieldID, field.TypeString)) + if ps := pd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, pd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + pd.mutation.done = true + return affected, err +} + +// PlanDeleteOne is the builder for deleting a single Plan entity. +type PlanDeleteOne struct { + pd *PlanDelete +} + +// Where appends a list predicates to the PlanDelete builder. +func (pdo *PlanDeleteOne) Where(ps ...predicate.Plan) *PlanDeleteOne { + pdo.pd.mutation.Where(ps...) + return pdo +} + +// Exec executes the deletion query. +func (pdo *PlanDeleteOne) Exec(ctx context.Context) error { + n, err := pdo.pd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{dbplan.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (pdo *PlanDeleteOne) ExecX(ctx context.Context) { + if err := pdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/openmeter/ent/db/plan_query.go b/openmeter/ent/db/plan_query.go new file mode 100644 index 000000000..2350b02c2 --- /dev/null +++ b/openmeter/ent/db/plan_query.go @@ -0,0 +1,643 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" +) + +// PlanQuery is the builder for querying Plan entities. +type PlanQuery struct { + config + ctx *QueryContext + order []dbplan.OrderOption + inters []Interceptor + predicates []predicate.Plan + withPhases *PlanPhaseQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PlanQuery builder. +func (pq *PlanQuery) Where(ps ...predicate.Plan) *PlanQuery { + pq.predicates = append(pq.predicates, ps...) + return pq +} + +// Limit the number of records to be returned by this query. +func (pq *PlanQuery) Limit(limit int) *PlanQuery { + pq.ctx.Limit = &limit + return pq +} + +// Offset to start from. +func (pq *PlanQuery) Offset(offset int) *PlanQuery { + pq.ctx.Offset = &offset + return pq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (pq *PlanQuery) Unique(unique bool) *PlanQuery { + pq.ctx.Unique = &unique + return pq +} + +// Order specifies how the records should be ordered. +func (pq *PlanQuery) Order(o ...dbplan.OrderOption) *PlanQuery { + pq.order = append(pq.order, o...) + return pq +} + +// QueryPhases chains the current query on the "phases" edge. +func (pq *PlanQuery) QueryPhases() *PlanPhaseQuery { + query := (&PlanPhaseClient{config: pq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := pq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := pq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(dbplan.Table, dbplan.FieldID, selector), + sqlgraph.To(planphase.Table, planphase.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, dbplan.PhasesTable, dbplan.PhasesColumn), + ) + fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Plan entity from the query. +// Returns a *NotFoundError when no Plan was found. +func (pq *PlanQuery) First(ctx context.Context) (*Plan, error) { + nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{dbplan.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (pq *PlanQuery) FirstX(ctx context.Context) *Plan { + node, err := pq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Plan ID from the query. +// Returns a *NotFoundError when no Plan ID was found. +func (pq *PlanQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{dbplan.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (pq *PlanQuery) FirstIDX(ctx context.Context) string { + id, err := pq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Plan entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Plan entity is found. +// Returns a *NotFoundError when no Plan entities are found. +func (pq *PlanQuery) Only(ctx context.Context) (*Plan, error) { + nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{dbplan.Label} + default: + return nil, &NotSingularError{dbplan.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (pq *PlanQuery) OnlyX(ctx context.Context) *Plan { + node, err := pq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Plan ID in the query. +// Returns a *NotSingularError when more than one Plan ID is found. +// Returns a *NotFoundError when no entities are found. +func (pq *PlanQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{dbplan.Label} + default: + err = &NotSingularError{dbplan.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (pq *PlanQuery) OnlyIDX(ctx context.Context) string { + id, err := pq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Plans. +func (pq *PlanQuery) All(ctx context.Context) ([]*Plan, error) { + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryAll) + if err := pq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Plan, *PlanQuery]() + return withInterceptors[[]*Plan](ctx, pq, qr, pq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (pq *PlanQuery) AllX(ctx context.Context) []*Plan { + nodes, err := pq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Plan IDs. +func (pq *PlanQuery) IDs(ctx context.Context) (ids []string, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryIDs) + if err = pq.Select(dbplan.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (pq *PlanQuery) IDsX(ctx context.Context) []string { + ids, err := pq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (pq *PlanQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryCount) + if err := pq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, pq, querierCount[*PlanQuery](), pq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (pq *PlanQuery) CountX(ctx context.Context) int { + count, err := pq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (pq *PlanQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryExist) + switch _, err := pq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (pq *PlanQuery) ExistX(ctx context.Context) bool { + exist, err := pq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PlanQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (pq *PlanQuery) Clone() *PlanQuery { + if pq == nil { + return nil + } + return &PlanQuery{ + config: pq.config, + ctx: pq.ctx.Clone(), + order: append([]dbplan.OrderOption{}, pq.order...), + inters: append([]Interceptor{}, pq.inters...), + predicates: append([]predicate.Plan{}, pq.predicates...), + withPhases: pq.withPhases.Clone(), + // clone intermediate query. + sql: pq.sql.Clone(), + path: pq.path, + } +} + +// WithPhases tells the query-builder to eager-load the nodes that are connected to +// the "phases" edge. The optional arguments are used to configure the query builder of the edge. +func (pq *PlanQuery) WithPhases(opts ...func(*PlanPhaseQuery)) *PlanQuery { + query := (&PlanPhaseClient{config: pq.config}).Query() + for _, opt := range opts { + opt(query) + } + pq.withPhases = query + return pq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Namespace string `json:"namespace,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Plan.Query(). +// GroupBy(dbplan.FieldNamespace). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (pq *PlanQuery) GroupBy(field string, fields ...string) *PlanGroupBy { + pq.ctx.Fields = append([]string{field}, fields...) + grbuild := &PlanGroupBy{build: pq} + grbuild.flds = &pq.ctx.Fields + grbuild.label = dbplan.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Namespace string `json:"namespace,omitempty"` +// } +// +// client.Plan.Query(). +// Select(dbplan.FieldNamespace). +// Scan(ctx, &v) +func (pq *PlanQuery) Select(fields ...string) *PlanSelect { + pq.ctx.Fields = append(pq.ctx.Fields, fields...) + sbuild := &PlanSelect{PlanQuery: pq} + sbuild.label = dbplan.Label + sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PlanSelect configured with the given aggregations. +func (pq *PlanQuery) Aggregate(fns ...AggregateFunc) *PlanSelect { + return pq.Select().Aggregate(fns...) +} + +func (pq *PlanQuery) prepareQuery(ctx context.Context) error { + for _, inter := range pq.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, pq); err != nil { + return err + } + } + } + for _, f := range pq.ctx.Fields { + if !dbplan.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if pq.path != nil { + prev, err := pq.path(ctx) + if err != nil { + return err + } + pq.sql = prev + } + return nil +} + +func (pq *PlanQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Plan, error) { + var ( + nodes = []*Plan{} + _spec = pq.querySpec() + loadedTypes = [1]bool{ + pq.withPhases != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Plan).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Plan{config: pq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(pq.modifiers) > 0 { + _spec.Modifiers = pq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, pq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := pq.withPhases; query != nil { + if err := pq.loadPhases(ctx, query, nodes, + func(n *Plan) { n.Edges.Phases = []*PlanPhase{} }, + func(n *Plan, e *PlanPhase) { n.Edges.Phases = append(n.Edges.Phases, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (pq *PlanQuery) loadPhases(ctx context.Context, query *PlanPhaseQuery, nodes []*Plan, init func(*Plan), assign func(*Plan, *PlanPhase)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*Plan) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(planphase.FieldPlanID) + } + query.Where(predicate.PlanPhase(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(dbplan.PhasesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.PlanID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "plan_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (pq *PlanQuery) sqlCount(ctx context.Context) (int, error) { + _spec := pq.querySpec() + if len(pq.modifiers) > 0 { + _spec.Modifiers = pq.modifiers + } + _spec.Node.Columns = pq.ctx.Fields + if len(pq.ctx.Fields) > 0 { + _spec.Unique = pq.ctx.Unique != nil && *pq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, pq.driver, _spec) +} + +func (pq *PlanQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(dbplan.Table, dbplan.Columns, sqlgraph.NewFieldSpec(dbplan.FieldID, field.TypeString)) + _spec.From = pq.sql + if unique := pq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true + } + if fields := pq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, dbplan.FieldID) + for i := range fields { + if fields[i] != dbplan.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := pq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := pq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := pq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := pq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (pq *PlanQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(pq.driver.Dialect()) + t1 := builder.Table(dbplan.Table) + columns := pq.ctx.Fields + if len(columns) == 0 { + columns = dbplan.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if pq.sql != nil { + selector = pq.sql + selector.Select(selector.Columns(columns...)...) + } + if pq.ctx.Unique != nil && *pq.ctx.Unique { + selector.Distinct() + } + for _, m := range pq.modifiers { + m(selector) + } + for _, p := range pq.predicates { + p(selector) + } + for _, p := range pq.order { + p(selector) + } + if offset := pq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := pq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (pq *PlanQuery) ForUpdate(opts ...sql.LockOption) *PlanQuery { + if pq.driver.Dialect() == dialect.Postgres { + pq.Unique(false) + } + pq.modifiers = append(pq.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return pq +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (pq *PlanQuery) ForShare(opts ...sql.LockOption) *PlanQuery { + if pq.driver.Dialect() == dialect.Postgres { + pq.Unique(false) + } + pq.modifiers = append(pq.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return pq +} + +// PlanGroupBy is the group-by builder for Plan entities. +type PlanGroupBy struct { + selector + build *PlanQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (pgb *PlanGroupBy) Aggregate(fns ...AggregateFunc) *PlanGroupBy { + pgb.fns = append(pgb.fns, fns...) + return pgb +} + +// Scan applies the selector query and scans the result into the given value. +func (pgb *PlanGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, pgb.build.ctx, ent.OpQueryGroupBy) + if err := pgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PlanQuery, *PlanGroupBy](ctx, pgb.build, pgb, pgb.build.inters, v) +} + +func (pgb *PlanGroupBy) sqlScan(ctx context.Context, root *PlanQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(pgb.fns)) + for _, fn := range pgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*pgb.flds)+len(pgb.fns)) + for _, f := range *pgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*pgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := pgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// PlanSelect is the builder for selecting fields of Plan entities. +type PlanSelect struct { + *PlanQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ps *PlanSelect) Aggregate(fns ...AggregateFunc) *PlanSelect { + ps.fns = append(ps.fns, fns...) + return ps +} + +// Scan applies the selector query and scans the result into the given value. +func (ps *PlanSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ps.ctx, ent.OpQuerySelect) + if err := ps.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PlanQuery, *PlanSelect](ctx, ps.PlanQuery, ps, ps.inters, v) +} + +func (ps *PlanSelect) sqlScan(ctx context.Context, root *PlanQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ps.fns)) + for _, fn := range ps.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ps.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ps.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/openmeter/ent/db/plan_update.go b/openmeter/ent/db/plan_update.go new file mode 100644 index 000000000..cd372b871 --- /dev/null +++ b/openmeter/ent/db/plan_update.go @@ -0,0 +1,733 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" +) + +// PlanUpdate is the builder for updating Plan entities. +type PlanUpdate struct { + config + hooks []Hook + mutation *PlanMutation +} + +// Where appends a list predicates to the PlanUpdate builder. +func (pu *PlanUpdate) Where(ps ...predicate.Plan) *PlanUpdate { + pu.mutation.Where(ps...) + return pu +} + +// SetMetadata sets the "metadata" field. +func (pu *PlanUpdate) SetMetadata(m map[string]string) *PlanUpdate { + pu.mutation.SetMetadata(m) + return pu +} + +// ClearMetadata clears the value of the "metadata" field. +func (pu *PlanUpdate) ClearMetadata() *PlanUpdate { + pu.mutation.ClearMetadata() + return pu +} + +// SetUpdatedAt sets the "updated_at" field. +func (pu *PlanUpdate) SetUpdatedAt(t time.Time) *PlanUpdate { + pu.mutation.SetUpdatedAt(t) + return pu +} + +// SetDeletedAt sets the "deleted_at" field. +func (pu *PlanUpdate) SetDeletedAt(t time.Time) *PlanUpdate { + pu.mutation.SetDeletedAt(t) + return pu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (pu *PlanUpdate) SetNillableDeletedAt(t *time.Time) *PlanUpdate { + if t != nil { + pu.SetDeletedAt(*t) + } + return pu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (pu *PlanUpdate) ClearDeletedAt() *PlanUpdate { + pu.mutation.ClearDeletedAt() + return pu +} + +// SetName sets the "name" field. +func (pu *PlanUpdate) SetName(s string) *PlanUpdate { + pu.mutation.SetName(s) + return pu +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (pu *PlanUpdate) SetNillableName(s *string) *PlanUpdate { + if s != nil { + pu.SetName(*s) + } + return pu +} + +// SetDescription sets the "description" field. +func (pu *PlanUpdate) SetDescription(s string) *PlanUpdate { + pu.mutation.SetDescription(s) + return pu +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (pu *PlanUpdate) SetNillableDescription(s *string) *PlanUpdate { + if s != nil { + pu.SetDescription(*s) + } + return pu +} + +// ClearDescription clears the value of the "description" field. +func (pu *PlanUpdate) ClearDescription() *PlanUpdate { + pu.mutation.ClearDescription() + return pu +} + +// SetVersion sets the "version" field. +func (pu *PlanUpdate) SetVersion(i int) *PlanUpdate { + pu.mutation.ResetVersion() + pu.mutation.SetVersion(i) + return pu +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (pu *PlanUpdate) SetNillableVersion(i *int) *PlanUpdate { + if i != nil { + pu.SetVersion(*i) + } + return pu +} + +// AddVersion adds i to the "version" field. +func (pu *PlanUpdate) AddVersion(i int) *PlanUpdate { + pu.mutation.AddVersion(i) + return pu +} + +// SetEffectiveFrom sets the "effective_from" field. +func (pu *PlanUpdate) SetEffectiveFrom(t time.Time) *PlanUpdate { + pu.mutation.SetEffectiveFrom(t) + return pu +} + +// SetNillableEffectiveFrom sets the "effective_from" field if the given value is not nil. +func (pu *PlanUpdate) SetNillableEffectiveFrom(t *time.Time) *PlanUpdate { + if t != nil { + pu.SetEffectiveFrom(*t) + } + return pu +} + +// ClearEffectiveFrom clears the value of the "effective_from" field. +func (pu *PlanUpdate) ClearEffectiveFrom() *PlanUpdate { + pu.mutation.ClearEffectiveFrom() + return pu +} + +// SetEffectiveTo sets the "effective_to" field. +func (pu *PlanUpdate) SetEffectiveTo(t time.Time) *PlanUpdate { + pu.mutation.SetEffectiveTo(t) + return pu +} + +// SetNillableEffectiveTo sets the "effective_to" field if the given value is not nil. +func (pu *PlanUpdate) SetNillableEffectiveTo(t *time.Time) *PlanUpdate { + if t != nil { + pu.SetEffectiveTo(*t) + } + return pu +} + +// ClearEffectiveTo clears the value of the "effective_to" field. +func (pu *PlanUpdate) ClearEffectiveTo() *PlanUpdate { + pu.mutation.ClearEffectiveTo() + return pu +} + +// AddPhaseIDs adds the "phases" edge to the PlanPhase entity by IDs. +func (pu *PlanUpdate) AddPhaseIDs(ids ...string) *PlanUpdate { + pu.mutation.AddPhaseIDs(ids...) + return pu +} + +// AddPhases adds the "phases" edges to the PlanPhase entity. +func (pu *PlanUpdate) AddPhases(p ...*PlanPhase) *PlanUpdate { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return pu.AddPhaseIDs(ids...) +} + +// Mutation returns the PlanMutation object of the builder. +func (pu *PlanUpdate) Mutation() *PlanMutation { + return pu.mutation +} + +// ClearPhases clears all "phases" edges to the PlanPhase entity. +func (pu *PlanUpdate) ClearPhases() *PlanUpdate { + pu.mutation.ClearPhases() + return pu +} + +// RemovePhaseIDs removes the "phases" edge to PlanPhase entities by IDs. +func (pu *PlanUpdate) RemovePhaseIDs(ids ...string) *PlanUpdate { + pu.mutation.RemovePhaseIDs(ids...) + return pu +} + +// RemovePhases removes "phases" edges to PlanPhase entities. +func (pu *PlanUpdate) RemovePhases(p ...*PlanPhase) *PlanUpdate { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return pu.RemovePhaseIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (pu *PlanUpdate) Save(ctx context.Context) (int, error) { + pu.defaults() + return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (pu *PlanUpdate) SaveX(ctx context.Context) int { + affected, err := pu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (pu *PlanUpdate) Exec(ctx context.Context) error { + _, err := pu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (pu *PlanUpdate) ExecX(ctx context.Context) { + if err := pu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (pu *PlanUpdate) defaults() { + if _, ok := pu.mutation.UpdatedAt(); !ok { + v := dbplan.UpdateDefaultUpdatedAt() + pu.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (pu *PlanUpdate) check() error { + if v, ok := pu.mutation.Version(); ok { + if err := dbplan.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "Plan.version": %w`, err)} + } + } + return nil +} + +func (pu *PlanUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := pu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(dbplan.Table, dbplan.Columns, sqlgraph.NewFieldSpec(dbplan.FieldID, field.TypeString)) + if ps := pu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := pu.mutation.Metadata(); ok { + _spec.SetField(dbplan.FieldMetadata, field.TypeJSON, value) + } + if pu.mutation.MetadataCleared() { + _spec.ClearField(dbplan.FieldMetadata, field.TypeJSON) + } + if value, ok := pu.mutation.UpdatedAt(); ok { + _spec.SetField(dbplan.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := pu.mutation.DeletedAt(); ok { + _spec.SetField(dbplan.FieldDeletedAt, field.TypeTime, value) + } + if pu.mutation.DeletedAtCleared() { + _spec.ClearField(dbplan.FieldDeletedAt, field.TypeTime) + } + if value, ok := pu.mutation.Name(); ok { + _spec.SetField(dbplan.FieldName, field.TypeString, value) + } + if value, ok := pu.mutation.Description(); ok { + _spec.SetField(dbplan.FieldDescription, field.TypeString, value) + } + if pu.mutation.DescriptionCleared() { + _spec.ClearField(dbplan.FieldDescription, field.TypeString) + } + if value, ok := pu.mutation.Version(); ok { + _spec.SetField(dbplan.FieldVersion, field.TypeInt, value) + } + if value, ok := pu.mutation.AddedVersion(); ok { + _spec.AddField(dbplan.FieldVersion, field.TypeInt, value) + } + if value, ok := pu.mutation.EffectiveFrom(); ok { + _spec.SetField(dbplan.FieldEffectiveFrom, field.TypeTime, value) + } + if pu.mutation.EffectiveFromCleared() { + _spec.ClearField(dbplan.FieldEffectiveFrom, field.TypeTime) + } + if value, ok := pu.mutation.EffectiveTo(); ok { + _spec.SetField(dbplan.FieldEffectiveTo, field.TypeTime, value) + } + if pu.mutation.EffectiveToCleared() { + _spec.ClearField(dbplan.FieldEffectiveTo, field.TypeTime) + } + if pu.mutation.PhasesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: dbplan.PhasesTable, + Columns: []string{dbplan.PhasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := pu.mutation.RemovedPhasesIDs(); len(nodes) > 0 && !pu.mutation.PhasesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: dbplan.PhasesTable, + Columns: []string{dbplan.PhasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := pu.mutation.PhasesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: dbplan.PhasesTable, + Columns: []string{dbplan.PhasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{dbplan.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + pu.mutation.done = true + return n, nil +} + +// PlanUpdateOne is the builder for updating a single Plan entity. +type PlanUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PlanMutation +} + +// SetMetadata sets the "metadata" field. +func (puo *PlanUpdateOne) SetMetadata(m map[string]string) *PlanUpdateOne { + puo.mutation.SetMetadata(m) + return puo +} + +// ClearMetadata clears the value of the "metadata" field. +func (puo *PlanUpdateOne) ClearMetadata() *PlanUpdateOne { + puo.mutation.ClearMetadata() + return puo +} + +// SetUpdatedAt sets the "updated_at" field. +func (puo *PlanUpdateOne) SetUpdatedAt(t time.Time) *PlanUpdateOne { + puo.mutation.SetUpdatedAt(t) + return puo +} + +// SetDeletedAt sets the "deleted_at" field. +func (puo *PlanUpdateOne) SetDeletedAt(t time.Time) *PlanUpdateOne { + puo.mutation.SetDeletedAt(t) + return puo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (puo *PlanUpdateOne) SetNillableDeletedAt(t *time.Time) *PlanUpdateOne { + if t != nil { + puo.SetDeletedAt(*t) + } + return puo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (puo *PlanUpdateOne) ClearDeletedAt() *PlanUpdateOne { + puo.mutation.ClearDeletedAt() + return puo +} + +// SetName sets the "name" field. +func (puo *PlanUpdateOne) SetName(s string) *PlanUpdateOne { + puo.mutation.SetName(s) + return puo +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (puo *PlanUpdateOne) SetNillableName(s *string) *PlanUpdateOne { + if s != nil { + puo.SetName(*s) + } + return puo +} + +// SetDescription sets the "description" field. +func (puo *PlanUpdateOne) SetDescription(s string) *PlanUpdateOne { + puo.mutation.SetDescription(s) + return puo +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (puo *PlanUpdateOne) SetNillableDescription(s *string) *PlanUpdateOne { + if s != nil { + puo.SetDescription(*s) + } + return puo +} + +// ClearDescription clears the value of the "description" field. +func (puo *PlanUpdateOne) ClearDescription() *PlanUpdateOne { + puo.mutation.ClearDescription() + return puo +} + +// SetVersion sets the "version" field. +func (puo *PlanUpdateOne) SetVersion(i int) *PlanUpdateOne { + puo.mutation.ResetVersion() + puo.mutation.SetVersion(i) + return puo +} + +// SetNillableVersion sets the "version" field if the given value is not nil. +func (puo *PlanUpdateOne) SetNillableVersion(i *int) *PlanUpdateOne { + if i != nil { + puo.SetVersion(*i) + } + return puo +} + +// AddVersion adds i to the "version" field. +func (puo *PlanUpdateOne) AddVersion(i int) *PlanUpdateOne { + puo.mutation.AddVersion(i) + return puo +} + +// SetEffectiveFrom sets the "effective_from" field. +func (puo *PlanUpdateOne) SetEffectiveFrom(t time.Time) *PlanUpdateOne { + puo.mutation.SetEffectiveFrom(t) + return puo +} + +// SetNillableEffectiveFrom sets the "effective_from" field if the given value is not nil. +func (puo *PlanUpdateOne) SetNillableEffectiveFrom(t *time.Time) *PlanUpdateOne { + if t != nil { + puo.SetEffectiveFrom(*t) + } + return puo +} + +// ClearEffectiveFrom clears the value of the "effective_from" field. +func (puo *PlanUpdateOne) ClearEffectiveFrom() *PlanUpdateOne { + puo.mutation.ClearEffectiveFrom() + return puo +} + +// SetEffectiveTo sets the "effective_to" field. +func (puo *PlanUpdateOne) SetEffectiveTo(t time.Time) *PlanUpdateOne { + puo.mutation.SetEffectiveTo(t) + return puo +} + +// SetNillableEffectiveTo sets the "effective_to" field if the given value is not nil. +func (puo *PlanUpdateOne) SetNillableEffectiveTo(t *time.Time) *PlanUpdateOne { + if t != nil { + puo.SetEffectiveTo(*t) + } + return puo +} + +// ClearEffectiveTo clears the value of the "effective_to" field. +func (puo *PlanUpdateOne) ClearEffectiveTo() *PlanUpdateOne { + puo.mutation.ClearEffectiveTo() + return puo +} + +// AddPhaseIDs adds the "phases" edge to the PlanPhase entity by IDs. +func (puo *PlanUpdateOne) AddPhaseIDs(ids ...string) *PlanUpdateOne { + puo.mutation.AddPhaseIDs(ids...) + return puo +} + +// AddPhases adds the "phases" edges to the PlanPhase entity. +func (puo *PlanUpdateOne) AddPhases(p ...*PlanPhase) *PlanUpdateOne { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return puo.AddPhaseIDs(ids...) +} + +// Mutation returns the PlanMutation object of the builder. +func (puo *PlanUpdateOne) Mutation() *PlanMutation { + return puo.mutation +} + +// ClearPhases clears all "phases" edges to the PlanPhase entity. +func (puo *PlanUpdateOne) ClearPhases() *PlanUpdateOne { + puo.mutation.ClearPhases() + return puo +} + +// RemovePhaseIDs removes the "phases" edge to PlanPhase entities by IDs. +func (puo *PlanUpdateOne) RemovePhaseIDs(ids ...string) *PlanUpdateOne { + puo.mutation.RemovePhaseIDs(ids...) + return puo +} + +// RemovePhases removes "phases" edges to PlanPhase entities. +func (puo *PlanUpdateOne) RemovePhases(p ...*PlanPhase) *PlanUpdateOne { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return puo.RemovePhaseIDs(ids...) +} + +// Where appends a list predicates to the PlanUpdate builder. +func (puo *PlanUpdateOne) Where(ps ...predicate.Plan) *PlanUpdateOne { + puo.mutation.Where(ps...) + return puo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (puo *PlanUpdateOne) Select(field string, fields ...string) *PlanUpdateOne { + puo.fields = append([]string{field}, fields...) + return puo +} + +// Save executes the query and returns the updated Plan entity. +func (puo *PlanUpdateOne) Save(ctx context.Context) (*Plan, error) { + puo.defaults() + return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (puo *PlanUpdateOne) SaveX(ctx context.Context) *Plan { + node, err := puo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (puo *PlanUpdateOne) Exec(ctx context.Context) error { + _, err := puo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (puo *PlanUpdateOne) ExecX(ctx context.Context) { + if err := puo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (puo *PlanUpdateOne) defaults() { + if _, ok := puo.mutation.UpdatedAt(); !ok { + v := dbplan.UpdateDefaultUpdatedAt() + puo.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (puo *PlanUpdateOne) check() error { + if v, ok := puo.mutation.Version(); ok { + if err := dbplan.VersionValidator(v); err != nil { + return &ValidationError{Name: "version", err: fmt.Errorf(`db: validator failed for field "Plan.version": %w`, err)} + } + } + return nil +} + +func (puo *PlanUpdateOne) sqlSave(ctx context.Context) (_node *Plan, err error) { + if err := puo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(dbplan.Table, dbplan.Columns, sqlgraph.NewFieldSpec(dbplan.FieldID, field.TypeString)) + id, ok := puo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "Plan.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := puo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, dbplan.FieldID) + for _, f := range fields { + if !dbplan.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != dbplan.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := puo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := puo.mutation.Metadata(); ok { + _spec.SetField(dbplan.FieldMetadata, field.TypeJSON, value) + } + if puo.mutation.MetadataCleared() { + _spec.ClearField(dbplan.FieldMetadata, field.TypeJSON) + } + if value, ok := puo.mutation.UpdatedAt(); ok { + _spec.SetField(dbplan.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := puo.mutation.DeletedAt(); ok { + _spec.SetField(dbplan.FieldDeletedAt, field.TypeTime, value) + } + if puo.mutation.DeletedAtCleared() { + _spec.ClearField(dbplan.FieldDeletedAt, field.TypeTime) + } + if value, ok := puo.mutation.Name(); ok { + _spec.SetField(dbplan.FieldName, field.TypeString, value) + } + if value, ok := puo.mutation.Description(); ok { + _spec.SetField(dbplan.FieldDescription, field.TypeString, value) + } + if puo.mutation.DescriptionCleared() { + _spec.ClearField(dbplan.FieldDescription, field.TypeString) + } + if value, ok := puo.mutation.Version(); ok { + _spec.SetField(dbplan.FieldVersion, field.TypeInt, value) + } + if value, ok := puo.mutation.AddedVersion(); ok { + _spec.AddField(dbplan.FieldVersion, field.TypeInt, value) + } + if value, ok := puo.mutation.EffectiveFrom(); ok { + _spec.SetField(dbplan.FieldEffectiveFrom, field.TypeTime, value) + } + if puo.mutation.EffectiveFromCleared() { + _spec.ClearField(dbplan.FieldEffectiveFrom, field.TypeTime) + } + if value, ok := puo.mutation.EffectiveTo(); ok { + _spec.SetField(dbplan.FieldEffectiveTo, field.TypeTime, value) + } + if puo.mutation.EffectiveToCleared() { + _spec.ClearField(dbplan.FieldEffectiveTo, field.TypeTime) + } + if puo.mutation.PhasesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: dbplan.PhasesTable, + Columns: []string{dbplan.PhasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := puo.mutation.RemovedPhasesIDs(); len(nodes) > 0 && !puo.mutation.PhasesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: dbplan.PhasesTable, + Columns: []string{dbplan.PhasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := puo.mutation.PhasesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: dbplan.PhasesTable, + Columns: []string{dbplan.PhasesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Plan{config: puo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{dbplan.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + puo.mutation.done = true + return _node, nil +} diff --git a/openmeter/ent/db/planphase.go b/openmeter/ent/db/planphase.go new file mode 100644 index 000000000..4bfa56067 --- /dev/null +++ b/openmeter/ent/db/planphase.go @@ -0,0 +1,274 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" + "github.com/openmeterio/openmeter/pkg/datex" +) + +// PlanPhase is the model entity for the PlanPhase schema. +type PlanPhase struct { + config `json:"-"` + // ID of the ent. + ID string `json:"id,omitempty"` + // Namespace holds the value of the "namespace" field. + Namespace string `json:"namespace,omitempty"` + // Metadata holds the value of the "metadata" field. + Metadata map[string]string `json:"metadata,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt *time.Time `json:"deleted_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description *string `json:"description,omitempty"` + // Key holds the value of the "key" field. + Key string `json:"key,omitempty"` + // StartAfter holds the value of the "start_after" field. + StartAfter datex.ISOString `json:"start_after,omitempty"` + // Discounts holds the value of the "discounts" field. + Discounts []plan.Discount `json:"discounts,omitempty"` + // The plan identifier the phase is assigned to. + PlanID string `json:"plan_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PlanPhaseQuery when eager-loading is set. + Edges PlanPhaseEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PlanPhaseEdges holds the relations/edges for other nodes in the graph. +type PlanPhaseEdges struct { + // Plan holds the value of the plan edge. + Plan *Plan `json:"plan,omitempty"` + // Ratecards holds the value of the ratecards edge. + Ratecards []*PlanRateCard `json:"ratecards,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// PlanOrErr returns the Plan value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PlanPhaseEdges) PlanOrErr() (*Plan, error) { + if e.Plan != nil { + return e.Plan, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: dbplan.Label} + } + return nil, &NotLoadedError{edge: "plan"} +} + +// RatecardsOrErr returns the Ratecards value or an error if the edge +// was not loaded in eager-loading. +func (e PlanPhaseEdges) RatecardsOrErr() ([]*PlanRateCard, error) { + if e.loadedTypes[1] { + return e.Ratecards, nil + } + return nil, &NotLoadedError{edge: "ratecards"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*PlanPhase) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case planphase.FieldMetadata: + values[i] = new([]byte) + case planphase.FieldID, planphase.FieldNamespace, planphase.FieldName, planphase.FieldDescription, planphase.FieldKey, planphase.FieldStartAfter, planphase.FieldPlanID: + values[i] = new(sql.NullString) + case planphase.FieldCreatedAt, planphase.FieldUpdatedAt, planphase.FieldDeletedAt: + values[i] = new(sql.NullTime) + case planphase.FieldDiscounts: + values[i] = planphase.ValueScanner.Discounts.ScanValue() + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the PlanPhase fields. +func (pp *PlanPhase) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case planphase.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + pp.ID = value.String + } + case planphase.FieldNamespace: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field namespace", values[i]) + } else if value.Valid { + pp.Namespace = value.String + } + case planphase.FieldMetadata: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field metadata", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &pp.Metadata); err != nil { + return fmt.Errorf("unmarshal field metadata: %w", err) + } + } + case planphase.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + pp.CreatedAt = value.Time + } + case planphase.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + pp.UpdatedAt = value.Time + } + case planphase.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + pp.DeletedAt = new(time.Time) + *pp.DeletedAt = value.Time + } + case planphase.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + pp.Name = value.String + } + case planphase.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + pp.Description = new(string) + *pp.Description = value.String + } + case planphase.FieldKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field key", values[i]) + } else if value.Valid { + pp.Key = value.String + } + case planphase.FieldStartAfter: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field start_after", values[i]) + } else if value.Valid { + pp.StartAfter = datex.ISOString(value.String) + } + case planphase.FieldDiscounts: + if value, err := planphase.ValueScanner.Discounts.FromValue(values[i]); err != nil { + return err + } else { + pp.Discounts = value + } + case planphase.FieldPlanID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field plan_id", values[i]) + } else if value.Valid { + pp.PlanID = value.String + } + default: + pp.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the PlanPhase. +// This includes values selected through modifiers, order, etc. +func (pp *PlanPhase) Value(name string) (ent.Value, error) { + return pp.selectValues.Get(name) +} + +// QueryPlan queries the "plan" edge of the PlanPhase entity. +func (pp *PlanPhase) QueryPlan() *PlanQuery { + return NewPlanPhaseClient(pp.config).QueryPlan(pp) +} + +// QueryRatecards queries the "ratecards" edge of the PlanPhase entity. +func (pp *PlanPhase) QueryRatecards() *PlanRateCardQuery { + return NewPlanPhaseClient(pp.config).QueryRatecards(pp) +} + +// Update returns a builder for updating this PlanPhase. +// Note that you need to call PlanPhase.Unwrap() before calling this method if this PlanPhase +// was returned from a transaction, and the transaction was committed or rolled back. +func (pp *PlanPhase) Update() *PlanPhaseUpdateOne { + return NewPlanPhaseClient(pp.config).UpdateOne(pp) +} + +// Unwrap unwraps the PlanPhase entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (pp *PlanPhase) Unwrap() *PlanPhase { + _tx, ok := pp.config.driver.(*txDriver) + if !ok { + panic("db: PlanPhase is not a transactional entity") + } + pp.config.driver = _tx.drv + return pp +} + +// String implements the fmt.Stringer. +func (pp *PlanPhase) String() string { + var builder strings.Builder + builder.WriteString("PlanPhase(") + builder.WriteString(fmt.Sprintf("id=%v, ", pp.ID)) + builder.WriteString("namespace=") + builder.WriteString(pp.Namespace) + builder.WriteString(", ") + builder.WriteString("metadata=") + builder.WriteString(fmt.Sprintf("%v", pp.Metadata)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(pp.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(pp.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + if v := pp.DeletedAt; v != nil { + builder.WriteString("deleted_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(pp.Name) + builder.WriteString(", ") + if v := pp.Description; v != nil { + builder.WriteString("description=") + builder.WriteString(*v) + } + builder.WriteString(", ") + builder.WriteString("key=") + builder.WriteString(pp.Key) + builder.WriteString(", ") + builder.WriteString("start_after=") + builder.WriteString(fmt.Sprintf("%v", pp.StartAfter)) + builder.WriteString(", ") + builder.WriteString("discounts=") + builder.WriteString(fmt.Sprintf("%v", pp.Discounts)) + builder.WriteString(", ") + builder.WriteString("plan_id=") + builder.WriteString(pp.PlanID) + builder.WriteByte(')') + return builder.String() +} + +// PlanPhases is a parsable slice of PlanPhase. +type PlanPhases []*PlanPhase diff --git a/openmeter/ent/db/planphase/planphase.go b/openmeter/ent/db/planphase/planphase.go new file mode 100644 index 000000000..fb67a9682 --- /dev/null +++ b/openmeter/ent/db/planphase/planphase.go @@ -0,0 +1,204 @@ +// Code generated by ent, DO NOT EDIT. + +package planphase + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" + "github.com/openmeterio/openmeter/pkg/datex" +) + +const ( + // Label holds the string label denoting the planphase type in the database. + Label = "plan_phase" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldNamespace holds the string denoting the namespace field in the database. + FieldNamespace = "namespace" + // FieldMetadata holds the string denoting the metadata field in the database. + FieldMetadata = "metadata" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldKey holds the string denoting the key field in the database. + FieldKey = "key" + // FieldStartAfter holds the string denoting the start_after field in the database. + FieldStartAfter = "start_after" + // FieldDiscounts holds the string denoting the discounts field in the database. + FieldDiscounts = "discounts" + // FieldPlanID holds the string denoting the plan_id field in the database. + FieldPlanID = "plan_id" + // EdgePlan holds the string denoting the plan edge name in mutations. + EdgePlan = "plan" + // EdgeRatecards holds the string denoting the ratecards edge name in mutations. + EdgeRatecards = "ratecards" + // Table holds the table name of the planphase in the database. + Table = "plan_phases" + // PlanTable is the table that holds the plan relation/edge. + PlanTable = "plan_phases" + // PlanInverseTable is the table name for the Plan entity. + // It exists in this package in order to avoid circular dependency with the "dbplan" package. + PlanInverseTable = "plans" + // PlanColumn is the table column denoting the plan relation/edge. + PlanColumn = "plan_id" + // RatecardsTable is the table that holds the ratecards relation/edge. + RatecardsTable = "plan_rate_cards" + // RatecardsInverseTable is the table name for the PlanRateCard entity. + // It exists in this package in order to avoid circular dependency with the "planratecard" package. + RatecardsInverseTable = "plan_rate_cards" + // RatecardsColumn is the table column denoting the ratecards relation/edge. + RatecardsColumn = "phase_id" +) + +// Columns holds all SQL columns for planphase fields. +var Columns = []string{ + FieldID, + FieldNamespace, + FieldMetadata, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldName, + FieldDescription, + FieldKey, + FieldStartAfter, + FieldDiscounts, + FieldPlanID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // NamespaceValidator is a validator for the "namespace" field. It is called by the builders before save. + NamespaceValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // KeyValidator is a validator for the "key" field. It is called by the builders before save. + KeyValidator func(string) error + // DefaultStartAfter holds the default value on creation for the "start_after" field. + DefaultStartAfter datex.ISOString + // PlanIDValidator is a validator for the "plan_id" field. It is called by the builders before save. + PlanIDValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string + // ValueScanner of all PlanPhase fields. + ValueScanner struct { + Discounts field.TypeValueScanner[[]plan.Discount] + } +) + +// OrderOption defines the ordering options for the PlanPhase queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByNamespace orders the results by the namespace field. +func ByNamespace(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNamespace, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByKey orders the results by the key field. +func ByKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKey, opts...).ToFunc() +} + +// ByStartAfter orders the results by the start_after field. +func ByStartAfter(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStartAfter, opts...).ToFunc() +} + +// ByDiscounts orders the results by the discounts field. +func ByDiscounts(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDiscounts, opts...).ToFunc() +} + +// ByPlanID orders the results by the plan_id field. +func ByPlanID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPlanID, opts...).ToFunc() +} + +// ByPlanField orders the results by plan field. +func ByPlanField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPlanStep(), sql.OrderByField(field, opts...)) + } +} + +// ByRatecardsCount orders the results by ratecards count. +func ByRatecardsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRatecardsStep(), opts...) + } +} + +// ByRatecards orders the results by ratecards terms. +func ByRatecards(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRatecardsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newPlanStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PlanInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, PlanTable, PlanColumn), + ) +} +func newRatecardsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RatecardsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, RatecardsTable, RatecardsColumn), + ) +} diff --git a/openmeter/ent/db/planphase/where.go b/openmeter/ent/db/planphase/where.go new file mode 100644 index 000000000..90dd35f87 --- /dev/null +++ b/openmeter/ent/db/planphase/where.go @@ -0,0 +1,743 @@ +// Code generated by ent, DO NOT EDIT. + +package planphase + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" + "github.com/openmeterio/openmeter/pkg/datex" +) + +// ID filters vertices based on their ID field. +func ID(id string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContainsFold(FieldID, id)) +} + +// Namespace applies equality check predicate on the "namespace" field. It's identical to NamespaceEQ. +func Namespace(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldNamespace, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldName, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldDescription, v)) +} + +// Key applies equality check predicate on the "key" field. It's identical to KeyEQ. +func Key(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldKey, v)) +} + +// StartAfter applies equality check predicate on the "start_after" field. It's identical to StartAfterEQ. +func StartAfter(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldEQ(FieldStartAfter, vc)) +} + +// PlanID applies equality check predicate on the "plan_id" field. It's identical to PlanIDEQ. +func PlanID(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldPlanID, v)) +} + +// NamespaceEQ applies the EQ predicate on the "namespace" field. +func NamespaceEQ(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldNamespace, v)) +} + +// NamespaceNEQ applies the NEQ predicate on the "namespace" field. +func NamespaceNEQ(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNEQ(FieldNamespace, v)) +} + +// NamespaceIn applies the In predicate on the "namespace" field. +func NamespaceIn(vs ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIn(FieldNamespace, vs...)) +} + +// NamespaceNotIn applies the NotIn predicate on the "namespace" field. +func NamespaceNotIn(vs ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotIn(FieldNamespace, vs...)) +} + +// NamespaceGT applies the GT predicate on the "namespace" field. +func NamespaceGT(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGT(FieldNamespace, v)) +} + +// NamespaceGTE applies the GTE predicate on the "namespace" field. +func NamespaceGTE(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGTE(FieldNamespace, v)) +} + +// NamespaceLT applies the LT predicate on the "namespace" field. +func NamespaceLT(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLT(FieldNamespace, v)) +} + +// NamespaceLTE applies the LTE predicate on the "namespace" field. +func NamespaceLTE(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLTE(FieldNamespace, v)) +} + +// NamespaceContains applies the Contains predicate on the "namespace" field. +func NamespaceContains(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContains(FieldNamespace, v)) +} + +// NamespaceHasPrefix applies the HasPrefix predicate on the "namespace" field. +func NamespaceHasPrefix(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldHasPrefix(FieldNamespace, v)) +} + +// NamespaceHasSuffix applies the HasSuffix predicate on the "namespace" field. +func NamespaceHasSuffix(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldHasSuffix(FieldNamespace, v)) +} + +// NamespaceEqualFold applies the EqualFold predicate on the "namespace" field. +func NamespaceEqualFold(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEqualFold(FieldNamespace, v)) +} + +// NamespaceContainsFold applies the ContainsFold predicate on the "namespace" field. +func NamespaceContainsFold(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContainsFold(FieldNamespace, v)) +} + +// MetadataIsNil applies the IsNil predicate on the "metadata" field. +func MetadataIsNil() predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIsNull(FieldMetadata)) +} + +// MetadataNotNil applies the NotNil predicate on the "metadata" field. +func MetadataNotNil() predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotNull(FieldMetadata)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotNull(FieldDeletedAt)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContainsFold(FieldName, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContainsFold(FieldDescription, v)) +} + +// KeyEQ applies the EQ predicate on the "key" field. +func KeyEQ(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldKey, v)) +} + +// KeyNEQ applies the NEQ predicate on the "key" field. +func KeyNEQ(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNEQ(FieldKey, v)) +} + +// KeyIn applies the In predicate on the "key" field. +func KeyIn(vs ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIn(FieldKey, vs...)) +} + +// KeyNotIn applies the NotIn predicate on the "key" field. +func KeyNotIn(vs ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotIn(FieldKey, vs...)) +} + +// KeyGT applies the GT predicate on the "key" field. +func KeyGT(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGT(FieldKey, v)) +} + +// KeyGTE applies the GTE predicate on the "key" field. +func KeyGTE(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGTE(FieldKey, v)) +} + +// KeyLT applies the LT predicate on the "key" field. +func KeyLT(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLT(FieldKey, v)) +} + +// KeyLTE applies the LTE predicate on the "key" field. +func KeyLTE(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLTE(FieldKey, v)) +} + +// KeyContains applies the Contains predicate on the "key" field. +func KeyContains(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContains(FieldKey, v)) +} + +// KeyHasPrefix applies the HasPrefix predicate on the "key" field. +func KeyHasPrefix(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldHasPrefix(FieldKey, v)) +} + +// KeyHasSuffix applies the HasSuffix predicate on the "key" field. +func KeyHasSuffix(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldHasSuffix(FieldKey, v)) +} + +// KeyEqualFold applies the EqualFold predicate on the "key" field. +func KeyEqualFold(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEqualFold(FieldKey, v)) +} + +// KeyContainsFold applies the ContainsFold predicate on the "key" field. +func KeyContainsFold(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContainsFold(FieldKey, v)) +} + +// StartAfterEQ applies the EQ predicate on the "start_after" field. +func StartAfterEQ(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldEQ(FieldStartAfter, vc)) +} + +// StartAfterNEQ applies the NEQ predicate on the "start_after" field. +func StartAfterNEQ(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldNEQ(FieldStartAfter, vc)) +} + +// StartAfterIn applies the In predicate on the "start_after" field. +func StartAfterIn(vs ...datex.ISOString) predicate.PlanPhase { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.PlanPhase(sql.FieldIn(FieldStartAfter, v...)) +} + +// StartAfterNotIn applies the NotIn predicate on the "start_after" field. +func StartAfterNotIn(vs ...datex.ISOString) predicate.PlanPhase { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.PlanPhase(sql.FieldNotIn(FieldStartAfter, v...)) +} + +// StartAfterGT applies the GT predicate on the "start_after" field. +func StartAfterGT(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldGT(FieldStartAfter, vc)) +} + +// StartAfterGTE applies the GTE predicate on the "start_after" field. +func StartAfterGTE(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldGTE(FieldStartAfter, vc)) +} + +// StartAfterLT applies the LT predicate on the "start_after" field. +func StartAfterLT(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldLT(FieldStartAfter, vc)) +} + +// StartAfterLTE applies the LTE predicate on the "start_after" field. +func StartAfterLTE(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldLTE(FieldStartAfter, vc)) +} + +// StartAfterContains applies the Contains predicate on the "start_after" field. +func StartAfterContains(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldContains(FieldStartAfter, vc)) +} + +// StartAfterHasPrefix applies the HasPrefix predicate on the "start_after" field. +func StartAfterHasPrefix(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldHasPrefix(FieldStartAfter, vc)) +} + +// StartAfterHasSuffix applies the HasSuffix predicate on the "start_after" field. +func StartAfterHasSuffix(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldHasSuffix(FieldStartAfter, vc)) +} + +// StartAfterEqualFold applies the EqualFold predicate on the "start_after" field. +func StartAfterEqualFold(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldEqualFold(FieldStartAfter, vc)) +} + +// StartAfterContainsFold applies the ContainsFold predicate on the "start_after" field. +func StartAfterContainsFold(v datex.ISOString) predicate.PlanPhase { + vc := string(v) + return predicate.PlanPhase(sql.FieldContainsFold(FieldStartAfter, vc)) +} + +// DiscountsIsNil applies the IsNil predicate on the "discounts" field. +func DiscountsIsNil() predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIsNull(FieldDiscounts)) +} + +// DiscountsNotNil applies the NotNil predicate on the "discounts" field. +func DiscountsNotNil() predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotNull(FieldDiscounts)) +} + +// PlanIDEQ applies the EQ predicate on the "plan_id" field. +func PlanIDEQ(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEQ(FieldPlanID, v)) +} + +// PlanIDNEQ applies the NEQ predicate on the "plan_id" field. +func PlanIDNEQ(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNEQ(FieldPlanID, v)) +} + +// PlanIDIn applies the In predicate on the "plan_id" field. +func PlanIDIn(vs ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldIn(FieldPlanID, vs...)) +} + +// PlanIDNotIn applies the NotIn predicate on the "plan_id" field. +func PlanIDNotIn(vs ...string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldNotIn(FieldPlanID, vs...)) +} + +// PlanIDGT applies the GT predicate on the "plan_id" field. +func PlanIDGT(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGT(FieldPlanID, v)) +} + +// PlanIDGTE applies the GTE predicate on the "plan_id" field. +func PlanIDGTE(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldGTE(FieldPlanID, v)) +} + +// PlanIDLT applies the LT predicate on the "plan_id" field. +func PlanIDLT(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLT(FieldPlanID, v)) +} + +// PlanIDLTE applies the LTE predicate on the "plan_id" field. +func PlanIDLTE(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldLTE(FieldPlanID, v)) +} + +// PlanIDContains applies the Contains predicate on the "plan_id" field. +func PlanIDContains(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContains(FieldPlanID, v)) +} + +// PlanIDHasPrefix applies the HasPrefix predicate on the "plan_id" field. +func PlanIDHasPrefix(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldHasPrefix(FieldPlanID, v)) +} + +// PlanIDHasSuffix applies the HasSuffix predicate on the "plan_id" field. +func PlanIDHasSuffix(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldHasSuffix(FieldPlanID, v)) +} + +// PlanIDEqualFold applies the EqualFold predicate on the "plan_id" field. +func PlanIDEqualFold(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldEqualFold(FieldPlanID, v)) +} + +// PlanIDContainsFold applies the ContainsFold predicate on the "plan_id" field. +func PlanIDContainsFold(v string) predicate.PlanPhase { + return predicate.PlanPhase(sql.FieldContainsFold(FieldPlanID, v)) +} + +// HasPlan applies the HasEdge predicate on the "plan" edge. +func HasPlan() predicate.PlanPhase { + return predicate.PlanPhase(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, PlanTable, PlanColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPlanWith applies the HasEdge predicate on the "plan" edge with a given conditions (other predicates). +func HasPlanWith(preds ...predicate.Plan) predicate.PlanPhase { + return predicate.PlanPhase(func(s *sql.Selector) { + step := newPlanStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasRatecards applies the HasEdge predicate on the "ratecards" edge. +func HasRatecards() predicate.PlanPhase { + return predicate.PlanPhase(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, RatecardsTable, RatecardsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRatecardsWith applies the HasEdge predicate on the "ratecards" edge with a given conditions (other predicates). +func HasRatecardsWith(preds ...predicate.PlanRateCard) predicate.PlanPhase { + return predicate.PlanPhase(func(s *sql.Selector) { + step := newRatecardsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PlanPhase) predicate.PlanPhase { + return predicate.PlanPhase(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PlanPhase) predicate.PlanPhase { + return predicate.PlanPhase(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PlanPhase) predicate.PlanPhase { + return predicate.PlanPhase(sql.NotPredicates(p)) +} diff --git a/openmeter/ent/db/planphase_create.go b/openmeter/ent/db/planphase_create.go new file mode 100644 index 000000000..b01feb4fb --- /dev/null +++ b/openmeter/ent/db/planphase_create.go @@ -0,0 +1,1137 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" + "github.com/openmeterio/openmeter/pkg/datex" +) + +// PlanPhaseCreate is the builder for creating a PlanPhase entity. +type PlanPhaseCreate struct { + config + mutation *PlanPhaseMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetNamespace sets the "namespace" field. +func (ppc *PlanPhaseCreate) SetNamespace(s string) *PlanPhaseCreate { + ppc.mutation.SetNamespace(s) + return ppc +} + +// SetMetadata sets the "metadata" field. +func (ppc *PlanPhaseCreate) SetMetadata(m map[string]string) *PlanPhaseCreate { + ppc.mutation.SetMetadata(m) + return ppc +} + +// SetCreatedAt sets the "created_at" field. +func (ppc *PlanPhaseCreate) SetCreatedAt(t time.Time) *PlanPhaseCreate { + ppc.mutation.SetCreatedAt(t) + return ppc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (ppc *PlanPhaseCreate) SetNillableCreatedAt(t *time.Time) *PlanPhaseCreate { + if t != nil { + ppc.SetCreatedAt(*t) + } + return ppc +} + +// SetUpdatedAt sets the "updated_at" field. +func (ppc *PlanPhaseCreate) SetUpdatedAt(t time.Time) *PlanPhaseCreate { + ppc.mutation.SetUpdatedAt(t) + return ppc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (ppc *PlanPhaseCreate) SetNillableUpdatedAt(t *time.Time) *PlanPhaseCreate { + if t != nil { + ppc.SetUpdatedAt(*t) + } + return ppc +} + +// SetDeletedAt sets the "deleted_at" field. +func (ppc *PlanPhaseCreate) SetDeletedAt(t time.Time) *PlanPhaseCreate { + ppc.mutation.SetDeletedAt(t) + return ppc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (ppc *PlanPhaseCreate) SetNillableDeletedAt(t *time.Time) *PlanPhaseCreate { + if t != nil { + ppc.SetDeletedAt(*t) + } + return ppc +} + +// SetName sets the "name" field. +func (ppc *PlanPhaseCreate) SetName(s string) *PlanPhaseCreate { + ppc.mutation.SetName(s) + return ppc +} + +// SetDescription sets the "description" field. +func (ppc *PlanPhaseCreate) SetDescription(s string) *PlanPhaseCreate { + ppc.mutation.SetDescription(s) + return ppc +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (ppc *PlanPhaseCreate) SetNillableDescription(s *string) *PlanPhaseCreate { + if s != nil { + ppc.SetDescription(*s) + } + return ppc +} + +// SetKey sets the "key" field. +func (ppc *PlanPhaseCreate) SetKey(s string) *PlanPhaseCreate { + ppc.mutation.SetKey(s) + return ppc +} + +// SetStartAfter sets the "start_after" field. +func (ppc *PlanPhaseCreate) SetStartAfter(ds datex.ISOString) *PlanPhaseCreate { + ppc.mutation.SetStartAfter(ds) + return ppc +} + +// SetNillableStartAfter sets the "start_after" field if the given value is not nil. +func (ppc *PlanPhaseCreate) SetNillableStartAfter(ds *datex.ISOString) *PlanPhaseCreate { + if ds != nil { + ppc.SetStartAfter(*ds) + } + return ppc +} + +// SetDiscounts sets the "discounts" field. +func (ppc *PlanPhaseCreate) SetDiscounts(pl []plan.Discount) *PlanPhaseCreate { + ppc.mutation.SetDiscounts(pl) + return ppc +} + +// SetPlanID sets the "plan_id" field. +func (ppc *PlanPhaseCreate) SetPlanID(s string) *PlanPhaseCreate { + ppc.mutation.SetPlanID(s) + return ppc +} + +// SetID sets the "id" field. +func (ppc *PlanPhaseCreate) SetID(s string) *PlanPhaseCreate { + ppc.mutation.SetID(s) + return ppc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (ppc *PlanPhaseCreate) SetNillableID(s *string) *PlanPhaseCreate { + if s != nil { + ppc.SetID(*s) + } + return ppc +} + +// SetPlan sets the "plan" edge to the Plan entity. +func (ppc *PlanPhaseCreate) SetPlan(p *Plan) *PlanPhaseCreate { + return ppc.SetPlanID(p.ID) +} + +// AddRatecardIDs adds the "ratecards" edge to the PlanRateCard entity by IDs. +func (ppc *PlanPhaseCreate) AddRatecardIDs(ids ...string) *PlanPhaseCreate { + ppc.mutation.AddRatecardIDs(ids...) + return ppc +} + +// AddRatecards adds the "ratecards" edges to the PlanRateCard entity. +func (ppc *PlanPhaseCreate) AddRatecards(p ...*PlanRateCard) *PlanPhaseCreate { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return ppc.AddRatecardIDs(ids...) +} + +// Mutation returns the PlanPhaseMutation object of the builder. +func (ppc *PlanPhaseCreate) Mutation() *PlanPhaseMutation { + return ppc.mutation +} + +// Save creates the PlanPhase in the database. +func (ppc *PlanPhaseCreate) Save(ctx context.Context) (*PlanPhase, error) { + ppc.defaults() + return withHooks(ctx, ppc.sqlSave, ppc.mutation, ppc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (ppc *PlanPhaseCreate) SaveX(ctx context.Context) *PlanPhase { + v, err := ppc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ppc *PlanPhaseCreate) Exec(ctx context.Context) error { + _, err := ppc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ppc *PlanPhaseCreate) ExecX(ctx context.Context) { + if err := ppc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (ppc *PlanPhaseCreate) defaults() { + if _, ok := ppc.mutation.CreatedAt(); !ok { + v := planphase.DefaultCreatedAt() + ppc.mutation.SetCreatedAt(v) + } + if _, ok := ppc.mutation.UpdatedAt(); !ok { + v := planphase.DefaultUpdatedAt() + ppc.mutation.SetUpdatedAt(v) + } + if _, ok := ppc.mutation.StartAfter(); !ok { + v := planphase.DefaultStartAfter + ppc.mutation.SetStartAfter(v) + } + if _, ok := ppc.mutation.ID(); !ok { + v := planphase.DefaultID() + ppc.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (ppc *PlanPhaseCreate) check() error { + if _, ok := ppc.mutation.Namespace(); !ok { + return &ValidationError{Name: "namespace", err: errors.New(`db: missing required field "PlanPhase.namespace"`)} + } + if v, ok := ppc.mutation.Namespace(); ok { + if err := planphase.NamespaceValidator(v); err != nil { + return &ValidationError{Name: "namespace", err: fmt.Errorf(`db: validator failed for field "PlanPhase.namespace": %w`, err)} + } + } + if _, ok := ppc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "PlanPhase.created_at"`)} + } + if _, ok := ppc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "PlanPhase.updated_at"`)} + } + if _, ok := ppc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`db: missing required field "PlanPhase.name"`)} + } + if _, ok := ppc.mutation.Key(); !ok { + return &ValidationError{Name: "key", err: errors.New(`db: missing required field "PlanPhase.key"`)} + } + if v, ok := ppc.mutation.Key(); ok { + if err := planphase.KeyValidator(v); err != nil { + return &ValidationError{Name: "key", err: fmt.Errorf(`db: validator failed for field "PlanPhase.key": %w`, err)} + } + } + if _, ok := ppc.mutation.StartAfter(); !ok { + return &ValidationError{Name: "start_after", err: errors.New(`db: missing required field "PlanPhase.start_after"`)} + } + if _, ok := ppc.mutation.PlanID(); !ok { + return &ValidationError{Name: "plan_id", err: errors.New(`db: missing required field "PlanPhase.plan_id"`)} + } + if v, ok := ppc.mutation.PlanID(); ok { + if err := planphase.PlanIDValidator(v); err != nil { + return &ValidationError{Name: "plan_id", err: fmt.Errorf(`db: validator failed for field "PlanPhase.plan_id": %w`, err)} + } + } + if len(ppc.mutation.PlanIDs()) == 0 { + return &ValidationError{Name: "plan", err: errors.New(`db: missing required edge "PlanPhase.plan"`)} + } + return nil +} + +func (ppc *PlanPhaseCreate) sqlSave(ctx context.Context) (*PlanPhase, error) { + if err := ppc.check(); err != nil { + return nil, err + } + _node, _spec, err := ppc.createSpec() + if err != nil { + return nil, err + } + if err := sqlgraph.CreateNode(ctx, ppc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(string); ok { + _node.ID = id + } else { + return nil, fmt.Errorf("unexpected PlanPhase.ID type: %T", _spec.ID.Value) + } + } + ppc.mutation.id = &_node.ID + ppc.mutation.done = true + return _node, nil +} + +func (ppc *PlanPhaseCreate) createSpec() (*PlanPhase, *sqlgraph.CreateSpec, error) { + var ( + _node = &PlanPhase{config: ppc.config} + _spec = sqlgraph.NewCreateSpec(planphase.Table, sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString)) + ) + _spec.OnConflict = ppc.conflict + if id, ok := ppc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := ppc.mutation.Namespace(); ok { + _spec.SetField(planphase.FieldNamespace, field.TypeString, value) + _node.Namespace = value + } + if value, ok := ppc.mutation.Metadata(); ok { + _spec.SetField(planphase.FieldMetadata, field.TypeJSON, value) + _node.Metadata = value + } + if value, ok := ppc.mutation.CreatedAt(); ok { + _spec.SetField(planphase.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := ppc.mutation.UpdatedAt(); ok { + _spec.SetField(planphase.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := ppc.mutation.DeletedAt(); ok { + _spec.SetField(planphase.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = &value + } + if value, ok := ppc.mutation.Name(); ok { + _spec.SetField(planphase.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := ppc.mutation.Description(); ok { + _spec.SetField(planphase.FieldDescription, field.TypeString, value) + _node.Description = &value + } + if value, ok := ppc.mutation.Key(); ok { + _spec.SetField(planphase.FieldKey, field.TypeString, value) + _node.Key = value + } + if value, ok := ppc.mutation.StartAfter(); ok { + _spec.SetField(planphase.FieldStartAfter, field.TypeString, value) + _node.StartAfter = value + } + if value, ok := ppc.mutation.Discounts(); ok { + vv, err := planphase.ValueScanner.Discounts.Value(value) + if err != nil { + return nil, nil, err + } + _spec.SetField(planphase.FieldDiscounts, field.TypeString, vv) + _node.Discounts = value + } + if nodes := ppc.mutation.PlanIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planphase.PlanTable, + Columns: []string{planphase.PlanColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(dbplan.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.PlanID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := ppc.mutation.RatecardsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: planphase.RatecardsTable, + Columns: []string{planphase.RatecardsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec, nil +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.PlanPhase.Create(). +// SetNamespace(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.PlanPhaseUpsert) { +// SetNamespace(v+v). +// }). +// Exec(ctx) +func (ppc *PlanPhaseCreate) OnConflict(opts ...sql.ConflictOption) *PlanPhaseUpsertOne { + ppc.conflict = opts + return &PlanPhaseUpsertOne{ + create: ppc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.PlanPhase.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (ppc *PlanPhaseCreate) OnConflictColumns(columns ...string) *PlanPhaseUpsertOne { + ppc.conflict = append(ppc.conflict, sql.ConflictColumns(columns...)) + return &PlanPhaseUpsertOne{ + create: ppc, + } +} + +type ( + // PlanPhaseUpsertOne is the builder for "upsert"-ing + // one PlanPhase node. + PlanPhaseUpsertOne struct { + create *PlanPhaseCreate + } + + // PlanPhaseUpsert is the "OnConflict" setter. + PlanPhaseUpsert struct { + *sql.UpdateSet + } +) + +// SetMetadata sets the "metadata" field. +func (u *PlanPhaseUpsert) SetMetadata(v map[string]string) *PlanPhaseUpsert { + u.Set(planphase.FieldMetadata, v) + return u +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *PlanPhaseUpsert) UpdateMetadata() *PlanPhaseUpsert { + u.SetExcluded(planphase.FieldMetadata) + return u +} + +// ClearMetadata clears the value of the "metadata" field. +func (u *PlanPhaseUpsert) ClearMetadata() *PlanPhaseUpsert { + u.SetNull(planphase.FieldMetadata) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *PlanPhaseUpsert) SetUpdatedAt(v time.Time) *PlanPhaseUpsert { + u.Set(planphase.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *PlanPhaseUpsert) UpdateUpdatedAt() *PlanPhaseUpsert { + u.SetExcluded(planphase.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *PlanPhaseUpsert) SetDeletedAt(v time.Time) *PlanPhaseUpsert { + u.Set(planphase.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *PlanPhaseUpsert) UpdateDeletedAt() *PlanPhaseUpsert { + u.SetExcluded(planphase.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *PlanPhaseUpsert) ClearDeletedAt() *PlanPhaseUpsert { + u.SetNull(planphase.FieldDeletedAt) + return u +} + +// SetName sets the "name" field. +func (u *PlanPhaseUpsert) SetName(v string) *PlanPhaseUpsert { + u.Set(planphase.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *PlanPhaseUpsert) UpdateName() *PlanPhaseUpsert { + u.SetExcluded(planphase.FieldName) + return u +} + +// SetDescription sets the "description" field. +func (u *PlanPhaseUpsert) SetDescription(v string) *PlanPhaseUpsert { + u.Set(planphase.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PlanPhaseUpsert) UpdateDescription() *PlanPhaseUpsert { + u.SetExcluded(planphase.FieldDescription) + return u +} + +// ClearDescription clears the value of the "description" field. +func (u *PlanPhaseUpsert) ClearDescription() *PlanPhaseUpsert { + u.SetNull(planphase.FieldDescription) + return u +} + +// SetStartAfter sets the "start_after" field. +func (u *PlanPhaseUpsert) SetStartAfter(v datex.ISOString) *PlanPhaseUpsert { + u.Set(planphase.FieldStartAfter, v) + return u +} + +// UpdateStartAfter sets the "start_after" field to the value that was provided on create. +func (u *PlanPhaseUpsert) UpdateStartAfter() *PlanPhaseUpsert { + u.SetExcluded(planphase.FieldStartAfter) + return u +} + +// SetDiscounts sets the "discounts" field. +func (u *PlanPhaseUpsert) SetDiscounts(v []plan.Discount) *PlanPhaseUpsert { + u.Set(planphase.FieldDiscounts, v) + return u +} + +// UpdateDiscounts sets the "discounts" field to the value that was provided on create. +func (u *PlanPhaseUpsert) UpdateDiscounts() *PlanPhaseUpsert { + u.SetExcluded(planphase.FieldDiscounts) + return u +} + +// ClearDiscounts clears the value of the "discounts" field. +func (u *PlanPhaseUpsert) ClearDiscounts() *PlanPhaseUpsert { + u.SetNull(planphase.FieldDiscounts) + return u +} + +// SetPlanID sets the "plan_id" field. +func (u *PlanPhaseUpsert) SetPlanID(v string) *PlanPhaseUpsert { + u.Set(planphase.FieldPlanID, v) + return u +} + +// UpdatePlanID sets the "plan_id" field to the value that was provided on create. +func (u *PlanPhaseUpsert) UpdatePlanID() *PlanPhaseUpsert { + u.SetExcluded(planphase.FieldPlanID) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.PlanPhase.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(planphase.FieldID) +// }), +// ). +// Exec(ctx) +func (u *PlanPhaseUpsertOne) UpdateNewValues() *PlanPhaseUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(planphase.FieldID) + } + if _, exists := u.create.mutation.Namespace(); exists { + s.SetIgnore(planphase.FieldNamespace) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(planphase.FieldCreatedAt) + } + if _, exists := u.create.mutation.Key(); exists { + s.SetIgnore(planphase.FieldKey) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.PlanPhase.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *PlanPhaseUpsertOne) Ignore() *PlanPhaseUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *PlanPhaseUpsertOne) DoNothing() *PlanPhaseUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the PlanPhaseCreate.OnConflict +// documentation for more info. +func (u *PlanPhaseUpsertOne) Update(set func(*PlanPhaseUpsert)) *PlanPhaseUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&PlanPhaseUpsert{UpdateSet: update}) + })) + return u +} + +// SetMetadata sets the "metadata" field. +func (u *PlanPhaseUpsertOne) SetMetadata(v map[string]string) *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetMetadata(v) + }) +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *PlanPhaseUpsertOne) UpdateMetadata() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateMetadata() + }) +} + +// ClearMetadata clears the value of the "metadata" field. +func (u *PlanPhaseUpsertOne) ClearMetadata() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.ClearMetadata() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *PlanPhaseUpsertOne) SetUpdatedAt(v time.Time) *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *PlanPhaseUpsertOne) UpdateUpdatedAt() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *PlanPhaseUpsertOne) SetDeletedAt(v time.Time) *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *PlanPhaseUpsertOne) UpdateDeletedAt() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *PlanPhaseUpsertOne) ClearDeletedAt() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.ClearDeletedAt() + }) +} + +// SetName sets the "name" field. +func (u *PlanPhaseUpsertOne) SetName(v string) *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *PlanPhaseUpsertOne) UpdateName() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *PlanPhaseUpsertOne) SetDescription(v string) *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PlanPhaseUpsertOne) UpdateDescription() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *PlanPhaseUpsertOne) ClearDescription() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.ClearDescription() + }) +} + +// SetStartAfter sets the "start_after" field. +func (u *PlanPhaseUpsertOne) SetStartAfter(v datex.ISOString) *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetStartAfter(v) + }) +} + +// UpdateStartAfter sets the "start_after" field to the value that was provided on create. +func (u *PlanPhaseUpsertOne) UpdateStartAfter() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateStartAfter() + }) +} + +// SetDiscounts sets the "discounts" field. +func (u *PlanPhaseUpsertOne) SetDiscounts(v []plan.Discount) *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetDiscounts(v) + }) +} + +// UpdateDiscounts sets the "discounts" field to the value that was provided on create. +func (u *PlanPhaseUpsertOne) UpdateDiscounts() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateDiscounts() + }) +} + +// ClearDiscounts clears the value of the "discounts" field. +func (u *PlanPhaseUpsertOne) ClearDiscounts() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.ClearDiscounts() + }) +} + +// SetPlanID sets the "plan_id" field. +func (u *PlanPhaseUpsertOne) SetPlanID(v string) *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetPlanID(v) + }) +} + +// UpdatePlanID sets the "plan_id" field to the value that was provided on create. +func (u *PlanPhaseUpsertOne) UpdatePlanID() *PlanPhaseUpsertOne { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdatePlanID() + }) +} + +// Exec executes the query. +func (u *PlanPhaseUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for PlanPhaseCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *PlanPhaseUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *PlanPhaseUpsertOne) ID(ctx context.Context) (id string, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: PlanPhaseUpsertOne.ID is not supported by MySQL driver. Use PlanPhaseUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *PlanPhaseUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// PlanPhaseCreateBulk is the builder for creating many PlanPhase entities in bulk. +type PlanPhaseCreateBulk struct { + config + err error + builders []*PlanPhaseCreate + conflict []sql.ConflictOption +} + +// Save creates the PlanPhase entities in the database. +func (ppcb *PlanPhaseCreateBulk) Save(ctx context.Context) ([]*PlanPhase, error) { + if ppcb.err != nil { + return nil, ppcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(ppcb.builders)) + nodes := make([]*PlanPhase, len(ppcb.builders)) + mutators := make([]Mutator, len(ppcb.builders)) + for i := range ppcb.builders { + func(i int, root context.Context) { + builder := ppcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PlanPhaseMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i], err = builder.createSpec() + if err != nil { + return nil, err + } + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, ppcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = ppcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, ppcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, ppcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ppcb *PlanPhaseCreateBulk) SaveX(ctx context.Context) []*PlanPhase { + v, err := ppcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ppcb *PlanPhaseCreateBulk) Exec(ctx context.Context) error { + _, err := ppcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ppcb *PlanPhaseCreateBulk) ExecX(ctx context.Context) { + if err := ppcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.PlanPhase.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.PlanPhaseUpsert) { +// SetNamespace(v+v). +// }). +// Exec(ctx) +func (ppcb *PlanPhaseCreateBulk) OnConflict(opts ...sql.ConflictOption) *PlanPhaseUpsertBulk { + ppcb.conflict = opts + return &PlanPhaseUpsertBulk{ + create: ppcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.PlanPhase.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (ppcb *PlanPhaseCreateBulk) OnConflictColumns(columns ...string) *PlanPhaseUpsertBulk { + ppcb.conflict = append(ppcb.conflict, sql.ConflictColumns(columns...)) + return &PlanPhaseUpsertBulk{ + create: ppcb, + } +} + +// PlanPhaseUpsertBulk is the builder for "upsert"-ing +// a bulk of PlanPhase nodes. +type PlanPhaseUpsertBulk struct { + create *PlanPhaseCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.PlanPhase.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(planphase.FieldID) +// }), +// ). +// Exec(ctx) +func (u *PlanPhaseUpsertBulk) UpdateNewValues() *PlanPhaseUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(planphase.FieldID) + } + if _, exists := b.mutation.Namespace(); exists { + s.SetIgnore(planphase.FieldNamespace) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(planphase.FieldCreatedAt) + } + if _, exists := b.mutation.Key(); exists { + s.SetIgnore(planphase.FieldKey) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.PlanPhase.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *PlanPhaseUpsertBulk) Ignore() *PlanPhaseUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *PlanPhaseUpsertBulk) DoNothing() *PlanPhaseUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the PlanPhaseCreateBulk.OnConflict +// documentation for more info. +func (u *PlanPhaseUpsertBulk) Update(set func(*PlanPhaseUpsert)) *PlanPhaseUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&PlanPhaseUpsert{UpdateSet: update}) + })) + return u +} + +// SetMetadata sets the "metadata" field. +func (u *PlanPhaseUpsertBulk) SetMetadata(v map[string]string) *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetMetadata(v) + }) +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *PlanPhaseUpsertBulk) UpdateMetadata() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateMetadata() + }) +} + +// ClearMetadata clears the value of the "metadata" field. +func (u *PlanPhaseUpsertBulk) ClearMetadata() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.ClearMetadata() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *PlanPhaseUpsertBulk) SetUpdatedAt(v time.Time) *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *PlanPhaseUpsertBulk) UpdateUpdatedAt() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *PlanPhaseUpsertBulk) SetDeletedAt(v time.Time) *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *PlanPhaseUpsertBulk) UpdateDeletedAt() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *PlanPhaseUpsertBulk) ClearDeletedAt() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.ClearDeletedAt() + }) +} + +// SetName sets the "name" field. +func (u *PlanPhaseUpsertBulk) SetName(v string) *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *PlanPhaseUpsertBulk) UpdateName() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *PlanPhaseUpsertBulk) SetDescription(v string) *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PlanPhaseUpsertBulk) UpdateDescription() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *PlanPhaseUpsertBulk) ClearDescription() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.ClearDescription() + }) +} + +// SetStartAfter sets the "start_after" field. +func (u *PlanPhaseUpsertBulk) SetStartAfter(v datex.ISOString) *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetStartAfter(v) + }) +} + +// UpdateStartAfter sets the "start_after" field to the value that was provided on create. +func (u *PlanPhaseUpsertBulk) UpdateStartAfter() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateStartAfter() + }) +} + +// SetDiscounts sets the "discounts" field. +func (u *PlanPhaseUpsertBulk) SetDiscounts(v []plan.Discount) *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetDiscounts(v) + }) +} + +// UpdateDiscounts sets the "discounts" field to the value that was provided on create. +func (u *PlanPhaseUpsertBulk) UpdateDiscounts() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdateDiscounts() + }) +} + +// ClearDiscounts clears the value of the "discounts" field. +func (u *PlanPhaseUpsertBulk) ClearDiscounts() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.ClearDiscounts() + }) +} + +// SetPlanID sets the "plan_id" field. +func (u *PlanPhaseUpsertBulk) SetPlanID(v string) *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.SetPlanID(v) + }) +} + +// UpdatePlanID sets the "plan_id" field to the value that was provided on create. +func (u *PlanPhaseUpsertBulk) UpdatePlanID() *PlanPhaseUpsertBulk { + return u.Update(func(s *PlanPhaseUpsert) { + s.UpdatePlanID() + }) +} + +// Exec executes the query. +func (u *PlanPhaseUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the PlanPhaseCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for PlanPhaseCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *PlanPhaseUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/openmeter/ent/db/planphase_delete.go b/openmeter/ent/db/planphase_delete.go new file mode 100644 index 000000000..dc5c9aeb7 --- /dev/null +++ b/openmeter/ent/db/planphase_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" +) + +// PlanPhaseDelete is the builder for deleting a PlanPhase entity. +type PlanPhaseDelete struct { + config + hooks []Hook + mutation *PlanPhaseMutation +} + +// Where appends a list predicates to the PlanPhaseDelete builder. +func (ppd *PlanPhaseDelete) Where(ps ...predicate.PlanPhase) *PlanPhaseDelete { + ppd.mutation.Where(ps...) + return ppd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (ppd *PlanPhaseDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, ppd.sqlExec, ppd.mutation, ppd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (ppd *PlanPhaseDelete) ExecX(ctx context.Context) int { + n, err := ppd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (ppd *PlanPhaseDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(planphase.Table, sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString)) + if ps := ppd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, ppd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + ppd.mutation.done = true + return affected, err +} + +// PlanPhaseDeleteOne is the builder for deleting a single PlanPhase entity. +type PlanPhaseDeleteOne struct { + ppd *PlanPhaseDelete +} + +// Where appends a list predicates to the PlanPhaseDelete builder. +func (ppdo *PlanPhaseDeleteOne) Where(ps ...predicate.PlanPhase) *PlanPhaseDeleteOne { + ppdo.ppd.mutation.Where(ps...) + return ppdo +} + +// Exec executes the deletion query. +func (ppdo *PlanPhaseDeleteOne) Exec(ctx context.Context) error { + n, err := ppdo.ppd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{planphase.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (ppdo *PlanPhaseDeleteOne) ExecX(ctx context.Context) { + if err := ppdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/openmeter/ent/db/planphase_query.go b/openmeter/ent/db/planphase_query.go new file mode 100644 index 000000000..506d259be --- /dev/null +++ b/openmeter/ent/db/planphase_query.go @@ -0,0 +1,718 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" +) + +// PlanPhaseQuery is the builder for querying PlanPhase entities. +type PlanPhaseQuery struct { + config + ctx *QueryContext + order []planphase.OrderOption + inters []Interceptor + predicates []predicate.PlanPhase + withPlan *PlanQuery + withRatecards *PlanRateCardQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PlanPhaseQuery builder. +func (ppq *PlanPhaseQuery) Where(ps ...predicate.PlanPhase) *PlanPhaseQuery { + ppq.predicates = append(ppq.predicates, ps...) + return ppq +} + +// Limit the number of records to be returned by this query. +func (ppq *PlanPhaseQuery) Limit(limit int) *PlanPhaseQuery { + ppq.ctx.Limit = &limit + return ppq +} + +// Offset to start from. +func (ppq *PlanPhaseQuery) Offset(offset int) *PlanPhaseQuery { + ppq.ctx.Offset = &offset + return ppq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (ppq *PlanPhaseQuery) Unique(unique bool) *PlanPhaseQuery { + ppq.ctx.Unique = &unique + return ppq +} + +// Order specifies how the records should be ordered. +func (ppq *PlanPhaseQuery) Order(o ...planphase.OrderOption) *PlanPhaseQuery { + ppq.order = append(ppq.order, o...) + return ppq +} + +// QueryPlan chains the current query on the "plan" edge. +func (ppq *PlanPhaseQuery) QueryPlan() *PlanQuery { + query := (&PlanClient{config: ppq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := ppq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := ppq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(planphase.Table, planphase.FieldID, selector), + sqlgraph.To(dbplan.Table, dbplan.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, planphase.PlanTable, planphase.PlanColumn), + ) + fromU = sqlgraph.SetNeighbors(ppq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryRatecards chains the current query on the "ratecards" edge. +func (ppq *PlanPhaseQuery) QueryRatecards() *PlanRateCardQuery { + query := (&PlanRateCardClient{config: ppq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := ppq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := ppq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(planphase.Table, planphase.FieldID, selector), + sqlgraph.To(planratecard.Table, planratecard.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, planphase.RatecardsTable, planphase.RatecardsColumn), + ) + fromU = sqlgraph.SetNeighbors(ppq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first PlanPhase entity from the query. +// Returns a *NotFoundError when no PlanPhase was found. +func (ppq *PlanPhaseQuery) First(ctx context.Context) (*PlanPhase, error) { + nodes, err := ppq.Limit(1).All(setContextOp(ctx, ppq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{planphase.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (ppq *PlanPhaseQuery) FirstX(ctx context.Context) *PlanPhase { + node, err := ppq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first PlanPhase ID from the query. +// Returns a *NotFoundError when no PlanPhase ID was found. +func (ppq *PlanPhaseQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = ppq.Limit(1).IDs(setContextOp(ctx, ppq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{planphase.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (ppq *PlanPhaseQuery) FirstIDX(ctx context.Context) string { + id, err := ppq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single PlanPhase entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one PlanPhase entity is found. +// Returns a *NotFoundError when no PlanPhase entities are found. +func (ppq *PlanPhaseQuery) Only(ctx context.Context) (*PlanPhase, error) { + nodes, err := ppq.Limit(2).All(setContextOp(ctx, ppq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{planphase.Label} + default: + return nil, &NotSingularError{planphase.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (ppq *PlanPhaseQuery) OnlyX(ctx context.Context) *PlanPhase { + node, err := ppq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only PlanPhase ID in the query. +// Returns a *NotSingularError when more than one PlanPhase ID is found. +// Returns a *NotFoundError when no entities are found. +func (ppq *PlanPhaseQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = ppq.Limit(2).IDs(setContextOp(ctx, ppq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{planphase.Label} + default: + err = &NotSingularError{planphase.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (ppq *PlanPhaseQuery) OnlyIDX(ctx context.Context) string { + id, err := ppq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of PlanPhases. +func (ppq *PlanPhaseQuery) All(ctx context.Context) ([]*PlanPhase, error) { + ctx = setContextOp(ctx, ppq.ctx, ent.OpQueryAll) + if err := ppq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*PlanPhase, *PlanPhaseQuery]() + return withInterceptors[[]*PlanPhase](ctx, ppq, qr, ppq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (ppq *PlanPhaseQuery) AllX(ctx context.Context) []*PlanPhase { + nodes, err := ppq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of PlanPhase IDs. +func (ppq *PlanPhaseQuery) IDs(ctx context.Context) (ids []string, err error) { + if ppq.ctx.Unique == nil && ppq.path != nil { + ppq.Unique(true) + } + ctx = setContextOp(ctx, ppq.ctx, ent.OpQueryIDs) + if err = ppq.Select(planphase.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (ppq *PlanPhaseQuery) IDsX(ctx context.Context) []string { + ids, err := ppq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (ppq *PlanPhaseQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, ppq.ctx, ent.OpQueryCount) + if err := ppq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, ppq, querierCount[*PlanPhaseQuery](), ppq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (ppq *PlanPhaseQuery) CountX(ctx context.Context) int { + count, err := ppq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (ppq *PlanPhaseQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, ppq.ctx, ent.OpQueryExist) + switch _, err := ppq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (ppq *PlanPhaseQuery) ExistX(ctx context.Context) bool { + exist, err := ppq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PlanPhaseQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (ppq *PlanPhaseQuery) Clone() *PlanPhaseQuery { + if ppq == nil { + return nil + } + return &PlanPhaseQuery{ + config: ppq.config, + ctx: ppq.ctx.Clone(), + order: append([]planphase.OrderOption{}, ppq.order...), + inters: append([]Interceptor{}, ppq.inters...), + predicates: append([]predicate.PlanPhase{}, ppq.predicates...), + withPlan: ppq.withPlan.Clone(), + withRatecards: ppq.withRatecards.Clone(), + // clone intermediate query. + sql: ppq.sql.Clone(), + path: ppq.path, + } +} + +// WithPlan tells the query-builder to eager-load the nodes that are connected to +// the "plan" edge. The optional arguments are used to configure the query builder of the edge. +func (ppq *PlanPhaseQuery) WithPlan(opts ...func(*PlanQuery)) *PlanPhaseQuery { + query := (&PlanClient{config: ppq.config}).Query() + for _, opt := range opts { + opt(query) + } + ppq.withPlan = query + return ppq +} + +// WithRatecards tells the query-builder to eager-load the nodes that are connected to +// the "ratecards" edge. The optional arguments are used to configure the query builder of the edge. +func (ppq *PlanPhaseQuery) WithRatecards(opts ...func(*PlanRateCardQuery)) *PlanPhaseQuery { + query := (&PlanRateCardClient{config: ppq.config}).Query() + for _, opt := range opts { + opt(query) + } + ppq.withRatecards = query + return ppq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Namespace string `json:"namespace,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.PlanPhase.Query(). +// GroupBy(planphase.FieldNamespace). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (ppq *PlanPhaseQuery) GroupBy(field string, fields ...string) *PlanPhaseGroupBy { + ppq.ctx.Fields = append([]string{field}, fields...) + grbuild := &PlanPhaseGroupBy{build: ppq} + grbuild.flds = &ppq.ctx.Fields + grbuild.label = planphase.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Namespace string `json:"namespace,omitempty"` +// } +// +// client.PlanPhase.Query(). +// Select(planphase.FieldNamespace). +// Scan(ctx, &v) +func (ppq *PlanPhaseQuery) Select(fields ...string) *PlanPhaseSelect { + ppq.ctx.Fields = append(ppq.ctx.Fields, fields...) + sbuild := &PlanPhaseSelect{PlanPhaseQuery: ppq} + sbuild.label = planphase.Label + sbuild.flds, sbuild.scan = &ppq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PlanPhaseSelect configured with the given aggregations. +func (ppq *PlanPhaseQuery) Aggregate(fns ...AggregateFunc) *PlanPhaseSelect { + return ppq.Select().Aggregate(fns...) +} + +func (ppq *PlanPhaseQuery) prepareQuery(ctx context.Context) error { + for _, inter := range ppq.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, ppq); err != nil { + return err + } + } + } + for _, f := range ppq.ctx.Fields { + if !planphase.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if ppq.path != nil { + prev, err := ppq.path(ctx) + if err != nil { + return err + } + ppq.sql = prev + } + return nil +} + +func (ppq *PlanPhaseQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PlanPhase, error) { + var ( + nodes = []*PlanPhase{} + _spec = ppq.querySpec() + loadedTypes = [2]bool{ + ppq.withPlan != nil, + ppq.withRatecards != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*PlanPhase).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &PlanPhase{config: ppq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(ppq.modifiers) > 0 { + _spec.Modifiers = ppq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, ppq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := ppq.withPlan; query != nil { + if err := ppq.loadPlan(ctx, query, nodes, nil, + func(n *PlanPhase, e *Plan) { n.Edges.Plan = e }); err != nil { + return nil, err + } + } + if query := ppq.withRatecards; query != nil { + if err := ppq.loadRatecards(ctx, query, nodes, + func(n *PlanPhase) { n.Edges.Ratecards = []*PlanRateCard{} }, + func(n *PlanPhase, e *PlanRateCard) { n.Edges.Ratecards = append(n.Edges.Ratecards, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (ppq *PlanPhaseQuery) loadPlan(ctx context.Context, query *PlanQuery, nodes []*PlanPhase, init func(*PlanPhase), assign func(*PlanPhase, *Plan)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*PlanPhase) + for i := range nodes { + fk := nodes[i].PlanID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(dbplan.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "plan_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (ppq *PlanPhaseQuery) loadRatecards(ctx context.Context, query *PlanRateCardQuery, nodes []*PlanPhase, init func(*PlanPhase), assign func(*PlanPhase, *PlanRateCard)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*PlanPhase) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(planratecard.FieldPhaseID) + } + query.Where(predicate.PlanRateCard(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(planphase.RatecardsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.PhaseID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "phase_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (ppq *PlanPhaseQuery) sqlCount(ctx context.Context) (int, error) { + _spec := ppq.querySpec() + if len(ppq.modifiers) > 0 { + _spec.Modifiers = ppq.modifiers + } + _spec.Node.Columns = ppq.ctx.Fields + if len(ppq.ctx.Fields) > 0 { + _spec.Unique = ppq.ctx.Unique != nil && *ppq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, ppq.driver, _spec) +} + +func (ppq *PlanPhaseQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(planphase.Table, planphase.Columns, sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString)) + _spec.From = ppq.sql + if unique := ppq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if ppq.path != nil { + _spec.Unique = true + } + if fields := ppq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, planphase.FieldID) + for i := range fields { + if fields[i] != planphase.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if ppq.withPlan != nil { + _spec.Node.AddColumnOnce(planphase.FieldPlanID) + } + } + if ps := ppq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := ppq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := ppq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := ppq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (ppq *PlanPhaseQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(ppq.driver.Dialect()) + t1 := builder.Table(planphase.Table) + columns := ppq.ctx.Fields + if len(columns) == 0 { + columns = planphase.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if ppq.sql != nil { + selector = ppq.sql + selector.Select(selector.Columns(columns...)...) + } + if ppq.ctx.Unique != nil && *ppq.ctx.Unique { + selector.Distinct() + } + for _, m := range ppq.modifiers { + m(selector) + } + for _, p := range ppq.predicates { + p(selector) + } + for _, p := range ppq.order { + p(selector) + } + if offset := ppq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := ppq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (ppq *PlanPhaseQuery) ForUpdate(opts ...sql.LockOption) *PlanPhaseQuery { + if ppq.driver.Dialect() == dialect.Postgres { + ppq.Unique(false) + } + ppq.modifiers = append(ppq.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return ppq +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (ppq *PlanPhaseQuery) ForShare(opts ...sql.LockOption) *PlanPhaseQuery { + if ppq.driver.Dialect() == dialect.Postgres { + ppq.Unique(false) + } + ppq.modifiers = append(ppq.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return ppq +} + +// PlanPhaseGroupBy is the group-by builder for PlanPhase entities. +type PlanPhaseGroupBy struct { + selector + build *PlanPhaseQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (ppgb *PlanPhaseGroupBy) Aggregate(fns ...AggregateFunc) *PlanPhaseGroupBy { + ppgb.fns = append(ppgb.fns, fns...) + return ppgb +} + +// Scan applies the selector query and scans the result into the given value. +func (ppgb *PlanPhaseGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ppgb.build.ctx, ent.OpQueryGroupBy) + if err := ppgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PlanPhaseQuery, *PlanPhaseGroupBy](ctx, ppgb.build, ppgb, ppgb.build.inters, v) +} + +func (ppgb *PlanPhaseGroupBy) sqlScan(ctx context.Context, root *PlanPhaseQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(ppgb.fns)) + for _, fn := range ppgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*ppgb.flds)+len(ppgb.fns)) + for _, f := range *ppgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*ppgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ppgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// PlanPhaseSelect is the builder for selecting fields of PlanPhase entities. +type PlanPhaseSelect struct { + *PlanPhaseQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (pps *PlanPhaseSelect) Aggregate(fns ...AggregateFunc) *PlanPhaseSelect { + pps.fns = append(pps.fns, fns...) + return pps +} + +// Scan applies the selector query and scans the result into the given value. +func (pps *PlanPhaseSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, pps.ctx, ent.OpQuerySelect) + if err := pps.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PlanPhaseQuery, *PlanPhaseSelect](ctx, pps.PlanPhaseQuery, pps, pps.inters, v) +} + +func (pps *PlanPhaseSelect) sqlScan(ctx context.Context, root *PlanPhaseQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(pps.fns)) + for _, fn := range pps.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*pps.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := pps.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/openmeter/ent/db/planphase_update.go b/openmeter/ent/db/planphase_update.go new file mode 100644 index 000000000..8f639d4fd --- /dev/null +++ b/openmeter/ent/db/planphase_update.go @@ -0,0 +1,770 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" + "github.com/openmeterio/openmeter/pkg/datex" +) + +// PlanPhaseUpdate is the builder for updating PlanPhase entities. +type PlanPhaseUpdate struct { + config + hooks []Hook + mutation *PlanPhaseMutation +} + +// Where appends a list predicates to the PlanPhaseUpdate builder. +func (ppu *PlanPhaseUpdate) Where(ps ...predicate.PlanPhase) *PlanPhaseUpdate { + ppu.mutation.Where(ps...) + return ppu +} + +// SetMetadata sets the "metadata" field. +func (ppu *PlanPhaseUpdate) SetMetadata(m map[string]string) *PlanPhaseUpdate { + ppu.mutation.SetMetadata(m) + return ppu +} + +// ClearMetadata clears the value of the "metadata" field. +func (ppu *PlanPhaseUpdate) ClearMetadata() *PlanPhaseUpdate { + ppu.mutation.ClearMetadata() + return ppu +} + +// SetUpdatedAt sets the "updated_at" field. +func (ppu *PlanPhaseUpdate) SetUpdatedAt(t time.Time) *PlanPhaseUpdate { + ppu.mutation.SetUpdatedAt(t) + return ppu +} + +// SetDeletedAt sets the "deleted_at" field. +func (ppu *PlanPhaseUpdate) SetDeletedAt(t time.Time) *PlanPhaseUpdate { + ppu.mutation.SetDeletedAt(t) + return ppu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (ppu *PlanPhaseUpdate) SetNillableDeletedAt(t *time.Time) *PlanPhaseUpdate { + if t != nil { + ppu.SetDeletedAt(*t) + } + return ppu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (ppu *PlanPhaseUpdate) ClearDeletedAt() *PlanPhaseUpdate { + ppu.mutation.ClearDeletedAt() + return ppu +} + +// SetName sets the "name" field. +func (ppu *PlanPhaseUpdate) SetName(s string) *PlanPhaseUpdate { + ppu.mutation.SetName(s) + return ppu +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (ppu *PlanPhaseUpdate) SetNillableName(s *string) *PlanPhaseUpdate { + if s != nil { + ppu.SetName(*s) + } + return ppu +} + +// SetDescription sets the "description" field. +func (ppu *PlanPhaseUpdate) SetDescription(s string) *PlanPhaseUpdate { + ppu.mutation.SetDescription(s) + return ppu +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (ppu *PlanPhaseUpdate) SetNillableDescription(s *string) *PlanPhaseUpdate { + if s != nil { + ppu.SetDescription(*s) + } + return ppu +} + +// ClearDescription clears the value of the "description" field. +func (ppu *PlanPhaseUpdate) ClearDescription() *PlanPhaseUpdate { + ppu.mutation.ClearDescription() + return ppu +} + +// SetStartAfter sets the "start_after" field. +func (ppu *PlanPhaseUpdate) SetStartAfter(ds datex.ISOString) *PlanPhaseUpdate { + ppu.mutation.SetStartAfter(ds) + return ppu +} + +// SetNillableStartAfter sets the "start_after" field if the given value is not nil. +func (ppu *PlanPhaseUpdate) SetNillableStartAfter(ds *datex.ISOString) *PlanPhaseUpdate { + if ds != nil { + ppu.SetStartAfter(*ds) + } + return ppu +} + +// SetDiscounts sets the "discounts" field. +func (ppu *PlanPhaseUpdate) SetDiscounts(pl []plan.Discount) *PlanPhaseUpdate { + ppu.mutation.SetDiscounts(pl) + return ppu +} + +// ClearDiscounts clears the value of the "discounts" field. +func (ppu *PlanPhaseUpdate) ClearDiscounts() *PlanPhaseUpdate { + ppu.mutation.ClearDiscounts() + return ppu +} + +// SetPlanID sets the "plan_id" field. +func (ppu *PlanPhaseUpdate) SetPlanID(s string) *PlanPhaseUpdate { + ppu.mutation.SetPlanID(s) + return ppu +} + +// SetNillablePlanID sets the "plan_id" field if the given value is not nil. +func (ppu *PlanPhaseUpdate) SetNillablePlanID(s *string) *PlanPhaseUpdate { + if s != nil { + ppu.SetPlanID(*s) + } + return ppu +} + +// SetPlan sets the "plan" edge to the Plan entity. +func (ppu *PlanPhaseUpdate) SetPlan(p *Plan) *PlanPhaseUpdate { + return ppu.SetPlanID(p.ID) +} + +// AddRatecardIDs adds the "ratecards" edge to the PlanRateCard entity by IDs. +func (ppu *PlanPhaseUpdate) AddRatecardIDs(ids ...string) *PlanPhaseUpdate { + ppu.mutation.AddRatecardIDs(ids...) + return ppu +} + +// AddRatecards adds the "ratecards" edges to the PlanRateCard entity. +func (ppu *PlanPhaseUpdate) AddRatecards(p ...*PlanRateCard) *PlanPhaseUpdate { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return ppu.AddRatecardIDs(ids...) +} + +// Mutation returns the PlanPhaseMutation object of the builder. +func (ppu *PlanPhaseUpdate) Mutation() *PlanPhaseMutation { + return ppu.mutation +} + +// ClearPlan clears the "plan" edge to the Plan entity. +func (ppu *PlanPhaseUpdate) ClearPlan() *PlanPhaseUpdate { + ppu.mutation.ClearPlan() + return ppu +} + +// ClearRatecards clears all "ratecards" edges to the PlanRateCard entity. +func (ppu *PlanPhaseUpdate) ClearRatecards() *PlanPhaseUpdate { + ppu.mutation.ClearRatecards() + return ppu +} + +// RemoveRatecardIDs removes the "ratecards" edge to PlanRateCard entities by IDs. +func (ppu *PlanPhaseUpdate) RemoveRatecardIDs(ids ...string) *PlanPhaseUpdate { + ppu.mutation.RemoveRatecardIDs(ids...) + return ppu +} + +// RemoveRatecards removes "ratecards" edges to PlanRateCard entities. +func (ppu *PlanPhaseUpdate) RemoveRatecards(p ...*PlanRateCard) *PlanPhaseUpdate { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return ppu.RemoveRatecardIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (ppu *PlanPhaseUpdate) Save(ctx context.Context) (int, error) { + ppu.defaults() + return withHooks(ctx, ppu.sqlSave, ppu.mutation, ppu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ppu *PlanPhaseUpdate) SaveX(ctx context.Context) int { + affected, err := ppu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (ppu *PlanPhaseUpdate) Exec(ctx context.Context) error { + _, err := ppu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ppu *PlanPhaseUpdate) ExecX(ctx context.Context) { + if err := ppu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (ppu *PlanPhaseUpdate) defaults() { + if _, ok := ppu.mutation.UpdatedAt(); !ok { + v := planphase.UpdateDefaultUpdatedAt() + ppu.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (ppu *PlanPhaseUpdate) check() error { + if v, ok := ppu.mutation.PlanID(); ok { + if err := planphase.PlanIDValidator(v); err != nil { + return &ValidationError{Name: "plan_id", err: fmt.Errorf(`db: validator failed for field "PlanPhase.plan_id": %w`, err)} + } + } + if ppu.mutation.PlanCleared() && len(ppu.mutation.PlanIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "PlanPhase.plan"`) + } + return nil +} + +func (ppu *PlanPhaseUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := ppu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(planphase.Table, planphase.Columns, sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString)) + if ps := ppu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := ppu.mutation.Metadata(); ok { + _spec.SetField(planphase.FieldMetadata, field.TypeJSON, value) + } + if ppu.mutation.MetadataCleared() { + _spec.ClearField(planphase.FieldMetadata, field.TypeJSON) + } + if value, ok := ppu.mutation.UpdatedAt(); ok { + _spec.SetField(planphase.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := ppu.mutation.DeletedAt(); ok { + _spec.SetField(planphase.FieldDeletedAt, field.TypeTime, value) + } + if ppu.mutation.DeletedAtCleared() { + _spec.ClearField(planphase.FieldDeletedAt, field.TypeTime) + } + if value, ok := ppu.mutation.Name(); ok { + _spec.SetField(planphase.FieldName, field.TypeString, value) + } + if value, ok := ppu.mutation.Description(); ok { + _spec.SetField(planphase.FieldDescription, field.TypeString, value) + } + if ppu.mutation.DescriptionCleared() { + _spec.ClearField(planphase.FieldDescription, field.TypeString) + } + if value, ok := ppu.mutation.StartAfter(); ok { + _spec.SetField(planphase.FieldStartAfter, field.TypeString, value) + } + if value, ok := ppu.mutation.Discounts(); ok { + vv, err := planphase.ValueScanner.Discounts.Value(value) + if err != nil { + return 0, err + } + _spec.SetField(planphase.FieldDiscounts, field.TypeString, vv) + } + if ppu.mutation.DiscountsCleared() { + _spec.ClearField(planphase.FieldDiscounts, field.TypeString) + } + if ppu.mutation.PlanCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planphase.PlanTable, + Columns: []string{planphase.PlanColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(dbplan.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ppu.mutation.PlanIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planphase.PlanTable, + Columns: []string{planphase.PlanColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(dbplan.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if ppu.mutation.RatecardsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: planphase.RatecardsTable, + Columns: []string{planphase.RatecardsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ppu.mutation.RemovedRatecardsIDs(); len(nodes) > 0 && !ppu.mutation.RatecardsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: planphase.RatecardsTable, + Columns: []string{planphase.RatecardsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ppu.mutation.RatecardsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: planphase.RatecardsTable, + Columns: []string{planphase.RatecardsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, ppu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{planphase.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + ppu.mutation.done = true + return n, nil +} + +// PlanPhaseUpdateOne is the builder for updating a single PlanPhase entity. +type PlanPhaseUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PlanPhaseMutation +} + +// SetMetadata sets the "metadata" field. +func (ppuo *PlanPhaseUpdateOne) SetMetadata(m map[string]string) *PlanPhaseUpdateOne { + ppuo.mutation.SetMetadata(m) + return ppuo +} + +// ClearMetadata clears the value of the "metadata" field. +func (ppuo *PlanPhaseUpdateOne) ClearMetadata() *PlanPhaseUpdateOne { + ppuo.mutation.ClearMetadata() + return ppuo +} + +// SetUpdatedAt sets the "updated_at" field. +func (ppuo *PlanPhaseUpdateOne) SetUpdatedAt(t time.Time) *PlanPhaseUpdateOne { + ppuo.mutation.SetUpdatedAt(t) + return ppuo +} + +// SetDeletedAt sets the "deleted_at" field. +func (ppuo *PlanPhaseUpdateOne) SetDeletedAt(t time.Time) *PlanPhaseUpdateOne { + ppuo.mutation.SetDeletedAt(t) + return ppuo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (ppuo *PlanPhaseUpdateOne) SetNillableDeletedAt(t *time.Time) *PlanPhaseUpdateOne { + if t != nil { + ppuo.SetDeletedAt(*t) + } + return ppuo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (ppuo *PlanPhaseUpdateOne) ClearDeletedAt() *PlanPhaseUpdateOne { + ppuo.mutation.ClearDeletedAt() + return ppuo +} + +// SetName sets the "name" field. +func (ppuo *PlanPhaseUpdateOne) SetName(s string) *PlanPhaseUpdateOne { + ppuo.mutation.SetName(s) + return ppuo +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (ppuo *PlanPhaseUpdateOne) SetNillableName(s *string) *PlanPhaseUpdateOne { + if s != nil { + ppuo.SetName(*s) + } + return ppuo +} + +// SetDescription sets the "description" field. +func (ppuo *PlanPhaseUpdateOne) SetDescription(s string) *PlanPhaseUpdateOne { + ppuo.mutation.SetDescription(s) + return ppuo +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (ppuo *PlanPhaseUpdateOne) SetNillableDescription(s *string) *PlanPhaseUpdateOne { + if s != nil { + ppuo.SetDescription(*s) + } + return ppuo +} + +// ClearDescription clears the value of the "description" field. +func (ppuo *PlanPhaseUpdateOne) ClearDescription() *PlanPhaseUpdateOne { + ppuo.mutation.ClearDescription() + return ppuo +} + +// SetStartAfter sets the "start_after" field. +func (ppuo *PlanPhaseUpdateOne) SetStartAfter(ds datex.ISOString) *PlanPhaseUpdateOne { + ppuo.mutation.SetStartAfter(ds) + return ppuo +} + +// SetNillableStartAfter sets the "start_after" field if the given value is not nil. +func (ppuo *PlanPhaseUpdateOne) SetNillableStartAfter(ds *datex.ISOString) *PlanPhaseUpdateOne { + if ds != nil { + ppuo.SetStartAfter(*ds) + } + return ppuo +} + +// SetDiscounts sets the "discounts" field. +func (ppuo *PlanPhaseUpdateOne) SetDiscounts(pl []plan.Discount) *PlanPhaseUpdateOne { + ppuo.mutation.SetDiscounts(pl) + return ppuo +} + +// ClearDiscounts clears the value of the "discounts" field. +func (ppuo *PlanPhaseUpdateOne) ClearDiscounts() *PlanPhaseUpdateOne { + ppuo.mutation.ClearDiscounts() + return ppuo +} + +// SetPlanID sets the "plan_id" field. +func (ppuo *PlanPhaseUpdateOne) SetPlanID(s string) *PlanPhaseUpdateOne { + ppuo.mutation.SetPlanID(s) + return ppuo +} + +// SetNillablePlanID sets the "plan_id" field if the given value is not nil. +func (ppuo *PlanPhaseUpdateOne) SetNillablePlanID(s *string) *PlanPhaseUpdateOne { + if s != nil { + ppuo.SetPlanID(*s) + } + return ppuo +} + +// SetPlan sets the "plan" edge to the Plan entity. +func (ppuo *PlanPhaseUpdateOne) SetPlan(p *Plan) *PlanPhaseUpdateOne { + return ppuo.SetPlanID(p.ID) +} + +// AddRatecardIDs adds the "ratecards" edge to the PlanRateCard entity by IDs. +func (ppuo *PlanPhaseUpdateOne) AddRatecardIDs(ids ...string) *PlanPhaseUpdateOne { + ppuo.mutation.AddRatecardIDs(ids...) + return ppuo +} + +// AddRatecards adds the "ratecards" edges to the PlanRateCard entity. +func (ppuo *PlanPhaseUpdateOne) AddRatecards(p ...*PlanRateCard) *PlanPhaseUpdateOne { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return ppuo.AddRatecardIDs(ids...) +} + +// Mutation returns the PlanPhaseMutation object of the builder. +func (ppuo *PlanPhaseUpdateOne) Mutation() *PlanPhaseMutation { + return ppuo.mutation +} + +// ClearPlan clears the "plan" edge to the Plan entity. +func (ppuo *PlanPhaseUpdateOne) ClearPlan() *PlanPhaseUpdateOne { + ppuo.mutation.ClearPlan() + return ppuo +} + +// ClearRatecards clears all "ratecards" edges to the PlanRateCard entity. +func (ppuo *PlanPhaseUpdateOne) ClearRatecards() *PlanPhaseUpdateOne { + ppuo.mutation.ClearRatecards() + return ppuo +} + +// RemoveRatecardIDs removes the "ratecards" edge to PlanRateCard entities by IDs. +func (ppuo *PlanPhaseUpdateOne) RemoveRatecardIDs(ids ...string) *PlanPhaseUpdateOne { + ppuo.mutation.RemoveRatecardIDs(ids...) + return ppuo +} + +// RemoveRatecards removes "ratecards" edges to PlanRateCard entities. +func (ppuo *PlanPhaseUpdateOne) RemoveRatecards(p ...*PlanRateCard) *PlanPhaseUpdateOne { + ids := make([]string, len(p)) + for i := range p { + ids[i] = p[i].ID + } + return ppuo.RemoveRatecardIDs(ids...) +} + +// Where appends a list predicates to the PlanPhaseUpdate builder. +func (ppuo *PlanPhaseUpdateOne) Where(ps ...predicate.PlanPhase) *PlanPhaseUpdateOne { + ppuo.mutation.Where(ps...) + return ppuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (ppuo *PlanPhaseUpdateOne) Select(field string, fields ...string) *PlanPhaseUpdateOne { + ppuo.fields = append([]string{field}, fields...) + return ppuo +} + +// Save executes the query and returns the updated PlanPhase entity. +func (ppuo *PlanPhaseUpdateOne) Save(ctx context.Context) (*PlanPhase, error) { + ppuo.defaults() + return withHooks(ctx, ppuo.sqlSave, ppuo.mutation, ppuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ppuo *PlanPhaseUpdateOne) SaveX(ctx context.Context) *PlanPhase { + node, err := ppuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (ppuo *PlanPhaseUpdateOne) Exec(ctx context.Context) error { + _, err := ppuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ppuo *PlanPhaseUpdateOne) ExecX(ctx context.Context) { + if err := ppuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (ppuo *PlanPhaseUpdateOne) defaults() { + if _, ok := ppuo.mutation.UpdatedAt(); !ok { + v := planphase.UpdateDefaultUpdatedAt() + ppuo.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (ppuo *PlanPhaseUpdateOne) check() error { + if v, ok := ppuo.mutation.PlanID(); ok { + if err := planphase.PlanIDValidator(v); err != nil { + return &ValidationError{Name: "plan_id", err: fmt.Errorf(`db: validator failed for field "PlanPhase.plan_id": %w`, err)} + } + } + if ppuo.mutation.PlanCleared() && len(ppuo.mutation.PlanIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "PlanPhase.plan"`) + } + return nil +} + +func (ppuo *PlanPhaseUpdateOne) sqlSave(ctx context.Context) (_node *PlanPhase, err error) { + if err := ppuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(planphase.Table, planphase.Columns, sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString)) + id, ok := ppuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "PlanPhase.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := ppuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, planphase.FieldID) + for _, f := range fields { + if !planphase.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != planphase.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := ppuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := ppuo.mutation.Metadata(); ok { + _spec.SetField(planphase.FieldMetadata, field.TypeJSON, value) + } + if ppuo.mutation.MetadataCleared() { + _spec.ClearField(planphase.FieldMetadata, field.TypeJSON) + } + if value, ok := ppuo.mutation.UpdatedAt(); ok { + _spec.SetField(planphase.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := ppuo.mutation.DeletedAt(); ok { + _spec.SetField(planphase.FieldDeletedAt, field.TypeTime, value) + } + if ppuo.mutation.DeletedAtCleared() { + _spec.ClearField(planphase.FieldDeletedAt, field.TypeTime) + } + if value, ok := ppuo.mutation.Name(); ok { + _spec.SetField(planphase.FieldName, field.TypeString, value) + } + if value, ok := ppuo.mutation.Description(); ok { + _spec.SetField(planphase.FieldDescription, field.TypeString, value) + } + if ppuo.mutation.DescriptionCleared() { + _spec.ClearField(planphase.FieldDescription, field.TypeString) + } + if value, ok := ppuo.mutation.StartAfter(); ok { + _spec.SetField(planphase.FieldStartAfter, field.TypeString, value) + } + if value, ok := ppuo.mutation.Discounts(); ok { + vv, err := planphase.ValueScanner.Discounts.Value(value) + if err != nil { + return nil, err + } + _spec.SetField(planphase.FieldDiscounts, field.TypeString, vv) + } + if ppuo.mutation.DiscountsCleared() { + _spec.ClearField(planphase.FieldDiscounts, field.TypeString) + } + if ppuo.mutation.PlanCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planphase.PlanTable, + Columns: []string{planphase.PlanColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(dbplan.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ppuo.mutation.PlanIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planphase.PlanTable, + Columns: []string{planphase.PlanColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(dbplan.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if ppuo.mutation.RatecardsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: planphase.RatecardsTable, + Columns: []string{planphase.RatecardsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ppuo.mutation.RemovedRatecardsIDs(); len(nodes) > 0 && !ppuo.mutation.RatecardsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: planphase.RatecardsTable, + Columns: []string{planphase.RatecardsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ppuo.mutation.RatecardsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: planphase.RatecardsTable, + Columns: []string{planphase.RatecardsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &PlanPhase{config: ppuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, ppuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{planphase.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + ppuo.mutation.done = true + return _node, nil +} diff --git a/openmeter/ent/db/planratecard.go b/openmeter/ent/db/planratecard.go new file mode 100644 index 000000000..bbf989468 --- /dev/null +++ b/openmeter/ent/db/planratecard.go @@ -0,0 +1,351 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/openmeterio/openmeter/openmeter/ent/db/feature" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" + "github.com/openmeterio/openmeter/pkg/datex" +) + +// PlanRateCard is the model entity for the PlanRateCard schema. +type PlanRateCard struct { + config `json:"-"` + // ID of the ent. + ID string `json:"id,omitempty"` + // Namespace holds the value of the "namespace" field. + Namespace string `json:"namespace,omitempty"` + // Metadata holds the value of the "metadata" field. + Metadata map[string]string `json:"metadata,omitempty"` + // CreatedAt holds the value of the "created_at" field. + CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` + // DeletedAt holds the value of the "deleted_at" field. + DeletedAt *time.Time `json:"deleted_at,omitempty"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Description holds the value of the "description" field. + Description *string `json:"description,omitempty"` + // Key holds the value of the "key" field. + Key string `json:"key,omitempty"` + // Type holds the value of the "type" field. + Type plan.RateCardType `json:"type,omitempty"` + // FeatureKey holds the value of the "feature_key" field. + FeatureKey *string `json:"feature_key,omitempty"` + // EntitlementTemplate holds the value of the "entitlement_template" field. + EntitlementTemplate *plan.EntitlementTemplate `json:"entitlement_template,omitempty"` + // TaxConfig holds the value of the "tax_config" field. + TaxConfig *plan.TaxConfig `json:"tax_config,omitempty"` + // BillingCadence holds the value of the "billing_cadence" field. + BillingCadence *datex.ISOString `json:"billing_cadence,omitempty"` + // Price holds the value of the "price" field. + Price *plan.Price `json:"price,omitempty"` + // The phase identifier the ratecard is assigned to. + PhaseID string `json:"phase_id,omitempty"` + // The feature identifier the ratecard is related to. + FeatureID *string `json:"feature_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PlanRateCardQuery when eager-loading is set. + Edges PlanRateCardEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PlanRateCardEdges holds the relations/edges for other nodes in the graph. +type PlanRateCardEdges struct { + // Phase holds the value of the phase edge. + Phase *PlanPhase `json:"phase,omitempty"` + // Features holds the value of the features edge. + Features *Feature `json:"features,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// PhaseOrErr returns the Phase value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PlanRateCardEdges) PhaseOrErr() (*PlanPhase, error) { + if e.Phase != nil { + return e.Phase, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: planphase.Label} + } + return nil, &NotLoadedError{edge: "phase"} +} + +// FeaturesOrErr returns the Features value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PlanRateCardEdges) FeaturesOrErr() (*Feature, error) { + if e.Features != nil { + return e.Features, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: feature.Label} + } + return nil, &NotLoadedError{edge: "features"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*PlanRateCard) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case planratecard.FieldMetadata: + values[i] = new([]byte) + case planratecard.FieldID, planratecard.FieldNamespace, planratecard.FieldName, planratecard.FieldDescription, planratecard.FieldKey, planratecard.FieldType, planratecard.FieldFeatureKey, planratecard.FieldBillingCadence, planratecard.FieldPhaseID, planratecard.FieldFeatureID: + values[i] = new(sql.NullString) + case planratecard.FieldCreatedAt, planratecard.FieldUpdatedAt, planratecard.FieldDeletedAt: + values[i] = new(sql.NullTime) + case planratecard.FieldEntitlementTemplate: + values[i] = planratecard.ValueScanner.EntitlementTemplate.ScanValue() + case planratecard.FieldTaxConfig: + values[i] = planratecard.ValueScanner.TaxConfig.ScanValue() + case planratecard.FieldPrice: + values[i] = planratecard.ValueScanner.Price.ScanValue() + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the PlanRateCard fields. +func (prc *PlanRateCard) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case planratecard.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + prc.ID = value.String + } + case planratecard.FieldNamespace: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field namespace", values[i]) + } else if value.Valid { + prc.Namespace = value.String + } + case planratecard.FieldMetadata: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field metadata", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &prc.Metadata); err != nil { + return fmt.Errorf("unmarshal field metadata: %w", err) + } + } + case planratecard.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + prc.CreatedAt = value.Time + } + case planratecard.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + prc.UpdatedAt = value.Time + } + case planratecard.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + prc.DeletedAt = new(time.Time) + *prc.DeletedAt = value.Time + } + case planratecard.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + prc.Name = value.String + } + case planratecard.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + prc.Description = new(string) + *prc.Description = value.String + } + case planratecard.FieldKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field key", values[i]) + } else if value.Valid { + prc.Key = value.String + } + case planratecard.FieldType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + prc.Type = plan.RateCardType(value.String) + } + case planratecard.FieldFeatureKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field feature_key", values[i]) + } else if value.Valid { + prc.FeatureKey = new(string) + *prc.FeatureKey = value.String + } + case planratecard.FieldEntitlementTemplate: + if value, err := planratecard.ValueScanner.EntitlementTemplate.FromValue(values[i]); err != nil { + return err + } else { + prc.EntitlementTemplate = value + } + case planratecard.FieldTaxConfig: + if value, err := planratecard.ValueScanner.TaxConfig.FromValue(values[i]); err != nil { + return err + } else { + prc.TaxConfig = value + } + case planratecard.FieldBillingCadence: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field billing_cadence", values[i]) + } else if value.Valid { + prc.BillingCadence = new(datex.ISOString) + *prc.BillingCadence = datex.ISOString(value.String) + } + case planratecard.FieldPrice: + if value, err := planratecard.ValueScanner.Price.FromValue(values[i]); err != nil { + return err + } else { + prc.Price = value + } + case planratecard.FieldPhaseID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field phase_id", values[i]) + } else if value.Valid { + prc.PhaseID = value.String + } + case planratecard.FieldFeatureID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field feature_id", values[i]) + } else if value.Valid { + prc.FeatureID = new(string) + *prc.FeatureID = value.String + } + default: + prc.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the PlanRateCard. +// This includes values selected through modifiers, order, etc. +func (prc *PlanRateCard) Value(name string) (ent.Value, error) { + return prc.selectValues.Get(name) +} + +// QueryPhase queries the "phase" edge of the PlanRateCard entity. +func (prc *PlanRateCard) QueryPhase() *PlanPhaseQuery { + return NewPlanRateCardClient(prc.config).QueryPhase(prc) +} + +// QueryFeatures queries the "features" edge of the PlanRateCard entity. +func (prc *PlanRateCard) QueryFeatures() *FeatureQuery { + return NewPlanRateCardClient(prc.config).QueryFeatures(prc) +} + +// Update returns a builder for updating this PlanRateCard. +// Note that you need to call PlanRateCard.Unwrap() before calling this method if this PlanRateCard +// was returned from a transaction, and the transaction was committed or rolled back. +func (prc *PlanRateCard) Update() *PlanRateCardUpdateOne { + return NewPlanRateCardClient(prc.config).UpdateOne(prc) +} + +// Unwrap unwraps the PlanRateCard entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (prc *PlanRateCard) Unwrap() *PlanRateCard { + _tx, ok := prc.config.driver.(*txDriver) + if !ok { + panic("db: PlanRateCard is not a transactional entity") + } + prc.config.driver = _tx.drv + return prc +} + +// String implements the fmt.Stringer. +func (prc *PlanRateCard) String() string { + var builder strings.Builder + builder.WriteString("PlanRateCard(") + builder.WriteString(fmt.Sprintf("id=%v, ", prc.ID)) + builder.WriteString("namespace=") + builder.WriteString(prc.Namespace) + builder.WriteString(", ") + builder.WriteString("metadata=") + builder.WriteString(fmt.Sprintf("%v", prc.Metadata)) + builder.WriteString(", ") + builder.WriteString("created_at=") + builder.WriteString(prc.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(prc.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + if v := prc.DeletedAt; v != nil { + builder.WriteString("deleted_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(prc.Name) + builder.WriteString(", ") + if v := prc.Description; v != nil { + builder.WriteString("description=") + builder.WriteString(*v) + } + builder.WriteString(", ") + builder.WriteString("key=") + builder.WriteString(prc.Key) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(fmt.Sprintf("%v", prc.Type)) + builder.WriteString(", ") + if v := prc.FeatureKey; v != nil { + builder.WriteString("feature_key=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := prc.EntitlementTemplate; v != nil { + builder.WriteString("entitlement_template=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + if v := prc.TaxConfig; v != nil { + builder.WriteString("tax_config=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + if v := prc.BillingCadence; v != nil { + builder.WriteString("billing_cadence=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + if v := prc.Price; v != nil { + builder.WriteString("price=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + builder.WriteString("phase_id=") + builder.WriteString(prc.PhaseID) + builder.WriteString(", ") + if v := prc.FeatureID; v != nil { + builder.WriteString("feature_id=") + builder.WriteString(*v) + } + builder.WriteByte(')') + return builder.String() +} + +// PlanRateCards is a parsable slice of PlanRateCard. +type PlanRateCards []*PlanRateCard diff --git a/openmeter/ent/db/planratecard/planratecard.go b/openmeter/ent/db/planratecard/planratecard.go new file mode 100644 index 000000000..efc0cba6b --- /dev/null +++ b/openmeter/ent/db/planratecard/planratecard.go @@ -0,0 +1,247 @@ +// Code generated by ent, DO NOT EDIT. + +package planratecard + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" +) + +const ( + // Label holds the string label denoting the planratecard type in the database. + Label = "plan_rate_card" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldNamespace holds the string denoting the namespace field in the database. + FieldNamespace = "namespace" + // FieldMetadata holds the string denoting the metadata field in the database. + FieldMetadata = "metadata" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldKey holds the string denoting the key field in the database. + FieldKey = "key" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldFeatureKey holds the string denoting the feature_key field in the database. + FieldFeatureKey = "feature_key" + // FieldEntitlementTemplate holds the string denoting the entitlement_template field in the database. + FieldEntitlementTemplate = "entitlement_template" + // FieldTaxConfig holds the string denoting the tax_config field in the database. + FieldTaxConfig = "tax_config" + // FieldBillingCadence holds the string denoting the billing_cadence field in the database. + FieldBillingCadence = "billing_cadence" + // FieldPrice holds the string denoting the price field in the database. + FieldPrice = "price" + // FieldPhaseID holds the string denoting the phase_id field in the database. + FieldPhaseID = "phase_id" + // FieldFeatureID holds the string denoting the feature_id field in the database. + FieldFeatureID = "feature_id" + // EdgePhase holds the string denoting the phase edge name in mutations. + EdgePhase = "phase" + // EdgeFeatures holds the string denoting the features edge name in mutations. + EdgeFeatures = "features" + // Table holds the table name of the planratecard in the database. + Table = "plan_rate_cards" + // PhaseTable is the table that holds the phase relation/edge. + PhaseTable = "plan_rate_cards" + // PhaseInverseTable is the table name for the PlanPhase entity. + // It exists in this package in order to avoid circular dependency with the "planphase" package. + PhaseInverseTable = "plan_phases" + // PhaseColumn is the table column denoting the phase relation/edge. + PhaseColumn = "phase_id" + // FeaturesTable is the table that holds the features relation/edge. + FeaturesTable = "plan_rate_cards" + // FeaturesInverseTable is the table name for the Feature entity. + // It exists in this package in order to avoid circular dependency with the "feature" package. + FeaturesInverseTable = "features" + // FeaturesColumn is the table column denoting the features relation/edge. + FeaturesColumn = "feature_id" +) + +// Columns holds all SQL columns for planratecard fields. +var Columns = []string{ + FieldID, + FieldNamespace, + FieldMetadata, + FieldCreatedAt, + FieldUpdatedAt, + FieldDeletedAt, + FieldName, + FieldDescription, + FieldKey, + FieldType, + FieldFeatureKey, + FieldEntitlementTemplate, + FieldTaxConfig, + FieldBillingCadence, + FieldPrice, + FieldPhaseID, + FieldFeatureID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // NamespaceValidator is a validator for the "namespace" field. It is called by the builders before save. + NamespaceValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // KeyValidator is a validator for the "key" field. It is called by the builders before save. + KeyValidator func(string) error + // PhaseIDValidator is a validator for the "phase_id" field. It is called by the builders before save. + PhaseIDValidator func(string) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() string + // ValueScanner of all PlanRateCard fields. + ValueScanner struct { + EntitlementTemplate field.TypeValueScanner[*plan.EntitlementTemplate] + TaxConfig field.TypeValueScanner[*plan.TaxConfig] + Price field.TypeValueScanner[*plan.Price] + } +) + +// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save. +func TypeValidator(_type plan.RateCardType) error { + switch _type { + case "flat_fee", "usage_based": + return nil + default: + return fmt.Errorf("planratecard: invalid enum value for type field: %q", _type) + } +} + +// OrderOption defines the ordering options for the PlanRateCard queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByNamespace orders the results by the namespace field. +func ByNamespace(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNamespace, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByKey orders the results by the key field. +func ByKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKey, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// ByFeatureKey orders the results by the feature_key field. +func ByFeatureKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFeatureKey, opts...).ToFunc() +} + +// ByEntitlementTemplate orders the results by the entitlement_template field. +func ByEntitlementTemplate(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEntitlementTemplate, opts...).ToFunc() +} + +// ByTaxConfig orders the results by the tax_config field. +func ByTaxConfig(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTaxConfig, opts...).ToFunc() +} + +// ByBillingCadence orders the results by the billing_cadence field. +func ByBillingCadence(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBillingCadence, opts...).ToFunc() +} + +// ByPrice orders the results by the price field. +func ByPrice(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPrice, opts...).ToFunc() +} + +// ByPhaseID orders the results by the phase_id field. +func ByPhaseID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPhaseID, opts...).ToFunc() +} + +// ByFeatureID orders the results by the feature_id field. +func ByFeatureID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFeatureID, opts...).ToFunc() +} + +// ByPhaseField orders the results by phase field. +func ByPhaseField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPhaseStep(), sql.OrderByField(field, opts...)) + } +} + +// ByFeaturesField orders the results by features field. +func ByFeaturesField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newFeaturesStep(), sql.OrderByField(field, opts...)) + } +} +func newPhaseStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PhaseInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, PhaseTable, PhaseColumn), + ) +} +func newFeaturesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(FeaturesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, FeaturesTable, FeaturesColumn), + ) +} diff --git a/openmeter/ent/db/planratecard/where.go b/openmeter/ent/db/planratecard/where.go new file mode 100644 index 000000000..a8e05f4b8 --- /dev/null +++ b/openmeter/ent/db/planratecard/where.go @@ -0,0 +1,964 @@ +// Code generated by ent, DO NOT EDIT. + +package planratecard + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" + "github.com/openmeterio/openmeter/pkg/datex" +) + +// ID filters vertices based on their ID field. +func ID(id string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldID, id)) +} + +// IDEqualFold applies the EqualFold predicate on the ID field. +func IDEqualFold(id string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEqualFold(FieldID, id)) +} + +// IDContainsFold applies the ContainsFold predicate on the ID field. +func IDContainsFold(id string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContainsFold(FieldID, id)) +} + +// Namespace applies equality check predicate on the "namespace" field. It's identical to NamespaceEQ. +func Namespace(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldNamespace, v)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldName, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldDescription, v)) +} + +// Key applies equality check predicate on the "key" field. It's identical to KeyEQ. +func Key(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldKey, v)) +} + +// FeatureKey applies equality check predicate on the "feature_key" field. It's identical to FeatureKeyEQ. +func FeatureKey(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldFeatureKey, v)) +} + +// BillingCadence applies equality check predicate on the "billing_cadence" field. It's identical to BillingCadenceEQ. +func BillingCadence(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldEQ(FieldBillingCadence, vc)) +} + +// PhaseID applies equality check predicate on the "phase_id" field. It's identical to PhaseIDEQ. +func PhaseID(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldPhaseID, v)) +} + +// FeatureID applies equality check predicate on the "feature_id" field. It's identical to FeatureIDEQ. +func FeatureID(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldFeatureID, v)) +} + +// NamespaceEQ applies the EQ predicate on the "namespace" field. +func NamespaceEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldNamespace, v)) +} + +// NamespaceNEQ applies the NEQ predicate on the "namespace" field. +func NamespaceNEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldNamespace, v)) +} + +// NamespaceIn applies the In predicate on the "namespace" field. +func NamespaceIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldNamespace, vs...)) +} + +// NamespaceNotIn applies the NotIn predicate on the "namespace" field. +func NamespaceNotIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldNamespace, vs...)) +} + +// NamespaceGT applies the GT predicate on the "namespace" field. +func NamespaceGT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldNamespace, v)) +} + +// NamespaceGTE applies the GTE predicate on the "namespace" field. +func NamespaceGTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldNamespace, v)) +} + +// NamespaceLT applies the LT predicate on the "namespace" field. +func NamespaceLT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldNamespace, v)) +} + +// NamespaceLTE applies the LTE predicate on the "namespace" field. +func NamespaceLTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldNamespace, v)) +} + +// NamespaceContains applies the Contains predicate on the "namespace" field. +func NamespaceContains(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContains(FieldNamespace, v)) +} + +// NamespaceHasPrefix applies the HasPrefix predicate on the "namespace" field. +func NamespaceHasPrefix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasPrefix(FieldNamespace, v)) +} + +// NamespaceHasSuffix applies the HasSuffix predicate on the "namespace" field. +func NamespaceHasSuffix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasSuffix(FieldNamespace, v)) +} + +// NamespaceEqualFold applies the EqualFold predicate on the "namespace" field. +func NamespaceEqualFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEqualFold(FieldNamespace, v)) +} + +// NamespaceContainsFold applies the ContainsFold predicate on the "namespace" field. +func NamespaceContainsFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContainsFold(FieldNamespace, v)) +} + +// MetadataIsNil applies the IsNil predicate on the "metadata" field. +func MetadataIsNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIsNull(FieldMetadata)) +} + +// MetadataNotNil applies the NotNil predicate on the "metadata" field. +func MetadataNotNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotNull(FieldMetadata)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotNull(FieldDeletedAt)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContainsFold(FieldName, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContainsFold(FieldDescription, v)) +} + +// KeyEQ applies the EQ predicate on the "key" field. +func KeyEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldKey, v)) +} + +// KeyNEQ applies the NEQ predicate on the "key" field. +func KeyNEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldKey, v)) +} + +// KeyIn applies the In predicate on the "key" field. +func KeyIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldKey, vs...)) +} + +// KeyNotIn applies the NotIn predicate on the "key" field. +func KeyNotIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldKey, vs...)) +} + +// KeyGT applies the GT predicate on the "key" field. +func KeyGT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldKey, v)) +} + +// KeyGTE applies the GTE predicate on the "key" field. +func KeyGTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldKey, v)) +} + +// KeyLT applies the LT predicate on the "key" field. +func KeyLT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldKey, v)) +} + +// KeyLTE applies the LTE predicate on the "key" field. +func KeyLTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldKey, v)) +} + +// KeyContains applies the Contains predicate on the "key" field. +func KeyContains(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContains(FieldKey, v)) +} + +// KeyHasPrefix applies the HasPrefix predicate on the "key" field. +func KeyHasPrefix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasPrefix(FieldKey, v)) +} + +// KeyHasSuffix applies the HasSuffix predicate on the "key" field. +func KeyHasSuffix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasSuffix(FieldKey, v)) +} + +// KeyEqualFold applies the EqualFold predicate on the "key" field. +func KeyEqualFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEqualFold(FieldKey, v)) +} + +// KeyContainsFold applies the ContainsFold predicate on the "key" field. +func KeyContainsFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContainsFold(FieldKey, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v plan.RateCardType) predicate.PlanRateCard { + vc := v + return predicate.PlanRateCard(sql.FieldEQ(FieldType, vc)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v plan.RateCardType) predicate.PlanRateCard { + vc := v + return predicate.PlanRateCard(sql.FieldNEQ(FieldType, vc)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...plan.RateCardType) predicate.PlanRateCard { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.PlanRateCard(sql.FieldIn(FieldType, v...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...plan.RateCardType) predicate.PlanRateCard { + v := make([]any, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.PlanRateCard(sql.FieldNotIn(FieldType, v...)) +} + +// FeatureKeyEQ applies the EQ predicate on the "feature_key" field. +func FeatureKeyEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldFeatureKey, v)) +} + +// FeatureKeyNEQ applies the NEQ predicate on the "feature_key" field. +func FeatureKeyNEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldFeatureKey, v)) +} + +// FeatureKeyIn applies the In predicate on the "feature_key" field. +func FeatureKeyIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldFeatureKey, vs...)) +} + +// FeatureKeyNotIn applies the NotIn predicate on the "feature_key" field. +func FeatureKeyNotIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldFeatureKey, vs...)) +} + +// FeatureKeyGT applies the GT predicate on the "feature_key" field. +func FeatureKeyGT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldFeatureKey, v)) +} + +// FeatureKeyGTE applies the GTE predicate on the "feature_key" field. +func FeatureKeyGTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldFeatureKey, v)) +} + +// FeatureKeyLT applies the LT predicate on the "feature_key" field. +func FeatureKeyLT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldFeatureKey, v)) +} + +// FeatureKeyLTE applies the LTE predicate on the "feature_key" field. +func FeatureKeyLTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldFeatureKey, v)) +} + +// FeatureKeyContains applies the Contains predicate on the "feature_key" field. +func FeatureKeyContains(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContains(FieldFeatureKey, v)) +} + +// FeatureKeyHasPrefix applies the HasPrefix predicate on the "feature_key" field. +func FeatureKeyHasPrefix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasPrefix(FieldFeatureKey, v)) +} + +// FeatureKeyHasSuffix applies the HasSuffix predicate on the "feature_key" field. +func FeatureKeyHasSuffix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasSuffix(FieldFeatureKey, v)) +} + +// FeatureKeyIsNil applies the IsNil predicate on the "feature_key" field. +func FeatureKeyIsNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIsNull(FieldFeatureKey)) +} + +// FeatureKeyNotNil applies the NotNil predicate on the "feature_key" field. +func FeatureKeyNotNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotNull(FieldFeatureKey)) +} + +// FeatureKeyEqualFold applies the EqualFold predicate on the "feature_key" field. +func FeatureKeyEqualFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEqualFold(FieldFeatureKey, v)) +} + +// FeatureKeyContainsFold applies the ContainsFold predicate on the "feature_key" field. +func FeatureKeyContainsFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContainsFold(FieldFeatureKey, v)) +} + +// EntitlementTemplateIsNil applies the IsNil predicate on the "entitlement_template" field. +func EntitlementTemplateIsNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIsNull(FieldEntitlementTemplate)) +} + +// EntitlementTemplateNotNil applies the NotNil predicate on the "entitlement_template" field. +func EntitlementTemplateNotNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotNull(FieldEntitlementTemplate)) +} + +// TaxConfigIsNil applies the IsNil predicate on the "tax_config" field. +func TaxConfigIsNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIsNull(FieldTaxConfig)) +} + +// TaxConfigNotNil applies the NotNil predicate on the "tax_config" field. +func TaxConfigNotNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotNull(FieldTaxConfig)) +} + +// BillingCadenceEQ applies the EQ predicate on the "billing_cadence" field. +func BillingCadenceEQ(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldEQ(FieldBillingCadence, vc)) +} + +// BillingCadenceNEQ applies the NEQ predicate on the "billing_cadence" field. +func BillingCadenceNEQ(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldNEQ(FieldBillingCadence, vc)) +} + +// BillingCadenceIn applies the In predicate on the "billing_cadence" field. +func BillingCadenceIn(vs ...datex.ISOString) predicate.PlanRateCard { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.PlanRateCard(sql.FieldIn(FieldBillingCadence, v...)) +} + +// BillingCadenceNotIn applies the NotIn predicate on the "billing_cadence" field. +func BillingCadenceNotIn(vs ...datex.ISOString) predicate.PlanRateCard { + v := make([]any, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.PlanRateCard(sql.FieldNotIn(FieldBillingCadence, v...)) +} + +// BillingCadenceGT applies the GT predicate on the "billing_cadence" field. +func BillingCadenceGT(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldGT(FieldBillingCadence, vc)) +} + +// BillingCadenceGTE applies the GTE predicate on the "billing_cadence" field. +func BillingCadenceGTE(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldGTE(FieldBillingCadence, vc)) +} + +// BillingCadenceLT applies the LT predicate on the "billing_cadence" field. +func BillingCadenceLT(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldLT(FieldBillingCadence, vc)) +} + +// BillingCadenceLTE applies the LTE predicate on the "billing_cadence" field. +func BillingCadenceLTE(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldLTE(FieldBillingCadence, vc)) +} + +// BillingCadenceContains applies the Contains predicate on the "billing_cadence" field. +func BillingCadenceContains(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldContains(FieldBillingCadence, vc)) +} + +// BillingCadenceHasPrefix applies the HasPrefix predicate on the "billing_cadence" field. +func BillingCadenceHasPrefix(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldHasPrefix(FieldBillingCadence, vc)) +} + +// BillingCadenceHasSuffix applies the HasSuffix predicate on the "billing_cadence" field. +func BillingCadenceHasSuffix(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldHasSuffix(FieldBillingCadence, vc)) +} + +// BillingCadenceIsNil applies the IsNil predicate on the "billing_cadence" field. +func BillingCadenceIsNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIsNull(FieldBillingCadence)) +} + +// BillingCadenceNotNil applies the NotNil predicate on the "billing_cadence" field. +func BillingCadenceNotNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotNull(FieldBillingCadence)) +} + +// BillingCadenceEqualFold applies the EqualFold predicate on the "billing_cadence" field. +func BillingCadenceEqualFold(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldEqualFold(FieldBillingCadence, vc)) +} + +// BillingCadenceContainsFold applies the ContainsFold predicate on the "billing_cadence" field. +func BillingCadenceContainsFold(v datex.ISOString) predicate.PlanRateCard { + vc := string(v) + return predicate.PlanRateCard(sql.FieldContainsFold(FieldBillingCadence, vc)) +} + +// PriceIsNil applies the IsNil predicate on the "price" field. +func PriceIsNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIsNull(FieldPrice)) +} + +// PriceNotNil applies the NotNil predicate on the "price" field. +func PriceNotNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotNull(FieldPrice)) +} + +// PhaseIDEQ applies the EQ predicate on the "phase_id" field. +func PhaseIDEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldPhaseID, v)) +} + +// PhaseIDNEQ applies the NEQ predicate on the "phase_id" field. +func PhaseIDNEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldPhaseID, v)) +} + +// PhaseIDIn applies the In predicate on the "phase_id" field. +func PhaseIDIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldPhaseID, vs...)) +} + +// PhaseIDNotIn applies the NotIn predicate on the "phase_id" field. +func PhaseIDNotIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldPhaseID, vs...)) +} + +// PhaseIDGT applies the GT predicate on the "phase_id" field. +func PhaseIDGT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldPhaseID, v)) +} + +// PhaseIDGTE applies the GTE predicate on the "phase_id" field. +func PhaseIDGTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldPhaseID, v)) +} + +// PhaseIDLT applies the LT predicate on the "phase_id" field. +func PhaseIDLT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldPhaseID, v)) +} + +// PhaseIDLTE applies the LTE predicate on the "phase_id" field. +func PhaseIDLTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldPhaseID, v)) +} + +// PhaseIDContains applies the Contains predicate on the "phase_id" field. +func PhaseIDContains(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContains(FieldPhaseID, v)) +} + +// PhaseIDHasPrefix applies the HasPrefix predicate on the "phase_id" field. +func PhaseIDHasPrefix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasPrefix(FieldPhaseID, v)) +} + +// PhaseIDHasSuffix applies the HasSuffix predicate on the "phase_id" field. +func PhaseIDHasSuffix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasSuffix(FieldPhaseID, v)) +} + +// PhaseIDEqualFold applies the EqualFold predicate on the "phase_id" field. +func PhaseIDEqualFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEqualFold(FieldPhaseID, v)) +} + +// PhaseIDContainsFold applies the ContainsFold predicate on the "phase_id" field. +func PhaseIDContainsFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContainsFold(FieldPhaseID, v)) +} + +// FeatureIDEQ applies the EQ predicate on the "feature_id" field. +func FeatureIDEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEQ(FieldFeatureID, v)) +} + +// FeatureIDNEQ applies the NEQ predicate on the "feature_id" field. +func FeatureIDNEQ(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNEQ(FieldFeatureID, v)) +} + +// FeatureIDIn applies the In predicate on the "feature_id" field. +func FeatureIDIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIn(FieldFeatureID, vs...)) +} + +// FeatureIDNotIn applies the NotIn predicate on the "feature_id" field. +func FeatureIDNotIn(vs ...string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotIn(FieldFeatureID, vs...)) +} + +// FeatureIDGT applies the GT predicate on the "feature_id" field. +func FeatureIDGT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGT(FieldFeatureID, v)) +} + +// FeatureIDGTE applies the GTE predicate on the "feature_id" field. +func FeatureIDGTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldGTE(FieldFeatureID, v)) +} + +// FeatureIDLT applies the LT predicate on the "feature_id" field. +func FeatureIDLT(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLT(FieldFeatureID, v)) +} + +// FeatureIDLTE applies the LTE predicate on the "feature_id" field. +func FeatureIDLTE(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldLTE(FieldFeatureID, v)) +} + +// FeatureIDContains applies the Contains predicate on the "feature_id" field. +func FeatureIDContains(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContains(FieldFeatureID, v)) +} + +// FeatureIDHasPrefix applies the HasPrefix predicate on the "feature_id" field. +func FeatureIDHasPrefix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasPrefix(FieldFeatureID, v)) +} + +// FeatureIDHasSuffix applies the HasSuffix predicate on the "feature_id" field. +func FeatureIDHasSuffix(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldHasSuffix(FieldFeatureID, v)) +} + +// FeatureIDIsNil applies the IsNil predicate on the "feature_id" field. +func FeatureIDIsNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldIsNull(FieldFeatureID)) +} + +// FeatureIDNotNil applies the NotNil predicate on the "feature_id" field. +func FeatureIDNotNil() predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldNotNull(FieldFeatureID)) +} + +// FeatureIDEqualFold applies the EqualFold predicate on the "feature_id" field. +func FeatureIDEqualFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldEqualFold(FieldFeatureID, v)) +} + +// FeatureIDContainsFold applies the ContainsFold predicate on the "feature_id" field. +func FeatureIDContainsFold(v string) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.FieldContainsFold(FieldFeatureID, v)) +} + +// HasPhase applies the HasEdge predicate on the "phase" edge. +func HasPhase() predicate.PlanRateCard { + return predicate.PlanRateCard(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, PhaseTable, PhaseColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPhaseWith applies the HasEdge predicate on the "phase" edge with a given conditions (other predicates). +func HasPhaseWith(preds ...predicate.PlanPhase) predicate.PlanRateCard { + return predicate.PlanRateCard(func(s *sql.Selector) { + step := newPhaseStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasFeatures applies the HasEdge predicate on the "features" edge. +func HasFeatures() predicate.PlanRateCard { + return predicate.PlanRateCard(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, FeaturesTable, FeaturesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasFeaturesWith applies the HasEdge predicate on the "features" edge with a given conditions (other predicates). +func HasFeaturesWith(preds ...predicate.Feature) predicate.PlanRateCard { + return predicate.PlanRateCard(func(s *sql.Selector) { + step := newFeaturesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PlanRateCard) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PlanRateCard) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PlanRateCard) predicate.PlanRateCard { + return predicate.PlanRateCard(sql.NotPredicates(p)) +} diff --git a/openmeter/ent/db/planratecard_create.go b/openmeter/ent/db/planratecard_create.go new file mode 100644 index 000000000..f31b31430 --- /dev/null +++ b/openmeter/ent/db/planratecard_create.go @@ -0,0 +1,1494 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/openmeterio/openmeter/openmeter/ent/db/feature" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" + "github.com/openmeterio/openmeter/pkg/datex" +) + +// PlanRateCardCreate is the builder for creating a PlanRateCard entity. +type PlanRateCardCreate struct { + config + mutation *PlanRateCardMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetNamespace sets the "namespace" field. +func (prcc *PlanRateCardCreate) SetNamespace(s string) *PlanRateCardCreate { + prcc.mutation.SetNamespace(s) + return prcc +} + +// SetMetadata sets the "metadata" field. +func (prcc *PlanRateCardCreate) SetMetadata(m map[string]string) *PlanRateCardCreate { + prcc.mutation.SetMetadata(m) + return prcc +} + +// SetCreatedAt sets the "created_at" field. +func (prcc *PlanRateCardCreate) SetCreatedAt(t time.Time) *PlanRateCardCreate { + prcc.mutation.SetCreatedAt(t) + return prcc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (prcc *PlanRateCardCreate) SetNillableCreatedAt(t *time.Time) *PlanRateCardCreate { + if t != nil { + prcc.SetCreatedAt(*t) + } + return prcc +} + +// SetUpdatedAt sets the "updated_at" field. +func (prcc *PlanRateCardCreate) SetUpdatedAt(t time.Time) *PlanRateCardCreate { + prcc.mutation.SetUpdatedAt(t) + return prcc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (prcc *PlanRateCardCreate) SetNillableUpdatedAt(t *time.Time) *PlanRateCardCreate { + if t != nil { + prcc.SetUpdatedAt(*t) + } + return prcc +} + +// SetDeletedAt sets the "deleted_at" field. +func (prcc *PlanRateCardCreate) SetDeletedAt(t time.Time) *PlanRateCardCreate { + prcc.mutation.SetDeletedAt(t) + return prcc +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (prcc *PlanRateCardCreate) SetNillableDeletedAt(t *time.Time) *PlanRateCardCreate { + if t != nil { + prcc.SetDeletedAt(*t) + } + return prcc +} + +// SetName sets the "name" field. +func (prcc *PlanRateCardCreate) SetName(s string) *PlanRateCardCreate { + prcc.mutation.SetName(s) + return prcc +} + +// SetDescription sets the "description" field. +func (prcc *PlanRateCardCreate) SetDescription(s string) *PlanRateCardCreate { + prcc.mutation.SetDescription(s) + return prcc +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (prcc *PlanRateCardCreate) SetNillableDescription(s *string) *PlanRateCardCreate { + if s != nil { + prcc.SetDescription(*s) + } + return prcc +} + +// SetKey sets the "key" field. +func (prcc *PlanRateCardCreate) SetKey(s string) *PlanRateCardCreate { + prcc.mutation.SetKey(s) + return prcc +} + +// SetType sets the "type" field. +func (prcc *PlanRateCardCreate) SetType(pct plan.RateCardType) *PlanRateCardCreate { + prcc.mutation.SetType(pct) + return prcc +} + +// SetFeatureKey sets the "feature_key" field. +func (prcc *PlanRateCardCreate) SetFeatureKey(s string) *PlanRateCardCreate { + prcc.mutation.SetFeatureKey(s) + return prcc +} + +// SetNillableFeatureKey sets the "feature_key" field if the given value is not nil. +func (prcc *PlanRateCardCreate) SetNillableFeatureKey(s *string) *PlanRateCardCreate { + if s != nil { + prcc.SetFeatureKey(*s) + } + return prcc +} + +// SetEntitlementTemplate sets the "entitlement_template" field. +func (prcc *PlanRateCardCreate) SetEntitlementTemplate(pt *plan.EntitlementTemplate) *PlanRateCardCreate { + prcc.mutation.SetEntitlementTemplate(pt) + return prcc +} + +// SetTaxConfig sets the "tax_config" field. +func (prcc *PlanRateCardCreate) SetTaxConfig(pc *plan.TaxConfig) *PlanRateCardCreate { + prcc.mutation.SetTaxConfig(pc) + return prcc +} + +// SetBillingCadence sets the "billing_cadence" field. +func (prcc *PlanRateCardCreate) SetBillingCadence(ds datex.ISOString) *PlanRateCardCreate { + prcc.mutation.SetBillingCadence(ds) + return prcc +} + +// SetNillableBillingCadence sets the "billing_cadence" field if the given value is not nil. +func (prcc *PlanRateCardCreate) SetNillableBillingCadence(ds *datex.ISOString) *PlanRateCardCreate { + if ds != nil { + prcc.SetBillingCadence(*ds) + } + return prcc +} + +// SetPrice sets the "price" field. +func (prcc *PlanRateCardCreate) SetPrice(pl *plan.Price) *PlanRateCardCreate { + prcc.mutation.SetPrice(pl) + return prcc +} + +// SetPhaseID sets the "phase_id" field. +func (prcc *PlanRateCardCreate) SetPhaseID(s string) *PlanRateCardCreate { + prcc.mutation.SetPhaseID(s) + return prcc +} + +// SetFeatureID sets the "feature_id" field. +func (prcc *PlanRateCardCreate) SetFeatureID(s string) *PlanRateCardCreate { + prcc.mutation.SetFeatureID(s) + return prcc +} + +// SetNillableFeatureID sets the "feature_id" field if the given value is not nil. +func (prcc *PlanRateCardCreate) SetNillableFeatureID(s *string) *PlanRateCardCreate { + if s != nil { + prcc.SetFeatureID(*s) + } + return prcc +} + +// SetID sets the "id" field. +func (prcc *PlanRateCardCreate) SetID(s string) *PlanRateCardCreate { + prcc.mutation.SetID(s) + return prcc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (prcc *PlanRateCardCreate) SetNillableID(s *string) *PlanRateCardCreate { + if s != nil { + prcc.SetID(*s) + } + return prcc +} + +// SetPhase sets the "phase" edge to the PlanPhase entity. +func (prcc *PlanRateCardCreate) SetPhase(p *PlanPhase) *PlanRateCardCreate { + return prcc.SetPhaseID(p.ID) +} + +// SetFeaturesID sets the "features" edge to the Feature entity by ID. +func (prcc *PlanRateCardCreate) SetFeaturesID(id string) *PlanRateCardCreate { + prcc.mutation.SetFeaturesID(id) + return prcc +} + +// SetNillableFeaturesID sets the "features" edge to the Feature entity by ID if the given value is not nil. +func (prcc *PlanRateCardCreate) SetNillableFeaturesID(id *string) *PlanRateCardCreate { + if id != nil { + prcc = prcc.SetFeaturesID(*id) + } + return prcc +} + +// SetFeatures sets the "features" edge to the Feature entity. +func (prcc *PlanRateCardCreate) SetFeatures(f *Feature) *PlanRateCardCreate { + return prcc.SetFeaturesID(f.ID) +} + +// Mutation returns the PlanRateCardMutation object of the builder. +func (prcc *PlanRateCardCreate) Mutation() *PlanRateCardMutation { + return prcc.mutation +} + +// Save creates the PlanRateCard in the database. +func (prcc *PlanRateCardCreate) Save(ctx context.Context) (*PlanRateCard, error) { + prcc.defaults() + return withHooks(ctx, prcc.sqlSave, prcc.mutation, prcc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (prcc *PlanRateCardCreate) SaveX(ctx context.Context) *PlanRateCard { + v, err := prcc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (prcc *PlanRateCardCreate) Exec(ctx context.Context) error { + _, err := prcc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (prcc *PlanRateCardCreate) ExecX(ctx context.Context) { + if err := prcc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (prcc *PlanRateCardCreate) defaults() { + if _, ok := prcc.mutation.CreatedAt(); !ok { + v := planratecard.DefaultCreatedAt() + prcc.mutation.SetCreatedAt(v) + } + if _, ok := prcc.mutation.UpdatedAt(); !ok { + v := planratecard.DefaultUpdatedAt() + prcc.mutation.SetUpdatedAt(v) + } + if _, ok := prcc.mutation.ID(); !ok { + v := planratecard.DefaultID() + prcc.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (prcc *PlanRateCardCreate) check() error { + if _, ok := prcc.mutation.Namespace(); !ok { + return &ValidationError{Name: "namespace", err: errors.New(`db: missing required field "PlanRateCard.namespace"`)} + } + if v, ok := prcc.mutation.Namespace(); ok { + if err := planratecard.NamespaceValidator(v); err != nil { + return &ValidationError{Name: "namespace", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.namespace": %w`, err)} + } + } + if _, ok := prcc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "PlanRateCard.created_at"`)} + } + if _, ok := prcc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "PlanRateCard.updated_at"`)} + } + if _, ok := prcc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`db: missing required field "PlanRateCard.name"`)} + } + if _, ok := prcc.mutation.Key(); !ok { + return &ValidationError{Name: "key", err: errors.New(`db: missing required field "PlanRateCard.key"`)} + } + if v, ok := prcc.mutation.Key(); ok { + if err := planratecard.KeyValidator(v); err != nil { + return &ValidationError{Name: "key", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.key": %w`, err)} + } + } + if _, ok := prcc.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`db: missing required field "PlanRateCard.type"`)} + } + if v, ok := prcc.mutation.GetType(); ok { + if err := planratecard.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.type": %w`, err)} + } + } + if v, ok := prcc.mutation.EntitlementTemplate(); ok { + if err := v.Validate(); err != nil { + return &ValidationError{Name: "entitlement_template", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.entitlement_template": %w`, err)} + } + } + if v, ok := prcc.mutation.TaxConfig(); ok { + if err := v.Validate(); err != nil { + return &ValidationError{Name: "tax_config", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.tax_config": %w`, err)} + } + } + if v, ok := prcc.mutation.Price(); ok { + if err := v.Validate(); err != nil { + return &ValidationError{Name: "price", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.price": %w`, err)} + } + } + if _, ok := prcc.mutation.PhaseID(); !ok { + return &ValidationError{Name: "phase_id", err: errors.New(`db: missing required field "PlanRateCard.phase_id"`)} + } + if v, ok := prcc.mutation.PhaseID(); ok { + if err := planratecard.PhaseIDValidator(v); err != nil { + return &ValidationError{Name: "phase_id", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.phase_id": %w`, err)} + } + } + if len(prcc.mutation.PhaseIDs()) == 0 { + return &ValidationError{Name: "phase", err: errors.New(`db: missing required edge "PlanRateCard.phase"`)} + } + return nil +} + +func (prcc *PlanRateCardCreate) sqlSave(ctx context.Context) (*PlanRateCard, error) { + if err := prcc.check(); err != nil { + return nil, err + } + _node, _spec, err := prcc.createSpec() + if err != nil { + return nil, err + } + if err := sqlgraph.CreateNode(ctx, prcc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(string); ok { + _node.ID = id + } else { + return nil, fmt.Errorf("unexpected PlanRateCard.ID type: %T", _spec.ID.Value) + } + } + prcc.mutation.id = &_node.ID + prcc.mutation.done = true + return _node, nil +} + +func (prcc *PlanRateCardCreate) createSpec() (*PlanRateCard, *sqlgraph.CreateSpec, error) { + var ( + _node = &PlanRateCard{config: prcc.config} + _spec = sqlgraph.NewCreateSpec(planratecard.Table, sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString)) + ) + _spec.OnConflict = prcc.conflict + if id, ok := prcc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := prcc.mutation.Namespace(); ok { + _spec.SetField(planratecard.FieldNamespace, field.TypeString, value) + _node.Namespace = value + } + if value, ok := prcc.mutation.Metadata(); ok { + _spec.SetField(planratecard.FieldMetadata, field.TypeJSON, value) + _node.Metadata = value + } + if value, ok := prcc.mutation.CreatedAt(); ok { + _spec.SetField(planratecard.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := prcc.mutation.UpdatedAt(); ok { + _spec.SetField(planratecard.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := prcc.mutation.DeletedAt(); ok { + _spec.SetField(planratecard.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = &value + } + if value, ok := prcc.mutation.Name(); ok { + _spec.SetField(planratecard.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := prcc.mutation.Description(); ok { + _spec.SetField(planratecard.FieldDescription, field.TypeString, value) + _node.Description = &value + } + if value, ok := prcc.mutation.Key(); ok { + _spec.SetField(planratecard.FieldKey, field.TypeString, value) + _node.Key = value + } + if value, ok := prcc.mutation.GetType(); ok { + _spec.SetField(planratecard.FieldType, field.TypeEnum, value) + _node.Type = value + } + if value, ok := prcc.mutation.FeatureKey(); ok { + _spec.SetField(planratecard.FieldFeatureKey, field.TypeString, value) + _node.FeatureKey = &value + } + if value, ok := prcc.mutation.EntitlementTemplate(); ok { + vv, err := planratecard.ValueScanner.EntitlementTemplate.Value(value) + if err != nil { + return nil, nil, err + } + _spec.SetField(planratecard.FieldEntitlementTemplate, field.TypeString, vv) + _node.EntitlementTemplate = value + } + if value, ok := prcc.mutation.TaxConfig(); ok { + vv, err := planratecard.ValueScanner.TaxConfig.Value(value) + if err != nil { + return nil, nil, err + } + _spec.SetField(planratecard.FieldTaxConfig, field.TypeString, vv) + _node.TaxConfig = value + } + if value, ok := prcc.mutation.BillingCadence(); ok { + _spec.SetField(planratecard.FieldBillingCadence, field.TypeString, value) + _node.BillingCadence = &value + } + if value, ok := prcc.mutation.Price(); ok { + vv, err := planratecard.ValueScanner.Price.Value(value) + if err != nil { + return nil, nil, err + } + _spec.SetField(planratecard.FieldPrice, field.TypeString, vv) + _node.Price = value + } + if nodes := prcc.mutation.PhaseIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planratecard.PhaseTable, + Columns: []string{planratecard.PhaseColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.PhaseID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := prcc.mutation.FeaturesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planratecard.FeaturesTable, + Columns: []string{planratecard.FeaturesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(feature.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.FeatureID = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec, nil +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.PlanRateCard.Create(). +// SetNamespace(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.PlanRateCardUpsert) { +// SetNamespace(v+v). +// }). +// Exec(ctx) +func (prcc *PlanRateCardCreate) OnConflict(opts ...sql.ConflictOption) *PlanRateCardUpsertOne { + prcc.conflict = opts + return &PlanRateCardUpsertOne{ + create: prcc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.PlanRateCard.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (prcc *PlanRateCardCreate) OnConflictColumns(columns ...string) *PlanRateCardUpsertOne { + prcc.conflict = append(prcc.conflict, sql.ConflictColumns(columns...)) + return &PlanRateCardUpsertOne{ + create: prcc, + } +} + +type ( + // PlanRateCardUpsertOne is the builder for "upsert"-ing + // one PlanRateCard node. + PlanRateCardUpsertOne struct { + create *PlanRateCardCreate + } + + // PlanRateCardUpsert is the "OnConflict" setter. + PlanRateCardUpsert struct { + *sql.UpdateSet + } +) + +// SetMetadata sets the "metadata" field. +func (u *PlanRateCardUpsert) SetMetadata(v map[string]string) *PlanRateCardUpsert { + u.Set(planratecard.FieldMetadata, v) + return u +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdateMetadata() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldMetadata) + return u +} + +// ClearMetadata clears the value of the "metadata" field. +func (u *PlanRateCardUpsert) ClearMetadata() *PlanRateCardUpsert { + u.SetNull(planratecard.FieldMetadata) + return u +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *PlanRateCardUpsert) SetUpdatedAt(v time.Time) *PlanRateCardUpsert { + u.Set(planratecard.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdateUpdatedAt() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldUpdatedAt) + return u +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *PlanRateCardUpsert) SetDeletedAt(v time.Time) *PlanRateCardUpsert { + u.Set(planratecard.FieldDeletedAt, v) + return u +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdateDeletedAt() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldDeletedAt) + return u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *PlanRateCardUpsert) ClearDeletedAt() *PlanRateCardUpsert { + u.SetNull(planratecard.FieldDeletedAt) + return u +} + +// SetName sets the "name" field. +func (u *PlanRateCardUpsert) SetName(v string) *PlanRateCardUpsert { + u.Set(planratecard.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdateName() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldName) + return u +} + +// SetDescription sets the "description" field. +func (u *PlanRateCardUpsert) SetDescription(v string) *PlanRateCardUpsert { + u.Set(planratecard.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdateDescription() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldDescription) + return u +} + +// ClearDescription clears the value of the "description" field. +func (u *PlanRateCardUpsert) ClearDescription() *PlanRateCardUpsert { + u.SetNull(planratecard.FieldDescription) + return u +} + +// SetFeatureKey sets the "feature_key" field. +func (u *PlanRateCardUpsert) SetFeatureKey(v string) *PlanRateCardUpsert { + u.Set(planratecard.FieldFeatureKey, v) + return u +} + +// UpdateFeatureKey sets the "feature_key" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdateFeatureKey() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldFeatureKey) + return u +} + +// ClearFeatureKey clears the value of the "feature_key" field. +func (u *PlanRateCardUpsert) ClearFeatureKey() *PlanRateCardUpsert { + u.SetNull(planratecard.FieldFeatureKey) + return u +} + +// SetEntitlementTemplate sets the "entitlement_template" field. +func (u *PlanRateCardUpsert) SetEntitlementTemplate(v *plan.EntitlementTemplate) *PlanRateCardUpsert { + u.Set(planratecard.FieldEntitlementTemplate, v) + return u +} + +// UpdateEntitlementTemplate sets the "entitlement_template" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdateEntitlementTemplate() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldEntitlementTemplate) + return u +} + +// ClearEntitlementTemplate clears the value of the "entitlement_template" field. +func (u *PlanRateCardUpsert) ClearEntitlementTemplate() *PlanRateCardUpsert { + u.SetNull(planratecard.FieldEntitlementTemplate) + return u +} + +// SetTaxConfig sets the "tax_config" field. +func (u *PlanRateCardUpsert) SetTaxConfig(v *plan.TaxConfig) *PlanRateCardUpsert { + u.Set(planratecard.FieldTaxConfig, v) + return u +} + +// UpdateTaxConfig sets the "tax_config" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdateTaxConfig() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldTaxConfig) + return u +} + +// ClearTaxConfig clears the value of the "tax_config" field. +func (u *PlanRateCardUpsert) ClearTaxConfig() *PlanRateCardUpsert { + u.SetNull(planratecard.FieldTaxConfig) + return u +} + +// SetBillingCadence sets the "billing_cadence" field. +func (u *PlanRateCardUpsert) SetBillingCadence(v datex.ISOString) *PlanRateCardUpsert { + u.Set(planratecard.FieldBillingCadence, v) + return u +} + +// UpdateBillingCadence sets the "billing_cadence" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdateBillingCadence() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldBillingCadence) + return u +} + +// ClearBillingCadence clears the value of the "billing_cadence" field. +func (u *PlanRateCardUpsert) ClearBillingCadence() *PlanRateCardUpsert { + u.SetNull(planratecard.FieldBillingCadence) + return u +} + +// SetPrice sets the "price" field. +func (u *PlanRateCardUpsert) SetPrice(v *plan.Price) *PlanRateCardUpsert { + u.Set(planratecard.FieldPrice, v) + return u +} + +// UpdatePrice sets the "price" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdatePrice() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldPrice) + return u +} + +// ClearPrice clears the value of the "price" field. +func (u *PlanRateCardUpsert) ClearPrice() *PlanRateCardUpsert { + u.SetNull(planratecard.FieldPrice) + return u +} + +// SetPhaseID sets the "phase_id" field. +func (u *PlanRateCardUpsert) SetPhaseID(v string) *PlanRateCardUpsert { + u.Set(planratecard.FieldPhaseID, v) + return u +} + +// UpdatePhaseID sets the "phase_id" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdatePhaseID() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldPhaseID) + return u +} + +// SetFeatureID sets the "feature_id" field. +func (u *PlanRateCardUpsert) SetFeatureID(v string) *PlanRateCardUpsert { + u.Set(planratecard.FieldFeatureID, v) + return u +} + +// UpdateFeatureID sets the "feature_id" field to the value that was provided on create. +func (u *PlanRateCardUpsert) UpdateFeatureID() *PlanRateCardUpsert { + u.SetExcluded(planratecard.FieldFeatureID) + return u +} + +// ClearFeatureID clears the value of the "feature_id" field. +func (u *PlanRateCardUpsert) ClearFeatureID() *PlanRateCardUpsert { + u.SetNull(planratecard.FieldFeatureID) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.PlanRateCard.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(planratecard.FieldID) +// }), +// ). +// Exec(ctx) +func (u *PlanRateCardUpsertOne) UpdateNewValues() *PlanRateCardUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(planratecard.FieldID) + } + if _, exists := u.create.mutation.Namespace(); exists { + s.SetIgnore(planratecard.FieldNamespace) + } + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(planratecard.FieldCreatedAt) + } + if _, exists := u.create.mutation.Key(); exists { + s.SetIgnore(planratecard.FieldKey) + } + if _, exists := u.create.mutation.GetType(); exists { + s.SetIgnore(planratecard.FieldType) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.PlanRateCard.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *PlanRateCardUpsertOne) Ignore() *PlanRateCardUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *PlanRateCardUpsertOne) DoNothing() *PlanRateCardUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the PlanRateCardCreate.OnConflict +// documentation for more info. +func (u *PlanRateCardUpsertOne) Update(set func(*PlanRateCardUpsert)) *PlanRateCardUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&PlanRateCardUpsert{UpdateSet: update}) + })) + return u +} + +// SetMetadata sets the "metadata" field. +func (u *PlanRateCardUpsertOne) SetMetadata(v map[string]string) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetMetadata(v) + }) +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdateMetadata() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateMetadata() + }) +} + +// ClearMetadata clears the value of the "metadata" field. +func (u *PlanRateCardUpsertOne) ClearMetadata() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearMetadata() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *PlanRateCardUpsertOne) SetUpdatedAt(v time.Time) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdateUpdatedAt() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *PlanRateCardUpsertOne) SetDeletedAt(v time.Time) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdateDeletedAt() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *PlanRateCardUpsertOne) ClearDeletedAt() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearDeletedAt() + }) +} + +// SetName sets the "name" field. +func (u *PlanRateCardUpsertOne) SetName(v string) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdateName() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *PlanRateCardUpsertOne) SetDescription(v string) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdateDescription() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *PlanRateCardUpsertOne) ClearDescription() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearDescription() + }) +} + +// SetFeatureKey sets the "feature_key" field. +func (u *PlanRateCardUpsertOne) SetFeatureKey(v string) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetFeatureKey(v) + }) +} + +// UpdateFeatureKey sets the "feature_key" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdateFeatureKey() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateFeatureKey() + }) +} + +// ClearFeatureKey clears the value of the "feature_key" field. +func (u *PlanRateCardUpsertOne) ClearFeatureKey() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearFeatureKey() + }) +} + +// SetEntitlementTemplate sets the "entitlement_template" field. +func (u *PlanRateCardUpsertOne) SetEntitlementTemplate(v *plan.EntitlementTemplate) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetEntitlementTemplate(v) + }) +} + +// UpdateEntitlementTemplate sets the "entitlement_template" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdateEntitlementTemplate() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateEntitlementTemplate() + }) +} + +// ClearEntitlementTemplate clears the value of the "entitlement_template" field. +func (u *PlanRateCardUpsertOne) ClearEntitlementTemplate() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearEntitlementTemplate() + }) +} + +// SetTaxConfig sets the "tax_config" field. +func (u *PlanRateCardUpsertOne) SetTaxConfig(v *plan.TaxConfig) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetTaxConfig(v) + }) +} + +// UpdateTaxConfig sets the "tax_config" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdateTaxConfig() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateTaxConfig() + }) +} + +// ClearTaxConfig clears the value of the "tax_config" field. +func (u *PlanRateCardUpsertOne) ClearTaxConfig() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearTaxConfig() + }) +} + +// SetBillingCadence sets the "billing_cadence" field. +func (u *PlanRateCardUpsertOne) SetBillingCadence(v datex.ISOString) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetBillingCadence(v) + }) +} + +// UpdateBillingCadence sets the "billing_cadence" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdateBillingCadence() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateBillingCadence() + }) +} + +// ClearBillingCadence clears the value of the "billing_cadence" field. +func (u *PlanRateCardUpsertOne) ClearBillingCadence() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearBillingCadence() + }) +} + +// SetPrice sets the "price" field. +func (u *PlanRateCardUpsertOne) SetPrice(v *plan.Price) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetPrice(v) + }) +} + +// UpdatePrice sets the "price" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdatePrice() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdatePrice() + }) +} + +// ClearPrice clears the value of the "price" field. +func (u *PlanRateCardUpsertOne) ClearPrice() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearPrice() + }) +} + +// SetPhaseID sets the "phase_id" field. +func (u *PlanRateCardUpsertOne) SetPhaseID(v string) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetPhaseID(v) + }) +} + +// UpdatePhaseID sets the "phase_id" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdatePhaseID() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdatePhaseID() + }) +} + +// SetFeatureID sets the "feature_id" field. +func (u *PlanRateCardUpsertOne) SetFeatureID(v string) *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetFeatureID(v) + }) +} + +// UpdateFeatureID sets the "feature_id" field to the value that was provided on create. +func (u *PlanRateCardUpsertOne) UpdateFeatureID() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateFeatureID() + }) +} + +// ClearFeatureID clears the value of the "feature_id" field. +func (u *PlanRateCardUpsertOne) ClearFeatureID() *PlanRateCardUpsertOne { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearFeatureID() + }) +} + +// Exec executes the query. +func (u *PlanRateCardUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for PlanRateCardCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *PlanRateCardUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *PlanRateCardUpsertOne) ID(ctx context.Context) (id string, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("db: PlanRateCardUpsertOne.ID is not supported by MySQL driver. Use PlanRateCardUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *PlanRateCardUpsertOne) IDX(ctx context.Context) string { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// PlanRateCardCreateBulk is the builder for creating many PlanRateCard entities in bulk. +type PlanRateCardCreateBulk struct { + config + err error + builders []*PlanRateCardCreate + conflict []sql.ConflictOption +} + +// Save creates the PlanRateCard entities in the database. +func (prccb *PlanRateCardCreateBulk) Save(ctx context.Context) ([]*PlanRateCard, error) { + if prccb.err != nil { + return nil, prccb.err + } + specs := make([]*sqlgraph.CreateSpec, len(prccb.builders)) + nodes := make([]*PlanRateCard, len(prccb.builders)) + mutators := make([]Mutator, len(prccb.builders)) + for i := range prccb.builders { + func(i int, root context.Context) { + builder := prccb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PlanRateCardMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i], err = builder.createSpec() + if err != nil { + return nil, err + } + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, prccb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = prccb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, prccb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, prccb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (prccb *PlanRateCardCreateBulk) SaveX(ctx context.Context) []*PlanRateCard { + v, err := prccb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (prccb *PlanRateCardCreateBulk) Exec(ctx context.Context) error { + _, err := prccb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (prccb *PlanRateCardCreateBulk) ExecX(ctx context.Context) { + if err := prccb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.PlanRateCard.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.PlanRateCardUpsert) { +// SetNamespace(v+v). +// }). +// Exec(ctx) +func (prccb *PlanRateCardCreateBulk) OnConflict(opts ...sql.ConflictOption) *PlanRateCardUpsertBulk { + prccb.conflict = opts + return &PlanRateCardUpsertBulk{ + create: prccb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.PlanRateCard.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (prccb *PlanRateCardCreateBulk) OnConflictColumns(columns ...string) *PlanRateCardUpsertBulk { + prccb.conflict = append(prccb.conflict, sql.ConflictColumns(columns...)) + return &PlanRateCardUpsertBulk{ + create: prccb, + } +} + +// PlanRateCardUpsertBulk is the builder for "upsert"-ing +// a bulk of PlanRateCard nodes. +type PlanRateCardUpsertBulk struct { + create *PlanRateCardCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.PlanRateCard.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(planratecard.FieldID) +// }), +// ). +// Exec(ctx) +func (u *PlanRateCardUpsertBulk) UpdateNewValues() *PlanRateCardUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(planratecard.FieldID) + } + if _, exists := b.mutation.Namespace(); exists { + s.SetIgnore(planratecard.FieldNamespace) + } + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(planratecard.FieldCreatedAt) + } + if _, exists := b.mutation.Key(); exists { + s.SetIgnore(planratecard.FieldKey) + } + if _, exists := b.mutation.GetType(); exists { + s.SetIgnore(planratecard.FieldType) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.PlanRateCard.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *PlanRateCardUpsertBulk) Ignore() *PlanRateCardUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *PlanRateCardUpsertBulk) DoNothing() *PlanRateCardUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the PlanRateCardCreateBulk.OnConflict +// documentation for more info. +func (u *PlanRateCardUpsertBulk) Update(set func(*PlanRateCardUpsert)) *PlanRateCardUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&PlanRateCardUpsert{UpdateSet: update}) + })) + return u +} + +// SetMetadata sets the "metadata" field. +func (u *PlanRateCardUpsertBulk) SetMetadata(v map[string]string) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetMetadata(v) + }) +} + +// UpdateMetadata sets the "metadata" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdateMetadata() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateMetadata() + }) +} + +// ClearMetadata clears the value of the "metadata" field. +func (u *PlanRateCardUpsertBulk) ClearMetadata() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearMetadata() + }) +} + +// SetUpdatedAt sets the "updated_at" field. +func (u *PlanRateCardUpsertBulk) SetUpdatedAt(v time.Time) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdateUpdatedAt() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateUpdatedAt() + }) +} + +// SetDeletedAt sets the "deleted_at" field. +func (u *PlanRateCardUpsertBulk) SetDeletedAt(v time.Time) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetDeletedAt(v) + }) +} + +// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdateDeletedAt() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateDeletedAt() + }) +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (u *PlanRateCardUpsertBulk) ClearDeletedAt() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearDeletedAt() + }) +} + +// SetName sets the "name" field. +func (u *PlanRateCardUpsertBulk) SetName(v string) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdateName() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateName() + }) +} + +// SetDescription sets the "description" field. +func (u *PlanRateCardUpsertBulk) SetDescription(v string) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdateDescription() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *PlanRateCardUpsertBulk) ClearDescription() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearDescription() + }) +} + +// SetFeatureKey sets the "feature_key" field. +func (u *PlanRateCardUpsertBulk) SetFeatureKey(v string) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetFeatureKey(v) + }) +} + +// UpdateFeatureKey sets the "feature_key" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdateFeatureKey() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateFeatureKey() + }) +} + +// ClearFeatureKey clears the value of the "feature_key" field. +func (u *PlanRateCardUpsertBulk) ClearFeatureKey() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearFeatureKey() + }) +} + +// SetEntitlementTemplate sets the "entitlement_template" field. +func (u *PlanRateCardUpsertBulk) SetEntitlementTemplate(v *plan.EntitlementTemplate) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetEntitlementTemplate(v) + }) +} + +// UpdateEntitlementTemplate sets the "entitlement_template" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdateEntitlementTemplate() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateEntitlementTemplate() + }) +} + +// ClearEntitlementTemplate clears the value of the "entitlement_template" field. +func (u *PlanRateCardUpsertBulk) ClearEntitlementTemplate() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearEntitlementTemplate() + }) +} + +// SetTaxConfig sets the "tax_config" field. +func (u *PlanRateCardUpsertBulk) SetTaxConfig(v *plan.TaxConfig) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetTaxConfig(v) + }) +} + +// UpdateTaxConfig sets the "tax_config" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdateTaxConfig() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateTaxConfig() + }) +} + +// ClearTaxConfig clears the value of the "tax_config" field. +func (u *PlanRateCardUpsertBulk) ClearTaxConfig() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearTaxConfig() + }) +} + +// SetBillingCadence sets the "billing_cadence" field. +func (u *PlanRateCardUpsertBulk) SetBillingCadence(v datex.ISOString) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetBillingCadence(v) + }) +} + +// UpdateBillingCadence sets the "billing_cadence" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdateBillingCadence() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateBillingCadence() + }) +} + +// ClearBillingCadence clears the value of the "billing_cadence" field. +func (u *PlanRateCardUpsertBulk) ClearBillingCadence() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearBillingCadence() + }) +} + +// SetPrice sets the "price" field. +func (u *PlanRateCardUpsertBulk) SetPrice(v *plan.Price) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetPrice(v) + }) +} + +// UpdatePrice sets the "price" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdatePrice() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdatePrice() + }) +} + +// ClearPrice clears the value of the "price" field. +func (u *PlanRateCardUpsertBulk) ClearPrice() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearPrice() + }) +} + +// SetPhaseID sets the "phase_id" field. +func (u *PlanRateCardUpsertBulk) SetPhaseID(v string) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetPhaseID(v) + }) +} + +// UpdatePhaseID sets the "phase_id" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdatePhaseID() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdatePhaseID() + }) +} + +// SetFeatureID sets the "feature_id" field. +func (u *PlanRateCardUpsertBulk) SetFeatureID(v string) *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.SetFeatureID(v) + }) +} + +// UpdateFeatureID sets the "feature_id" field to the value that was provided on create. +func (u *PlanRateCardUpsertBulk) UpdateFeatureID() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.UpdateFeatureID() + }) +} + +// ClearFeatureID clears the value of the "feature_id" field. +func (u *PlanRateCardUpsertBulk) ClearFeatureID() *PlanRateCardUpsertBulk { + return u.Update(func(s *PlanRateCardUpsert) { + s.ClearFeatureID() + }) +} + +// Exec executes the query. +func (u *PlanRateCardUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("db: OnConflict was set for builder %d. Set it on the PlanRateCardCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("db: missing options for PlanRateCardCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *PlanRateCardUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/openmeter/ent/db/planratecard_delete.go b/openmeter/ent/db/planratecard_delete.go new file mode 100644 index 000000000..59daf1ced --- /dev/null +++ b/openmeter/ent/db/planratecard_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" +) + +// PlanRateCardDelete is the builder for deleting a PlanRateCard entity. +type PlanRateCardDelete struct { + config + hooks []Hook + mutation *PlanRateCardMutation +} + +// Where appends a list predicates to the PlanRateCardDelete builder. +func (prcd *PlanRateCardDelete) Where(ps ...predicate.PlanRateCard) *PlanRateCardDelete { + prcd.mutation.Where(ps...) + return prcd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (prcd *PlanRateCardDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, prcd.sqlExec, prcd.mutation, prcd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (prcd *PlanRateCardDelete) ExecX(ctx context.Context) int { + n, err := prcd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (prcd *PlanRateCardDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(planratecard.Table, sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString)) + if ps := prcd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, prcd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + prcd.mutation.done = true + return affected, err +} + +// PlanRateCardDeleteOne is the builder for deleting a single PlanRateCard entity. +type PlanRateCardDeleteOne struct { + prcd *PlanRateCardDelete +} + +// Where appends a list predicates to the PlanRateCardDelete builder. +func (prcdo *PlanRateCardDeleteOne) Where(ps ...predicate.PlanRateCard) *PlanRateCardDeleteOne { + prcdo.prcd.mutation.Where(ps...) + return prcdo +} + +// Exec executes the deletion query. +func (prcdo *PlanRateCardDeleteOne) Exec(ctx context.Context) error { + n, err := prcdo.prcd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{planratecard.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (prcdo *PlanRateCardDeleteOne) ExecX(ctx context.Context) { + if err := prcdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/openmeter/ent/db/planratecard_query.go b/openmeter/ent/db/planratecard_query.go new file mode 100644 index 000000000..0ee6a7a14 --- /dev/null +++ b/openmeter/ent/db/planratecard_query.go @@ -0,0 +1,721 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/openmeterio/openmeter/openmeter/ent/db/feature" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" +) + +// PlanRateCardQuery is the builder for querying PlanRateCard entities. +type PlanRateCardQuery struct { + config + ctx *QueryContext + order []planratecard.OrderOption + inters []Interceptor + predicates []predicate.PlanRateCard + withPhase *PlanPhaseQuery + withFeatures *FeatureQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PlanRateCardQuery builder. +func (prcq *PlanRateCardQuery) Where(ps ...predicate.PlanRateCard) *PlanRateCardQuery { + prcq.predicates = append(prcq.predicates, ps...) + return prcq +} + +// Limit the number of records to be returned by this query. +func (prcq *PlanRateCardQuery) Limit(limit int) *PlanRateCardQuery { + prcq.ctx.Limit = &limit + return prcq +} + +// Offset to start from. +func (prcq *PlanRateCardQuery) Offset(offset int) *PlanRateCardQuery { + prcq.ctx.Offset = &offset + return prcq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (prcq *PlanRateCardQuery) Unique(unique bool) *PlanRateCardQuery { + prcq.ctx.Unique = &unique + return prcq +} + +// Order specifies how the records should be ordered. +func (prcq *PlanRateCardQuery) Order(o ...planratecard.OrderOption) *PlanRateCardQuery { + prcq.order = append(prcq.order, o...) + return prcq +} + +// QueryPhase chains the current query on the "phase" edge. +func (prcq *PlanRateCardQuery) QueryPhase() *PlanPhaseQuery { + query := (&PlanPhaseClient{config: prcq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := prcq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := prcq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(planratecard.Table, planratecard.FieldID, selector), + sqlgraph.To(planphase.Table, planphase.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, planratecard.PhaseTable, planratecard.PhaseColumn), + ) + fromU = sqlgraph.SetNeighbors(prcq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryFeatures chains the current query on the "features" edge. +func (prcq *PlanRateCardQuery) QueryFeatures() *FeatureQuery { + query := (&FeatureClient{config: prcq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := prcq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := prcq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(planratecard.Table, planratecard.FieldID, selector), + sqlgraph.To(feature.Table, feature.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, planratecard.FeaturesTable, planratecard.FeaturesColumn), + ) + fromU = sqlgraph.SetNeighbors(prcq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first PlanRateCard entity from the query. +// Returns a *NotFoundError when no PlanRateCard was found. +func (prcq *PlanRateCardQuery) First(ctx context.Context) (*PlanRateCard, error) { + nodes, err := prcq.Limit(1).All(setContextOp(ctx, prcq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{planratecard.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (prcq *PlanRateCardQuery) FirstX(ctx context.Context) *PlanRateCard { + node, err := prcq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first PlanRateCard ID from the query. +// Returns a *NotFoundError when no PlanRateCard ID was found. +func (prcq *PlanRateCardQuery) FirstID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = prcq.Limit(1).IDs(setContextOp(ctx, prcq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{planratecard.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (prcq *PlanRateCardQuery) FirstIDX(ctx context.Context) string { + id, err := prcq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single PlanRateCard entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one PlanRateCard entity is found. +// Returns a *NotFoundError when no PlanRateCard entities are found. +func (prcq *PlanRateCardQuery) Only(ctx context.Context) (*PlanRateCard, error) { + nodes, err := prcq.Limit(2).All(setContextOp(ctx, prcq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{planratecard.Label} + default: + return nil, &NotSingularError{planratecard.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (prcq *PlanRateCardQuery) OnlyX(ctx context.Context) *PlanRateCard { + node, err := prcq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only PlanRateCard ID in the query. +// Returns a *NotSingularError when more than one PlanRateCard ID is found. +// Returns a *NotFoundError when no entities are found. +func (prcq *PlanRateCardQuery) OnlyID(ctx context.Context) (id string, err error) { + var ids []string + if ids, err = prcq.Limit(2).IDs(setContextOp(ctx, prcq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{planratecard.Label} + default: + err = &NotSingularError{planratecard.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (prcq *PlanRateCardQuery) OnlyIDX(ctx context.Context) string { + id, err := prcq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of PlanRateCards. +func (prcq *PlanRateCardQuery) All(ctx context.Context) ([]*PlanRateCard, error) { + ctx = setContextOp(ctx, prcq.ctx, ent.OpQueryAll) + if err := prcq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*PlanRateCard, *PlanRateCardQuery]() + return withInterceptors[[]*PlanRateCard](ctx, prcq, qr, prcq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (prcq *PlanRateCardQuery) AllX(ctx context.Context) []*PlanRateCard { + nodes, err := prcq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of PlanRateCard IDs. +func (prcq *PlanRateCardQuery) IDs(ctx context.Context) (ids []string, err error) { + if prcq.ctx.Unique == nil && prcq.path != nil { + prcq.Unique(true) + } + ctx = setContextOp(ctx, prcq.ctx, ent.OpQueryIDs) + if err = prcq.Select(planratecard.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (prcq *PlanRateCardQuery) IDsX(ctx context.Context) []string { + ids, err := prcq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (prcq *PlanRateCardQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, prcq.ctx, ent.OpQueryCount) + if err := prcq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, prcq, querierCount[*PlanRateCardQuery](), prcq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (prcq *PlanRateCardQuery) CountX(ctx context.Context) int { + count, err := prcq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (prcq *PlanRateCardQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, prcq.ctx, ent.OpQueryExist) + switch _, err := prcq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("db: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (prcq *PlanRateCardQuery) ExistX(ctx context.Context) bool { + exist, err := prcq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PlanRateCardQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (prcq *PlanRateCardQuery) Clone() *PlanRateCardQuery { + if prcq == nil { + return nil + } + return &PlanRateCardQuery{ + config: prcq.config, + ctx: prcq.ctx.Clone(), + order: append([]planratecard.OrderOption{}, prcq.order...), + inters: append([]Interceptor{}, prcq.inters...), + predicates: append([]predicate.PlanRateCard{}, prcq.predicates...), + withPhase: prcq.withPhase.Clone(), + withFeatures: prcq.withFeatures.Clone(), + // clone intermediate query. + sql: prcq.sql.Clone(), + path: prcq.path, + } +} + +// WithPhase tells the query-builder to eager-load the nodes that are connected to +// the "phase" edge. The optional arguments are used to configure the query builder of the edge. +func (prcq *PlanRateCardQuery) WithPhase(opts ...func(*PlanPhaseQuery)) *PlanRateCardQuery { + query := (&PlanPhaseClient{config: prcq.config}).Query() + for _, opt := range opts { + opt(query) + } + prcq.withPhase = query + return prcq +} + +// WithFeatures tells the query-builder to eager-load the nodes that are connected to +// the "features" edge. The optional arguments are used to configure the query builder of the edge. +func (prcq *PlanRateCardQuery) WithFeatures(opts ...func(*FeatureQuery)) *PlanRateCardQuery { + query := (&FeatureClient{config: prcq.config}).Query() + for _, opt := range opts { + opt(query) + } + prcq.withFeatures = query + return prcq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Namespace string `json:"namespace,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.PlanRateCard.Query(). +// GroupBy(planratecard.FieldNamespace). +// Aggregate(db.Count()). +// Scan(ctx, &v) +func (prcq *PlanRateCardQuery) GroupBy(field string, fields ...string) *PlanRateCardGroupBy { + prcq.ctx.Fields = append([]string{field}, fields...) + grbuild := &PlanRateCardGroupBy{build: prcq} + grbuild.flds = &prcq.ctx.Fields + grbuild.label = planratecard.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Namespace string `json:"namespace,omitempty"` +// } +// +// client.PlanRateCard.Query(). +// Select(planratecard.FieldNamespace). +// Scan(ctx, &v) +func (prcq *PlanRateCardQuery) Select(fields ...string) *PlanRateCardSelect { + prcq.ctx.Fields = append(prcq.ctx.Fields, fields...) + sbuild := &PlanRateCardSelect{PlanRateCardQuery: prcq} + sbuild.label = planratecard.Label + sbuild.flds, sbuild.scan = &prcq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PlanRateCardSelect configured with the given aggregations. +func (prcq *PlanRateCardQuery) Aggregate(fns ...AggregateFunc) *PlanRateCardSelect { + return prcq.Select().Aggregate(fns...) +} + +func (prcq *PlanRateCardQuery) prepareQuery(ctx context.Context) error { + for _, inter := range prcq.inters { + if inter == nil { + return fmt.Errorf("db: uninitialized interceptor (forgotten import db/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, prcq); err != nil { + return err + } + } + } + for _, f := range prcq.ctx.Fields { + if !planratecard.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + } + if prcq.path != nil { + prev, err := prcq.path(ctx) + if err != nil { + return err + } + prcq.sql = prev + } + return nil +} + +func (prcq *PlanRateCardQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PlanRateCard, error) { + var ( + nodes = []*PlanRateCard{} + _spec = prcq.querySpec() + loadedTypes = [2]bool{ + prcq.withPhase != nil, + prcq.withFeatures != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*PlanRateCard).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &PlanRateCard{config: prcq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(prcq.modifiers) > 0 { + _spec.Modifiers = prcq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, prcq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := prcq.withPhase; query != nil { + if err := prcq.loadPhase(ctx, query, nodes, nil, + func(n *PlanRateCard, e *PlanPhase) { n.Edges.Phase = e }); err != nil { + return nil, err + } + } + if query := prcq.withFeatures; query != nil { + if err := prcq.loadFeatures(ctx, query, nodes, nil, + func(n *PlanRateCard, e *Feature) { n.Edges.Features = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (prcq *PlanRateCardQuery) loadPhase(ctx context.Context, query *PlanPhaseQuery, nodes []*PlanRateCard, init func(*PlanRateCard), assign func(*PlanRateCard, *PlanPhase)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*PlanRateCard) + for i := range nodes { + fk := nodes[i].PhaseID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(planphase.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "phase_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (prcq *PlanRateCardQuery) loadFeatures(ctx context.Context, query *FeatureQuery, nodes []*PlanRateCard, init func(*PlanRateCard), assign func(*PlanRateCard, *Feature)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*PlanRateCard) + for i := range nodes { + if nodes[i].FeatureID == nil { + continue + } + fk := *nodes[i].FeatureID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(feature.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "feature_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (prcq *PlanRateCardQuery) sqlCount(ctx context.Context) (int, error) { + _spec := prcq.querySpec() + if len(prcq.modifiers) > 0 { + _spec.Modifiers = prcq.modifiers + } + _spec.Node.Columns = prcq.ctx.Fields + if len(prcq.ctx.Fields) > 0 { + _spec.Unique = prcq.ctx.Unique != nil && *prcq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, prcq.driver, _spec) +} + +func (prcq *PlanRateCardQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(planratecard.Table, planratecard.Columns, sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString)) + _spec.From = prcq.sql + if unique := prcq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if prcq.path != nil { + _spec.Unique = true + } + if fields := prcq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, planratecard.FieldID) + for i := range fields { + if fields[i] != planratecard.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if prcq.withPhase != nil { + _spec.Node.AddColumnOnce(planratecard.FieldPhaseID) + } + if prcq.withFeatures != nil { + _spec.Node.AddColumnOnce(planratecard.FieldFeatureID) + } + } + if ps := prcq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := prcq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := prcq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := prcq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (prcq *PlanRateCardQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(prcq.driver.Dialect()) + t1 := builder.Table(planratecard.Table) + columns := prcq.ctx.Fields + if len(columns) == 0 { + columns = planratecard.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if prcq.sql != nil { + selector = prcq.sql + selector.Select(selector.Columns(columns...)...) + } + if prcq.ctx.Unique != nil && *prcq.ctx.Unique { + selector.Distinct() + } + for _, m := range prcq.modifiers { + m(selector) + } + for _, p := range prcq.predicates { + p(selector) + } + for _, p := range prcq.order { + p(selector) + } + if offset := prcq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := prcq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (prcq *PlanRateCardQuery) ForUpdate(opts ...sql.LockOption) *PlanRateCardQuery { + if prcq.driver.Dialect() == dialect.Postgres { + prcq.Unique(false) + } + prcq.modifiers = append(prcq.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return prcq +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (prcq *PlanRateCardQuery) ForShare(opts ...sql.LockOption) *PlanRateCardQuery { + if prcq.driver.Dialect() == dialect.Postgres { + prcq.Unique(false) + } + prcq.modifiers = append(prcq.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return prcq +} + +// PlanRateCardGroupBy is the group-by builder for PlanRateCard entities. +type PlanRateCardGroupBy struct { + selector + build *PlanRateCardQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (prcgb *PlanRateCardGroupBy) Aggregate(fns ...AggregateFunc) *PlanRateCardGroupBy { + prcgb.fns = append(prcgb.fns, fns...) + return prcgb +} + +// Scan applies the selector query and scans the result into the given value. +func (prcgb *PlanRateCardGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, prcgb.build.ctx, ent.OpQueryGroupBy) + if err := prcgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PlanRateCardQuery, *PlanRateCardGroupBy](ctx, prcgb.build, prcgb, prcgb.build.inters, v) +} + +func (prcgb *PlanRateCardGroupBy) sqlScan(ctx context.Context, root *PlanRateCardQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(prcgb.fns)) + for _, fn := range prcgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*prcgb.flds)+len(prcgb.fns)) + for _, f := range *prcgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*prcgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := prcgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// PlanRateCardSelect is the builder for selecting fields of PlanRateCard entities. +type PlanRateCardSelect struct { + *PlanRateCardQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (prcs *PlanRateCardSelect) Aggregate(fns ...AggregateFunc) *PlanRateCardSelect { + prcs.fns = append(prcs.fns, fns...) + return prcs +} + +// Scan applies the selector query and scans the result into the given value. +func (prcs *PlanRateCardSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, prcs.ctx, ent.OpQuerySelect) + if err := prcs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PlanRateCardQuery, *PlanRateCardSelect](ctx, prcs.PlanRateCardQuery, prcs, prcs.inters, v) +} + +func (prcs *PlanRateCardSelect) sqlScan(ctx context.Context, root *PlanRateCardQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(prcs.fns)) + for _, fn := range prcs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*prcs.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := prcs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/openmeter/ent/db/planratecard_update.go b/openmeter/ent/db/planratecard_update.go new file mode 100644 index 000000000..978729283 --- /dev/null +++ b/openmeter/ent/db/planratecard_update.go @@ -0,0 +1,944 @@ +// Code generated by ent, DO NOT EDIT. + +package db + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/openmeterio/openmeter/openmeter/ent/db/feature" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" + "github.com/openmeterio/openmeter/openmeter/ent/db/predicate" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" + "github.com/openmeterio/openmeter/pkg/datex" +) + +// PlanRateCardUpdate is the builder for updating PlanRateCard entities. +type PlanRateCardUpdate struct { + config + hooks []Hook + mutation *PlanRateCardMutation +} + +// Where appends a list predicates to the PlanRateCardUpdate builder. +func (prcu *PlanRateCardUpdate) Where(ps ...predicate.PlanRateCard) *PlanRateCardUpdate { + prcu.mutation.Where(ps...) + return prcu +} + +// SetMetadata sets the "metadata" field. +func (prcu *PlanRateCardUpdate) SetMetadata(m map[string]string) *PlanRateCardUpdate { + prcu.mutation.SetMetadata(m) + return prcu +} + +// ClearMetadata clears the value of the "metadata" field. +func (prcu *PlanRateCardUpdate) ClearMetadata() *PlanRateCardUpdate { + prcu.mutation.ClearMetadata() + return prcu +} + +// SetUpdatedAt sets the "updated_at" field. +func (prcu *PlanRateCardUpdate) SetUpdatedAt(t time.Time) *PlanRateCardUpdate { + prcu.mutation.SetUpdatedAt(t) + return prcu +} + +// SetDeletedAt sets the "deleted_at" field. +func (prcu *PlanRateCardUpdate) SetDeletedAt(t time.Time) *PlanRateCardUpdate { + prcu.mutation.SetDeletedAt(t) + return prcu +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (prcu *PlanRateCardUpdate) SetNillableDeletedAt(t *time.Time) *PlanRateCardUpdate { + if t != nil { + prcu.SetDeletedAt(*t) + } + return prcu +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (prcu *PlanRateCardUpdate) ClearDeletedAt() *PlanRateCardUpdate { + prcu.mutation.ClearDeletedAt() + return prcu +} + +// SetName sets the "name" field. +func (prcu *PlanRateCardUpdate) SetName(s string) *PlanRateCardUpdate { + prcu.mutation.SetName(s) + return prcu +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (prcu *PlanRateCardUpdate) SetNillableName(s *string) *PlanRateCardUpdate { + if s != nil { + prcu.SetName(*s) + } + return prcu +} + +// SetDescription sets the "description" field. +func (prcu *PlanRateCardUpdate) SetDescription(s string) *PlanRateCardUpdate { + prcu.mutation.SetDescription(s) + return prcu +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (prcu *PlanRateCardUpdate) SetNillableDescription(s *string) *PlanRateCardUpdate { + if s != nil { + prcu.SetDescription(*s) + } + return prcu +} + +// ClearDescription clears the value of the "description" field. +func (prcu *PlanRateCardUpdate) ClearDescription() *PlanRateCardUpdate { + prcu.mutation.ClearDescription() + return prcu +} + +// SetFeatureKey sets the "feature_key" field. +func (prcu *PlanRateCardUpdate) SetFeatureKey(s string) *PlanRateCardUpdate { + prcu.mutation.SetFeatureKey(s) + return prcu +} + +// SetNillableFeatureKey sets the "feature_key" field if the given value is not nil. +func (prcu *PlanRateCardUpdate) SetNillableFeatureKey(s *string) *PlanRateCardUpdate { + if s != nil { + prcu.SetFeatureKey(*s) + } + return prcu +} + +// ClearFeatureKey clears the value of the "feature_key" field. +func (prcu *PlanRateCardUpdate) ClearFeatureKey() *PlanRateCardUpdate { + prcu.mutation.ClearFeatureKey() + return prcu +} + +// SetEntitlementTemplate sets the "entitlement_template" field. +func (prcu *PlanRateCardUpdate) SetEntitlementTemplate(pt *plan.EntitlementTemplate) *PlanRateCardUpdate { + prcu.mutation.SetEntitlementTemplate(pt) + return prcu +} + +// ClearEntitlementTemplate clears the value of the "entitlement_template" field. +func (prcu *PlanRateCardUpdate) ClearEntitlementTemplate() *PlanRateCardUpdate { + prcu.mutation.ClearEntitlementTemplate() + return prcu +} + +// SetTaxConfig sets the "tax_config" field. +func (prcu *PlanRateCardUpdate) SetTaxConfig(pc *plan.TaxConfig) *PlanRateCardUpdate { + prcu.mutation.SetTaxConfig(pc) + return prcu +} + +// ClearTaxConfig clears the value of the "tax_config" field. +func (prcu *PlanRateCardUpdate) ClearTaxConfig() *PlanRateCardUpdate { + prcu.mutation.ClearTaxConfig() + return prcu +} + +// SetBillingCadence sets the "billing_cadence" field. +func (prcu *PlanRateCardUpdate) SetBillingCadence(ds datex.ISOString) *PlanRateCardUpdate { + prcu.mutation.SetBillingCadence(ds) + return prcu +} + +// SetNillableBillingCadence sets the "billing_cadence" field if the given value is not nil. +func (prcu *PlanRateCardUpdate) SetNillableBillingCadence(ds *datex.ISOString) *PlanRateCardUpdate { + if ds != nil { + prcu.SetBillingCadence(*ds) + } + return prcu +} + +// ClearBillingCadence clears the value of the "billing_cadence" field. +func (prcu *PlanRateCardUpdate) ClearBillingCadence() *PlanRateCardUpdate { + prcu.mutation.ClearBillingCadence() + return prcu +} + +// SetPrice sets the "price" field. +func (prcu *PlanRateCardUpdate) SetPrice(pl *plan.Price) *PlanRateCardUpdate { + prcu.mutation.SetPrice(pl) + return prcu +} + +// ClearPrice clears the value of the "price" field. +func (prcu *PlanRateCardUpdate) ClearPrice() *PlanRateCardUpdate { + prcu.mutation.ClearPrice() + return prcu +} + +// SetPhaseID sets the "phase_id" field. +func (prcu *PlanRateCardUpdate) SetPhaseID(s string) *PlanRateCardUpdate { + prcu.mutation.SetPhaseID(s) + return prcu +} + +// SetNillablePhaseID sets the "phase_id" field if the given value is not nil. +func (prcu *PlanRateCardUpdate) SetNillablePhaseID(s *string) *PlanRateCardUpdate { + if s != nil { + prcu.SetPhaseID(*s) + } + return prcu +} + +// SetFeatureID sets the "feature_id" field. +func (prcu *PlanRateCardUpdate) SetFeatureID(s string) *PlanRateCardUpdate { + prcu.mutation.SetFeatureID(s) + return prcu +} + +// SetNillableFeatureID sets the "feature_id" field if the given value is not nil. +func (prcu *PlanRateCardUpdate) SetNillableFeatureID(s *string) *PlanRateCardUpdate { + if s != nil { + prcu.SetFeatureID(*s) + } + return prcu +} + +// ClearFeatureID clears the value of the "feature_id" field. +func (prcu *PlanRateCardUpdate) ClearFeatureID() *PlanRateCardUpdate { + prcu.mutation.ClearFeatureID() + return prcu +} + +// SetPhase sets the "phase" edge to the PlanPhase entity. +func (prcu *PlanRateCardUpdate) SetPhase(p *PlanPhase) *PlanRateCardUpdate { + return prcu.SetPhaseID(p.ID) +} + +// SetFeaturesID sets the "features" edge to the Feature entity by ID. +func (prcu *PlanRateCardUpdate) SetFeaturesID(id string) *PlanRateCardUpdate { + prcu.mutation.SetFeaturesID(id) + return prcu +} + +// SetNillableFeaturesID sets the "features" edge to the Feature entity by ID if the given value is not nil. +func (prcu *PlanRateCardUpdate) SetNillableFeaturesID(id *string) *PlanRateCardUpdate { + if id != nil { + prcu = prcu.SetFeaturesID(*id) + } + return prcu +} + +// SetFeatures sets the "features" edge to the Feature entity. +func (prcu *PlanRateCardUpdate) SetFeatures(f *Feature) *PlanRateCardUpdate { + return prcu.SetFeaturesID(f.ID) +} + +// Mutation returns the PlanRateCardMutation object of the builder. +func (prcu *PlanRateCardUpdate) Mutation() *PlanRateCardMutation { + return prcu.mutation +} + +// ClearPhase clears the "phase" edge to the PlanPhase entity. +func (prcu *PlanRateCardUpdate) ClearPhase() *PlanRateCardUpdate { + prcu.mutation.ClearPhase() + return prcu +} + +// ClearFeatures clears the "features" edge to the Feature entity. +func (prcu *PlanRateCardUpdate) ClearFeatures() *PlanRateCardUpdate { + prcu.mutation.ClearFeatures() + return prcu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (prcu *PlanRateCardUpdate) Save(ctx context.Context) (int, error) { + prcu.defaults() + return withHooks(ctx, prcu.sqlSave, prcu.mutation, prcu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (prcu *PlanRateCardUpdate) SaveX(ctx context.Context) int { + affected, err := prcu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (prcu *PlanRateCardUpdate) Exec(ctx context.Context) error { + _, err := prcu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (prcu *PlanRateCardUpdate) ExecX(ctx context.Context) { + if err := prcu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (prcu *PlanRateCardUpdate) defaults() { + if _, ok := prcu.mutation.UpdatedAt(); !ok { + v := planratecard.UpdateDefaultUpdatedAt() + prcu.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (prcu *PlanRateCardUpdate) check() error { + if v, ok := prcu.mutation.EntitlementTemplate(); ok { + if err := v.Validate(); err != nil { + return &ValidationError{Name: "entitlement_template", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.entitlement_template": %w`, err)} + } + } + if v, ok := prcu.mutation.TaxConfig(); ok { + if err := v.Validate(); err != nil { + return &ValidationError{Name: "tax_config", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.tax_config": %w`, err)} + } + } + if v, ok := prcu.mutation.Price(); ok { + if err := v.Validate(); err != nil { + return &ValidationError{Name: "price", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.price": %w`, err)} + } + } + if v, ok := prcu.mutation.PhaseID(); ok { + if err := planratecard.PhaseIDValidator(v); err != nil { + return &ValidationError{Name: "phase_id", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.phase_id": %w`, err)} + } + } + if prcu.mutation.PhaseCleared() && len(prcu.mutation.PhaseIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "PlanRateCard.phase"`) + } + return nil +} + +func (prcu *PlanRateCardUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := prcu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(planratecard.Table, planratecard.Columns, sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString)) + if ps := prcu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := prcu.mutation.Metadata(); ok { + _spec.SetField(planratecard.FieldMetadata, field.TypeJSON, value) + } + if prcu.mutation.MetadataCleared() { + _spec.ClearField(planratecard.FieldMetadata, field.TypeJSON) + } + if value, ok := prcu.mutation.UpdatedAt(); ok { + _spec.SetField(planratecard.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := prcu.mutation.DeletedAt(); ok { + _spec.SetField(planratecard.FieldDeletedAt, field.TypeTime, value) + } + if prcu.mutation.DeletedAtCleared() { + _spec.ClearField(planratecard.FieldDeletedAt, field.TypeTime) + } + if value, ok := prcu.mutation.Name(); ok { + _spec.SetField(planratecard.FieldName, field.TypeString, value) + } + if value, ok := prcu.mutation.Description(); ok { + _spec.SetField(planratecard.FieldDescription, field.TypeString, value) + } + if prcu.mutation.DescriptionCleared() { + _spec.ClearField(planratecard.FieldDescription, field.TypeString) + } + if value, ok := prcu.mutation.FeatureKey(); ok { + _spec.SetField(planratecard.FieldFeatureKey, field.TypeString, value) + } + if prcu.mutation.FeatureKeyCleared() { + _spec.ClearField(planratecard.FieldFeatureKey, field.TypeString) + } + if value, ok := prcu.mutation.EntitlementTemplate(); ok { + vv, err := planratecard.ValueScanner.EntitlementTemplate.Value(value) + if err != nil { + return 0, err + } + _spec.SetField(planratecard.FieldEntitlementTemplate, field.TypeString, vv) + } + if prcu.mutation.EntitlementTemplateCleared() { + _spec.ClearField(planratecard.FieldEntitlementTemplate, field.TypeString) + } + if value, ok := prcu.mutation.TaxConfig(); ok { + vv, err := planratecard.ValueScanner.TaxConfig.Value(value) + if err != nil { + return 0, err + } + _spec.SetField(planratecard.FieldTaxConfig, field.TypeString, vv) + } + if prcu.mutation.TaxConfigCleared() { + _spec.ClearField(planratecard.FieldTaxConfig, field.TypeString) + } + if value, ok := prcu.mutation.BillingCadence(); ok { + _spec.SetField(planratecard.FieldBillingCadence, field.TypeString, value) + } + if prcu.mutation.BillingCadenceCleared() { + _spec.ClearField(planratecard.FieldBillingCadence, field.TypeString) + } + if value, ok := prcu.mutation.Price(); ok { + vv, err := planratecard.ValueScanner.Price.Value(value) + if err != nil { + return 0, err + } + _spec.SetField(planratecard.FieldPrice, field.TypeString, vv) + } + if prcu.mutation.PriceCleared() { + _spec.ClearField(planratecard.FieldPrice, field.TypeString) + } + if prcu.mutation.PhaseCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planratecard.PhaseTable, + Columns: []string{planratecard.PhaseColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := prcu.mutation.PhaseIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planratecard.PhaseTable, + Columns: []string{planratecard.PhaseColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if prcu.mutation.FeaturesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planratecard.FeaturesTable, + Columns: []string{planratecard.FeaturesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(feature.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := prcu.mutation.FeaturesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planratecard.FeaturesTable, + Columns: []string{planratecard.FeaturesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(feature.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, prcu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{planratecard.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + prcu.mutation.done = true + return n, nil +} + +// PlanRateCardUpdateOne is the builder for updating a single PlanRateCard entity. +type PlanRateCardUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PlanRateCardMutation +} + +// SetMetadata sets the "metadata" field. +func (prcuo *PlanRateCardUpdateOne) SetMetadata(m map[string]string) *PlanRateCardUpdateOne { + prcuo.mutation.SetMetadata(m) + return prcuo +} + +// ClearMetadata clears the value of the "metadata" field. +func (prcuo *PlanRateCardUpdateOne) ClearMetadata() *PlanRateCardUpdateOne { + prcuo.mutation.ClearMetadata() + return prcuo +} + +// SetUpdatedAt sets the "updated_at" field. +func (prcuo *PlanRateCardUpdateOne) SetUpdatedAt(t time.Time) *PlanRateCardUpdateOne { + prcuo.mutation.SetUpdatedAt(t) + return prcuo +} + +// SetDeletedAt sets the "deleted_at" field. +func (prcuo *PlanRateCardUpdateOne) SetDeletedAt(t time.Time) *PlanRateCardUpdateOne { + prcuo.mutation.SetDeletedAt(t) + return prcuo +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (prcuo *PlanRateCardUpdateOne) SetNillableDeletedAt(t *time.Time) *PlanRateCardUpdateOne { + if t != nil { + prcuo.SetDeletedAt(*t) + } + return prcuo +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (prcuo *PlanRateCardUpdateOne) ClearDeletedAt() *PlanRateCardUpdateOne { + prcuo.mutation.ClearDeletedAt() + return prcuo +} + +// SetName sets the "name" field. +func (prcuo *PlanRateCardUpdateOne) SetName(s string) *PlanRateCardUpdateOne { + prcuo.mutation.SetName(s) + return prcuo +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (prcuo *PlanRateCardUpdateOne) SetNillableName(s *string) *PlanRateCardUpdateOne { + if s != nil { + prcuo.SetName(*s) + } + return prcuo +} + +// SetDescription sets the "description" field. +func (prcuo *PlanRateCardUpdateOne) SetDescription(s string) *PlanRateCardUpdateOne { + prcuo.mutation.SetDescription(s) + return prcuo +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (prcuo *PlanRateCardUpdateOne) SetNillableDescription(s *string) *PlanRateCardUpdateOne { + if s != nil { + prcuo.SetDescription(*s) + } + return prcuo +} + +// ClearDescription clears the value of the "description" field. +func (prcuo *PlanRateCardUpdateOne) ClearDescription() *PlanRateCardUpdateOne { + prcuo.mutation.ClearDescription() + return prcuo +} + +// SetFeatureKey sets the "feature_key" field. +func (prcuo *PlanRateCardUpdateOne) SetFeatureKey(s string) *PlanRateCardUpdateOne { + prcuo.mutation.SetFeatureKey(s) + return prcuo +} + +// SetNillableFeatureKey sets the "feature_key" field if the given value is not nil. +func (prcuo *PlanRateCardUpdateOne) SetNillableFeatureKey(s *string) *PlanRateCardUpdateOne { + if s != nil { + prcuo.SetFeatureKey(*s) + } + return prcuo +} + +// ClearFeatureKey clears the value of the "feature_key" field. +func (prcuo *PlanRateCardUpdateOne) ClearFeatureKey() *PlanRateCardUpdateOne { + prcuo.mutation.ClearFeatureKey() + return prcuo +} + +// SetEntitlementTemplate sets the "entitlement_template" field. +func (prcuo *PlanRateCardUpdateOne) SetEntitlementTemplate(pt *plan.EntitlementTemplate) *PlanRateCardUpdateOne { + prcuo.mutation.SetEntitlementTemplate(pt) + return prcuo +} + +// ClearEntitlementTemplate clears the value of the "entitlement_template" field. +func (prcuo *PlanRateCardUpdateOne) ClearEntitlementTemplate() *PlanRateCardUpdateOne { + prcuo.mutation.ClearEntitlementTemplate() + return prcuo +} + +// SetTaxConfig sets the "tax_config" field. +func (prcuo *PlanRateCardUpdateOne) SetTaxConfig(pc *plan.TaxConfig) *PlanRateCardUpdateOne { + prcuo.mutation.SetTaxConfig(pc) + return prcuo +} + +// ClearTaxConfig clears the value of the "tax_config" field. +func (prcuo *PlanRateCardUpdateOne) ClearTaxConfig() *PlanRateCardUpdateOne { + prcuo.mutation.ClearTaxConfig() + return prcuo +} + +// SetBillingCadence sets the "billing_cadence" field. +func (prcuo *PlanRateCardUpdateOne) SetBillingCadence(ds datex.ISOString) *PlanRateCardUpdateOne { + prcuo.mutation.SetBillingCadence(ds) + return prcuo +} + +// SetNillableBillingCadence sets the "billing_cadence" field if the given value is not nil. +func (prcuo *PlanRateCardUpdateOne) SetNillableBillingCadence(ds *datex.ISOString) *PlanRateCardUpdateOne { + if ds != nil { + prcuo.SetBillingCadence(*ds) + } + return prcuo +} + +// ClearBillingCadence clears the value of the "billing_cadence" field. +func (prcuo *PlanRateCardUpdateOne) ClearBillingCadence() *PlanRateCardUpdateOne { + prcuo.mutation.ClearBillingCadence() + return prcuo +} + +// SetPrice sets the "price" field. +func (prcuo *PlanRateCardUpdateOne) SetPrice(pl *plan.Price) *PlanRateCardUpdateOne { + prcuo.mutation.SetPrice(pl) + return prcuo +} + +// ClearPrice clears the value of the "price" field. +func (prcuo *PlanRateCardUpdateOne) ClearPrice() *PlanRateCardUpdateOne { + prcuo.mutation.ClearPrice() + return prcuo +} + +// SetPhaseID sets the "phase_id" field. +func (prcuo *PlanRateCardUpdateOne) SetPhaseID(s string) *PlanRateCardUpdateOne { + prcuo.mutation.SetPhaseID(s) + return prcuo +} + +// SetNillablePhaseID sets the "phase_id" field if the given value is not nil. +func (prcuo *PlanRateCardUpdateOne) SetNillablePhaseID(s *string) *PlanRateCardUpdateOne { + if s != nil { + prcuo.SetPhaseID(*s) + } + return prcuo +} + +// SetFeatureID sets the "feature_id" field. +func (prcuo *PlanRateCardUpdateOne) SetFeatureID(s string) *PlanRateCardUpdateOne { + prcuo.mutation.SetFeatureID(s) + return prcuo +} + +// SetNillableFeatureID sets the "feature_id" field if the given value is not nil. +func (prcuo *PlanRateCardUpdateOne) SetNillableFeatureID(s *string) *PlanRateCardUpdateOne { + if s != nil { + prcuo.SetFeatureID(*s) + } + return prcuo +} + +// ClearFeatureID clears the value of the "feature_id" field. +func (prcuo *PlanRateCardUpdateOne) ClearFeatureID() *PlanRateCardUpdateOne { + prcuo.mutation.ClearFeatureID() + return prcuo +} + +// SetPhase sets the "phase" edge to the PlanPhase entity. +func (prcuo *PlanRateCardUpdateOne) SetPhase(p *PlanPhase) *PlanRateCardUpdateOne { + return prcuo.SetPhaseID(p.ID) +} + +// SetFeaturesID sets the "features" edge to the Feature entity by ID. +func (prcuo *PlanRateCardUpdateOne) SetFeaturesID(id string) *PlanRateCardUpdateOne { + prcuo.mutation.SetFeaturesID(id) + return prcuo +} + +// SetNillableFeaturesID sets the "features" edge to the Feature entity by ID if the given value is not nil. +func (prcuo *PlanRateCardUpdateOne) SetNillableFeaturesID(id *string) *PlanRateCardUpdateOne { + if id != nil { + prcuo = prcuo.SetFeaturesID(*id) + } + return prcuo +} + +// SetFeatures sets the "features" edge to the Feature entity. +func (prcuo *PlanRateCardUpdateOne) SetFeatures(f *Feature) *PlanRateCardUpdateOne { + return prcuo.SetFeaturesID(f.ID) +} + +// Mutation returns the PlanRateCardMutation object of the builder. +func (prcuo *PlanRateCardUpdateOne) Mutation() *PlanRateCardMutation { + return prcuo.mutation +} + +// ClearPhase clears the "phase" edge to the PlanPhase entity. +func (prcuo *PlanRateCardUpdateOne) ClearPhase() *PlanRateCardUpdateOne { + prcuo.mutation.ClearPhase() + return prcuo +} + +// ClearFeatures clears the "features" edge to the Feature entity. +func (prcuo *PlanRateCardUpdateOne) ClearFeatures() *PlanRateCardUpdateOne { + prcuo.mutation.ClearFeatures() + return prcuo +} + +// Where appends a list predicates to the PlanRateCardUpdate builder. +func (prcuo *PlanRateCardUpdateOne) Where(ps ...predicate.PlanRateCard) *PlanRateCardUpdateOne { + prcuo.mutation.Where(ps...) + return prcuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (prcuo *PlanRateCardUpdateOne) Select(field string, fields ...string) *PlanRateCardUpdateOne { + prcuo.fields = append([]string{field}, fields...) + return prcuo +} + +// Save executes the query and returns the updated PlanRateCard entity. +func (prcuo *PlanRateCardUpdateOne) Save(ctx context.Context) (*PlanRateCard, error) { + prcuo.defaults() + return withHooks(ctx, prcuo.sqlSave, prcuo.mutation, prcuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (prcuo *PlanRateCardUpdateOne) SaveX(ctx context.Context) *PlanRateCard { + node, err := prcuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (prcuo *PlanRateCardUpdateOne) Exec(ctx context.Context) error { + _, err := prcuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (prcuo *PlanRateCardUpdateOne) ExecX(ctx context.Context) { + if err := prcuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (prcuo *PlanRateCardUpdateOne) defaults() { + if _, ok := prcuo.mutation.UpdatedAt(); !ok { + v := planratecard.UpdateDefaultUpdatedAt() + prcuo.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (prcuo *PlanRateCardUpdateOne) check() error { + if v, ok := prcuo.mutation.EntitlementTemplate(); ok { + if err := v.Validate(); err != nil { + return &ValidationError{Name: "entitlement_template", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.entitlement_template": %w`, err)} + } + } + if v, ok := prcuo.mutation.TaxConfig(); ok { + if err := v.Validate(); err != nil { + return &ValidationError{Name: "tax_config", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.tax_config": %w`, err)} + } + } + if v, ok := prcuo.mutation.Price(); ok { + if err := v.Validate(); err != nil { + return &ValidationError{Name: "price", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.price": %w`, err)} + } + } + if v, ok := prcuo.mutation.PhaseID(); ok { + if err := planratecard.PhaseIDValidator(v); err != nil { + return &ValidationError{Name: "phase_id", err: fmt.Errorf(`db: validator failed for field "PlanRateCard.phase_id": %w`, err)} + } + } + if prcuo.mutation.PhaseCleared() && len(prcuo.mutation.PhaseIDs()) > 0 { + return errors.New(`db: clearing a required unique edge "PlanRateCard.phase"`) + } + return nil +} + +func (prcuo *PlanRateCardUpdateOne) sqlSave(ctx context.Context) (_node *PlanRateCard, err error) { + if err := prcuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(planratecard.Table, planratecard.Columns, sqlgraph.NewFieldSpec(planratecard.FieldID, field.TypeString)) + id, ok := prcuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "PlanRateCard.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := prcuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, planratecard.FieldID) + for _, f := range fields { + if !planratecard.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)} + } + if f != planratecard.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := prcuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := prcuo.mutation.Metadata(); ok { + _spec.SetField(planratecard.FieldMetadata, field.TypeJSON, value) + } + if prcuo.mutation.MetadataCleared() { + _spec.ClearField(planratecard.FieldMetadata, field.TypeJSON) + } + if value, ok := prcuo.mutation.UpdatedAt(); ok { + _spec.SetField(planratecard.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := prcuo.mutation.DeletedAt(); ok { + _spec.SetField(planratecard.FieldDeletedAt, field.TypeTime, value) + } + if prcuo.mutation.DeletedAtCleared() { + _spec.ClearField(planratecard.FieldDeletedAt, field.TypeTime) + } + if value, ok := prcuo.mutation.Name(); ok { + _spec.SetField(planratecard.FieldName, field.TypeString, value) + } + if value, ok := prcuo.mutation.Description(); ok { + _spec.SetField(planratecard.FieldDescription, field.TypeString, value) + } + if prcuo.mutation.DescriptionCleared() { + _spec.ClearField(planratecard.FieldDescription, field.TypeString) + } + if value, ok := prcuo.mutation.FeatureKey(); ok { + _spec.SetField(planratecard.FieldFeatureKey, field.TypeString, value) + } + if prcuo.mutation.FeatureKeyCleared() { + _spec.ClearField(planratecard.FieldFeatureKey, field.TypeString) + } + if value, ok := prcuo.mutation.EntitlementTemplate(); ok { + vv, err := planratecard.ValueScanner.EntitlementTemplate.Value(value) + if err != nil { + return nil, err + } + _spec.SetField(planratecard.FieldEntitlementTemplate, field.TypeString, vv) + } + if prcuo.mutation.EntitlementTemplateCleared() { + _spec.ClearField(planratecard.FieldEntitlementTemplate, field.TypeString) + } + if value, ok := prcuo.mutation.TaxConfig(); ok { + vv, err := planratecard.ValueScanner.TaxConfig.Value(value) + if err != nil { + return nil, err + } + _spec.SetField(planratecard.FieldTaxConfig, field.TypeString, vv) + } + if prcuo.mutation.TaxConfigCleared() { + _spec.ClearField(planratecard.FieldTaxConfig, field.TypeString) + } + if value, ok := prcuo.mutation.BillingCadence(); ok { + _spec.SetField(planratecard.FieldBillingCadence, field.TypeString, value) + } + if prcuo.mutation.BillingCadenceCleared() { + _spec.ClearField(planratecard.FieldBillingCadence, field.TypeString) + } + if value, ok := prcuo.mutation.Price(); ok { + vv, err := planratecard.ValueScanner.Price.Value(value) + if err != nil { + return nil, err + } + _spec.SetField(planratecard.FieldPrice, field.TypeString, vv) + } + if prcuo.mutation.PriceCleared() { + _spec.ClearField(planratecard.FieldPrice, field.TypeString) + } + if prcuo.mutation.PhaseCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planratecard.PhaseTable, + Columns: []string{planratecard.PhaseColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := prcuo.mutation.PhaseIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planratecard.PhaseTable, + Columns: []string{planratecard.PhaseColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(planphase.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if prcuo.mutation.FeaturesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planratecard.FeaturesTable, + Columns: []string{planratecard.FeaturesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(feature.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := prcuo.mutation.FeaturesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: planratecard.FeaturesTable, + Columns: []string{planratecard.FeaturesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(feature.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &PlanRateCard{config: prcuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, prcuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{planratecard.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + prcuo.mutation.done = true + return _node, nil +} diff --git a/openmeter/ent/db/predicate/predicate.go b/openmeter/ent/db/predicate/predicate.go index 5781ab06d..af83790d5 100644 --- a/openmeter/ent/db/predicate/predicate.go +++ b/openmeter/ent/db/predicate/predicate.go @@ -102,5 +102,36 @@ func NotificationRuleOrErr(p NotificationRule, err error) NotificationRule { } } +// Plan is the predicate function for dbplan builders. +type Plan func(*sql.Selector) + +// PlanPhase is the predicate function for planphase builders. +type PlanPhase func(*sql.Selector) + +// PlanPhaseOrErr calls the predicate only if the error is not nit. +func PlanPhaseOrErr(p PlanPhase, err error) PlanPhase { + return func(s *sql.Selector) { + if err != nil { + s.AddError(err) + return + } + p(s) + } +} + +// PlanRateCard is the predicate function for planratecard builders. +type PlanRateCard func(*sql.Selector) + +// PlanRateCardOrErr calls the predicate only if the error is not nit. +func PlanRateCardOrErr(p PlanRateCard, err error) PlanRateCard { + return func(s *sql.Selector) { + if err != nil { + s.AddError(err) + return + } + p(s) + } +} + // UsageReset is the predicate function for usagereset builders. type UsageReset func(*sql.Selector) diff --git a/openmeter/ent/db/runtime.go b/openmeter/ent/db/runtime.go index f1c9a49cf..eca51f9a7 100644 --- a/openmeter/ent/db/runtime.go +++ b/openmeter/ent/db/runtime.go @@ -26,9 +26,14 @@ import ( "github.com/openmeterio/openmeter/openmeter/ent/db/notificationevent" "github.com/openmeterio/openmeter/openmeter/ent/db/notificationeventdeliverystatus" "github.com/openmeterio/openmeter/openmeter/ent/db/notificationrule" + dbplan "github.com/openmeterio/openmeter/openmeter/ent/db/plan" + "github.com/openmeterio/openmeter/openmeter/ent/db/planphase" + "github.com/openmeterio/openmeter/openmeter/ent/db/planratecard" "github.com/openmeterio/openmeter/openmeter/ent/db/usagereset" "github.com/openmeterio/openmeter/openmeter/ent/schema" "github.com/openmeterio/openmeter/openmeter/notification" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" + "github.com/openmeterio/openmeter/pkg/datex" "entgo.io/ent/schema/field" ) @@ -789,6 +794,121 @@ func init() { notificationruleDescID := notificationruleMixinFields0[0].Descriptor() // notificationrule.DefaultID holds the default value on creation for the id field. notificationrule.DefaultID = notificationruleDescID.Default.(func() string) + dbplanMixin := schema.Plan{}.Mixin() + dbplanMixinFields0 := dbplanMixin[0].Fields() + _ = dbplanMixinFields0 + dbplanFields := schema.Plan{}.Fields() + _ = dbplanFields + // dbplanDescNamespace is the schema descriptor for namespace field. + dbplanDescNamespace := dbplanMixinFields0[1].Descriptor() + // dbplan.NamespaceValidator is a validator for the "namespace" field. It is called by the builders before save. + dbplan.NamespaceValidator = dbplanDescNamespace.Validators[0].(func(string) error) + // dbplanDescCreatedAt is the schema descriptor for created_at field. + dbplanDescCreatedAt := dbplanMixinFields0[3].Descriptor() + // dbplan.DefaultCreatedAt holds the default value on creation for the created_at field. + dbplan.DefaultCreatedAt = dbplanDescCreatedAt.Default.(func() time.Time) + // dbplanDescUpdatedAt is the schema descriptor for updated_at field. + dbplanDescUpdatedAt := dbplanMixinFields0[4].Descriptor() + // dbplan.DefaultUpdatedAt holds the default value on creation for the updated_at field. + dbplan.DefaultUpdatedAt = dbplanDescUpdatedAt.Default.(func() time.Time) + // dbplan.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + dbplan.UpdateDefaultUpdatedAt = dbplanDescUpdatedAt.UpdateDefault.(func() time.Time) + // dbplanDescKey is the schema descriptor for key field. + dbplanDescKey := dbplanMixinFields0[8].Descriptor() + // dbplan.KeyValidator is a validator for the "key" field. It is called by the builders before save. + dbplan.KeyValidator = dbplanDescKey.Validators[0].(func(string) error) + // dbplanDescVersion is the schema descriptor for version field. + dbplanDescVersion := dbplanFields[0].Descriptor() + // dbplan.VersionValidator is a validator for the "version" field. It is called by the builders before save. + dbplan.VersionValidator = dbplanDescVersion.Validators[0].(func(int) error) + // dbplanDescCurrency is the schema descriptor for currency field. + dbplanDescCurrency := dbplanFields[1].Descriptor() + // dbplan.DefaultCurrency holds the default value on creation for the currency field. + dbplan.DefaultCurrency = dbplanDescCurrency.Default.(string) + // dbplan.CurrencyValidator is a validator for the "currency" field. It is called by the builders before save. + dbplan.CurrencyValidator = dbplanDescCurrency.Validators[0].(func(string) error) + // dbplanDescID is the schema descriptor for id field. + dbplanDescID := dbplanMixinFields0[0].Descriptor() + // dbplan.DefaultID holds the default value on creation for the id field. + dbplan.DefaultID = dbplanDescID.Default.(func() string) + planphaseMixin := schema.PlanPhase{}.Mixin() + planphaseMixinFields0 := planphaseMixin[0].Fields() + _ = planphaseMixinFields0 + planphaseFields := schema.PlanPhase{}.Fields() + _ = planphaseFields + // planphaseDescNamespace is the schema descriptor for namespace field. + planphaseDescNamespace := planphaseMixinFields0[1].Descriptor() + // planphase.NamespaceValidator is a validator for the "namespace" field. It is called by the builders before save. + planphase.NamespaceValidator = planphaseDescNamespace.Validators[0].(func(string) error) + // planphaseDescCreatedAt is the schema descriptor for created_at field. + planphaseDescCreatedAt := planphaseMixinFields0[3].Descriptor() + // planphase.DefaultCreatedAt holds the default value on creation for the created_at field. + planphase.DefaultCreatedAt = planphaseDescCreatedAt.Default.(func() time.Time) + // planphaseDescUpdatedAt is the schema descriptor for updated_at field. + planphaseDescUpdatedAt := planphaseMixinFields0[4].Descriptor() + // planphase.DefaultUpdatedAt holds the default value on creation for the updated_at field. + planphase.DefaultUpdatedAt = planphaseDescUpdatedAt.Default.(func() time.Time) + // planphase.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + planphase.UpdateDefaultUpdatedAt = planphaseDescUpdatedAt.UpdateDefault.(func() time.Time) + // planphaseDescKey is the schema descriptor for key field. + planphaseDescKey := planphaseMixinFields0[8].Descriptor() + // planphase.KeyValidator is a validator for the "key" field. It is called by the builders before save. + planphase.KeyValidator = planphaseDescKey.Validators[0].(func(string) error) + // planphaseDescStartAfter is the schema descriptor for start_after field. + planphaseDescStartAfter := planphaseFields[0].Descriptor() + // planphase.DefaultStartAfter holds the default value on creation for the start_after field. + planphase.DefaultStartAfter = datex.ISOString(planphaseDescStartAfter.Default.(string)) + // planphaseDescDiscounts is the schema descriptor for discounts field. + planphaseDescDiscounts := planphaseFields[1].Descriptor() + planphase.ValueScanner.Discounts = planphaseDescDiscounts.ValueScanner.(field.TypeValueScanner[[]plan.Discount]) + // planphaseDescPlanID is the schema descriptor for plan_id field. + planphaseDescPlanID := planphaseFields[2].Descriptor() + // planphase.PlanIDValidator is a validator for the "plan_id" field. It is called by the builders before save. + planphase.PlanIDValidator = planphaseDescPlanID.Validators[0].(func(string) error) + // planphaseDescID is the schema descriptor for id field. + planphaseDescID := planphaseMixinFields0[0].Descriptor() + // planphase.DefaultID holds the default value on creation for the id field. + planphase.DefaultID = planphaseDescID.Default.(func() string) + planratecardMixin := schema.PlanRateCard{}.Mixin() + planratecardMixinFields0 := planratecardMixin[0].Fields() + _ = planratecardMixinFields0 + planratecardFields := schema.PlanRateCard{}.Fields() + _ = planratecardFields + // planratecardDescNamespace is the schema descriptor for namespace field. + planratecardDescNamespace := planratecardMixinFields0[1].Descriptor() + // planratecard.NamespaceValidator is a validator for the "namespace" field. It is called by the builders before save. + planratecard.NamespaceValidator = planratecardDescNamespace.Validators[0].(func(string) error) + // planratecardDescCreatedAt is the schema descriptor for created_at field. + planratecardDescCreatedAt := planratecardMixinFields0[3].Descriptor() + // planratecard.DefaultCreatedAt holds the default value on creation for the created_at field. + planratecard.DefaultCreatedAt = planratecardDescCreatedAt.Default.(func() time.Time) + // planratecardDescUpdatedAt is the schema descriptor for updated_at field. + planratecardDescUpdatedAt := planratecardMixinFields0[4].Descriptor() + // planratecard.DefaultUpdatedAt holds the default value on creation for the updated_at field. + planratecard.DefaultUpdatedAt = planratecardDescUpdatedAt.Default.(func() time.Time) + // planratecard.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + planratecard.UpdateDefaultUpdatedAt = planratecardDescUpdatedAt.UpdateDefault.(func() time.Time) + // planratecardDescKey is the schema descriptor for key field. + planratecardDescKey := planratecardMixinFields0[8].Descriptor() + // planratecard.KeyValidator is a validator for the "key" field. It is called by the builders before save. + planratecard.KeyValidator = planratecardDescKey.Validators[0].(func(string) error) + // planratecardDescEntitlementTemplate is the schema descriptor for entitlement_template field. + planratecardDescEntitlementTemplate := planratecardFields[2].Descriptor() + planratecard.ValueScanner.EntitlementTemplate = planratecardDescEntitlementTemplate.ValueScanner.(field.TypeValueScanner[*plan.EntitlementTemplate]) + // planratecardDescTaxConfig is the schema descriptor for tax_config field. + planratecardDescTaxConfig := planratecardFields[3].Descriptor() + planratecard.ValueScanner.TaxConfig = planratecardDescTaxConfig.ValueScanner.(field.TypeValueScanner[*plan.TaxConfig]) + // planratecardDescPrice is the schema descriptor for price field. + planratecardDescPrice := planratecardFields[5].Descriptor() + planratecard.ValueScanner.Price = planratecardDescPrice.ValueScanner.(field.TypeValueScanner[*plan.Price]) + // planratecardDescPhaseID is the schema descriptor for phase_id field. + planratecardDescPhaseID := planratecardFields[6].Descriptor() + // planratecard.PhaseIDValidator is a validator for the "phase_id" field. It is called by the builders before save. + planratecard.PhaseIDValidator = planratecardDescPhaseID.Validators[0].(func(string) error) + // planratecardDescID is the schema descriptor for id field. + planratecardDescID := planratecardMixinFields0[0].Descriptor() + // planratecard.DefaultID holds the default value on creation for the id field. + planratecard.DefaultID = planratecardDescID.Default.(func() string) usageresetMixin := schema.UsageReset{}.Mixin() usageresetMixinFields0 := usageresetMixin[0].Fields() _ = usageresetMixinFields0 diff --git a/openmeter/ent/db/setorclear.go b/openmeter/ent/db/setorclear.go index d646f3aca..93f6cfa7a 100644 --- a/openmeter/ent/db/setorclear.go +++ b/openmeter/ent/db/setorclear.go @@ -7,6 +7,7 @@ import ( "github.com/alpacahq/alpacadecimal" billingentity "github.com/openmeterio/openmeter/openmeter/billing/entity" + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" "github.com/openmeterio/openmeter/pkg/currencyx" "github.com/openmeterio/openmeter/pkg/datex" "github.com/openmeterio/openmeter/pkg/models" @@ -1343,6 +1344,258 @@ func (u *NotificationRuleUpdateOne) SetOrClearDisabled(value *bool) *Notificatio return u.SetDisabled(*value) } +func (u *PlanUpdate) SetOrClearMetadata(value *map[string]string) *PlanUpdate { + if value == nil { + return u.ClearMetadata() + } + return u.SetMetadata(*value) +} + +func (u *PlanUpdateOne) SetOrClearMetadata(value *map[string]string) *PlanUpdateOne { + if value == nil { + return u.ClearMetadata() + } + return u.SetMetadata(*value) +} + +func (u *PlanUpdate) SetOrClearDeletedAt(value *time.Time) *PlanUpdate { + if value == nil { + return u.ClearDeletedAt() + } + return u.SetDeletedAt(*value) +} + +func (u *PlanUpdateOne) SetOrClearDeletedAt(value *time.Time) *PlanUpdateOne { + if value == nil { + return u.ClearDeletedAt() + } + return u.SetDeletedAt(*value) +} + +func (u *PlanUpdate) SetOrClearDescription(value *string) *PlanUpdate { + if value == nil { + return u.ClearDescription() + } + return u.SetDescription(*value) +} + +func (u *PlanUpdateOne) SetOrClearDescription(value *string) *PlanUpdateOne { + if value == nil { + return u.ClearDescription() + } + return u.SetDescription(*value) +} + +func (u *PlanUpdate) SetOrClearEffectiveFrom(value *time.Time) *PlanUpdate { + if value == nil { + return u.ClearEffectiveFrom() + } + return u.SetEffectiveFrom(*value) +} + +func (u *PlanUpdateOne) SetOrClearEffectiveFrom(value *time.Time) *PlanUpdateOne { + if value == nil { + return u.ClearEffectiveFrom() + } + return u.SetEffectiveFrom(*value) +} + +func (u *PlanUpdate) SetOrClearEffectiveTo(value *time.Time) *PlanUpdate { + if value == nil { + return u.ClearEffectiveTo() + } + return u.SetEffectiveTo(*value) +} + +func (u *PlanUpdateOne) SetOrClearEffectiveTo(value *time.Time) *PlanUpdateOne { + if value == nil { + return u.ClearEffectiveTo() + } + return u.SetEffectiveTo(*value) +} + +func (u *PlanPhaseUpdate) SetOrClearMetadata(value *map[string]string) *PlanPhaseUpdate { + if value == nil { + return u.ClearMetadata() + } + return u.SetMetadata(*value) +} + +func (u *PlanPhaseUpdateOne) SetOrClearMetadata(value *map[string]string) *PlanPhaseUpdateOne { + if value == nil { + return u.ClearMetadata() + } + return u.SetMetadata(*value) +} + +func (u *PlanPhaseUpdate) SetOrClearDeletedAt(value *time.Time) *PlanPhaseUpdate { + if value == nil { + return u.ClearDeletedAt() + } + return u.SetDeletedAt(*value) +} + +func (u *PlanPhaseUpdateOne) SetOrClearDeletedAt(value *time.Time) *PlanPhaseUpdateOne { + if value == nil { + return u.ClearDeletedAt() + } + return u.SetDeletedAt(*value) +} + +func (u *PlanPhaseUpdate) SetOrClearDescription(value *string) *PlanPhaseUpdate { + if value == nil { + return u.ClearDescription() + } + return u.SetDescription(*value) +} + +func (u *PlanPhaseUpdateOne) SetOrClearDescription(value *string) *PlanPhaseUpdateOne { + if value == nil { + return u.ClearDescription() + } + return u.SetDescription(*value) +} + +func (u *PlanPhaseUpdate) SetOrClearDiscounts(value *[]plan.Discount) *PlanPhaseUpdate { + if value == nil { + return u.ClearDiscounts() + } + return u.SetDiscounts(*value) +} + +func (u *PlanPhaseUpdateOne) SetOrClearDiscounts(value *[]plan.Discount) *PlanPhaseUpdateOne { + if value == nil { + return u.ClearDiscounts() + } + return u.SetDiscounts(*value) +} + +func (u *PlanRateCardUpdate) SetOrClearMetadata(value *map[string]string) *PlanRateCardUpdate { + if value == nil { + return u.ClearMetadata() + } + return u.SetMetadata(*value) +} + +func (u *PlanRateCardUpdateOne) SetOrClearMetadata(value *map[string]string) *PlanRateCardUpdateOne { + if value == nil { + return u.ClearMetadata() + } + return u.SetMetadata(*value) +} + +func (u *PlanRateCardUpdate) SetOrClearDeletedAt(value *time.Time) *PlanRateCardUpdate { + if value == nil { + return u.ClearDeletedAt() + } + return u.SetDeletedAt(*value) +} + +func (u *PlanRateCardUpdateOne) SetOrClearDeletedAt(value *time.Time) *PlanRateCardUpdateOne { + if value == nil { + return u.ClearDeletedAt() + } + return u.SetDeletedAt(*value) +} + +func (u *PlanRateCardUpdate) SetOrClearDescription(value *string) *PlanRateCardUpdate { + if value == nil { + return u.ClearDescription() + } + return u.SetDescription(*value) +} + +func (u *PlanRateCardUpdateOne) SetOrClearDescription(value *string) *PlanRateCardUpdateOne { + if value == nil { + return u.ClearDescription() + } + return u.SetDescription(*value) +} + +func (u *PlanRateCardUpdate) SetOrClearFeatureKey(value *string) *PlanRateCardUpdate { + if value == nil { + return u.ClearFeatureKey() + } + return u.SetFeatureKey(*value) +} + +func (u *PlanRateCardUpdateOne) SetOrClearFeatureKey(value *string) *PlanRateCardUpdateOne { + if value == nil { + return u.ClearFeatureKey() + } + return u.SetFeatureKey(*value) +} + +func (u *PlanRateCardUpdate) SetOrClearEntitlementTemplate(value **plan.EntitlementTemplate) *PlanRateCardUpdate { + if value == nil { + return u.ClearEntitlementTemplate() + } + return u.SetEntitlementTemplate(*value) +} + +func (u *PlanRateCardUpdateOne) SetOrClearEntitlementTemplate(value **plan.EntitlementTemplate) *PlanRateCardUpdateOne { + if value == nil { + return u.ClearEntitlementTemplate() + } + return u.SetEntitlementTemplate(*value) +} + +func (u *PlanRateCardUpdate) SetOrClearTaxConfig(value **plan.TaxConfig) *PlanRateCardUpdate { + if value == nil { + return u.ClearTaxConfig() + } + return u.SetTaxConfig(*value) +} + +func (u *PlanRateCardUpdateOne) SetOrClearTaxConfig(value **plan.TaxConfig) *PlanRateCardUpdateOne { + if value == nil { + return u.ClearTaxConfig() + } + return u.SetTaxConfig(*value) +} + +func (u *PlanRateCardUpdate) SetOrClearBillingCadence(value *datex.ISOString) *PlanRateCardUpdate { + if value == nil { + return u.ClearBillingCadence() + } + return u.SetBillingCadence(*value) +} + +func (u *PlanRateCardUpdateOne) SetOrClearBillingCadence(value *datex.ISOString) *PlanRateCardUpdateOne { + if value == nil { + return u.ClearBillingCadence() + } + return u.SetBillingCadence(*value) +} + +func (u *PlanRateCardUpdate) SetOrClearPrice(value **plan.Price) *PlanRateCardUpdate { + if value == nil { + return u.ClearPrice() + } + return u.SetPrice(*value) +} + +func (u *PlanRateCardUpdateOne) SetOrClearPrice(value **plan.Price) *PlanRateCardUpdateOne { + if value == nil { + return u.ClearPrice() + } + return u.SetPrice(*value) +} + +func (u *PlanRateCardUpdate) SetOrClearFeatureID(value *string) *PlanRateCardUpdate { + if value == nil { + return u.ClearFeatureID() + } + return u.SetFeatureID(*value) +} + +func (u *PlanRateCardUpdateOne) SetOrClearFeatureID(value *string) *PlanRateCardUpdateOne { + if value == nil { + return u.ClearFeatureID() + } + return u.SetFeatureID(*value) +} + func (u *UsageResetUpdate) SetOrClearDeletedAt(value *time.Time) *UsageResetUpdate { if value == nil { return u.ClearDeletedAt() diff --git a/openmeter/ent/db/tx.go b/openmeter/ent/db/tx.go index c9fd67469..4bf3a6175 100644 --- a/openmeter/ent/db/tx.go +++ b/openmeter/ent/db/tx.go @@ -56,6 +56,12 @@ type Tx struct { NotificationEventDeliveryStatus *NotificationEventDeliveryStatusClient // NotificationRule is the client for interacting with the NotificationRule builders. NotificationRule *NotificationRuleClient + // Plan is the client for interacting with the Plan builders. + Plan *PlanClient + // PlanPhase is the client for interacting with the PlanPhase builders. + PlanPhase *PlanPhaseClient + // PlanRateCard is the client for interacting with the PlanRateCard builders. + PlanRateCard *PlanRateCardClient // UsageReset is the client for interacting with the UsageReset builders. UsageReset *UsageResetClient @@ -210,6 +216,9 @@ func (tx *Tx) init() { tx.NotificationEvent = NewNotificationEventClient(tx.config) tx.NotificationEventDeliveryStatus = NewNotificationEventDeliveryStatusClient(tx.config) tx.NotificationRule = NewNotificationRuleClient(tx.config) + tx.Plan = NewPlanClient(tx.config) + tx.PlanPhase = NewPlanPhaseClient(tx.config) + tx.PlanRateCard = NewPlanRateCardClient(tx.config) tx.UsageReset = NewUsageResetClient(tx.config) } diff --git a/openmeter/ent/schema/feature.go b/openmeter/ent/schema/feature.go index aa1af92a3..88f507b14 100644 --- a/openmeter/ent/schema/feature.go +++ b/openmeter/ent/schema/feature.go @@ -41,5 +41,6 @@ func (Feature) Indexes() []ent.Index { func (Feature) Edges() []ent.Edge { return []ent.Edge{ edge.To("entitlement", Entitlement.Type), + edge.To("ratecard", PlanRateCard.Type), } } diff --git a/openmeter/ent/schema/productcatalog.go b/openmeter/ent/schema/productcatalog.go new file mode 100644 index 000000000..85cdf887c --- /dev/null +++ b/openmeter/ent/schema/productcatalog.go @@ -0,0 +1,196 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + + "github.com/openmeterio/openmeter/openmeter/productcatalog/plan" + "github.com/openmeterio/openmeter/pkg/datex" + "github.com/openmeterio/openmeter/pkg/framework/entutils" +) + +type Plan struct { + ent.Schema +} + +func (Plan) Mixin() []ent.Mixin { + return []ent.Mixin{ + entutils.UniqueResourceMixin{}, + } +} + +func (Plan) Fields() []ent.Field { + return []ent.Field{ + field.Int("version"). + Min(1), + field.String("currency"). + Default("USD"). + NotEmpty(). + Immutable(), + field.Time("effective_from"). + Optional(). + Nillable(), + field.Time("effective_to"). + Optional(). + Nillable(), + } +} + +func (Plan) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("phases", PlanPhase.Type). + Annotations(entsql.Annotation{ + OnDelete: entsql.Cascade, + }), + } +} + +func (Plan) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("namespace", "key", "version"). + Unique(), + } +} + +type PlanPhase struct { + ent.Schema +} + +func (PlanPhase) Mixin() []ent.Mixin { + return []ent.Mixin{ + entutils.UniqueResourceMixin{}, + } +} + +func (PlanPhase) Fields() []ent.Field { + return []ent.Field{ + field.String("start_after"). + GoType(datex.ISOString("")). + Default(plan.DefaultStartAfter), + field.String("discounts"). + GoType([]plan.Discount{}). + ValueScanner(DiscountsValueScanner). + SchemaType(map[string]string{ + dialect.Postgres: "jsonb", + }). + Optional(), + field.String("plan_id"). + NotEmpty(). + Comment("The plan identifier the phase is assigned to."), + } +} + +func (PlanPhase) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("plan", Plan.Type). + Ref("phases"). + Field("plan_id"). + Required(). + Unique(), + edge.To("ratecards", PlanRateCard.Type). + Annotations(entsql.Annotation{ + OnDelete: entsql.Cascade, + }), + } +} + +func (PlanPhase) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("namespace", "key"), + index.Fields("plan_id", "key"). + Unique(), + } +} + +type PlanRateCard struct { + ent.Schema +} + +func (PlanRateCard) Mixin() []ent.Mixin { + return []ent.Mixin{ + entutils.UniqueResourceMixin{}, + } +} + +type Price string + +func (PlanRateCard) Fields() []ent.Field { + return []ent.Field{ + field.Enum("type"). + GoType(plan.RateCardType("")). + Immutable(), + field.String("feature_key"). + Optional(). + Nillable(), + field.String("entitlement_template"). + GoType(&plan.EntitlementTemplate{}). + ValueScanner(EntitlementTemplateValueScanner). + SchemaType(map[string]string{ + dialect.Postgres: "jsonb", + }). + Optional(). + Nillable(), + field.String("tax_config"). + GoType(&plan.TaxConfig{}). + ValueScanner(TaxConfigValueScanner). + SchemaType(map[string]string{ + dialect.Postgres: "jsonb", + }). + Optional(). + Nillable(), + field.String("billing_cadence"). + GoType(datex.ISOString("")). + Optional(). + Nillable(), + field.String("price"). + GoType(&plan.Price{}). + ValueScanner(PriceValueScanner). + SchemaType(map[string]string{ + dialect.Postgres: "jsonb", + }). + Optional(). + Nillable(), + field.String("phase_id"). + NotEmpty(). + Comment("The phase identifier the ratecard is assigned to."), + field.String("feature_id"). + Optional(). + Nillable(). + Comment("The feature identifier the ratecard is related to."), + } +} + +func (PlanRateCard) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("phase", PlanPhase.Type). + Ref("ratecards"). + Field("phase_id"). + Required(). + Unique(), + edge.From("features", Feature.Type). + Ref("ratecard"). + Field("feature_id"). + Unique(), + } +} + +func (PlanRateCard) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("phase_id", "key"). + Unique(), + index.Fields("phase_id", "feature_key"). + Unique(), + } +} + +var EntitlementTemplateValueScanner = entutils.JSONStringValueScanner[*plan.EntitlementTemplate]() + +var TaxConfigValueScanner = entutils.JSONStringValueScanner[*plan.TaxConfig]() + +var PriceValueScanner = entutils.JSONStringValueScanner[*plan.Price]() + +var DiscountsValueScanner = entutils.JSONStringValueScanner[[]plan.Discount]() diff --git a/openmeter/productcatalog/plan/discount.go b/openmeter/productcatalog/plan/discount.go new file mode 100644 index 000000000..12b5cc8cf --- /dev/null +++ b/openmeter/productcatalog/plan/discount.go @@ -0,0 +1,154 @@ +package plan + +import ( + "encoding/json" + "errors" + "fmt" + + decimal "github.com/alpacahq/alpacadecimal" +) + +const ( + PercentageDiscountType DiscountType = "percentage" +) + +type DiscountType string + +func (p DiscountType) Values() []DiscountType { + return []DiscountType{ + PercentageDiscountType, + } +} + +func (p DiscountType) StringValues() []string { + return []string{ + string(PercentageDiscountType), + } +} + +type discounter interface { + json.Marshaler + json.Unmarshaler + Validator + + Type() DiscountType + AsPercentage() (PercentageDiscount, error) + FromPercentage(PercentageDiscount) +} + +var _ discounter = (*Discount)(nil) + +type Discount struct { + t DiscountType + percentage *PercentageDiscount +} + +func (d *Discount) MarshalJSON() ([]byte, error) { + var b []byte + var err error + + switch d.t { + case PercentageDiscountType: + b, err = json.Marshal(d.percentage) + if err != nil { + return nil, fmt.Errorf("failed to json marshal percentage discount: %w", err) + } + default: + return nil, fmt.Errorf("invalid discount type: %s", d.t) + } + + return b, nil +} + +func (d *Discount) UnmarshalJSON(bytes []byte) error { + meta := &DiscountMeta{} + + if err := json.Unmarshal(bytes, meta); err != nil { + return fmt.Errorf("failed to json unmarshal discount type: %w", err) + } + + switch meta.Type { + case PercentageDiscountType: + v := &PercentageDiscount{} + if err := json.Unmarshal(bytes, v); err != nil { + return fmt.Errorf("failed to json unmarshal percentage discount: %w", err) + } + + d.percentage = v + d.t = PercentageDiscountType + default: + return fmt.Errorf("invalid discount type: %s", meta.Type) + } + + return nil +} + +func (d *Discount) Validate() error { + switch d.t { + case PercentageDiscountType: + return d.percentage.Validate() + default: + return errors.New("invalid discount: not initialized") + } +} + +func (d *Discount) Type() DiscountType { + return d.t +} + +func (d *Discount) AsPercentage() (PercentageDiscount, error) { + if d.t == "" || d.percentage == nil { + return PercentageDiscount{}, errors.New("invalid discount: not initialized") + } + + if d.t != PercentageDiscountType { + return PercentageDiscount{}, fmt.Errorf("discount type mismatch: %s", d.t) + } + + return *d.percentage, nil +} + +func (d *Discount) FromPercentage(discount PercentageDiscount) { + d.percentage = &discount + d.t = PercentageDiscountType +} + +func NewDiscountFrom[T PercentageDiscount](v T) Discount { + d := Discount{} + + switch any(v).(type) { + case FlatPrice: + percentage := any(v).(PercentageDiscount) + d.FromPercentage(percentage) + } + + return d +} + +type DiscountMeta struct { + // Type of the Discount. + Type DiscountType `json:"type"` +} + +var _ Validator = (*PercentageDiscount)(nil) + +type PercentageDiscount struct { + DiscountMeta + + // Percentage defines percentage of the discount. + Percentage decimal.Decimal `json:"percentage"` +} + +func (f PercentageDiscount) Validate() error { + var errs []error + + if f.Percentage.LessThan(decimal.Zero) || f.Percentage.GreaterThan(decimal.NewFromInt(100)) { + errs = append(errs, errors.New("discount percentage must be between 0 and 100")) + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} diff --git a/openmeter/productcatalog/plan/entitlement.go b/openmeter/productcatalog/plan/entitlement.go new file mode 100644 index 000000000..4933ad537 --- /dev/null +++ b/openmeter/productcatalog/plan/entitlement.go @@ -0,0 +1,230 @@ +package plan + +import ( + "encoding/json" + "errors" + "fmt" + + "github.com/openmeterio/openmeter/openmeter/entitlement" + "github.com/openmeterio/openmeter/pkg/datex" +) + +type entitlementTemplater interface { + json.Marshaler + json.Unmarshaler + Validator + + Type() entitlement.EntitlementType + AsMetered() (MeteredEntitlementTemplate, error) + AsStatic() (StaticEntitlementTemplate, error) + AsBoolean() (BooleanEntitlementTemplate, error) + FromMetered(MeteredEntitlementTemplate) + FromStatic(StaticEntitlementTemplate) + FromBoolean(BooleanEntitlementTemplate) +} + +var _ entitlementTemplater = (*EntitlementTemplate)(nil) + +// EntitlementTemplate is the template used for instantiating entitlement.Entitlement for RateCard. +type EntitlementTemplate struct { + t entitlement.EntitlementType + metered *MeteredEntitlementTemplate + static *StaticEntitlementTemplate + boolean *BooleanEntitlementTemplate +} + +func (e *EntitlementTemplate) MarshalJSON() ([]byte, error) { + var b []byte + var err error + + switch e.t { + case entitlement.EntitlementTypeMetered: + b, err = json.Marshal(e.metered) + if err != nil { + return nil, fmt.Errorf("failed to json marshal metered entitlement: %w", err) + } + case entitlement.EntitlementTypeStatic: + b, err = json.Marshal(e.static) + if err != nil { + return nil, fmt.Errorf("failed to json marshal metered entitlement: %w", err) + } + case entitlement.EntitlementTypeBoolean: + b, err = json.Marshal(e.boolean) + if err != nil { + return nil, fmt.Errorf("failed to json marshal metered entitlement: %w", err) + } + default: + return nil, fmt.Errorf("invalid entitlement type: %s", e.t) + } + + return b, nil +} + +func (e *EntitlementTemplate) UnmarshalJSON(bytes []byte) error { + meta := &EntitlementTemplateMeta{} + + if err := json.Unmarshal(bytes, meta); err != nil { + return fmt.Errorf("failed to json unmarshal entitlement template type: %w", err) + } + + switch meta.Type { + case entitlement.EntitlementTypeMetered: + v := &MeteredEntitlementTemplate{} + if err := json.Unmarshal(bytes, v); err != nil { + return fmt.Errorf("failed to json unmarshal metered entitlement template: %w", err) + } + + e.metered = v + e.t = entitlement.EntitlementTypeMetered + case entitlement.EntitlementTypeStatic: + v := &StaticEntitlementTemplate{} + if err := json.Unmarshal(bytes, v); err != nil { + return fmt.Errorf("failed to json unmarshal metered entitlement template: %w", err) + } + + e.static = v + e.t = entitlement.EntitlementTypeStatic + case entitlement.EntitlementTypeBoolean: + v := &BooleanEntitlementTemplate{} + if err := json.Unmarshal(bytes, v); err != nil { + return fmt.Errorf("failed to json unmarshal boolean entitlement template: %w", err) + } + + e.boolean = v + e.t = entitlement.EntitlementTypeBoolean + default: + return fmt.Errorf("invalid entitlement type: %s", meta.Type) + } + + return nil +} + +func (e *EntitlementTemplate) Validate() error { + if e == nil { + return nil + } + + switch e.t { + case entitlement.EntitlementTypeMetered: + return e.metered.Validate() + case entitlement.EntitlementTypeStatic: + return e.static.Validate() + case entitlement.EntitlementTypeBoolean: + return e.boolean.Validate() + default: + return fmt.Errorf("invalid entitlement type: %q", e.t) + } +} + +func (e *EntitlementTemplate) Type() entitlement.EntitlementType { + return e.t +} + +func (e *EntitlementTemplate) AsMetered() (MeteredEntitlementTemplate, error) { + if e.t == "" || e.metered == nil { + return MeteredEntitlementTemplate{}, errors.New("invalid entitlement template: not initialized") + } + + return *e.metered, nil +} + +func (e *EntitlementTemplate) AsStatic() (StaticEntitlementTemplate, error) { + if e.t == "" || e.static == nil { + return StaticEntitlementTemplate{}, errors.New("invalid entitlement template: not initialized") + } + + return *e.static, nil +} + +func (e *EntitlementTemplate) AsBoolean() (BooleanEntitlementTemplate, error) { + if e.t == "" || e.boolean == nil { + return BooleanEntitlementTemplate{}, errors.New("invalid entitlement template: not initialized") + } + + return *e.boolean, nil +} + +func (e *EntitlementTemplate) FromMetered(t MeteredEntitlementTemplate) { + e.metered = &t + e.t = entitlement.EntitlementTypeMetered +} + +func (e *EntitlementTemplate) FromStatic(t StaticEntitlementTemplate) { + e.static = &t + e.t = entitlement.EntitlementTypeStatic +} + +func (e *EntitlementTemplate) FromBoolean(t BooleanEntitlementTemplate) { + e.boolean = &t + e.t = entitlement.EntitlementTypeBoolean +} + +type EntitlementTemplateMeta struct { + // Type defines the type of the entitlement.Entitlement. + Type entitlement.EntitlementType `json:"type"` +} + +type MeteredEntitlementTemplate struct { + EntitlementTemplateMeta + + // Metadata a set of key/value pairs describing metadata for the RateCard. + Metadata map[string]string `json:"metadata,omitempty"` + + // IsSoftLimit set to `true` for allowing the subject to use the feature even if the entitlement is exhausted. + IsSoftLimit bool `json:"isSoftLimit,omitempty"` + + // IssueAfterReset defines the amount to be automatically granted at entitlement.Entitlement creation or reset. + IssueAfterReset *float64 `json:"issueAfterReset,omitempty"` + + // IssueAfterResetPriority defines the grant priority for the default grant. + IssueAfterResetPriority *uint8 `json:"issueAfterResetPriority,omitempty"` + + // PreserveOverageAtReset defines whether the overage is preserved after reset. + PreserveOverageAtReset *bool `json:"preserveOverageAtReset,omitempty"` + + // UsagePeriod defines the interval of the entitlement in ISO8601 format. + // Defaults to the billing cadence of the rate card. + // Example: "P1D12H" + UsagePeriod datex.Period `json:"usagePeriod,omitempty"` +} + +func (t MeteredEntitlementTemplate) Validate() error { + if t.IssueAfterResetPriority != nil && t.IssueAfterReset == nil { + return errors.New("IssueAfterReset is required for IssueAfterResetPriority") + } + + return nil +} + +type StaticEntitlementTemplate struct { + EntitlementTemplateMeta + + // Metadata a set of key/value pairs describing metadata for the RateCard. + Metadata map[string]string `json:"metadata,omitempty"` + + // Config stores a JSON parsable configuration for the entitlement.Entitlement. + // This value is also returned when checking entitlement access, and + // it is useful for configuring fine-grained access settings to the feature implemented in customers own system. + Config json.RawMessage `json:"config,omitempty"` +} + +func (t StaticEntitlementTemplate) Validate() error { + if len(t.Config) > 0 { + if ok := json.Valid(t.Config); !ok { + return errors.New("invalid JSON in config") + } + } + + return nil +} + +type BooleanEntitlementTemplate struct { + EntitlementTemplateMeta + + // Metadata a set of key/value pairs describing metadata for the RateCard. + Metadata map[string]string `json:"metadata,omitempty"` +} + +func (t BooleanEntitlementTemplate) Validate() error { + return nil +} diff --git a/openmeter/productcatalog/plan/phase.go b/openmeter/productcatalog/plan/phase.go new file mode 100644 index 000000000..fa9436983 --- /dev/null +++ b/openmeter/productcatalog/plan/phase.go @@ -0,0 +1,99 @@ +package plan + +import ( + "errors" + "fmt" + "slices" + + "github.com/openmeterio/openmeter/pkg/datex" + "github.com/openmeterio/openmeter/pkg/models" +) + +const DefaultStartAfter = "P0D" + +type Phase struct { + models.NamespacedID + models.ManagedModel + + // Key is the unique key for Phase. + Key string `json:"key"` + + // Name + Name string `json:"name"` + + // Description + Description *string `json:"description,omitempty"` + + // Metadata + Metadata map[string]string `json:"metadata,omitempty"` + + // StartAfter + StartAfter datex.Period `json:"interval"` + + // RateCards + RateCards []RateCard `json:"rateCards"` + + // Discounts + Discounts []Discount `json:"discounts"` + + // PlanID + PlanID string `json:"-"` +} + +func (p Phase) Validate() error { + var errs []error + + if p.StartAfter.IsNegative() { + errs = append(errs, fmt.Errorf("startAfter must not be negative")) + } + + // Check for + // * duplicated rate card keys + // * namespace mismatch + // * invalid RateCards + rateCardKeys := make(map[string]RateCard) + for _, rateCard := range p.RateCards { + if _, ok := rateCardKeys[rateCard.Key()]; ok { + errs = append(errs, fmt.Errorf("duplicated rate card: %s", rateCard.Key())) + } else { + rateCardKeys[rateCard.Key()] = rateCard + } + + if rateCard.Namespace() != p.Namespace { + errs = append(errs, fmt.Errorf("invalid rate card %s: namespace mismatch %s", rateCard.Key(), rateCard.Namespace())) + } + + if err := rateCard.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid rate card %s: %w", rateCard.Key(), err)) + } + } + + for _, discount := range p.Discounts { + if err := discount.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid discount: %w", err)) + } + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} + +type SortFunc func(left, right Phase) int + +var SortPhasesByStartAfter SortFunc = func(left, right Phase) int { + lt, _ := left.StartAfter.Duration() + rt, _ := right.StartAfter.Duration() + + if lt > rt { + return 1 + } else if lt < rt { + return -1 + } + + return 0 +} + +var SortPhases = slices.SortFunc[[]Phase, Phase] diff --git a/openmeter/productcatalog/plan/phase_test.go b/openmeter/productcatalog/plan/phase_test.go new file mode 100644 index 000000000..bd2f0a635 --- /dev/null +++ b/openmeter/productcatalog/plan/phase_test.go @@ -0,0 +1,60 @@ +package plan + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/openmeterio/openmeter/pkg/datex" +) + +func TestPhaseSort(t *testing.T) { + tests := []struct { + Name string + + SortFunc SortFunc + Phases []Phase + Expected []Phase + }{ + { + Name: "ByStartAfter", + SortFunc: SortPhasesByStartAfter, + Phases: []Phase{ + { + Name: "Pro", + StartAfter: datex.MustParse(t, "P3M"), + }, + { + Name: "Trial", + StartAfter: datex.MustParse(t, "P0D"), + }, + { + Name: "Pro 2", + StartAfter: datex.MustParse(t, "P1Y"), + }, + }, + Expected: []Phase{ + { + Name: "Trial", + StartAfter: datex.MustParse(t, "P0D"), + }, + { + Name: "Pro", + StartAfter: datex.MustParse(t, "P3M"), + }, + { + Name: "Pro 2", + StartAfter: datex.MustParse(t, "P1Y"), + }, + }, + }, + } + + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + SortPhases(test.Phases, test.SortFunc) + + assert.ElementsMatch(t, test.Expected, test.Phases) + }) + } +} diff --git a/openmeter/productcatalog/plan/plan.go b/openmeter/productcatalog/plan/plan.go new file mode 100644 index 000000000..15e770f08 --- /dev/null +++ b/openmeter/productcatalog/plan/plan.go @@ -0,0 +1,146 @@ +package plan + +import ( + "errors" + "fmt" + "time" + + "github.com/invopop/gobl/currency" + + "github.com/openmeterio/openmeter/pkg/datex" + "github.com/openmeterio/openmeter/pkg/models" +) + +const ( + DraftStatus PlanStatus = "draft" + ActiveStatus PlanStatus = "active" + ArchivedStatus PlanStatus = "archived" + ScheduledStatus PlanStatus = "scheduled" + InvalidStatus PlanStatus = "invalid" +) + +type PlanStatus string + +func (s PlanStatus) Values() []string { + return []string{ + string(DraftStatus), + string(ActiveStatus), + string(ArchivedStatus), + string(ScheduledStatus), + } +} + +var _ Validator = (*Plan)(nil) + +type Plan struct { + models.NamespacedID + models.ManagedModel + EffectivePeriod + + // Key is the unique key for Plan. + Key string `json:"key"` + + // Name + Name string `json:"name"` + + // Description + Description *string `json:"description,omitempty"` + + // Metadata + Metadata map[string]string `json:"metadata,omitempty"` + + // Version + Version int `json:"version"` + + // Currency + Currency currency.Code `json:"currency"` + + // Phases + Phases []Phase `json:"phases"` +} + +func (p Plan) Validate() error { + var errs []error + + if err := p.Currency.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid currency code: %s", err)) + } + + if p.Status() == InvalidStatus { + errs = append(errs, fmt.Errorf("invalid effective time range: to is before from")) + } + + // Check if there are multiple plan phase with the same startAfter which is not allowed. + startAfters := make(map[datex.ISOString]Phase) + for _, phase := range p.Phases { + startAfter := phase.StartAfter.ISOString() + + if _, ok := startAfters[startAfter]; ok { + errs = append(errs, fmt.Errorf("multiple plan phases have the same startAfter which is not allowed: %q", phase.Name)) + } + + if phase.Namespace != p.Namespace { + errs = append(errs, fmt.Errorf("invalid phase %q: namespace mismatch %s", phase.Key, phase.Namespace)) + } + + if err := phase.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid phase %q: %s", phase.Name, err)) + } + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} + +var _ Validator = (*EffectivePeriod)(nil) + +type EffectivePeriod struct { + // EffectiveFrom + EffectiveFrom *time.Time `json:"effectiveFrom,omitempty"` + + // EffectiveTo + EffectiveTo *time.Time `json:"effectiveTo,omitempty"` +} + +func (p EffectivePeriod) Validate() error { + if p.Status() == InvalidStatus { + return fmt.Errorf("invalid effective time range: to is before from") + } + + return nil +} + +// Status returns the current status of the Plan +func (p EffectivePeriod) Status() PlanStatus { + return p.StatusAt(time.Now()) +} + +// StatusAt returns the plan status relative to time t. +func (p EffectivePeriod) StatusAt(t time.Time) PlanStatus { + // Plan has DraftStatus if neither the EffectiveFrom nor EffectiveTo are set + if p.EffectiveFrom == nil && p.EffectiveTo == nil { + return DraftStatus + } + + // Plan has ArchivedStatus if EffectiveTo is in the past relative to time t. + if p.EffectiveFrom != nil && p.EffectiveFrom.Before(t) && p.EffectiveTo != nil && p.EffectiveTo.Before(t) && p.EffectiveFrom.Before(*p.EffectiveTo) { + return ArchivedStatus + } + + // Plan has ActiveStatus if EffectiveFrom is set in the past relative to time t and EffectiveTo is not set + // or in the future relative to time t. + if p.EffectiveFrom != nil && p.EffectiveFrom.Before(t) && (p.EffectiveTo == nil || p.EffectiveTo.After(t)) { + return ActiveStatus + } + + // Plan is ScheduledForActiveStatus if EffectiveFrom is set in the future relative to time t and EffectiveTo is not set + // or in the future relative to time t. + if p.EffectiveFrom != nil && p.EffectiveFrom.After(t) && (p.EffectiveTo == nil || p.EffectiveTo.After(t)) { + return ScheduledStatus + } + + return InvalidStatus +} diff --git a/openmeter/productcatalog/plan/plan_test.go b/openmeter/productcatalog/plan/plan_test.go new file mode 100644 index 000000000..7cb1db454 --- /dev/null +++ b/openmeter/productcatalog/plan/plan_test.go @@ -0,0 +1,91 @@ +package plan + +import ( + "testing" + "time" + + "github.com/samber/lo" + "github.com/stretchr/testify/assert" +) + +func TestPlanStatus(t *testing.T) { + now := time.Now() + + tests := []struct { + Name string + + Effective EffectivePeriod + Expected PlanStatus + }{ + { + Name: "Draft", + Effective: EffectivePeriod{ + EffectiveFrom: nil, + EffectiveTo: nil, + }, + Expected: DraftStatus, + }, + { + Name: "Archived", + Effective: EffectivePeriod{ + EffectiveFrom: lo.ToPtr(now.Add(-24 * time.Hour)), + EffectiveTo: lo.ToPtr(now.Add(-1 * time.Hour)), + }, + Expected: ArchivedStatus, + }, + { + Name: "Active with open end", + Effective: EffectivePeriod{ + EffectiveFrom: lo.ToPtr(now.Add(-24 * time.Hour)), + EffectiveTo: nil, + }, + Expected: ActiveStatus, + }, + { + Name: "Active with fixed end", + Effective: EffectivePeriod{ + EffectiveFrom: lo.ToPtr(now.Add(-24 * time.Hour)), + EffectiveTo: lo.ToPtr(now.Add(24 * time.Hour)), + }, + Expected: ActiveStatus, + }, + { + Name: "Scheduled with open end", + Effective: EffectivePeriod{ + EffectiveFrom: lo.ToPtr(now.Add(24 * time.Hour)), + EffectiveTo: nil, + }, + Expected: ScheduledStatus, + }, + { + Name: "Scheduled with fixed period", + Effective: EffectivePeriod{ + EffectiveFrom: lo.ToPtr(now.Add(24 * time.Hour)), + EffectiveTo: lo.ToPtr(now.Add(48 * time.Hour)), + }, + Expected: ScheduledStatus, + }, + { + Name: "Invalid with inverse period", + Effective: EffectivePeriod{ + EffectiveFrom: lo.ToPtr(now.Add(24 * time.Hour)), + EffectiveTo: lo.ToPtr(now.Add(-24 * time.Hour)), + }, + Expected: InvalidStatus, + }, + { + Name: "Invalid with missing start", + Effective: EffectivePeriod{ + EffectiveFrom: nil, + EffectiveTo: lo.ToPtr(now.Add(-24 * time.Hour)), + }, + Expected: InvalidStatus, + }, + } + + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + assert.Equal(t, test.Expected, test.Effective.Status()) + }) + } +} diff --git a/openmeter/productcatalog/plan/price.go b/openmeter/productcatalog/plan/price.go new file mode 100644 index 000000000..53bfe489d --- /dev/null +++ b/openmeter/productcatalog/plan/price.go @@ -0,0 +1,439 @@ +package plan + +import ( + "encoding/json" + "errors" + "fmt" + "strings" + + decimal "github.com/alpacahq/alpacadecimal" + "github.com/samber/lo" +) + +const ( + InAdvancePaymentTerm PaymentTermType = "in_advance" + InArrearsPaymentTerm PaymentTermType = "in_arrears" +) + +type PaymentTermType string + +func (p PaymentTermType) Values() []PaymentTermType { + return []PaymentTermType{ + InAdvancePaymentTerm, + InArrearsPaymentTerm, + } +} + +func (p PaymentTermType) StringValues() []string { + return []string{ + string(InAdvancePaymentTerm), + string(InArrearsPaymentTerm), + } +} + +const ( + FlatPriceType PriceType = "flat" + UnitPriceType PriceType = "unit" + TieredPriceType PriceType = "tiered" +) + +type PriceType string + +func (p PriceType) Values() []string { + return []string{ + string(FlatPriceType), + string(UnitPriceType), + string(TieredPriceType), + } +} + +type pricer interface { + json.Marshaler + json.Unmarshaler + Validator + + Type() PriceType + AsFlat() (FlatPrice, error) + AsUnit() (UnitPrice, error) + AsTiered() (TieredPrice, error) + FromFlat(FlatPrice) + FromUnit(UnitPrice) + FromTiered(TieredPrice) +} + +var _ pricer = (*Price)(nil) + +type Price struct { + t PriceType + flat *FlatPrice + unit *UnitPrice + tiered *TieredPrice +} + +func (p *Price) MarshalJSON() ([]byte, error) { + var b []byte + var err error + + switch p.t { + case FlatPriceType: + b, err = json.Marshal(p.flat) + if err != nil { + return nil, fmt.Errorf("failed to json marshal flat price: %w", err) + } + case UnitPriceType: + b, err = json.Marshal(p.unit) + if err != nil { + return nil, fmt.Errorf("failed to json marshal unit price: %w", err) + } + case TieredPriceType: + b, err = json.Marshal(p.tiered) + if err != nil { + return nil, fmt.Errorf("failed to json marshal tiered price: %w", err) + } + default: + return nil, fmt.Errorf("invalid price type: %s", p.t) + } + + return b, nil +} + +func (p *Price) UnmarshalJSON(bytes []byte) error { + meta := &PriceMeta{} + + if err := json.Unmarshal(bytes, meta); err != nil { + return fmt.Errorf("failed to json unmarshal price type: %w", err) + } + + switch meta.Type { + case FlatPriceType: + v := &FlatPrice{} + if err := json.Unmarshal(bytes, v); err != nil { + return fmt.Errorf("failed to json unmarshal metered entitlement template: %w", err) + } + + p.flat = v + p.t = FlatPriceType + case UnitPriceType: + v := &UnitPrice{} + if err := json.Unmarshal(bytes, v); err != nil { + return fmt.Errorf("failed to json unmarshal metered entitlement template: %w", err) + } + + p.unit = v + p.t = UnitPriceType + case TieredPriceType: + v := &TieredPrice{} + if err := json.Unmarshal(bytes, v); err != nil { + return fmt.Errorf("failed to json unmarshal boolean entitlement template: %w", err) + } + + p.tiered = v + p.t = TieredPriceType + default: + return fmt.Errorf("invalid entitlement type: %s", meta.Type) + } + + return nil +} + +func (p *Price) Validate() error { + switch p.t { + case FlatPriceType: + return p.flat.Validate() + case UnitPriceType: + return p.unit.Validate() + case TieredPriceType: + return p.tiered.Validate() + default: + return errors.New("invalid price: not initialized") + } +} + +func (p *Price) Type() PriceType { + return p.t +} + +func (p *Price) AsFlat() (FlatPrice, error) { + if p.t == "" || p.flat == nil { + return FlatPrice{}, errors.New("invalid price: not initialized") + } + + if p.t != FlatPriceType { + return FlatPrice{}, fmt.Errorf("price type mismatch: %s", p.t) + } + + return *p.flat, nil +} + +func (p *Price) AsUnit() (UnitPrice, error) { + if p.t == "" || p.unit == nil { + return UnitPrice{}, errors.New("invalid price: not initialized") + } + + if p.t != UnitPriceType { + return UnitPrice{}, fmt.Errorf("price type mismatch: %s", p.t) + } + + return *p.unit, nil +} + +func (p *Price) AsTiered() (TieredPrice, error) { + if p.t == "" || p.tiered == nil { + return TieredPrice{}, errors.New("invalid price: not initialized") + } + + if p.t != TieredPriceType { + return TieredPrice{}, fmt.Errorf("price type mismatch: %s", p.t) + } + + return *p.tiered, nil +} + +func (p *Price) FromFlat(price FlatPrice) { + p.flat = &price + p.t = FlatPriceType +} + +func (p *Price) FromUnit(price UnitPrice) { + p.unit = &price + p.t = UnitPriceType +} + +func (p *Price) FromTiered(price TieredPrice) { + p.tiered = &price + p.t = TieredPriceType +} + +func NewPriceFrom[T FlatPrice | UnitPrice | TieredPrice](v T) Price { + p := Price{} + + switch any(v).(type) { + case FlatPrice: + flat := any(v).(FlatPrice) + p.FromFlat(flat) + case UnitPrice: + unit := any(v).(UnitPrice) + p.FromUnit(unit) + case TieredPrice: + tiered := any(v).(TieredPrice) + p.FromTiered(tiered) + } + + return p +} + +type PriceMeta struct { + // Type of the price. + Type PriceType `json:"type"` +} + +type FlatPrice struct { + PriceMeta + + // Amount of the flat price. + Amount decimal.Decimal `json:"amount"` + + // PaymentTerm defines the payment term of the flat price. + // Defaults to InAdvancePaymentTerm. + PaymentTerm *PaymentTermType `json:"payment_term,omitempty"` +} + +func (f FlatPrice) Validate() error { + var errs []error + + if f.Amount.IsNegative() { + errs = append(errs, errors.New("amount must not be negative")) + } + + if f.PaymentTerm != nil && !lo.Contains(PaymentTermType("").Values(), *f.PaymentTerm) { + errs = append(errs, fmt.Errorf("invalid payment term: %s", *f.PaymentTerm)) + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} + +type UnitPrice struct { + PriceMeta + + // Amount of the unit price. + Amount decimal.Decimal `json:"amount"` + + // MinimumAmount defines the least amount the customer committed to spend. + MinimumAmount *decimal.Decimal `json:"minimumAmount,omitempty"` + + // MaximumAmount defines the upper limit of amount the customer entitled to spend. + MaximumAmount *decimal.Decimal `json:"maximumAmount,omitempty"` +} + +func (u UnitPrice) Validate() error { + var errs []error + + if u.Amount.IsNegative() { + errs = append(errs, errors.New("amount must not be negative")) + } + + minAmount := lo.FromPtrOr(u.MinimumAmount, decimal.Zero) + if minAmount.IsNegative() { + errs = append(errs, errors.New("minimum amount must not be negative")) + } + + maxAmount := lo.FromPtrOr(u.MaximumAmount, decimal.Zero) + if maxAmount.IsNegative() { + errs = append(errs, errors.New("maximum amount must not be negative")) + } + + if !minAmount.IsZero() && !maxAmount.IsZero() { + if minAmount.GreaterThan(maxAmount) { + errs = append(errs, errors.New("minimum amount must not be greater than maximum amount")) + } + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} + +const ( + VolumeTieredPrice TieredPriceMode = "volume" + GraduatedTieredPrice TieredPriceMode = "graduated" +) + +type TieredPriceMode string + +func (p TieredPriceMode) Values() []TieredPriceMode { + return []TieredPriceMode{ + VolumeTieredPrice, + GraduatedTieredPrice, + } +} + +func (p TieredPriceMode) StringValues() []string { + return []string{ + string(VolumeTieredPrice), + string(GraduatedTieredPrice), + } +} + +func NewTieredPriceMode(s string) (TieredPriceMode, error) { + switch strings.ToLower(strings.TrimSpace(s)) { + case string(VolumeTieredPrice): + return VolumeTieredPrice, nil + case string(GraduatedTieredPrice): + return GraduatedTieredPrice, nil + default: + return "", fmt.Errorf("invalid tiered price mode: %s", s) + } +} + +type TieredPrice struct { + PriceMeta + + // Mode defines whether the tier is volume-based or graduated. + // * VolumeTieredPrice: the maximum quantity within a period determines the per-unit price + // * GraduatedTieredPrice: pricing can change as the quantity grows + Mode TieredPriceMode `json:"mode"` + + // Tiers defines the list of PriceTier. + Tiers []PriceTier `json:"tiers"` + + // MinimumAmount defines the least amount the customer committed to spend. + MinimumAmount *decimal.Decimal `json:"minimumAmount,omitempty"` + + // MaximumAmount defines the upper limit of amount the customer entitled to spend. + MaximumAmount *decimal.Decimal `json:"maximumAmount,omitempty"` +} + +func (t TieredPrice) Validate() error { + var errs []error + + if !lo.Contains(TieredPriceMode("").Values(), t.Mode) { + errs = append(errs, fmt.Errorf("invalid tiered price mode: %s", t.Mode)) + } + + upToAmounts := make(map[string]struct{}, len(t.Tiers)) + for _, tier := range t.Tiers { + uta := lo.FromPtrOr(tier.UpToAmount, decimal.Zero) + if !uta.IsZero() { + if _, ok := upToAmounts[uta.String()]; ok { + errs = append(errs, errors.New("multiple price tiers with same up-to-amount are not allowed")) + + continue + } + upToAmounts[uta.String()] = struct{}{} + } + + if err := tier.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid price tier: %w", err)) + } + } + + minAmount := lo.FromPtrOr(t.MinimumAmount, decimal.Zero) + if minAmount.IsNegative() { + errs = append(errs, errors.New("minimum amount must not be negative")) + } + + maxAmount := lo.FromPtrOr(t.MaximumAmount, decimal.Zero) + if maxAmount.IsNegative() { + errs = append(errs, errors.New("maximum amount must not be negative")) + } + + if !minAmount.IsZero() && !maxAmount.IsZero() { + if minAmount.GreaterThan(maxAmount) { + errs = append(errs, errors.New("minimum amount must not be greater than maximum amount")) + } + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} + +var _ Validator = (*PriceTier)(nil) + +// PriceTier describes a tier of price(s). +type PriceTier struct { + // UpToAmount defines the quantity will be contained in the tier. Inclusive. + // If null, the tier is open-ended. + UpToAmount *decimal.Decimal `json:"upToAmount,omitempty"` + + // FlatPrice defines the flat price component of the tier. + FlatPrice *FlatPrice `json:"flatPrice,omitempty"` + + // UnitPrice defines the unit price component of the tier. + UnitPrice *UnitPrice `json:"unitPrice,omitempty"` +} + +func (p PriceTier) Validate() error { + var errs []error + + upToAmount := lo.FromPtrOr(p.UpToAmount, decimal.Zero) + if upToAmount.IsNegative() { + errs = append(errs, errors.New("up-to-amount must not be negative")) + } + + if p.FlatPrice != nil { + if err := p.FlatPrice.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid flat price: %w", err)) + } + } + + if p.UnitPrice != nil { + if err := p.UnitPrice.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid unit price: %w", err)) + } + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} diff --git a/openmeter/productcatalog/plan/price_test.go b/openmeter/productcatalog/plan/price_test.go new file mode 100644 index 000000000..2f7c13654 --- /dev/null +++ b/openmeter/productcatalog/plan/price_test.go @@ -0,0 +1,362 @@ +package plan + +import ( + "errors" + "fmt" + "testing" + + decimal "github.com/alpacahq/alpacadecimal" + "github.com/samber/lo" + "github.com/stretchr/testify/assert" +) + +func TestFlatPrice(t *testing.T) { + t.Run("Validate", func(t *testing.T) { + tests := []struct { + Name string + Price FlatPrice + ExpectedError error + }{ + { + Name: "valid", + Price: FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(1000), + PaymentTerm: lo.ToPtr(InArrearsPaymentTerm), + }, + ExpectedError: nil, + }, + { + Name: "invalid", + Price: FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(-1000), + PaymentTerm: lo.ToPtr(PaymentTermType("invalid")), + }, + ExpectedError: errors.Join([]error{ + errors.New("amount must not be negative"), + fmt.Errorf("invalid payment term: %s", "invalid"), + }...), + }, + } + + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + err := test.Price.Validate() + assert.Equal(t, test.ExpectedError, err) + }) + } + }) +} + +func TestUnitPrice(t *testing.T) { + t.Run("Validate", func(t *testing.T) { + tests := []struct { + Name string + Price UnitPrice + ExpectedError error + }{ + { + Name: "valid with min,max", + Price: UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(1000), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(1000)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(5000)), + }, + ExpectedError: nil, + }, + { + Name: "valid with min only", + Price: UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(1000), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(1000)), + MaximumAmount: nil, + }, + ExpectedError: nil, + }, + { + Name: "valid with max only", + Price: UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(1000), + MinimumAmount: nil, + MaximumAmount: lo.ToPtr(decimal.NewFromInt(1000)), + }, + ExpectedError: nil, + }, + { + Name: "invalid", + Price: UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(-1000), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(-1000)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(-2000)), + }, + ExpectedError: errors.Join([]error{ + errors.New("amount must not be negative"), + errors.New("minimum amount must not be negative"), + errors.New("maximum amount must not be negative"), + errors.New("minimum amount must not be greater than maximum amount"), + }...), + }, + } + + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + err := test.Price.Validate() + assert.Equal(t, test.ExpectedError, err) + }) + } + }) +} + +func TestTieredPrice(t *testing.T) { + t.Run("Validate", func(t *testing.T) { + tests := []struct { + Name string + Price TieredPrice + ExpectedError error + }{ + { + Name: "valid with min,max", + Price: TieredPrice{ + PriceMeta: PriceMeta{ + Type: TieredPriceType, + }, + Mode: VolumeTieredPrice, + Tiers: []PriceTier{ + { + UpToAmount: lo.ToPtr(decimal.NewFromInt(1000)), + FlatPrice: &FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(5), + PaymentTerm: lo.ToPtr(InAdvancePaymentTerm), + }, + UnitPrice: &UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(5), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(100)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(1000)), + }, + }, + { + UpToAmount: lo.ToPtr(decimal.NewFromInt(2500)), + FlatPrice: &FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(3), + PaymentTerm: lo.ToPtr(InArrearsPaymentTerm), + }, + UnitPrice: &UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(1), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(2500)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(5000)), + }, + }, + }, + MinimumAmount: lo.ToPtr(decimal.NewFromInt(1000)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(5000)), + }, + ExpectedError: nil, + }, + { + Name: "valid with min only", + Price: TieredPrice{ + PriceMeta: PriceMeta{ + Type: TieredPriceType, + }, + Mode: VolumeTieredPrice, + Tiers: []PriceTier{ + { + UpToAmount: lo.ToPtr(decimal.NewFromInt(1000)), + FlatPrice: &FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(5), + PaymentTerm: lo.ToPtr(InAdvancePaymentTerm), + }, + UnitPrice: &UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(5), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(100)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(1000)), + }, + }, + { + UpToAmount: lo.ToPtr(decimal.NewFromInt(2500)), + FlatPrice: &FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(3), + PaymentTerm: lo.ToPtr(InArrearsPaymentTerm), + }, + UnitPrice: &UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(1), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(2500)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(5000)), + }, + }, + }, + MinimumAmount: lo.ToPtr(decimal.NewFromInt(1000)), + MaximumAmount: nil, + }, + ExpectedError: nil, + }, + { + Name: "valid with max only", + Price: TieredPrice{ + PriceMeta: PriceMeta{ + Type: TieredPriceType, + }, + Mode: VolumeTieredPrice, + Tiers: []PriceTier{ + { + UpToAmount: lo.ToPtr(decimal.NewFromInt(1000)), + FlatPrice: &FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(5), + PaymentTerm: lo.ToPtr(InAdvancePaymentTerm), + }, + UnitPrice: &UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(5), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(100)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(1000)), + }, + }, + { + UpToAmount: lo.ToPtr(decimal.NewFromInt(2500)), + FlatPrice: &FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(3), + PaymentTerm: lo.ToPtr(InArrearsPaymentTerm), + }, + UnitPrice: &UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(1), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(2500)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(5000)), + }, + }, + }, + MinimumAmount: nil, + MaximumAmount: lo.ToPtr(decimal.NewFromInt(1000)), + }, + ExpectedError: nil, + }, + { + Name: "invalid", + Price: TieredPrice{ + PriceMeta: PriceMeta{ + Type: TieredPriceType, + }, + Mode: TieredPriceMode("invalid"), + Tiers: []PriceTier{ + { + UpToAmount: lo.ToPtr(decimal.NewFromInt(-1000)), + FlatPrice: &FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(-5), + PaymentTerm: lo.ToPtr(PaymentTermType("invalid")), + }, + UnitPrice: &UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(-5), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(-100)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(-1000)), + }, + }, + { + UpToAmount: lo.ToPtr(decimal.NewFromInt(-1000)), + FlatPrice: &FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(-3), + PaymentTerm: lo.ToPtr(PaymentTermType("invalid")), + }, + UnitPrice: &UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(-1), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(-2500)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(-5000)), + }, + }, + }, + MinimumAmount: lo.ToPtr(decimal.NewFromInt(-1000)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(-5000)), + }, + ExpectedError: errors.Join([]error{ + errors.New("invalid tiered price mode: invalid"), + fmt.Errorf("invalid price tier: %w", errors.Join([]error{ + errors.New("up-to-amount must not be negative"), + fmt.Errorf("invalid flat price: %w", errors.Join([]error{ + errors.New("amount must not be negative"), + errors.New("invalid payment term: invalid"), + }...)), + fmt.Errorf("invalid unit price: %w", errors.Join([]error{ + errors.New("amount must not be negative"), + errors.New("minimum amount must not be negative"), + errors.New("maximum amount must not be negative"), + errors.New("minimum amount must not be greater than maximum amount"), + }...)), + }...)), + errors.New("multiple price tiers with same up-to-amount are not allowed"), + errors.New("minimum amount must not be negative"), + errors.New("maximum amount must not be negative"), + errors.New("minimum amount must not be greater than maximum amount"), + }...), + }, + } + + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + err := test.Price.Validate() + assert.Equal(t, test.ExpectedError, err) + }) + } + }) +} diff --git a/openmeter/productcatalog/plan/ratecard.go b/openmeter/productcatalog/plan/ratecard.go new file mode 100644 index 000000000..44051c1d4 --- /dev/null +++ b/openmeter/productcatalog/plan/ratecard.go @@ -0,0 +1,348 @@ +package plan + +import ( + "encoding/json" + "errors" + "fmt" + + "github.com/openmeterio/openmeter/openmeter/productcatalog/feature" + "github.com/openmeterio/openmeter/pkg/datex" + "github.com/openmeterio/openmeter/pkg/models" +) + +const ( + FlatFeeRateCardType RateCardType = "flat_fee" + UsageBasedRateCardType RateCardType = "usage_based" +) + +type RateCardType string + +func (s RateCardType) Values() []string { + return []string{ + string(FlatFeeRateCardType), + string(UsageBasedRateCardType), + } +} + +type rateCarder interface { + json.Marshaler + json.Unmarshaler + Validator + + Type() RateCardType + AsFlatFee() (FlatFeeRateCard, error) + AsUsageBased() (UsageBasedRateCard, error) + AsMeta() (RateCardMeta, error) + FromFlatFee(FlatFeeRateCard) + FromUsageBased(UsageBasedRateCard) +} + +var _ rateCarder = (*RateCard)(nil) + +type RateCard struct { + t RateCardType + flatFee *FlatFeeRateCard + usageBased *UsageBasedRateCard +} + +func (r *RateCard) MarshalJSON() ([]byte, error) { + var b []byte + var err error + + switch r.t { + case FlatFeeRateCardType: + b, err = json.Marshal(r.flatFee) + if err != nil { + return nil, fmt.Errorf("failed to json marshal flat fee rate card: %w", err) + } + case UsageBasedRateCardType: + b, err = json.Marshal(r.usageBased) + if err != nil { + return nil, fmt.Errorf("failed to json marshal usage based rate card: %w", err) + } + default: + return nil, fmt.Errorf("invalid entitlement type: %s", r.t) + } + + return b, nil +} + +func (r *RateCard) UnmarshalJSON(bytes []byte) error { + meta := &RateCardMeta{} + + if err := json.Unmarshal(bytes, meta); err != nil { + return fmt.Errorf("failed to json unmarshal rate card type: %w", err) + } + + switch meta.Type { + case FlatFeeRateCardType: + v := &FlatFeeRateCard{} + if err := json.Unmarshal(bytes, v); err != nil { + return fmt.Errorf("failed to json unmarshal flat fee rate card: %w", err) + } + + r.flatFee = v + r.t = FlatFeeRateCardType + case UsageBasedRateCardType: + v := &UsageBasedRateCard{} + if err := json.Unmarshal(bytes, v); err != nil { + return fmt.Errorf("failed to json unmarshal uasge based rate card: %w", err) + } + + r.usageBased = v + r.t = UsageBasedRateCardType + default: + return fmt.Errorf("invalid entitlement type: %s", meta.Type) + } + + return nil +} + +func (r *RateCard) Validate() error { + switch r.t { + case FlatFeeRateCardType: + if r.flatFee != nil { + return r.flatFee.Validate() + } + + return errors.New("invalid rate card: not initialized") + case UsageBasedRateCardType: + if r.usageBased != nil { + return r.usageBased.Validate() + } + + return errors.New("invalid rate card: not initialized") + default: + return fmt.Errorf("invalid rate card type type: %s", r.t) + } +} + +func (r *RateCard) Type() RateCardType { + return r.t +} + +func (r *RateCard) Key() string { + var key string + + switch r.t { + case FlatFeeRateCardType: + if r.flatFee != nil { + key = r.flatFee.Key + } + case UsageBasedRateCardType: + if r.usageBased != nil { + key = r.usageBased.Key + } + } + + return key +} + +func (r *RateCard) Namespace() string { + var ns string + + switch r.t { + case FlatFeeRateCardType: + if r.flatFee != nil { + ns = r.flatFee.Namespace + } + case UsageBasedRateCardType: + if r.usageBased != nil { + ns = r.usageBased.Namespace + } + } + + return ns +} + +func (r *RateCard) AsFlatFee() (FlatFeeRateCard, error) { + if r.t == "" || r.flatFee == nil { + return FlatFeeRateCard{}, errors.New("invalid rate card: not initialized") + } + + return *r.flatFee, nil +} + +func (r *RateCard) AsUsageBased() (UsageBasedRateCard, error) { + if r.t == "" || r.usageBased == nil { + return UsageBasedRateCard{}, errors.New("invalid rate card: not initialized") + } + + if r.t != UsageBasedRateCardType { + return UsageBasedRateCard{}, fmt.Errorf("rate card type mismatch: %s", r.t) + } + + return *r.usageBased, nil +} + +func (r *RateCard) AsMeta() (RateCardMeta, error) { + if r.t == "" { + return RateCardMeta{}, errors.New("invalid rate card: not initialized") + } + + switch r.t { + case FlatFeeRateCardType: + return r.flatFee.RateCardMeta, nil + case UsageBasedRateCardType: + return r.usageBased.RateCardMeta, nil + default: + return RateCardMeta{}, fmt.Errorf("rate card type mismatch: %s", r.t) + } +} + +func (r *RateCard) FromFlatFee(c FlatFeeRateCard) { + r.flatFee = &c + r.t = FlatFeeRateCardType +} + +func (r *RateCard) FromUsageBased(c UsageBasedRateCard) { + r.usageBased = &c + r.t = UsageBasedRateCardType +} + +func NewRateCardFrom[T FlatFeeRateCard | UsageBasedRateCard](c T) RateCard { + r := &RateCard{} + + switch any(c).(type) { + case FlatFeeRateCard: + flatFee := any(c).(FlatFeeRateCard) + r.FromFlatFee(flatFee) + case UsageBasedRateCard: + usageBased := any(c).(UsageBasedRateCard) + r.FromUsageBased(usageBased) + } + + return *r +} + +var _ Validator = (*RateCardMeta)(nil) + +type RateCardMeta struct { + models.NamespacedID + models.ManagedModel + + // Key is the unique key for Plan. + Key string `json:"key"` + + // Type defines the type of the RateCard + Type RateCardType `json:"type"` + + // Name of the RateCard + Name string `json:"name"` + + // Description for the RateCard + Description *string `json:"description,omitempty"` + + // Metadata a set of key/value pairs describing metadata for the RateCard + Metadata map[string]string `json:"metadata,omitempty"` + + // Feature defines optional Feature assigned to RateCard + Feature *feature.Feature `json:"feature,omitempty"` + + // EntitlementTemplate defines the template used for instantiating entitlement.Entitlement. + // If Feature is set then template must be provided as well. + EntitlementTemplate *EntitlementTemplate `json:"entitlementTemplate,omitempty"` + + // TaxConfig defines provider specific tax information. + TaxConfig *TaxConfig `json:"taxConfig,omitempty"` + + // PhaseID is the ULID identifier of the Phase the RateCard belongs to. + PhaseID string `json:"-"` +} + +func (r *RateCardMeta) Validate() error { + var errs []error + + // TODO: invoke feature validation here as soon as there is implemented one. + + if r.EntitlementTemplate != nil { + if err := r.EntitlementTemplate.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid entitlement template: %w", err)) + } + } + + if r.TaxConfig != nil { + if err := r.TaxConfig.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid tax config: %w", err)) + } + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} + +var _ Validator = (*FlatFeeRateCard)(nil) + +type FlatFeeRateCard struct { + RateCardMeta + + // BillingCadence defines the billing cadence of the RateCard in ISO8601 format. + // When nil (null) it means it is a one time fee. + // Example: "P1D12H" + BillingCadence *datex.Period `json:"billingCadence"` + + // Price defines the price for the RateCard + Price Price `json:"price"` +} + +func (r *FlatFeeRateCard) Validate() error { + var errs []error + + if err := r.RateCardMeta.Validate(); err != nil { + errs = append(errs, err) + } + + if r.BillingCadence != nil { + if r.BillingCadence.IsNegative() || r.BillingCadence.IsZero() { + errs = append(errs, errors.New("billing cadence must not be negative or zero")) + } + } + + if err := r.Price.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid price: %w", err)) + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} + +var _ Validator = (*UsageBasedRateCard)(nil) + +type UsageBasedRateCard struct { + RateCardMeta + + // BillingCadence defines the billing cadence of the RateCard in ISO8601 format. + // Example: "P1D12H" + BillingCadence datex.Period `json:"billingCadence"` + + // Price defines the price for the RateCard + Price *Price `json:"price"` +} + +func (r *UsageBasedRateCard) Validate() error { + var errs []error + + if err := r.RateCardMeta.Validate(); err != nil { + errs = append(errs, err) + } + + if r.BillingCadence.IsNegative() || r.BillingCadence.IsZero() { + errs = append(errs, errors.New("billing cadence must not be negative or zero")) + } + + if err := r.Price.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid price: %w", err)) + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} diff --git a/openmeter/productcatalog/plan/ratecard_test.go b/openmeter/productcatalog/plan/ratecard_test.go new file mode 100644 index 000000000..441d2d5ac --- /dev/null +++ b/openmeter/productcatalog/plan/ratecard_test.go @@ -0,0 +1,339 @@ +package plan + +import ( + "testing" + "time" + + decimal "github.com/alpacahq/alpacadecimal" + "github.com/samber/lo" + "github.com/stretchr/testify/assert" + + "github.com/openmeterio/openmeter/openmeter/entitlement" + "github.com/openmeterio/openmeter/openmeter/productcatalog/feature" + "github.com/openmeterio/openmeter/pkg/datex" + "github.com/openmeterio/openmeter/pkg/models" +) + +func TestFlatFeeRateCard(t *testing.T) { + t.Run("Validate", func(t *testing.T) { + tests := []struct { + Name string + RateCard FlatFeeRateCard + ExpectedError bool + }{ + { + Name: "valid", + RateCard: FlatFeeRateCard{ + RateCardMeta: RateCardMeta{ + NamespacedID: models.NamespacedID{ + Namespace: "namespace-1", + ID: "01JBP3SGZ2WVRN5N746HKJR67X", + }, + ManagedModel: models.ManagedModel{ + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + DeletedAt: &time.Time{}, + }, + Key: "flat-1", + Type: FlatFeeRateCardType, + Name: "Flat 1", + Description: lo.ToPtr("Flat 1"), + Metadata: map[string]string{ + "name": "Flat 1", + }, + Feature: &feature.Feature{ + Namespace: "namespace-1", + ID: "01JBP3SGZ20Y7VRVC351TDFXYZ", + Name: "Feature 1", + Key: "feat-1", + MeterSlug: lo.ToPtr("meter-1"), + MeterGroupByFilters: nil, + Metadata: map[string]string{ + "name": "Feature 1", + }, + ArchivedAt: &time.Time{}, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + EntitlementTemplate: &EntitlementTemplate{ + t: entitlement.EntitlementTypeStatic, + static: &StaticEntitlementTemplate{ + EntitlementTemplateMeta: EntitlementTemplateMeta{ + Type: entitlement.EntitlementTypeStatic, + }, + Metadata: map[string]string{ + "name": "static-1", + }, + Config: []byte("\"test\""), + }, + }, + TaxConfig: &TaxConfig{ + Stripe: &StripeTaxConfig{ + Code: "txcd_99999999", + }, + }, + PhaseID: "", + }, + BillingCadence: lo.ToPtr(datex.MustParse(t, "P1M")), + Price: Price{ + t: FlatPriceType, + flat: &FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(1000), + PaymentTerm: lo.ToPtr(InArrearsPaymentTerm), + }, + }, + }, + ExpectedError: false, + }, + { + Name: "invalid", + RateCard: FlatFeeRateCard{ + RateCardMeta: RateCardMeta{ + NamespacedID: models.NamespacedID{ + Namespace: "namespace-2", + ID: "01JBP3SGZ26YSACQ7HQRZHZAMH", + }, + ManagedModel: models.ManagedModel{ + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + DeletedAt: &time.Time{}, + }, + Key: "flat-2", + Type: FlatFeeRateCardType, + Name: "Flat 2", + Description: lo.ToPtr("Flat 2"), + Metadata: map[string]string{ + "name": "Flat 2", + }, + Feature: &feature.Feature{ + Namespace: "namespace-2", + ID: "01JBP3SGZ2YTM6DVH2W318TPNH", + Name: "Feature 2", + Key: "feat-2", + MeterSlug: lo.ToPtr("meter-2"), + MeterGroupByFilters: nil, + Metadata: map[string]string{ + "name": "Feature 2", + }, + ArchivedAt: &time.Time{}, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + EntitlementTemplate: &EntitlementTemplate{ + t: entitlement.EntitlementTypeStatic, + static: &StaticEntitlementTemplate{ + EntitlementTemplateMeta: EntitlementTemplateMeta{ + Type: entitlement.EntitlementTypeStatic, + }, + Metadata: map[string]string{ + "name": "static-1", + }, + Config: []byte("invalid JSON"), + }, + }, + TaxConfig: &TaxConfig{ + Stripe: &StripeTaxConfig{ + Code: "invalid_code", + }, + }, + PhaseID: "", + }, + BillingCadence: lo.ToPtr(datex.MustParse(t, "P0M")), + Price: Price{ + t: FlatPriceType, + flat: &FlatPrice{ + PriceMeta: PriceMeta{ + Type: FlatPriceType, + }, + Amount: decimal.NewFromInt(-1000), + PaymentTerm: lo.ToPtr(PaymentTermType("invalid")), + }, + }, + }, + ExpectedError: true, + }, + } + + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + err := test.RateCard.Validate() + + if test.ExpectedError { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } + }) + } + }) +} + +func TestUsageBasedRateCard(t *testing.T) { + t.Run("Validate", func(t *testing.T) { + tests := []struct { + Name string + RateCard UsageBasedRateCard + ExpectedError bool + }{ + { + Name: "valid", + RateCard: UsageBasedRateCard{ + RateCardMeta: RateCardMeta{ + NamespacedID: models.NamespacedID{ + Namespace: "namespace-1", + ID: "01JBP3SGZ2WVRN5N746HKJR67X", + }, + ManagedModel: models.ManagedModel{ + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + DeletedAt: &time.Time{}, + }, + Key: "usage-1", + Type: UsageBasedRateCardType, + Name: "Usage 1", + Description: lo.ToPtr("Usage 1"), + Metadata: map[string]string{ + "name": "usage-1", + }, + Feature: &feature.Feature{ + Namespace: "namespace-1", + ID: "01JBP3SGZ20Y7VRVC351TDFXYZ", + Name: "Feature 1", + Key: "feat-1", + MeterSlug: lo.ToPtr("meter-1"), + MeterGroupByFilters: nil, + Metadata: map[string]string{ + "name": "Feature 1", + }, + ArchivedAt: &time.Time{}, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + EntitlementTemplate: &EntitlementTemplate{ + t: entitlement.EntitlementTypeMetered, + metered: &MeteredEntitlementTemplate{ + EntitlementTemplateMeta: EntitlementTemplateMeta{ + Type: entitlement.EntitlementTypeMetered, + }, + Metadata: map[string]string{ + "name": "Entitlement 1", + }, + IsSoftLimit: true, + IssueAfterReset: lo.ToPtr(500.0), + IssueAfterResetPriority: lo.ToPtr[uint8](1), + PreserveOverageAtReset: nil, + UsagePeriod: datex.MustParse(t, "P1M"), + }, + }, + TaxConfig: &TaxConfig{ + Stripe: &StripeTaxConfig{ + Code: "txcd_99999999", + }, + }, + PhaseID: "", + }, + BillingCadence: datex.MustParse(t, "P1M"), + Price: lo.ToPtr(Price{ + t: UnitPriceType, + unit: &UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(1000), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(500)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(1500)), + }, + }), + }, + ExpectedError: false, + }, + { + Name: "invalid", + RateCard: UsageBasedRateCard{ + RateCardMeta: RateCardMeta{ + NamespacedID: models.NamespacedID{ + Namespace: "namespace-2", + ID: "01JBWYPN0A4NJW0HCYVP47WQZ5", + }, + ManagedModel: models.ManagedModel{ + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + DeletedAt: &time.Time{}, + }, + Key: "usage-2", + Type: UsageBasedRateCardType, + Name: "Usage 2", + Description: lo.ToPtr("Usage 2"), + Metadata: map[string]string{ + "name": "usage-2", + }, + Feature: &feature.Feature{ + Namespace: "namespace-2", + ID: "01JBWYR0G2PYB9DVADKQXF8E0P", + Name: "Feature 2", + Key: "feat-2", + MeterSlug: lo.ToPtr("meter-2"), + MeterGroupByFilters: nil, + Metadata: map[string]string{ + "name": "Feature 2", + }, + ArchivedAt: &time.Time{}, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + EntitlementTemplate: &EntitlementTemplate{ + t: entitlement.EntitlementTypeMetered, + metered: &MeteredEntitlementTemplate{ + EntitlementTemplateMeta: EntitlementTemplateMeta{ + Type: entitlement.EntitlementTypeMetered, + }, + Metadata: map[string]string{ + "name": "Entitlement 1", + }, + IsSoftLimit: true, + IssueAfterReset: lo.ToPtr(500.0), + IssueAfterResetPriority: lo.ToPtr[uint8](1), + PreserveOverageAtReset: nil, + UsagePeriod: datex.MustParse(t, "P1M"), + }, + }, + TaxConfig: &TaxConfig{ + Stripe: &StripeTaxConfig{ + Code: "invalid_code", + }, + }, + PhaseID: "", + }, + BillingCadence: datex.MustParse(t, "P0M"), + Price: lo.ToPtr(Price{ + t: UnitPriceType, + unit: &UnitPrice{ + PriceMeta: PriceMeta{ + Type: UnitPriceType, + }, + Amount: decimal.NewFromInt(-1000), + MinimumAmount: lo.ToPtr(decimal.NewFromInt(1500)), + MaximumAmount: lo.ToPtr(decimal.NewFromInt(500)), + }, + }), + }, + ExpectedError: true, + }, + } + + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + err := test.RateCard.Validate() + + if test.ExpectedError { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } + }) + } + }) +} diff --git a/openmeter/productcatalog/plan/tax.go b/openmeter/productcatalog/plan/tax.go new file mode 100644 index 000000000..0c4251bcd --- /dev/null +++ b/openmeter/productcatalog/plan/tax.go @@ -0,0 +1,45 @@ +package plan + +import ( + "errors" + "fmt" + "regexp" +) + +// TaxConfig stores the provider specific tax configs. +type TaxConfig struct { + Stripe *StripeTaxConfig `json:"stripe,omitempty"` +} + +func (c TaxConfig) Validate() error { + var errs []error + + if c.Stripe != nil { + if err := c.Stripe.Validate(); err != nil { + errs = append(errs, fmt.Errorf("invalid stripe config: %w", err)) + } + } + + if len(errs) > 0 { + return errors.Join(errs...) + } + + return nil +} + +var StripeProductTaxCodeRegexp = regexp.MustCompile(`^txcd_\d{8}$`) + +type StripeTaxConfig struct { + // Code stores the product tax code. + // See: https://docs.stripe.com/tax/tax-codes + // Example:"txcd_10000000" + Code string `json:"code"` +} + +func (s StripeTaxConfig) Validate() error { + if s.Code != "" && !StripeProductTaxCodeRegexp.MatchString(s.Code) { + return fmt.Errorf("invalid product tax code: %s", s.Code) + } + + return nil +} diff --git a/openmeter/productcatalog/plan/tax_test.go b/openmeter/productcatalog/plan/tax_test.go new file mode 100644 index 000000000..61484a5d5 --- /dev/null +++ b/openmeter/productcatalog/plan/tax_test.go @@ -0,0 +1,36 @@ +package plan + +import ( + "errors" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestStripeTaxConfig(t *testing.T) { + tests := []struct { + Name string + TaxConfig StripeTaxConfig + ExpectedError error + }{ + { + Name: "valid", + TaxConfig: StripeTaxConfig{ + Code: "txcd_99999999", + }, + ExpectedError: nil, + }, + { + Name: "invalid", + TaxConfig: StripeTaxConfig{ + Code: "invalid_tax_code", + }, + ExpectedError: errors.New("invalid product tax code: invalid_tax_code"), + }, + } + + for _, test := range tests { + err := test.TaxConfig.Validate() + assert.Equal(t, test.ExpectedError, err) + } +} diff --git a/openmeter/productcatalog/plan/utils.go b/openmeter/productcatalog/plan/utils.go new file mode 100644 index 000000000..ba19f6651 --- /dev/null +++ b/openmeter/productcatalog/plan/utils.go @@ -0,0 +1,24 @@ +package plan + +// MetadataEqual returns false if the two metadata hashmaps are differ +func MetadataEqual(left, right map[string]string) bool { + if len(left) != len(right) { + return false + } + + visited := make([]string, 0, len(right)) + for lk, lv := range left { + rv, ok := right[lk] + if !ok { + return false + } + + if lv != rv { + return false + } + + visited = append(visited, lk) + } + + return len(visited) == len(right) +} diff --git a/openmeter/productcatalog/plan/utils_test.go b/openmeter/productcatalog/plan/utils_test.go new file mode 100644 index 000000000..8ff95a941 --- /dev/null +++ b/openmeter/productcatalog/plan/utils_test.go @@ -0,0 +1,81 @@ +package plan + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMetadataEqual(t *testing.T) { + tests := []struct { + Name string + + Left map[string]string + Right map[string]string + + ExpectedResult bool + }{ + { + Name: "Equal", + Left: map[string]string{ + "key1": "value1", + "key2": "value2", + "key3": "value3", + }, + Right: map[string]string{ + "key1": "value1", + "key2": "value2", + "key3": "value3", + }, + ExpectedResult: true, + }, + { + Name: "Left diff", + Left: map[string]string{ + "key1": "value1", + "key2": "value2", + "key3": "value3", + }, + Right: map[string]string{ + "key1": "value1", + "key2": "value2", + }, + ExpectedResult: false, + }, + { + Name: "Right diff", + Left: map[string]string{ + "key1": "value1", + "key2": "value2", + }, + Right: map[string]string{ + "key1": "value1", + "key2": "value2", + "key3": "value3", + }, + ExpectedResult: false, + }, + { + Name: "Complete diff", + Left: map[string]string{ + "key1": "value1", + "key2": "value2", + "key3": "value3", + }, + Right: map[string]string{ + "key4": "value4", + "key5": "value5", + "key6": "value6", + }, + ExpectedResult: false, + }, + } + + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + result := MetadataEqual(test.Left, test.Right) + + assert.Equal(t, test.ExpectedResult, result) + }) + } +} diff --git a/openmeter/productcatalog/plan/validator.go b/openmeter/productcatalog/plan/validator.go new file mode 100644 index 000000000..a42ec5bcc --- /dev/null +++ b/openmeter/productcatalog/plan/validator.go @@ -0,0 +1,6 @@ +package plan + +type Validator interface { + // Validate returns an error if the instance of the Validator is invalid. + Validate() error +} diff --git a/pkg/framework/entutils/valuescanner.go b/pkg/framework/entutils/valuescanner.go new file mode 100644 index 000000000..1dc658164 --- /dev/null +++ b/pkg/framework/entutils/valuescanner.go @@ -0,0 +1,30 @@ +package entutils + +import ( + "database/sql/driver" + "encoding/json" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/schema/field" +) + +func JSONStringValueScanner[T any]() field.ValueScannerFunc[T, *sql.NullString] { + return field.ValueScannerFunc[T, *sql.NullString]{ + V: func(t T) (driver.Value, error) { + return json.Marshal(t) + }, + S: func(ns *sql.NullString) (T, error) { + v := new(T) + if ns == nil || !ns.Valid { + return *v, nil + } + + b := []byte(ns.String) + if err := json.Unmarshal(b, v); err != nil { + return *v, err + } + + return *v, nil + }, + } +} diff --git a/tools/migrate/migrations/20241105171821_plan.down.sql b/tools/migrate/migrations/20241105171821_plan.down.sql new file mode 100644 index 000000000..94ba3410d --- /dev/null +++ b/tools/migrate/migrations/20241105171821_plan.down.sql @@ -0,0 +1,40 @@ +-- reverse: create index "planratecard_phase_id_key" to table: "plan_rate_cards" +DROP INDEX "planratecard_phase_id_key"; +-- reverse: create index "planratecard_phase_id_feature_key" to table: "plan_rate_cards" +DROP INDEX "planratecard_phase_id_feature_key"; +-- reverse: create index "planratecard_namespace_key_deleted_at" to table: "plan_rate_cards" +DROP INDEX "planratecard_namespace_key_deleted_at"; +-- reverse: create index "planratecard_namespace_id" to table: "plan_rate_cards" +DROP INDEX "planratecard_namespace_id"; +-- reverse: create index "planratecard_namespace" to table: "plan_rate_cards" +DROP INDEX "planratecard_namespace"; +-- reverse: create index "planratecard_id" to table: "plan_rate_cards" +DROP INDEX "planratecard_id"; +-- reverse: create "plan_rate_cards" table +DROP TABLE "plan_rate_cards"; +-- reverse: create index "planphase_plan_id_key" to table: "plan_phases" +DROP INDEX "planphase_plan_id_key"; +-- reverse: create index "planphase_namespace_key_deleted_at" to table: "plan_phases" +DROP INDEX "planphase_namespace_key_deleted_at"; +-- reverse: create index "planphase_namespace_key" to table: "plan_phases" +DROP INDEX "planphase_namespace_key"; +-- reverse: create index "planphase_namespace_id" to table: "plan_phases" +DROP INDEX "planphase_namespace_id"; +-- reverse: create index "planphase_namespace" to table: "plan_phases" +DROP INDEX "planphase_namespace"; +-- reverse: create index "planphase_id" to table: "plan_phases" +DROP INDEX "planphase_id"; +-- reverse: create "plan_phases" table +DROP TABLE "plan_phases"; +-- reverse: create index "plan_namespace_key_version" to table: "plans" +DROP INDEX "plan_namespace_key_version"; +-- reverse: create index "plan_namespace_key_deleted_at" to table: "plans" +DROP INDEX "plan_namespace_key_deleted_at"; +-- reverse: create index "plan_namespace_id" to table: "plans" +DROP INDEX "plan_namespace_id"; +-- reverse: create index "plan_namespace" to table: "plans" +DROP INDEX "plan_namespace"; +-- reverse: create index "plan_id" to table: "plans" +DROP INDEX "plan_id"; +-- reverse: create "plans" table +DROP TABLE "plans"; diff --git a/tools/migrate/migrations/20241105171821_plan.up.sql b/tools/migrate/migrations/20241105171821_plan.up.sql new file mode 100644 index 000000000..5e1b0168e --- /dev/null +++ b/tools/migrate/migrations/20241105171821_plan.up.sql @@ -0,0 +1,91 @@ +-- create "plans" table +CREATE TABLE "plans" ( + "id" character(26) NOT NULL, + "namespace" character varying NOT NULL, + "metadata" jsonb NULL, + "created_at" timestamptz NOT NULL, + "updated_at" timestamptz NOT NULL, + "deleted_at" timestamptz NULL, + "name" character varying NOT NULL, + "description" character varying NULL, + "key" character varying NOT NULL, + "version" bigint NOT NULL, + "currency" character varying NOT NULL DEFAULT 'USD', + "effective_from" timestamptz NULL, + "effective_to" timestamptz NULL, + PRIMARY KEY ("id") +); +-- create index "plan_id" to table: "plans" +CREATE UNIQUE INDEX "plan_id" ON "plans" ("id"); +-- create index "plan_namespace" to table: "plans" +CREATE INDEX "plan_namespace" ON "plans" ("namespace"); +-- create index "plan_namespace_id" to table: "plans" +CREATE UNIQUE INDEX "plan_namespace_id" ON "plans" ("namespace", "id"); +-- create index "plan_namespace_key_deleted_at" to table: "plans" +CREATE UNIQUE INDEX "plan_namespace_key_deleted_at" ON "plans" ("namespace", "key", "deleted_at"); +-- create index "plan_namespace_key_version" to table: "plans" +CREATE UNIQUE INDEX "plan_namespace_key_version" ON "plans" ("namespace", "key", "version"); +-- create "plan_phases" table +CREATE TABLE "plan_phases" ( + "id" character(26) NOT NULL, + "namespace" character varying NOT NULL, + "metadata" jsonb NULL, + "created_at" timestamptz NOT NULL, + "updated_at" timestamptz NOT NULL, + "deleted_at" timestamptz NULL, + "name" character varying NOT NULL, + "description" character varying NULL, + "key" character varying NOT NULL, + "start_after" character varying NOT NULL DEFAULT 'P0D', + "discounts" jsonb NULL, + "plan_id" character(26) NOT NULL, + PRIMARY KEY ("id"), + CONSTRAINT "plan_phases_plans_phases" FOREIGN KEY ("plan_id") REFERENCES "plans" ("id") ON UPDATE NO ACTION ON DELETE CASCADE +); +-- create index "planphase_id" to table: "plan_phases" +CREATE UNIQUE INDEX "planphase_id" ON "plan_phases" ("id"); +-- create index "planphase_namespace" to table: "plan_phases" +CREATE INDEX "planphase_namespace" ON "plan_phases" ("namespace"); +-- create index "planphase_namespace_id" to table: "plan_phases" +CREATE UNIQUE INDEX "planphase_namespace_id" ON "plan_phases" ("namespace", "id"); +-- create index "planphase_namespace_key" to table: "plan_phases" +CREATE INDEX "planphase_namespace_key" ON "plan_phases" ("namespace", "key"); +-- create index "planphase_namespace_key_deleted_at" to table: "plan_phases" +CREATE UNIQUE INDEX "planphase_namespace_key_deleted_at" ON "plan_phases" ("namespace", "key", "deleted_at"); +-- create index "planphase_plan_id_key" to table: "plan_phases" +CREATE UNIQUE INDEX "planphase_plan_id_key" ON "plan_phases" ("plan_id", "key"); +-- create "plan_rate_cards" table +CREATE TABLE "plan_rate_cards" ( + "id" character(26) NOT NULL, + "namespace" character varying NOT NULL, + "metadata" jsonb NULL, + "created_at" timestamptz NOT NULL, + "updated_at" timestamptz NOT NULL, + "deleted_at" timestamptz NULL, + "name" character varying NOT NULL, + "description" character varying NULL, + "key" character varying NOT NULL, + "type" character varying NOT NULL, + "feature_key" character varying NULL, + "entitlement_template" jsonb NULL, + "tax_config" jsonb NULL, + "billing_cadence" character varying NULL, + "price" jsonb NULL, + "feature_id" character(26) NULL, + "phase_id" character(26) NOT NULL, + PRIMARY KEY ("id"), + CONSTRAINT "plan_rate_cards_features_ratecard" FOREIGN KEY ("feature_id") REFERENCES "features" ("id") ON UPDATE NO ACTION ON DELETE SET NULL, + CONSTRAINT "plan_rate_cards_plan_phases_ratecards" FOREIGN KEY ("phase_id") REFERENCES "plan_phases" ("id") ON UPDATE NO ACTION ON DELETE CASCADE +); +-- create index "planratecard_id" to table: "plan_rate_cards" +CREATE UNIQUE INDEX "planratecard_id" ON "plan_rate_cards" ("id"); +-- create index "planratecard_namespace" to table: "plan_rate_cards" +CREATE INDEX "planratecard_namespace" ON "plan_rate_cards" ("namespace"); +-- create index "planratecard_namespace_id" to table: "plan_rate_cards" +CREATE UNIQUE INDEX "planratecard_namespace_id" ON "plan_rate_cards" ("namespace", "id"); +-- create index "planratecard_namespace_key_deleted_at" to table: "plan_rate_cards" +CREATE UNIQUE INDEX "planratecard_namespace_key_deleted_at" ON "plan_rate_cards" ("namespace", "key", "deleted_at"); +-- create index "planratecard_phase_id_feature_key" to table: "plan_rate_cards" +CREATE UNIQUE INDEX "planratecard_phase_id_feature_key" ON "plan_rate_cards" ("phase_id", "feature_key"); +-- create index "planratecard_phase_id_key" to table: "plan_rate_cards" +CREATE UNIQUE INDEX "planratecard_phase_id_key" ON "plan_rate_cards" ("phase_id", "key"); diff --git a/tools/migrate/migrations/atlas.sum b/tools/migrate/migrations/atlas.sum index 37962445f..40c73d364 100644 --- a/tools/migrate/migrations/atlas.sum +++ b/tools/migrate/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:KjdCAts0/JY1zpyAFxauj89SER4apdi65prH0pmdK3A= +h1:iVe3zTNhb6G7IUuP6UAnUza1mUCIZ1+pBhOBnfLfDLM= 20240826120919_init.down.sql h1:AIbgwwngjkJEYa3yRZsIXQyBa2+qoZttwMXHxXEbHLI= 20240826120919_init.up.sql h1:/hYHWF3Z3dab8SMKnw99ixVktCuJe2bAw5wstCZIEN8= 20240903155435_entitlement-expired-index.down.sql h1:np2xgYs3KQ2z7qPBcobtGNhqWQ3V8NwEP9E5U3TmpSA= @@ -37,3 +37,5 @@ h1:KjdCAts0/JY1zpyAFxauj89SER4apdi65prH0pmdK3A= 20241102151321_customer_filters.up.sql h1:8WP1TCYtV9+LABNfrujGhJqqYiqyaNJXWTE/xXK8ukc= 20241103150058_billing-validation-issues.down.sql h1:qwhd2An7iYL6Wrzbl3DDT7OOTuXdMgtvRMdod9wBAoI= 20241103150058_billing-validation-issues.up.sql h1:LtBQCcCPEtm2VQuIXYTfk9335xlKyeZLFR38knmTqPk= +20241105171821_plan.down.sql h1:TiTrI/fgGxJQgHZu+rnSjHKqCh+dlR02uXR9c4NPbI0= +20241105171821_plan.up.sql h1:sA1026KYY5Hhxst4QyrfyFVTV5FL6gDGtYwGCk8gOlg=