@saasicat/adapter-prisma 1.0.0-rc.13 → 1.0.0-rc.14
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 +1 -1
- package/dist/index.cjs +21 -6
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +21 -6
- package/package.json +4 -4
package/dist/.build-stamp
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
224ad69e1e527214b47293c92482fa438805bc542b962bb96bc94f87be216c3f
|
package/dist/index.cjs
CHANGED
|
@@ -541,6 +541,15 @@ function createPrismaPlanBindingResolver(options) {
|
|
|
541
541
|
}
|
|
542
542
|
return plan.id;
|
|
543
543
|
},
|
|
544
|
+
async findStoragePlanId(client, planKey) {
|
|
545
|
+
if (resolved.mode === "legacy-plan-key") return planKey;
|
|
546
|
+
const plan = await asPlanIdentityClient(client).plan.findFirst({
|
|
547
|
+
where: {
|
|
548
|
+
planKey
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
return plan?.id ?? null;
|
|
552
|
+
},
|
|
544
553
|
async toPlanKey(client, storedPlanId) {
|
|
545
554
|
if (resolved.mode === "legacy-plan-key") return storedPlanId;
|
|
546
555
|
const plan = await asPlanIdentityClient(client).plan.findUnique({
|
|
@@ -2687,7 +2696,8 @@ var PrismaPlanRepository = class {
|
|
|
2687
2696
|
// ─── Lifecycle operations (Pack 2a) — keyed by planKey ───
|
|
2688
2697
|
async listVersions(planKey) {
|
|
2689
2698
|
const db = this.db();
|
|
2690
|
-
const storedPlanId = await this.binding.
|
|
2699
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planKey);
|
|
2700
|
+
if (storedPlanId === null) return [];
|
|
2691
2701
|
const rows = await this.versions(db).findMany({
|
|
2692
2702
|
where: {
|
|
2693
2703
|
planId: storedPlanId
|
|
@@ -2709,7 +2719,8 @@ var PrismaPlanRepository = class {
|
|
|
2709
2719
|
}
|
|
2710
2720
|
async findCurrentDraft(planKey) {
|
|
2711
2721
|
const db = this.db();
|
|
2712
|
-
const storedPlanId = await this.binding.
|
|
2722
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planKey);
|
|
2723
|
+
if (storedPlanId === null) return null;
|
|
2713
2724
|
const row = await this.versions(db).findFirst({
|
|
2714
2725
|
where: {
|
|
2715
2726
|
planId: storedPlanId,
|
|
@@ -2720,7 +2731,8 @@ var PrismaPlanRepository = class {
|
|
|
2720
2731
|
}
|
|
2721
2732
|
async findLatestLivePlanVersion(planKey, tx) {
|
|
2722
2733
|
const db = this.db(tx);
|
|
2723
|
-
const storedPlanId = await this.binding.
|
|
2734
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planKey);
|
|
2735
|
+
if (storedPlanId === null) return null;
|
|
2724
2736
|
const row = await this.versions(db).findFirst({
|
|
2725
2737
|
where: {
|
|
2726
2738
|
planId: storedPlanId,
|
|
@@ -2749,7 +2761,8 @@ var PrismaPlanRepository = class {
|
|
|
2749
2761
|
}
|
|
2750
2762
|
async findActivePlanVersionWithValidity(planKey, asOf, tx) {
|
|
2751
2763
|
const db = this.db(tx);
|
|
2752
|
-
const storedPlanId = await this.binding.
|
|
2764
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planKey);
|
|
2765
|
+
if (storedPlanId === null) return null;
|
|
2753
2766
|
const activeWhere = this.fields.endsAt ? (0, import_core4.buildActivePlanVersionWhere)(asOf, {
|
|
2754
2767
|
withEndsAt: true
|
|
2755
2768
|
}) : (0, import_core4.buildActivePlanVersionWhere)(asOf);
|
|
@@ -2995,7 +3008,8 @@ var PrismaPlanVersionRepository = class {
|
|
|
2995
3008
|
}
|
|
2996
3009
|
async findLatestLive(planId, tx) {
|
|
2997
3010
|
const db = this.db(tx);
|
|
2998
|
-
const storedPlanId = await this.binding.
|
|
3011
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planId);
|
|
3012
|
+
if (storedPlanId === null) return null;
|
|
2999
3013
|
const row = await this.versions(db).findFirst({
|
|
3000
3014
|
where: {
|
|
3001
3015
|
planId: storedPlanId,
|
|
@@ -3013,7 +3027,8 @@ var PrismaPlanVersionRepository = class {
|
|
|
3013
3027
|
}
|
|
3014
3028
|
async findActivePlanVersion(planId, asOf, tx) {
|
|
3015
3029
|
const db = this.db(tx);
|
|
3016
|
-
const storedPlanId = await this.binding.
|
|
3030
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planId);
|
|
3031
|
+
if (storedPlanId === null) return null;
|
|
3017
3032
|
const activeWhere = this.fields.endsAt ? (0, import_core6.buildActivePlanVersionWhere)(asOf, {
|
|
3018
3033
|
withEndsAt: true
|
|
3019
3034
|
}) : (0, import_core6.buildActivePlanVersionWhere)(asOf);
|
package/dist/index.d.cts
CHANGED
|
@@ -688,7 +688,14 @@ interface ResolvedPrismaSchemaOptions {
|
|
|
688
688
|
declare const PRISMA_SCHEMA_OPTIONS_TOKEN: unique symbol;
|
|
689
689
|
interface PrismaPlanBindingResolver {
|
|
690
690
|
readonly mode: PrismaPlanBindingMode;
|
|
691
|
+
/** The stored id of the plan a write targets; a key no live plan has is an error. */
|
|
691
692
|
toStoragePlanId(client: unknown, planKey: string): Promise<string>;
|
|
693
|
+
/**
|
|
694
|
+
* The stored id a read looks versions up by, or `null` when no plan row has
|
|
695
|
+
* the key. A retired plan is found: its versions stay readable, and the
|
|
696
|
+
* deletion guard that counts them must not be told it has none.
|
|
697
|
+
*/
|
|
698
|
+
findStoragePlanId(client: unknown, planKey: string): Promise<string | null>;
|
|
692
699
|
toPlanKey(client: unknown, storedPlanId: string): Promise<string>;
|
|
693
700
|
}
|
|
694
701
|
declare function resolvePrismaSchemaOptions(options?: PrismaSchemaOptions): ResolvedPrismaSchemaOptions;
|
package/dist/index.d.ts
CHANGED
|
@@ -688,7 +688,14 @@ interface ResolvedPrismaSchemaOptions {
|
|
|
688
688
|
declare const PRISMA_SCHEMA_OPTIONS_TOKEN: unique symbol;
|
|
689
689
|
interface PrismaPlanBindingResolver {
|
|
690
690
|
readonly mode: PrismaPlanBindingMode;
|
|
691
|
+
/** The stored id of the plan a write targets; a key no live plan has is an error. */
|
|
691
692
|
toStoragePlanId(client: unknown, planKey: string): Promise<string>;
|
|
693
|
+
/**
|
|
694
|
+
* The stored id a read looks versions up by, or `null` when no plan row has
|
|
695
|
+
* the key. A retired plan is found: its versions stay readable, and the
|
|
696
|
+
* deletion guard that counts them must not be told it has none.
|
|
697
|
+
*/
|
|
698
|
+
findStoragePlanId(client: unknown, planKey: string): Promise<string | null>;
|
|
692
699
|
toPlanKey(client: unknown, storedPlanId: string): Promise<string>;
|
|
693
700
|
}
|
|
694
701
|
declare function resolvePrismaSchemaOptions(options?: PrismaSchemaOptions): ResolvedPrismaSchemaOptions;
|
package/dist/index.js
CHANGED
|
@@ -479,6 +479,15 @@ function createPrismaPlanBindingResolver(options) {
|
|
|
479
479
|
}
|
|
480
480
|
return plan.id;
|
|
481
481
|
},
|
|
482
|
+
async findStoragePlanId(client, planKey) {
|
|
483
|
+
if (resolved.mode === "legacy-plan-key") return planKey;
|
|
484
|
+
const plan = await asPlanIdentityClient(client).plan.findFirst({
|
|
485
|
+
where: {
|
|
486
|
+
planKey
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
return plan?.id ?? null;
|
|
490
|
+
},
|
|
482
491
|
async toPlanKey(client, storedPlanId) {
|
|
483
492
|
if (resolved.mode === "legacy-plan-key") return storedPlanId;
|
|
484
493
|
const plan = await asPlanIdentityClient(client).plan.findUnique({
|
|
@@ -2625,7 +2634,8 @@ var PrismaPlanRepository = class {
|
|
|
2625
2634
|
// ─── Lifecycle operations (Pack 2a) — keyed by planKey ───
|
|
2626
2635
|
async listVersions(planKey) {
|
|
2627
2636
|
const db = this.db();
|
|
2628
|
-
const storedPlanId = await this.binding.
|
|
2637
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planKey);
|
|
2638
|
+
if (storedPlanId === null) return [];
|
|
2629
2639
|
const rows = await this.versions(db).findMany({
|
|
2630
2640
|
where: {
|
|
2631
2641
|
planId: storedPlanId
|
|
@@ -2647,7 +2657,8 @@ var PrismaPlanRepository = class {
|
|
|
2647
2657
|
}
|
|
2648
2658
|
async findCurrentDraft(planKey) {
|
|
2649
2659
|
const db = this.db();
|
|
2650
|
-
const storedPlanId = await this.binding.
|
|
2660
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planKey);
|
|
2661
|
+
if (storedPlanId === null) return null;
|
|
2651
2662
|
const row = await this.versions(db).findFirst({
|
|
2652
2663
|
where: {
|
|
2653
2664
|
planId: storedPlanId,
|
|
@@ -2658,7 +2669,8 @@ var PrismaPlanRepository = class {
|
|
|
2658
2669
|
}
|
|
2659
2670
|
async findLatestLivePlanVersion(planKey, tx) {
|
|
2660
2671
|
const db = this.db(tx);
|
|
2661
|
-
const storedPlanId = await this.binding.
|
|
2672
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planKey);
|
|
2673
|
+
if (storedPlanId === null) return null;
|
|
2662
2674
|
const row = await this.versions(db).findFirst({
|
|
2663
2675
|
where: {
|
|
2664
2676
|
planId: storedPlanId,
|
|
@@ -2687,7 +2699,8 @@ var PrismaPlanRepository = class {
|
|
|
2687
2699
|
}
|
|
2688
2700
|
async findActivePlanVersionWithValidity(planKey, asOf, tx) {
|
|
2689
2701
|
const db = this.db(tx);
|
|
2690
|
-
const storedPlanId = await this.binding.
|
|
2702
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planKey);
|
|
2703
|
+
if (storedPlanId === null) return null;
|
|
2691
2704
|
const activeWhere = this.fields.endsAt ? buildActivePlanVersionWhere(asOf, {
|
|
2692
2705
|
withEndsAt: true
|
|
2693
2706
|
}) : buildActivePlanVersionWhere(asOf);
|
|
@@ -2933,7 +2946,8 @@ var PrismaPlanVersionRepository = class {
|
|
|
2933
2946
|
}
|
|
2934
2947
|
async findLatestLive(planId, tx) {
|
|
2935
2948
|
const db = this.db(tx);
|
|
2936
|
-
const storedPlanId = await this.binding.
|
|
2949
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planId);
|
|
2950
|
+
if (storedPlanId === null) return null;
|
|
2937
2951
|
const row = await this.versions(db).findFirst({
|
|
2938
2952
|
where: {
|
|
2939
2953
|
planId: storedPlanId,
|
|
@@ -2951,7 +2965,8 @@ var PrismaPlanVersionRepository = class {
|
|
|
2951
2965
|
}
|
|
2952
2966
|
async findActivePlanVersion(planId, asOf, tx) {
|
|
2953
2967
|
const db = this.db(tx);
|
|
2954
|
-
const storedPlanId = await this.binding.
|
|
2968
|
+
const storedPlanId = await this.binding.findStoragePlanId(db, planId);
|
|
2969
|
+
if (storedPlanId === null) return null;
|
|
2955
2970
|
const activeWhere = this.fields.endsAt ? buildActivePlanVersionWhere2(asOf, {
|
|
2956
2971
|
withEndsAt: true
|
|
2957
2972
|
}) : buildActivePlanVersionWhere2(asOf);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saasicat/adapter-prisma",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.14",
|
|
4
4
|
"description": "Prisma + PostgreSQL persistence for SaaSiCat: one standard bundle for core, catalog, entitlement, tenant billing, Admin resources and promo, plus individual adapters for custom compositions.",
|
|
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.
|
|
26
|
+
"@saasicat/core": "^1.0.0-rc.14"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@nestjs/common": "^11.0.0"
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@prisma/client": "^6.19.0",
|
|
36
36
|
"tsup": "^8.0.0",
|
|
37
37
|
"typescript": "^6.0.0",
|
|
38
|
-
"@saasicat/persistence-testing": "^1.0.0-rc.
|
|
39
|
-
"@saasicat/spec": "^1.0.0-rc.
|
|
38
|
+
"@saasicat/persistence-testing": "^1.0.0-rc.14",
|
|
39
|
+
"@saasicat/spec": "^1.0.0-rc.14"
|
|
40
40
|
},
|
|
41
41
|
"license": "PolyForm-Shield-1.0.0",
|
|
42
42
|
"author": "Taci Uelker",
|