@cedarjs/tenancy 8.0.0-canary.3556 → 8.0.0-canary.3559
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/prismaExtension.d.ts +34 -5
- package/dist/prismaExtension.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -72,14 +72,43 @@ type ExtendableClient = {
|
|
|
72
72
|
* an unscoped one allows.
|
|
73
73
|
*/
|
|
74
74
|
type RawSqlMethod = '$queryRaw' | '$queryRawUnsafe' | '$executeRaw' | '$executeRawUnsafe';
|
|
75
|
+
/**
|
|
76
|
+
* Raw SQL typed the way the un-extended client types it, instead of as
|
|
77
|
+
* always throwing.
|
|
78
|
+
*/
|
|
79
|
+
type AllowedRawSql<TClient> = Pick<TClient, Extract<keyof TClient, RawSqlMethod>>;
|
|
80
|
+
/**
|
|
81
|
+
* The `tx` and the options of `TDb`'s interactive `$transaction`, read from
|
|
82
|
+
* Prisma's own signature. A conditional type matches the last overload, which
|
|
83
|
+
* for Prisma is the interactive one (the batch form comes first).
|
|
84
|
+
*/
|
|
85
|
+
type InteractiveTransaction<TDb> = TDb extends {
|
|
86
|
+
$transaction: (fn: (tx: infer Tx) => Promise<unknown>, options?: infer Options) => Promise<unknown>;
|
|
87
|
+
} ? {
|
|
88
|
+
tx: Tx;
|
|
89
|
+
options: Options;
|
|
90
|
+
} : never;
|
|
91
|
+
/**
|
|
92
|
+
* The `$transaction` of `db.$withoutTenant()`: its callback's `tx` is `db`'s
|
|
93
|
+
* own transaction client with raw SQL allowed, like the client it was started
|
|
94
|
+
* on (at runtime it's built from that unscoped client). `db`'s own overloads
|
|
95
|
+
* follow it, unchanged: the batch form, and the callback form for a callback
|
|
96
|
+
* that names `db`'s `tx` type. Keeping them also lets TypeScript call
|
|
97
|
+
* `$transaction` on a union of `db` and the unscoped client, using the
|
|
98
|
+
* signatures the two have in common.
|
|
99
|
+
*/
|
|
100
|
+
type UnscopedTransaction<TDb, TClient> = (<R>(fn: (tx: Omit<InteractiveTransaction<TDb>['tx'], RawSqlMethod> & AllowedRawSql<TClient>) => Promise<R>, options?: InteractiveTransaction<TDb>['options']) => Promise<R>) & (TDb extends {
|
|
101
|
+
$transaction: infer T;
|
|
102
|
+
} ? T : never);
|
|
75
103
|
/**
|
|
76
104
|
* The type of `db.$withoutTenant()`: `db`'s own type, with raw SQL typed the
|
|
77
|
-
* way the un-extended client types it instead of as always throwing
|
|
78
|
-
*
|
|
79
|
-
* type, so code can take either client
|
|
80
|
-
* TypeScript can't call model methods on.
|
|
105
|
+
* way the un-extended client types it instead of as always throwing, on the
|
|
106
|
+
* client and on its interactive transactions' `tx`. Every other member, the
|
|
107
|
+
* models included, has exactly `db`'s type, so code can take either client
|
|
108
|
+
* without the two forming a union TypeScript can't call model methods on.
|
|
81
109
|
*/
|
|
82
|
-
export type UnscopedClient<TDb, TClient> = Omit<TDb, RawSqlMethod | '$forOrg' | '$withoutTenant'> &
|
|
110
|
+
export type UnscopedClient<TDb, TClient> = Omit<TDb, RawSqlMethod | '$transaction' | '$forOrg' | '$withoutTenant'> & AllowedRawSql<TClient> & {
|
|
111
|
+
$transaction: UnscopedTransaction<TDb, TClient>;
|
|
83
112
|
$forOrg(this: ExtendableClient, organizationId: string): TDb;
|
|
84
113
|
$withoutTenant(this: ExtendableClient): UnscopedClient<TDb, TClient>;
|
|
85
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prismaExtension.d.ts","sourceRoot":"","sources":["../src/prismaExtension.ts"],"names":[],"mappings":"AAQA,KAAK,uBAAuB,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,MAAM,EAAE,GACpD,KAAK,GACL,CAAC,SAAS,MAAM,GACd,KAAK,GACL,CAAC,CAAA;AAEP;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,OAAO,IAAI,uBAAuB,CAAC,MAAM,OAAO,CAAC,CAAA;AAE3E,MAAM,WAAW,aAAa,CAAC,OAAO;IACpC;;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-canary.
|
|
3
|
+
"version": "8.0.0-canary.3559",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -44,17 +44,17 @@
|
|
|
44
44
|
"test:watch": "vitest watch"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@cedarjs/api": "8.0.0-canary.
|
|
48
|
-
"@cedarjs/context": "8.0.0-canary.
|
|
49
|
-
"@cedarjs/graphql-server": "8.0.0-canary.
|
|
47
|
+
"@cedarjs/api": "8.0.0-canary.3559",
|
|
48
|
+
"@cedarjs/context": "8.0.0-canary.3559",
|
|
49
|
+
"@cedarjs/graphql-server": "8.0.0-canary.3559"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@apollo/client": "4.3.5",
|
|
53
53
|
"@arethetypeswrong/cli": "0.18.5",
|
|
54
|
-
"@cedarjs/auth": "8.0.0-canary.
|
|
55
|
-
"@cedarjs/framework-tools": "8.0.0-canary.
|
|
56
|
-
"@cedarjs/router": "8.0.0-canary.
|
|
57
|
-
"@cedarjs/web": "8.0.0-canary.
|
|
54
|
+
"@cedarjs/auth": "8.0.0-canary.3559",
|
|
55
|
+
"@cedarjs/framework-tools": "8.0.0-canary.3559",
|
|
56
|
+
"@cedarjs/router": "8.0.0-canary.3559",
|
|
57
|
+
"@cedarjs/web": "8.0.0-canary.3559",
|
|
58
58
|
"@prisma/adapter-better-sqlite3": "7.10.1",
|
|
59
59
|
"@prisma/client": "7.10.1",
|
|
60
60
|
"@testing-library/dom": "10.4.2",
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"@apollo/client": "4.3.5",
|
|
83
|
-
"@cedarjs/auth": "8.0.0-canary.
|
|
84
|
-
"@cedarjs/router": "8.0.0-canary.
|
|
85
|
-
"@cedarjs/web": "8.0.0-canary.
|
|
83
|
+
"@cedarjs/auth": "8.0.0-canary.3559",
|
|
84
|
+
"@cedarjs/router": "8.0.0-canary.3559",
|
|
85
|
+
"@cedarjs/web": "8.0.0-canary.3559",
|
|
86
86
|
"@prisma/client": "7.10.1",
|
|
87
87
|
"react": "19.3.1"
|
|
88
88
|
},
|