Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(pricing): implement new pricing tiers (#2051)
Will Hutchinsonb94c59daad17
diff --git a/.env-local.enc b/.env-local.encindex d7b170a18e..cd3924e6a8 100644--- a/.env-local.enc+++ b/.env-local.enc@@ -117,6 +117,9 @@ GITHUB_WEBHOOK_SECRET_KEY=ENC[AES256_GCM,data:tWL06eZICn0MEwmC8gL6piEnxV/Z7KTskFGITHUB_SYNC_APP_URL=ENC[AES256_GCM,data:CWXHrHGKV+DvcEJQaPG+VLmKtPmxr6E/mGKBxYVZsh9VTtNizscndw==,iv:gNrnMjQdEzg7mxFOyqhu9GeODHYXWFK/QYIDLt4UzyU=,tag:fdvbEimuX7qj8hCRJRDrNA==,type:str]GITHUB_SYNC_APP_PEM_SECRET_KEY=ENC[AES256_GCM,data:pXfLkLlU18W5YRrTEDQBmwk+PjPCCI2FEpVgpsVzep+Uwd8sd9xutrhf3m2CapEtm7fawfKEtxBT44Gn1tn4SyPuoalhytEWemzQqNVKLtaly+oTPF8HNkTzyaJEBtkMMSA7beJkaUnqwqBfhGJkuzIoT4/mg7MduqFI+cMBIyD9PlLBAQ1lhalrqXStoVGhHP01TH8gOzZVSM8jq6CNh2RH2FnkGnBRAvtB6/AgadCRikzJ3Rmi8kQCqxRp9sh9knJxSqpcJNZsJGt1+9GjAm5BgJZXr5ROMjyIqn2XhuvZeiYPqi7M7zixUUBARhX8ZZH89dZ5PQlR42Fcw/EEjZSpdLWhSPs3oYI/OIUL7dCaUKCCZxh2jrNqAo0JwozBNcMLblF8+fFUXKSRjMuFl7O0L2c0y6CKkpvya+6xGlhH26E9tCfQZ5TZDT0P45ibyRLHS5/UvfHVvzb4yFDrErm96EOJLI3+DO8i9MK3OjwK56857MlU5fX9VnxLRhBps0Zs4o6UBKEndNDj4nF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Xik4vXzwzlMiYtHuQNUkoI6L10=,iv:F0ghJOngMJURVGqbQEcrNUEARTo3uGKr2Ia6E9eXr/Y=,tag:HNoZAEbAtxfpur7wtKnxCg==,type:str]+STRIPE_PRICE_ID_OPUS=ENC[AES256_GCM,data:EWmSRm5ncUnZSfPX+TB6Q+Er9wfMpQFJTLtpwzcmH24=,iv:ySoEAspKd79+M88H9Fhcg4iVRqpebX6j+K/+YLZHMS0=,tag:BA/1DscWnUGbNC7lgU/qTg==,type:str]sops_age__list_0__map_enc=-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHBpdi1wMjU2IEUzMVUyZyBBM1lmcDc3\nUENpRVorSGVGa3R2NFlrdkx1Mm43aEcyR1ZtbEswL2RnWHlqMwpVMnY4ck5makNC\nZzVZc3JrZ3NKV2x3RTY0TFovRXJtVzEyeFZOZWRheHBNCi0tLSBobjhCbHpJa25s\nZDhyQjhCaEYrOWNiWHZkRWpnRlkwTnNEbjMwYzdxcTUwCqxxxmXy3mFUAbAy29y8\n2DFYDATdVvmplHpDTvgrNyY+lAL/3Jp9vtIs5DGXW/r73Nv3AhISmuCid18qhpAY\nUqE=\n-----END AGE ENCRYPTED FILE-----\nsops_age__list_0__map_recipient=age1yubikey1qw64ag5lzvn9ekrflu5ruj4a6ucycscl6ctk39fjzf76jptsay39z442pxvsops_kms__list_0__map_arn=arn:aws:kms:us-east-1:569036502058:key/mrk-cab29bf948044eb79005a81f48d40e93@@ -127,7 +130,7 @@ sops_kms__list_1__map_arn=arn:aws:kms:us-west-1:569036502058:key/mrk-cab29bf9480sops_kms__list_1__map_aws_profile=sops_kms__list_1__map_created_at=2026-03-03T19:32:07Zsops_kms__list_1__map_enc=AQICAHjuYcSMsjB0lKJtZ3DIAvxF8N3RNRn5KZaAN74Et6122wFUqf7u/HEfCUGv7j69Mb6YAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMpcJQR1XeIAFFE7ebAgEQgDvYRYIWelwN8TuwA+6fZVaB34yKo9EQ5xPLr/3BU+ro1Mn2eBPCg3q8ie2LuE/3voim1X35P/cdtDqTZg==-sops_lastmodified=2026-03-09T15:11:09Z-sops_mac=ENC[AES256_GCM,data:pUaHbcnc7wzmnvn5jdJMOWUWZ1exHRo9QTz/zCdUUFv4XLrVrwcwEtMHpak9dPHvsG4+eWfU4vUjKeTJ3NK2tZp3k5irC+s8XjALd0JjyS+k6jJF6sqxzkSf7UFChxM+mq9vVqY5Blo35ObT8E5PCQbdgNRmTUqMJZLqDEWZLKw=,iv:MLe2EfkffywyrmbkIM6YBTHNDZHmwR/JCsqrCYRsAyA=,tag:mC0ND4ZfQdp0PwgLFCvV6g==,type:str]+sops_lastmodified=2026-03-19T16:11:04Z+sops_mac=ENC[AES256_GCM,data:XW0l5ppZfEx2qPw2dZoDgt1euTe0TDGyxfuMv3pHCCOOlsj7VP9L59b5S1NDt/OM3Gw2XPnV5eNWptbXNsI95LJMWP7JNwyGe0b6jt7ZL59kBnqSAi1gPsvFHvsA3JpGbj3hQpvtwgRzXa5ENBSbu9eJjgLWfXkIHCLyAZREI34=,iv:Eexw2zeiEOIRUeWAm4mnNERQqa2bTBDas9zIV/rISL4=,tag:SYaSldzSKT0rVKL4213SdQ==,type:str]sops_unencrypted_suffix=_unencrypted-sops_version=3.11.0+sops_version=3.12.1diff --git a/.env-localdev.enc b/.env-localdev.encindex 436a6ff657..586ef107e4 100644--- a/.env-localdev.enc+++ b/.env-localdev.enc@@ -109,7 +109,6 @@ STATIC_FILE_SERVICE_S3_EVENT_QUEUE_URL=ENC[AES256_GCM,data:CGf8uHNt74AynAakj2rRrSTATIC_FILE_SERVICE_SERVICE_URL=ENC[AES256_GCM,data:XGyWeNiENTs2+Gt5Vo64Gp6fqJw8TVwbuHpl,iv:/yPLwC9IqBNCiE8HLyOq5rGaEUD0wPFp5rcUDmdTTU8=,tag:zzzDFfktEiBmcWs/29LlBA==,type:str]STATIC_FILE_SERVICE_URL=ENC[AES256_GCM,data:uYRP3991G1UruHLbKTb8ZKf8fMm7MfQ=,iv:iip1uDGAFIjGUesw23Qxan3JCxGSor2peXXfdKVYzUE=,tag:ChoY3JC7qLahnH8JFnhWTQ==,type:str]STATIC_STORAGE_BUCKET=ENC[AES256_GCM,data:dLl7rHKSIxRRsit+wOj/3QmCv+i9rpbDSw==,iv:usWe1EAjEbe+03Rt5OWFfZ+kzKAY701+EL3uJTBMqqw=,tag:iWgupDb+6CiBOx7rQW85jg==,type:str]-STRIPE_PRICE_ID=ENC[AES256_GCM,data:ude6khFSiy4ZwV4DnSOT4m5aWQdc,iv:mt/tEa3IZaom9I+vHtSEy18KMGl1xOawhNVJQGI/ClY=,tag:v8TApFzv3figI4l1ro7xag==,type:str]STRIPE_SECRET_KEY=ENC[AES256_GCM,data:FkpOFU9IYEdcJSpRxbivU/ZVzj2RHZm0Pbu1q6v7T8sBTzFHXYTlhBYE5Io=,iv:bG32ifKU8M22UKApdlflkdDr2UGmbhsJixHKOPDNScs=,tag:X4GmBTsU8UXiOn0dKiP9fg==,type:str]STRIPE_WEBHOOK_SECRET_KEY=ENC[AES256_GCM,data:d+NFMH7qtQETH7ftI0XOXGr4/q277au6i3egZMKTlBUpSnXMJX364FXyw0Su49wkBVnT4kSrV/UqnuaRNerSzaAle5HS21wDtgFS0OF2dZy5KGZ2/Nw+,iv:AL1B6hBgbc4nlSwU04L+kKMJsVUfHJFe0jliDMFN/ec=,tag:deggu2NnaKGOyIhUGeGYKw==,type:str]SYNC_SERVICE_AUTH_KEY=ENC[AES256_GCM,data:HVGdfzWqdw==,iv:GTW9x1whKQ6ceeVBNNksPsdnIiF9o8NmRBJVGt3WagQ=,tag:3wk9cYmfh2MsFIXw0+Le0g==,type:str]@@ -124,6 +123,9 @@ GITHUB_WEBHOOK_SECRET_KEY=ENC[AES256_GCM,data:8Jpg/QeIDEpJpCWp2WirEZZpRj65LGuTEwGITHUB_SYNC_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Gc3P5k+eubEppMXAZUsRY0tZjpMmwqL7R1c9LI7ZvZchju1dOYaaMqJaBZLDxL4D+qrO0gGlUE3hQp80YAtNhzyk/YXah0IipP+RMFw8A0SX5lrIBa25X92ViIJgkWYMEu0vE+afaqFBmUmmzESjbkh0eXns9okIHC2IHhnzhxIkWhKldilQ4WZWgSw9C5PN4PLVXqTcS3mNrnZkHY/KKdfnV56GIyhsuxEhrz2g+X5GfOFx/sZZBW+EaEaiIGfzcR21PnwuYbhd4FGY=,iv:0E5uTj0DC/qB0NXTfjHtM3arSbivMDFslHT+3dYBTUk=,tag:2UKgWGvcJMIqCy0B/Xil6w==,type:str]GITHUB_SYNC_APP_CLIENT_ID=ENC[AES256_GCM,data:b2qkbli7aE9odK8Q8THou2iayneW/w==,iv:GHCrNrq7BwiIiHbX9qjBFoLD33QlASPa74CdU5WMsbY=,tag:iYU1+Z4vY0vOmoi1CqXLDA==,type:str]+STRIPE_PRICE_ID_HAIKU=ENC[AES256_GCM,data:8lDkvr4V/G6bvIGYxv/s/cXLcPuaikYDREmbx6R/HPo=,iv:wj5dtSDj6+OYjbdrYKl2R0f1WPuJEFbdK8xZ+kGNjNI=,tag:yzvROLM01p0Jl1YtdHjyxQ==,type:str]+STRIPE_PRICE_ID_SONNET=ENC[AES256_GCM,data:anbLDuVNiR+N/XAlfbJl3Nx+Iy6ohhnAlsZtMM5w/xA=,iv:YYnl3fNSFnHdV2dchqdw5/1E8W/ga5Pnyf9WqN6bUco=,tag:jYTxEyeBlKBIwv18mZWPBg==,type:str]+STRIPE_PRICE_ID_OPUS=ENC[AES256_GCM,data:fgVL97kmyo7kTrG6UjvFr/2gbgAFSpV+hnpy3jkKhos=,iv:C7vXETcHpbUW2iUi+m2WR/xu7ANbGAI+8z74GKBY0FA=,tag:SQP2Go5fPmxZg6GeGMdl9A==,type:str]sops_age__list_0__map_enc=-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHBpdi1wMjU2IEUzMVUyZyBBNDlKWUVt\nbUpscDEzSE9IZTNvdkd6VUFpWWhQM1ZWcndzL0srVXE4SW5GUQpHR2xNR3lIUnBV\nY3BqbmRadVVPMUdkeUluR0RycDJsWWt1V2Z0T1hqbG1JCi0tLSA5cVZQSGtNNmgr\nVXdyWGZsLzg2N0lyakxuVDZuNEFDUlUrNXJIMHE3UmRRClCd0JD9Q51ZLVKv73Px\nebG4SM/4o73tU3IHJu4tyQUrFM+we+JEDvsYKHBuUgTGC+2yQRPmHV+HObTqqRnu\nzGg=\n-----END AGE ENCRYPTED FILE-----\nsops_age__list_0__map_recipient=age1yubikey1qw64ag5lzvn9ekrflu5ruj4a6ucycscl6ctk39fjzf76jptsay39z442pxvsops_kms__list_0__map_arn=arn:aws:kms:us-east-1:569036502058:key/mrk-cab29bf948044eb79005a81f48d40e93@@ -134,7 +136,7 @@ sops_kms__list_1__map_arn=arn:aws:kms:us-west-1:569036502058:key/mrk-cab29bf9480sops_kms__list_1__map_aws_profile=sops_kms__list_1__map_created_at=2026-03-03T19:32:17Zsops_kms__list_1__map_enc=AQICAHjuYcSMsjB0lKJtZ3DIAvxF8N3RNRn5KZaAN74Et6122wHtcTS4UVhM79Eansn1/OmrAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMRrFwSp99ZM2mPtJzAgEQgDvsIaiNifNz0/18C9OH77AG/LQLpmDiXiJYV46yLDv9vdyPL3PaLMvkAqgL3Xb2F4RcZOIUxkTS3u92xQ==-sops_lastmodified=2026-03-09T15:11:00Z-sops_mac=ENC[AES256_GCM,data:xjBSWjZw24siE5K5BA14w0ZRKu4h5BpFDLUAotWmozaSCUeaff7MuOHc/mgEkOtspKMlvVPc6mk2pCLUJ82tLLKTWX4LIBqJWE8xyJ+07oDpPraZKiAXB/dvJEoU9ybCSgmFzFw2u5tlLkP1qVT3sWprwqh8DpV/DN97jlLg5Vw=,iv:cwP8qcbtgx09du+J20w5OcGjVQDQGyKlCC7zaJ8Cc58=,tag:tBmemkctp+Sxi4h8LD+RZg==,type:str]+sops_lastmodified=2026-03-19T16:10:48Z+sops_mac=ENC[AES256_GCM,data:tGI7wxdb+gpE9ulVrzgLb5sKeIliBUPaYY0FUKGVeTxOp/uHCSA7ApgD2r8DRWKzXB6OprBk4nguxiuLMPkHcedfNvduSErSWwLZoGqmW31a1V7A852GainoOTDtvNFKOoBZ1v8z/sOlO3N3yPrKYuASpiG9MtskbHSC7oKRvfY=,iv:QloSpBBTxLCnA5VV9vEmI8eq6F2q/+7BYpy2gdvzsW4=,tag:aKMY+YvgvleXdnmMsn0hVg==,type:str]sops_unencrypted_suffix=_unencrypted-sops_version=3.11.0+sops_version=3.12.1diff --git a/infra/stacks/authentication-service/Pulumi.dev.yaml b/infra/stacks/authentication-service/Pulumi.dev.yamlindex 0470d281d4..2b5b80f5fe 100644--- a/infra/stacks/authentication-service/Pulumi.dev.yaml+++ b/infra/stacks/authentication-service/Pulumi.dev.yaml@@ -16,12 +16,13 @@ config:authentication-service:macro_api_token_private_secret_key: macro-api-token-private-key-devauthentication-service:macro_api_token_expiry_seconds: 3600authentication-service:stripe_webhook_secret_key: stripe-webhook-secret-dev- authentication-service:stripe_price_id: stripe-price-id-devauthentication-service:fusionauth_tenant_id: 5e13f524-8d32-0454-81f8-061936256aa4authentication-service:github_client_id_key: github-client-id-devauthentication-service:github_client_secret_key: github-client-secret-devauthentication-service:github_idp_id_key: github-idp-id-dev-authentication-service:ga_measurement_id: G-52HPEL3FTVauthentication-service:ga_api_secret: ga-api-secretauthentication-service:meta_pixel_id: 639142540393286+ authentication-service:stripe_price_id_haiku: stripe-price-id-haiku-dev+ authentication-service:stripe_price_id_sonnet: stripe-price-id-sonnet-dev+ authentication-service:stripe_price_id_opus: stripe-price-id-opus-devdiff --git a/infra/stacks/authentication-service/Pulumi.prod.yaml b/infra/stacks/authentication-service/Pulumi.prod.yamlindex e265361aa9..8fd5ab18db 100644--- a/infra/stacks/authentication-service/Pulumi.prod.yaml+++ b/infra/stacks/authentication-service/Pulumi.prod.yaml@@ -16,12 +16,13 @@ config:authentication-service:macro_api_token_private_secret_key: macro-api-token-private-key-prodauthentication-service:macro_api_token_expiry_seconds: 3600authentication-service:stripe_webhook_secret_key: stripe-webhook-secret-prod- authentication-service:stripe_price_id: stripe-price-id-prodauthentication-service:fusionauth_tenant_id: a3e53c3d-8d6a-3e92-d64c-fa3bf30a60beauthentication-service:github_client_id_key: github-client-id-prodauthentication-service:github_client_secret_key: github-client-secret-prodauthentication-service:github_idp_id_key: github-idp-id-prod-authentication-service:ga_measurement_id: G-52HPEL3FTVauthentication-service:ga_api_secret: ga-api-secretauthentication-service:meta_pixel_id: 639142540393286+ authentication-service:stripe_price_id_haiku: stripe-price-id-haiku-prod+ authentication-service:stripe_price_id_sonnet: stripe-price-id-sonnet-prod+ authentication-service:stripe_price_id_opus: stripe-price-id-opus-proddiff --git a/infra/stacks/authentication-service/index.ts b/infra/stacks/authentication-service/index.tsindex 11aabe1df2..6fb014597f 100644--- a/infra/stacks/authentication-service/index.ts+++ b/infra/stacks/authentication-service/index.ts@@ -115,14 +115,20 @@ const googleClientSecretKeyArn: pulumi.Output<string> = aws.secretsmanager.getSecretVersionOutput({ secretId: GOOGLE_CLIENT_SECRET_KEY }).apply((secret) => secret.arn);-const STRIPE_PRICE_ID_KEY = config.require(`stripe_price_id`);-const STRIPE_PREMIUM_PRICE_ID = aws.secretsmanager- .getSecretVersionOutput({ secretId: STRIPE_PRICE_ID_KEY })- .apply((secret) => secret.secretString);+// -- STRIPE PRICE IDs+const STRIPE_PRICE_ID_HAIKU = aws.secretsmanager+ .getSecretVersionOutput({ secretId: config.require('stripe_price_id_haiku') })+ .apply((s) => s.secretString);-const stripePriceIdArn: pulumi.Output<string> = aws.secretsmanager- .getSecretVersionOutput({ secretId: STRIPE_PRICE_ID_KEY })- .apply((secret) => secret.arn);+const STRIPE_PRICE_ID_SONNET = aws.secretsmanager+ .getSecretVersionOutput({+ secretId: config.require('stripe_price_id_sonnet'),+ })+ .apply((s) => s.secretString);++const STRIPE_PRICE_ID_OPUS = aws.secretsmanager+ .getSecretVersionOutput({ secretId: config.require('stripe_price_id_opus') })+ .apply((s) => s.secretString);const MACRO_API_TOKEN_EXPIRY_SECONDS = config.require(`macro_api_token_expiry_seconds`@@ -165,7 +171,6 @@ const secretKeyArns = [pulumi.interpolate`${MACRO_API_TOKENS.macroApiTokenPublicKeyArn}`,pulumi.interpolate`${macroApiTokenSecretPrivateKeyArn}`,pulumi.interpolate`${stripeWebhookSecretKeyArn}`,- pulumi.interpolate`${stripePriceIdArn}`,];const vpc = get_coparse_api_vpc();@@ -304,16 +309,20 @@ const service = new AuthenticationService('authentication-service', {name: 'STRIPE_WEBHOOK_SECRET_KEY',value: pulumi.interpolate`${stripeWebhookSecretKeyArn}`,},+ // Stripe price ids+ {+ name: 'STRIPE_PRICE_ID_HAIKU',+ value: pulumi.interpolate`${STRIPE_PRICE_ID_HAIKU}`,+ },{- name: 'STRIPE_PRICE_ID',- value: pulumi.interpolate`${STRIPE_PRICE_ID_KEY}`,+ name: 'STRIPE_PRICE_ID_SONNET',+ value: pulumi.interpolate`${STRIPE_PRICE_ID_SONNET}`,},{- // NOTE: this is the fetched secret value of the STRIPE_PRICE_ID- // from above. Will unify these in a separate PR.- name: 'STRIPE_PREMIUM_PRICE_ID',- value: pulumi.interpolate`${STRIPE_PREMIUM_PRICE_ID}`,+ name: 'STRIPE_PRICE_ID_OPUS',+ value: pulumi.interpolate`${STRIPE_PRICE_ID_OPUS}`,},+ // Github{name: 'GITHUB_CLIENT_ID',value: pulumi.interpolate`${GITHUB_CLIENT_ID}`,diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/createCheckoutSessionRequest.ts b/js/app/packages/service-clients/service-auth/generated/schemas/createCheckoutSessionRequest.tsindex 08967c4bcb..e0eec51b82 100644--- a/js/app/packages/service-clients/service-auth/generated/schemas/createCheckoutSessionRequest.ts+++ b/js/app/packages/service-clients/service-auth/generated/schemas/createCheckoutSessionRequest.ts@@ -6,6 +6,7 @@*/import type { CreateCheckoutSessionRequestDiscount } from './createCheckoutSessionRequestDiscount';import type { CreateCheckoutSessionRequestGaClientId } from './createCheckoutSessionRequestGaClientId';+import type { StripeProductTier } from './stripeProductTier';/*** Request body for creating a Stripe checkout session@@ -19,4 +20,6 @@ export interface CreateCheckoutSessionRequest {gaClientId?: CreateCheckoutSessionRequestGaClientId;/** The URL to redirect to on successful checkout */successUrl: string;+ /** The tier, defaults to haiku */+ tier?: StripeProductTier;}diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/index.ts b/js/app/packages/service-clients/service-auth/generated/schemas/index.tsindex 1fe62345ab..f2beabc7f2 100644--- a/js/app/packages/service-clients/service-auth/generated/schemas/index.ts+++ b/js/app/packages/service-clients/service-auth/generated/schemas/index.ts@@ -53,6 +53,7 @@ export * from './referralCode';export * from './resendFusionauthVerifyUserEmailRequest';export * from './ssoLoginParams';export * from './ssoRequiredResponse';+export * from './stripeProductTier';export * from './stripeSessionResponse';export * from './team';export * from './teamInviteDetails';diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/stripeProductTier.ts b/js/app/packages/service-clients/service-auth/generated/schemas/stripeProductTier.tsnew file mode 100644index 0000000000..aa0e2f2d30--- /dev/null+++ b/js/app/packages/service-clients/service-auth/generated/schemas/stripeProductTier.ts@@ -0,0 +1,16 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * authentication_service+ * OpenAPI spec version: 0.1.0+ */++export type StripeProductTier =+ (typeof StripeProductTier)[keyof typeof StripeProductTier];++// eslint-disable-next-line @typescript-eslint/no-redeclare+export const StripeProductTier = {+ haiku: 'haiku',+ sonnet: 'sonnet',+ opus: 'opus',+} as const;diff --git a/js/app/packages/service-clients/service-auth/openapi.json b/js/app/packages/service-clients/service-auth/openapi.jsonindex e88f2308d1..1591ff46de 100644--- a/js/app/packages/service-clients/service-auth/openapi.json+++ b/js/app/packages/service-clients/service-auth/openapi.json@@ -2989,6 +2989,10 @@"successUrl": {"type": "string","description": "The URL to redirect to on successful checkout"+ },+ "tier": {+ "$ref": "#/components/schemas/StripeProductTier",+ "description": "The tier, defaults to haiku"}}},@@ -3400,6 +3404,10 @@}}},+ "StripeProductTier": {+ "type": "string",+ "enum": ["haiku", "sonnet", "opus"]+ },"StripeSessionResponse": {"type": "object","description": "Response containing the Stripe session URL",diff --git a/rust/cloud-storage/authentication_service/src/api/context.rs b/rust/cloud-storage/authentication_service/src/api/context.rsindex 3b0ec23216..076e6e0d19 100644--- a/rust/cloud-storage/authentication_service/src/api/context.rs+++ b/rust/cloud-storage/authentication_service/src/api/context.rs@@ -24,6 +24,8 @@ use roles_and_permissions::{};use sqlx::PgPool;+use crate::config::StripePriceIds;+pub(crate) type NotificationIngressType = SqsNotificationIngress<SqsIngressQueue>;pub(crate) type TeamsServiceType = teams::domain::team_service::TeamServiceImpl<@@ -61,6 +63,8 @@ pub(crate) struct ApiContext {pub native_app_service: Arc<NativeAppServiceImpl<DefaultBundleFetcher>>,pub analytics_client: Arc<AnalyticsClient>,pub referral_service: Arc<ReferralServiceType>,+ /// The stripe price ids+ pub stripe_price_ids: StripePriceIds,}env_var! {diff --git a/rust/cloud-storage/authentication_service/src/api/swagger.rs b/rust/cloud-storage/authentication_service/src/api/swagger.rsindex 33aedc2271..d4b77b64c6 100644--- a/rust/cloud-storage/authentication_service/src/api/swagger.rs+++ b/rust/cloud-storage/authentication_service/src/api/swagger.rs@@ -26,7 +26,8 @@ use crate::api::user::patch_user_onboarding::PatchUserOnboardingRequest;use crate::api::user::post_get_names::PostGetNamesRequestBody;use crate::api::user::post_get_names_with_email::GetNamesWithEmailRequestBody;use crate::api::user::stripe::{- CreateCheckoutSessionRequest, CreatePortalSessionRequest, StripeSessionResponse,+ CreateCheckoutSessionRequest, CreatePortalSessionRequest, StripeProductTier,+ StripeSessionResponse,};use crate::api::{email, health, jwt, link, login, logout, merge, oauth, oauth2, permissions, session, user,@@ -161,6 +162,7 @@ use model::user::{PatchUserTutorialRequest,// Stripe+ StripeProductTier,CreateCheckoutSessionRequest,CreatePortalSessionRequest,StripeSessionResponse,diff --git a/rust/cloud-storage/authentication_service/src/api/user/stripe.rs b/rust/cloud-storage/authentication_service/src/api/user/stripe.rsindex 3d28fcb1c4..ac76a5eddb 100644--- a/rust/cloud-storage/authentication_service/src/api/user/stripe.rs+++ b/rust/cloud-storage/authentication_service/src/api/user/stripe.rs@@ -1,12 +1,9 @@-use std::sync::LazyLock;-use axum::{Extension, Json,extract::State,http::StatusCode,response::{IntoResponse, Response},};-use macro_env_var::env_var;use serde::{Deserialize, Serialize};use stripe::{ParseIdError, StripeError};use thiserror::Error;@@ -52,17 +49,14 @@ impl IntoResponse for StripeOperationError {}}-env_var!(- struct StripePremiumPriceId;-);--static STRIPE_PRICE_ID: LazyLock<StripePremiumPriceId> = LazyLock::new(|| {- match StripePremiumPriceId::new() {- Ok(var) => var,- // just use this non secret value if the value doesn't exist- Err(_) => StripePremiumPriceId::Comptime("price_1PnSgXJaD7zvQeOBfSYgOmZc"),- }-});+#[derive(Debug, Deserialize, Default, ToSchema)]+#[serde(rename_all = "lowercase")]+pub enum StripeProductTier {+ #[default]+ Haiku,+ Sonnet,+ Opus,+}/// Request body for creating a Stripe checkout session#[derive(Debug, Deserialize, ToSchema)]@@ -76,6 +70,9 @@ pub struct CreateCheckoutSessionRequest {pub discount: Option<String>,/// Google Analytics client ID for conversion trackingpub ga_client_id: Option<String>,+ /// The tier, defaults to haiku+ #[serde(default)]+ pub tier: StripeProductTier,}/// Response containing the Stripe session URL@@ -180,6 +177,12 @@ pub async fn create_checkout_session(..Default::default()});+ let price_id = match req.tier {+ StripeProductTier::Haiku => ctx.stripe_price_ids.stripe_price_id_haiku.as_ref(),+ StripeProductTier::Sonnet => ctx.stripe_price_ids.stripe_price_id_sonnet.as_ref(),+ StripeProductTier::Opus => ctx.stripe_price_ids.stripe_price_id_opus.as_ref(),+ };+// Create the checkout sessionlet params = stripe::CreateCheckoutSession {customer: Some(customer_id),@@ -194,7 +197,7 @@ pub async fn create_checkout_session(}]}),line_items: Some(vec![stripe::CreateCheckoutSessionLineItems {- price: Some(STRIPE_PRICE_ID.as_ref().to_string()),+ price: Some(price_id.to_string()),quantity: Some(1),..Default::default()}]),diff --git a/rust/cloud-storage/authentication_service/src/api/webhooks/user/stripe_webhook.rs b/rust/cloud-storage/authentication_service/src/api/webhooks/user/stripe_webhook.rsindex affd21d79c..4b4173f77d 100644--- a/rust/cloud-storage/authentication_service/src/api/webhooks/user/stripe_webhook.rs+++ b/rust/cloud-storage/authentication_service/src/api/webhooks/user/stripe_webhook.rs@@ -14,7 +14,7 @@ use macro_user_id::cowlike::CowLike;use macro_user_id::email::Email;use model::response::ErrorResponse;use referral::domain::ports::ReferralService;-use roles_and_permissions::domain::port::UserRolesAndPermissionsService;+use roles_and_permissions::domain::{model::ProductTier, port::UserRolesAndPermissionsService};use serde::Serialize;use stripe_webhook::{EventObject, EventType};use teams::domain::team_repo::TeamService;@@ -280,10 +280,26 @@ async fn handle_customer_subscription_event(tracing::error!(error=?e, "failed to process referral on subscription created");}+ // Extract the price ID(s) from the subscription items+ let price_id = subscription+ .items+ .data+ .first() // SAFETY: we only need the first item because we know the user is not in a team+ .map(|item| item.price.id.as_str().to_string())+ .context("no price id attached to subscription")?;++ let product_tier = match price_id.as_str() {+ id if id == ctx.stripe_price_ids.stripe_price_id_haiku.as_ref() => ProductTier::Haiku,+ id if id == ctx.stripe_price_ids.stripe_price_id_sonnet.as_ref() => ProductTier::Sonnet,+ id if id == ctx.stripe_price_ids.stripe_price_id_opus.as_ref() => ProductTier::Opus,+ _ => anyhow::bail!("unsupported price id: {price_id}"),+ };+ctx.user_roles_and_permissions_service.update_user_roles_and_permissions_for_subscription(email.clone(),subscription_status.try_into()?,+ product_tier,).await?;diff --git a/rust/cloud-storage/authentication_service/src/config.rs b/rust/cloud-storage/authentication_service/src/config.rsindex e908c2df4a..73a182c5c2 100644--- a/rust/cloud-storage/authentication_service/src/config.rs+++ b/rust/cloud-storage/authentication_service/src/config.rs@@ -2,6 +2,7 @@ use std::sync::LazyLock;use anyhow::Context;pub use macro_env::Environment;+use macro_env_var::env_var;// BASE_URL env var. This is validated when creating the config in main.rspub static BASE_URL: LazyLock<String> = LazyLock::new(|| std::env::var("BASE_URL").unwrap());@@ -59,9 +60,6 @@ pub struct Config {/// The search event queuepub search_event_queue: String,- /// The stripe price id for the professional subscription- pub stripe_price_id: String,-/// The github client idpub github_client_id: String,/// The github client secret@@ -80,6 +78,21 @@ pub struct Config {pub meta_access_token: Option<String>,/// Meta test event code for testing (optional)pub meta_test_event_code: Option<String>,++ /// The stripe price ids+ pub stripe_price_ids: StripePriceIds,+}++env_var! {+ #[derive(Clone)]+ pub struct StripePriceIds {+ #[derive(Clone)]+ pub StripePriceIdHaiku,+ #[derive(Clone)]+ pub StripePriceIdSonnet,+ #[derive(Clone)]+ pub StripePriceIdOpus,+ }}impl Config {@@ -129,9 +142,6 @@ impl Config {let search_event_queue =std::env::var("SEARCH_EVENT_QUEUE").context("SEARCH_EVENT_QUEUE must be provided")?;- let stripe_price_id =- std::env::var("STRIPE_PRICE_ID").context("STRIPE_PRICE_ID must be provided")?;-let github_client_id =std::env::var("GITHUB_CLIENT_ID").context("GITHUB_CLIENT_ID must be provided")?;let github_client_secret = std::env::var("GITHUB_CLIENT_SECRET")@@ -148,6 +158,8 @@ impl Config {let meta_access_token = std::env::var("META_ACCESS_TOKEN").ok();let meta_test_event_code = std::env::var("META_TEST_EVENT_CODE").ok();+ let stripe_price_ids = StripePriceIds::new()?;+Ok(Config {base_url,database_url,@@ -166,7 +178,6 @@ impl Config {document_storage_service_url,notification_queue,search_event_queue,- stripe_price_id,environment,github_client_id,github_client_secret,@@ -176,6 +187,7 @@ impl Config {meta_pixel_id,meta_access_token,meta_test_event_code,+ stripe_price_ids,})}}diff --git a/rust/cloud-storage/authentication_service/src/main.rs b/rust/cloud-storage/authentication_service/src/main.rsindex 48fd39b531..4a461de05c 100644--- a/rust/cloud-storage/authentication_service/src/main.rs+++ b/rust/cloud-storage/authentication_service/src/main.rs@@ -127,15 +127,6 @@ async fn main() -> anyhow::Result<()> {.to_string(),};- let stripe_price_id = match config.environment {- Environment::Local => config.stripe_price_id.clone(),- _ => secretsmanager_client- .get_secret_value(&config.stripe_price_id)- .await- .context("unable to get stripe price id")?- .to_string(),- };-let auth_client = fusionauth::FusionAuthClient::new(config.fusionauth_tenant_id,fusionauth_api_key,@@ -226,7 +217,10 @@ async fn main() -> anyhow::Result<()> {);let teams_repo_impl = TeamRepositoryImpl::new(db.clone());- let customer_repo_impl = CustomerRepositoryImpl::new(stripe_client.clone(), &stripe_price_id);+ let customer_repo_impl = CustomerRepositoryImpl::new(+ stripe_client.clone(),+ &config.stripe_price_ids.stripe_price_id_haiku,+ );let notification_ingress_service = Arc::new(notification_ingress_service);@@ -288,6 +282,7 @@ async fn main() -> anyhow::Result<()> {},}),analytics_client: Arc::new(analytics_client),+ stripe_price_ids: config.stripe_price_ids,},config.port,)diff --git a/rust/cloud-storage/macro_db_client/migrations/20260316195622_new_pricing_roles_and_permissions.sql b/rust/cloud-storage/macro_db_client/migrations/20260316195622_new_pricing_roles_and_permissions.sqlnew file mode 100644index 0000000000..2979188961--- /dev/null+++ b/rust/cloud-storage/macro_db_client/migrations/20260316195622_new_pricing_roles_and_permissions.sql@@ -0,0 +1,20 @@+INSERT INTO "Role" (id, description)+ VALUES ('sub_haiku', 'User is subscribed to the haiku pricing plan'),+ ('sub_sonnet', 'User is subscribed to the sonnet pricing plan'),+ ('sub_opus', 'User is subscribed to the opus pricing plan') ON CONFLICT DO NOTHING;+++INSERT INTO "Permission" (id, description) VALUES+ ('write:haiku', 'Allow users to use haiku'),+ ('write:sonnet', 'Allow users to use sonnet'),+ ('write:opus', 'Allow users to use opus') ON CONFLICT DO NOTHING;+++INSERT INTO "RolesOnPermissions" ("permissionId", "roleId") VALUES+ ('write:haiku', 'sub_haiku'),+ ('write:haiku', 'sub_sonnet'), -- sonnet access haiku+ ('write:opus', 'sub_opus'), -- opus accesses haiku+ ('write:sonnet', 'sub_sonnet'),+ ('write:sonnet', 'sub_opus'), -- opus accesses sonnet+ ('write:opus', 'sub_opus'),+ ('write:haiku', 'corporate') ON CONFLICT DO NOTHING;diff --git a/rust/cloud-storage/roles_and_permissions/src/domain/model.rs b/rust/cloud-storage/roles_and_permissions/src/domain/model.rsindex ab809ec1c6..16b6b640a5 100644--- a/rust/cloud-storage/roles_and_permissions/src/domain/model.rs+++ b/rust/cloud-storage/roles_and_permissions/src/domain/model.rs@@ -2,6 +2,28 @@use std::{fmt::Display, str::FromStr};+/// The product tier the user is on+#[derive(Debug, Default)]+pub enum ProductTier {+ /// Haiku tier - default+ #[default]+ Haiku,+ /// Sonnet tier+ Sonnet,+ /// Opus tier+ Opus,+}++impl Display for ProductTier {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ match self {+ ProductTier::Haiku => write!(f, "haiku"),+ ProductTier::Sonnet => write!(f, "sonnet"),+ ProductTier::Opus => write!(f, "opus"),+ }+ }+}+/// All valid roles that exist in our system#[derive(Debug, Clone, PartialEq, Eq, Hash)]pub enum RoleId {@@ -31,6 +53,12 @@ pub enum RoleId {AiSubscriber,/// The editor user roleEditorUser,+ /// The user is subscribed to haiku plan+ SubHaiku,+ /// The user is subscribed to sonnet plan+ SubSonnet,+ /// The user is subscribed to opus plan+ SubOpus,}impl Display for RoleId {@@ -49,6 +77,9 @@ impl Display for RoleId {RoleId::EmailToolOnPrem => write!(f, "email_tool_on_prem"),RoleId::AiSubscriber => write!(f, "ai_subscriber"),RoleId::EditorUser => write!(f, "editor_user"),+ RoleId::SubHaiku => write!(f, "sub_haiku"),+ RoleId::SubSonnet => write!(f, "sub_sonnet"),+ RoleId::SubOpus => write!(f, "sub_opus"),}}}@@ -76,6 +107,12 @@ pub enum PermissionId {WriteAiFeatures,/// Read access to the docx editorReadDocxEditor,+ /// Use haiku+ WriteHaiku,+ /// Use sonnet+ WriteSonnet,+ /// Use opus+ WriteOpus,}impl FromStr for PermissionId {@@ -93,6 +130,9 @@ impl FromStr for PermissionId {"write:email_tool" => Ok(Self::WriteEmailTool),"write:ai_features" => Ok(Self::WriteAiFeatures),"read:docx_editor" => Ok(Self::ReadDocxEditor),+ "write:haiku" => Ok(Self::WriteHaiku),+ "write:sonnet" => Ok(Self::WriteSonnet),+ "write:opus" => Ok(Self::WriteOpus),_ => Err(anyhow::anyhow!("invalid permission id {s}")),}}@@ -113,6 +153,9 @@ impl Display for PermissionId {PermissionId::WriteEmailTool => write!(f, "write:email_tool"),PermissionId::WriteAiFeatures => write!(f, "write:ai_features"),PermissionId::ReadDocxEditor => write!(f, "read:docx_editor"),+ PermissionId::WriteHaiku => write!(f, "write:haiku"),+ PermissionId::WriteSonnet => write!(f, "write:sonnet"),+ PermissionId::WriteOpus => write!(f, "write:opus"),}}}diff --git a/rust/cloud-storage/roles_and_permissions/src/domain/port.rs b/rust/cloud-storage/roles_and_permissions/src/domain/port.rsindex d60dffead6..25a18684a5 100644--- a/rust/cloud-storage/roles_and_permissions/src/domain/port.rs+++ b/rust/cloud-storage/roles_and_permissions/src/domain/port.rs@@ -4,7 +4,9 @@ use std::collections::HashSet;use macro_user_id::{email::Email, lowercased::Lowercase, user_id::MacroUserIdStr};-use crate::domain::model::{Permission, RoleId, SubscriptionStatus, UserRolesAndPermissionsError};+use crate::domain::model::{+ Permission, ProductTier, RoleId, SubscriptionStatus, UserRolesAndPermissionsError,+};#[cfg(test)]mod test;@@ -46,6 +48,7 @@ pub trait UserRolesAndPermissionsService: Clone + Send + Sync + 'static {&self,email: Email<Lowercase<'_>>,subscription_status: SubscriptionStatus,+ product_tier: ProductTier,) -> impl Future<Output = Result<(), UserRolesAndPermissionsError>> + Send;/// Given a user id, upserts the roles for the userdiff --git a/rust/cloud-storage/roles_and_permissions/src/domain/service.rs b/rust/cloud-storage/roles_and_permissions/src/domain/service.rsindex 3d4e30782c..3dddf745ed 100644--- a/rust/cloud-storage/roles_and_permissions/src/domain/service.rs+++ b/rust/cloud-storage/roles_and_permissions/src/domain/service.rs@@ -2,7 +2,7 @@use macro_user_id::{email::Email, lowercased::Lowercase, user_id::MacroUserIdStr};use crate::domain::{- model::{RoleId, SubscriptionStatus, UserRolesAndPermissionsError},+ model::{ProductTier, RoleId, SubscriptionStatus, UserRolesAndPermissionsError},port::{UserRepository, UserRolesAndPermissionsRepository, UserRolesAndPermissionsService},};@@ -46,19 +46,29 @@ where&self,email: Email<Lowercase<'_>>,subscription_status: SubscriptionStatus,+ product_tier: ProductTier,) -> Result<(), UserRolesAndPermissionsError> {let user_id = self.user_repository.get_user_id_by_email(&email).await?;++ let sub_role = match product_tier {+ ProductTier::Haiku => RoleId::SubHaiku,+ ProductTier::Sonnet => RoleId::SubSonnet,+ ProductTier::Opus => RoleId::SubOpus,+ };++ let roles = [RoleId::ProfessionalSubscriber, sub_role];+match subscription_status {SubscriptionStatus::Active => {self.user_roles_and_permissions_repository- .add_roles_to_user(&user_id, &[RoleId::ProfessionalSubscriber])+ .add_roles_to_user(&user_id, &roles).await}SubscriptionStatus::Canceled| SubscriptionStatus::Paused| SubscriptionStatus::Unpaid => {self.user_roles_and_permissions_repository- .remove_roles_from_user(&user_id, &[RoleId::ProfessionalSubscriber])+ .remove_roles_from_user(&user_id, &roles).await}_ => Err(UserRolesAndPermissionsError::InvalidSubscriptionStatus(diff --git a/rust/cloud-storage/roles_and_permissions/src/domain/service/test.rs b/rust/cloud-storage/roles_and_permissions/src/domain/service/test.rsindex 812843d464..d37904c7eb 100644--- a/rust/cloud-storage/roles_and_permissions/src/domain/service/test.rs+++ b/rust/cloud-storage/roles_and_permissions/src/domain/service/test.rs@@ -82,6 +82,7 @@ async fn test_user_respository_get_user_id_by_email() -> anyhow::Result<()> {.update_user_roles_and_permissions_for_subscription(Email::parse_from_str("[email protected]")?.lowercase(),SubscriptionStatus::Active,+ ProductTier::Haiku,).await?;@@ -94,6 +95,7 @@ async fn test_user_respository_get_user_id_by_email() -> anyhow::Result<()> {.update_user_roles_and_permissions_for_subscription(Email::parse_from_str("[email protected]")?.lowercase(),SubscriptionStatus::Paused,+ ProductTier::Haiku,).await?;diff --git a/rust/cloud-storage/roles_and_permissions/src/outbound/pgpool/test.rs b/rust/cloud-storage/roles_and_permissions/src/outbound/pgpool/test.rsindex 88e2c77c1a..e71fac4cb2 100644--- a/rust/cloud-storage/roles_and_permissions/src/outbound/pgpool/test.rs+++ b/rust/cloud-storage/roles_and_permissions/src/outbound/pgpool/test.rs@@ -56,7 +56,7 @@ async fn test_add_roles_to_user(pool: Pool<Postgres>) -> anyhow::Result<()> {.map(|p| p.id.to_string()).collect::<Vec<String>>();- assert_eq!(permissions.len(), 2);+ assert_eq!(permissions.len(), 3);assert!(permissions.contains(&"read:professional_features".to_string()));// add role to user that already has role@@ -76,7 +76,7 @@ async fn test_add_roles_to_user(pool: Pool<Postgres>) -> anyhow::Result<()> {.map(|p| p.id.to_string()).collect::<Vec<String>>();- assert_eq!(permissions.len(), 2);+ assert_eq!(permissions.len(), 3);// add role to user that doesn't existlet err = macro_db@@ -119,7 +119,7 @@ async fn test_remove_roles_from_user(pool: Pool<Postgres>) -> anyhow::Result<()>.map(|p| p.id.to_string()).collect::<Vec<String>>();- assert_eq!(permissions.len(), 1);+ assert_eq!(permissions.len(), 2);assert!(permissions.contains(&"read:professional_features".to_string()));// Remove role that doesn't exist@@ -139,7 +139,7 @@ async fn test_remove_roles_from_user(pool: Pool<Postgres>) -> anyhow::Result<()>.map(|p| p.id.to_string()).collect::<Vec<String>>();- assert_eq!(permissions.len(), 1);+ assert_eq!(permissions.len(), 2);assert!(permissions.contains(&"read:professional_features".to_string()));Ok(())