@saasicat/adapter-drizzle 1.0.0-rc.13 → 1.0.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/.build-stamp CHANGED
@@ -1 +1 @@
1
- 23dcf4025e8c8920725e6baadc23a88bc404eb42c74f93ee7dbf5898fef8bdec
1
+ 1d928abd10069a33647ab20de31e2f89fa1afccfcae8b9268f9b1d8cada839dc
package/dist/index.cjs CHANGED
@@ -1992,10 +1992,15 @@ var DrizzleSubscriptionContractRepository = class {
1992
1992
  ]), inWindowAt(asOf))).orderBy((0, import_drizzle_orm12.desc)(subscriptionContracts.effectiveFrom), (0, import_drizzle_orm12.desc)(subscriptionContracts.createdAt)).limit(1);
1993
1993
  return (await this.withLineItems(db, rows))[0] ?? null;
1994
1994
  }
1995
- async create(data) {
1995
+ async findByOriginalOfferId(offerId, tx) {
1996
+ const db = resolveDb(this.db, tx);
1997
+ const rows = await db.select().from(subscriptionContracts).where((0, import_drizzle_orm12.eq)(subscriptionContracts.originalOfferId, offerId)).orderBy((0, import_drizzle_orm12.asc)(subscriptionContracts.createdAt), (0, import_drizzle_orm12.asc)(subscriptionContracts.id)).limit(1);
1998
+ return (await this.withLineItems(db, rows))[0] ?? null;
1999
+ }
2000
+ async create(data, tx) {
1996
2001
  const now = /* @__PURE__ */ new Date();
1997
2002
  const contractId = (0, import_node_crypto8.randomUUID)();
1998
- return this.db.transaction(async (transaction) => {
2003
+ return resolveDb(this.db, tx).transaction(async (transaction) => {
1999
2004
  const db = transaction;
2000
2005
  const rows = await db.insert(subscriptionContracts).values({
2001
2006
  id: contractId,
package/dist/index.d.cts CHANGED
@@ -4741,7 +4741,8 @@ declare class DrizzleSubscriptionContractRepository implements SubscriptionContr
4741
4741
  list(filter: SubscriptionContractFilter): Promise<SubscriptionContractRecord[]>;
4742
4742
  findById(contractId: string): Promise<SubscriptionContractRecord | null>;
4743
4743
  findActiveByTenantId(tenantId: string, asOf?: Date, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
4744
- create(data: CreateSubscriptionContractData): Promise<SubscriptionContractRecord>;
4744
+ findByOriginalOfferId(offerId: string, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
4745
+ create(data: CreateSubscriptionContractData, tx?: TransactionContext): Promise<SubscriptionContractRecord>;
4745
4746
  terminate(contractId: string, data: TerminateSubscriptionContractData): Promise<SubscriptionContractRecord>;
4746
4747
  /**
4747
4748
  * The lines for a batch of contracts in one query rather than one per
package/dist/index.d.ts CHANGED
@@ -4741,7 +4741,8 @@ declare class DrizzleSubscriptionContractRepository implements SubscriptionContr
4741
4741
  list(filter: SubscriptionContractFilter): Promise<SubscriptionContractRecord[]>;
4742
4742
  findById(contractId: string): Promise<SubscriptionContractRecord | null>;
4743
4743
  findActiveByTenantId(tenantId: string, asOf?: Date, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
4744
- create(data: CreateSubscriptionContractData): Promise<SubscriptionContractRecord>;
4744
+ findByOriginalOfferId(offerId: string, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
4745
+ create(data: CreateSubscriptionContractData, tx?: TransactionContext): Promise<SubscriptionContractRecord>;
4745
4746
  terminate(contractId: string, data: TerminateSubscriptionContractData): Promise<SubscriptionContractRecord>;
4746
4747
  /**
4747
4748
  * The lines for a batch of contracts in one query rather than one per
package/dist/index.js CHANGED
@@ -1897,7 +1897,7 @@ __name(toNullableDate2, "toNullableDate");
1897
1897
  // src/drizzle-subscription-contract.repository.ts
1898
1898
  import { randomUUID as randomUUID8 } from "node:crypto";
1899
1899
  import { Inject as Inject13, Injectable as Injectable14 } from "@nestjs/common";
1900
- import { and as and10, desc as desc7, eq as eq10, gt, inArray as inArray4, isNull as isNull8, lte as lte4, or as or4 } from "drizzle-orm";
1900
+ import { and as and10, asc as asc4, desc as desc7, eq as eq10, gt, inArray as inArray4, isNull as isNull8, lte as lte4, or as or4 } from "drizzle-orm";
1901
1901
  import { ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES, toSubscriptionContractRecord } from "@saasicat/core";
1902
1902
  function _ts_decorate14(decorators, target, key, desc9) {
1903
1903
  var c = arguments.length, r = c < 3 ? target : desc9 === null ? desc9 = Object.getOwnPropertyDescriptor(target, key) : desc9, d;
@@ -1945,10 +1945,15 @@ var DrizzleSubscriptionContractRepository = class {
1945
1945
  ]), inWindowAt(asOf))).orderBy(desc7(subscriptionContracts.effectiveFrom), desc7(subscriptionContracts.createdAt)).limit(1);
1946
1946
  return (await this.withLineItems(db, rows))[0] ?? null;
1947
1947
  }
1948
- async create(data) {
1948
+ async findByOriginalOfferId(offerId, tx) {
1949
+ const db = resolveDb(this.db, tx);
1950
+ const rows = await db.select().from(subscriptionContracts).where(eq10(subscriptionContracts.originalOfferId, offerId)).orderBy(asc4(subscriptionContracts.createdAt), asc4(subscriptionContracts.id)).limit(1);
1951
+ return (await this.withLineItems(db, rows))[0] ?? null;
1952
+ }
1953
+ async create(data, tx) {
1949
1954
  const now = /* @__PURE__ */ new Date();
1950
1955
  const contractId = randomUUID8();
1951
- return this.db.transaction(async (transaction) => {
1956
+ return resolveDb(this.db, tx).transaction(async (transaction) => {
1952
1957
  const db = transaction;
1953
1958
  const rows = await db.insert(subscriptionContracts).values({
1954
1959
  id: contractId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasicat/adapter-drizzle",
3
- "version": "1.0.0-rc.13",
3
+ "version": "1.0.0-rc.15",
4
4
  "description": "Drizzle + PostgreSQL persistence adapter for SaaSiCat: drizzlePersistence() bundle plus the individual adapters (MFA, audit, RLS bypass, transaction runner, subscription/plan-version/promo repositories, SuperAdmin bootstrap, plan-catalog sinks). Targets the canonical schema from @saasicat/spec and passes the same executable persistence contract as @saasicat/adapter-prisma.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@saasicat/core": "^1.0.0-rc.13"
26
+ "@saasicat/core": "^1.0.0-rc.15"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@nestjs/common": "^11.0.0",
@@ -37,8 +37,8 @@
37
37
  "pg": "^8.22.0",
38
38
  "tsup": "^8.0.0",
39
39
  "typescript": "^6.0.0",
40
- "@saasicat/persistence-testing": "^1.0.0-rc.13",
41
- "@saasicat/spec": "^1.0.0-rc.13"
40
+ "@saasicat/persistence-testing": "^1.0.0-rc.15",
41
+ "@saasicat/spec": "^1.0.0-rc.15"
42
42
  },
43
43
  "license": "PolyForm-Shield-1.0.0",
44
44
  "author": "Taci Uelker",