From d458a27290982e22d86a7eea76b0f4fb1cea680f Mon Sep 17 00:00:00 2001 From: John Yeo Date: Wed, 17 Sep 2025 20:26:50 -0700 Subject: [PATCH] chore: updated .gitignore --- .gitignore | 3 +- server/src/check2.ts | 67 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 server/src/check2.ts diff --git a/.gitignore b/.gitignore index 5e7c175f3..fc7a0c1c9 100644 --- a/.gitignore +++ b/.gitignore @@ -106,4 +106,5 @@ supabase/ migration.sh stat.sh -CLAUDE.md \ No newline at end of file +CLAUDE.md +interview \ No newline at end of file diff --git a/server/src/check2.ts b/server/src/check2.ts new file mode 100644 index 000000000..ba9ed94af --- /dev/null +++ b/server/src/check2.ts @@ -0,0 +1,67 @@ +import { config } from "dotenv"; +config(); + +import { + getAllEntities, + getAllFullCustomers, +} from "@/utils/scriptUtils/getAll/getAllAutumnCustomers.js"; +import { initDrizzle } from "@/db/initDrizzle.js"; +import { + AppEnv, + CusProductStatus, + FullCusProduct, + FullCustomer, + Organization, + Entity, +} from "@autumn/shared"; +import Stripe from "stripe"; +import assert from "assert"; +import { cusProductToPrices } from "@autumn/shared"; +import { notNullish } from "@/utils/genUtils.js"; +import { + getAllStripeSchedules, + getAllStripeSubscriptions, +} from "@/utils/scriptUtils/getAll/getAllStripeSubs.js"; +import { OrgService } from "@/internal/orgs/OrgService.js"; +import { createStripeCli } from "@/external/stripe/utils.js"; +import { CusService } from "@/internal/customers/CusService.js"; +import { getStripeSchedules } from "@/external/stripe/stripeSubUtils.js"; +import { createSupabaseClient } from "@/external/supabaseUtils.js"; +import { isFreeProduct, isOneOff } from "@/internal/products/productUtils.js"; +import { getRelatedCusPrice } from "./internal/customers/cusProducts/cusEnts/cusEntUtils.js"; +import { checkCusSubCorrect } from "./utils/checkUtils/checkCustomerCorrect.js"; +import { EntityService } from "./internal/api/entities/EntityService.js"; + +const { db } = initDrizzle({ maxConnections: 5 }); + +export const check = async () => { + const env = AppEnv.Live; + const orgId = "99XYziU2vChNNpdeEpvse09b8UF6BPME"; + + let fullCustomers = await getAllFullCustomers({ + db, + orgId, + env, + }); + + const checkCustomers = ["9bafd636-0c52-46b3-8ecd-1708d6faa373"]; + + fullCustomers = fullCustomers.filter((customer) => + checkCustomers.includes(customer.id || "") + ); + + for (const customer of fullCustomers) { + console.log(`Checking ${customer.name} (${customer.id})`); + const cusProducts = customer.customer_products; + const cusEnts = cusProducts.flatMap((cp) => cp.customer_entitlements); + } +}; + +check() + .catch((error) => { + console.error(error); + process.exit(1); + }) + .finally(() => { + process.exit(0); + });