Skip to content

Commit e2a3f9b

Browse files
committed
update tests
1 parent 055c1fc commit e2a3f9b

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

packages/runtime/src/client/client-impl.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ export class ClientImpl<Schema extends SchemaDef> {
124124
return this.kyselyRaw;
125125
}
126126

127+
get isTransaction() {
128+
return this.kysely.isTransaction;
129+
}
130+
127131
/**
128132
* Create a new client with a new query executor.
129133
*/
@@ -162,7 +166,7 @@ export class ClientImpl<Schema extends SchemaDef> {
162166
async $transaction(input: any, options?: { isolationLevel?: TransactionIsolationLevel }) {
163167
invariant(
164168
typeof input === 'function' || (Array.isArray(input) && input.every((p) => p.then && p.cb)),
165-
'Invalid transaction input, expected a function or an array of ZenStackClient promises',
169+
'Invalid transaction input, expected a function or an array of ZenStackPromise',
166170
);
167171
if (typeof input === 'function') {
168172
return this.interactiveTransaction(input, options);

packages/runtime/src/client/plugin.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ type OnQueryHooks<Schema extends SchemaDef = SchemaDef> = {
157157
type OnQueryOperationHooks<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
158158
[Operation in keyof ModelOperations<Schema, Model>]?: (
159159
ctx: OnQueryHookContext<Schema, Model, Operation>,
160-
) => ReturnType<ModelOperations<Schema, Model>[Operation]>;
160+
) => Promise<Awaited<ReturnType<ModelOperations<Schema, Model>[Operation]>>>;
161161
} & {
162162
$allOperations?: (ctx: {
163163
model: Model;
@@ -192,11 +192,10 @@ type OnQueryHookContext<
192192
* It takes the same arguments as the operation method.
193193
*
194194
* @param args The query arguments.
195-
* @param tx Optional transaction client to use for the query.
196195
*/
197196
query: (
198197
args: Parameters<ModelOperations<Schema, Model>[Operation]>[0],
199-
tx?: ClientContract<Schema>,
198+
// tx?: ClientContract<Schema>,
200199
) => ReturnType<ModelOperations<Schema, Model>[Operation]>;
201200

202201
/**

packages/runtime/test/plugin/query-lifecycle.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,17 @@ describe('Query interception tests', () => {
254254
).toResolveTruthy();
255255
});
256256

257-
it('rolls back the effect with transaction', async () => {
257+
// TODO: revisit transactional hooks
258+
it.skip('rolls back the effect with transaction', async () => {
258259
let hooksCalled = false;
259260
const client = _client.$use({
260261
id: 'test-plugin',
261262
onQuery: {
262263
user: {
263264
create: async (ctx) => {
264265
hooksCalled = true;
265-
return ctx.client.$transaction(async (tx) => {
266-
await ctx.query(ctx.args, tx);
266+
return ctx.client.$transaction(async (_tx) => {
267+
await ctx.query(ctx.args /*, tx*/);
267268
throw new Error('trigger error');
268269
});
269270
},

0 commit comments

Comments
 (0)