Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/runtime/src/client/crud/operations/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { BaseOperationHandler } from './base';
export class AggregateOperationHandler<Schema extends SchemaDef> extends BaseOperationHandler<Schema> {
async handle(_operation: 'aggregate', args: unknown | undefined) {
// normalize args to strip `undefined` fields
const normalizeArgs = this.normalizeArgs(args);
const normalizedArgs = this.normalizeArgs(args);

// parse args
const parsedArgs = this.inputValidator.validateAggregateArgs(this.model, normalizeArgs);
const parsedArgs = this.inputValidator.validateAggregateArgs(this.model, normalizedArgs);

let query = this.kysely.selectFrom((eb) => {
// nested query for filtering and pagination
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime/src/client/crud/operations/count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { BaseOperationHandler } from './base';
export class CountOperationHandler<Schema extends SchemaDef> extends BaseOperationHandler<Schema> {
async handle(_operation: 'count', args: unknown | undefined) {
// normalize args to strip `undefined` fields
const normalizeArgs = this.normalizeArgs(args);
const normalizedArgs = this.normalizeArgs(args);

// parse args
const parsedArgs = this.inputValidator.validateCountArgs(this.model, normalizeArgs);
const parsedArgs = this.inputValidator.validateCountArgs(this.model, normalizedArgs);

let query = this.kysely.selectFrom((eb) => {
// nested query for filtering and pagination
Expand Down
8 changes: 4 additions & 4 deletions packages/runtime/src/client/crud/operations/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import { BaseOperationHandler } from './base';
export class CreateOperationHandler<Schema extends SchemaDef> extends BaseOperationHandler<Schema> {
async handle(operation: 'create' | 'createMany' | 'createManyAndReturn', args: unknown | undefined) {
// normalize args to strip `undefined` fields
const normalizeArgs = this.normalizeArgs(args);
const normalizedArgs = this.normalizeArgs(args);

return match(operation)
.with('create', () => this.runCreate(this.inputValidator.validateCreateArgs(this.model, normalizeArgs)))
.with('create', () => this.runCreate(this.inputValidator.validateCreateArgs(this.model, normalizedArgs)))
.with('createMany', () => {
return this.runCreateMany(this.inputValidator.validateCreateManyArgs(this.model, normalizeArgs));
return this.runCreateMany(this.inputValidator.validateCreateManyArgs(this.model, normalizedArgs));
})
.with('createManyAndReturn', () => {
return this.runCreateManyAndReturn(
this.inputValidator.validateCreateManyAndReturnArgs(this.model, normalizeArgs),
this.inputValidator.validateCreateManyAndReturnArgs(this.model, normalizedArgs),
);
})
.exhaustive();
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/src/client/crud/operations/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { BaseOperationHandler } from './base';
export class DeleteOperationHandler<Schema extends SchemaDef> extends BaseOperationHandler<Schema> {
async handle(operation: 'delete' | 'deleteMany', args: unknown | undefined) {
// normalize args to strip `undefined` fields
const normalizeArgs = this.normalizeArgs(args);
const normalizedArgs = this.normalizeArgs(args);

return match(operation)
.with('delete', () => this.runDelete(this.inputValidator.validateDeleteArgs(this.model, normalizeArgs)))
.with('delete', () => this.runDelete(this.inputValidator.validateDeleteArgs(this.model, normalizedArgs)))
.with('deleteMany', () =>
this.runDeleteMany(this.inputValidator.validateDeleteManyArgs(this.model, normalizeArgs)),
this.runDeleteMany(this.inputValidator.validateDeleteManyArgs(this.model, normalizedArgs)),
)
.exhaustive();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime/src/client/crud/operations/group-by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { BaseOperationHandler } from './base';
export class GroupByeOperationHandler<Schema extends SchemaDef> extends BaseOperationHandler<Schema> {
async handle(_operation: 'groupBy', args: unknown | undefined) {
// normalize args to strip `undefined` fields
const normalizeArgs = this.normalizeArgs(args);
const normalizedArgs = this.normalizeArgs(args);

// parse args
const parsedArgs = this.inputValidator.validateGroupByArgs(this.model, normalizeArgs);
const parsedArgs = this.inputValidator.validateGroupByArgs(this.model, normalizedArgs);

let query = this.kysely.selectFrom((eb) => {
// nested query for filtering and pagination
Expand Down
10 changes: 5 additions & 5 deletions packages/runtime/src/client/crud/operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import { BaseOperationHandler } from './base';
export class UpdateOperationHandler<Schema extends SchemaDef> extends BaseOperationHandler<Schema> {
async handle(operation: 'update' | 'updateMany' | 'updateManyAndReturn' | 'upsert', args: unknown) {
// normalize args to strip `undefined` fields
const normalizeArgs = this.normalizeArgs(args);
const normalizedArgs = this.normalizeArgs(args);

return match(operation)
.with('update', () => this.runUpdate(this.inputValidator.validateUpdateArgs(this.model, normalizeArgs)))
.with('update', () => this.runUpdate(this.inputValidator.validateUpdateArgs(this.model, normalizedArgs)))
.with('updateMany', () =>
this.runUpdateMany(this.inputValidator.validateUpdateManyArgs(this.model, normalizeArgs)),
this.runUpdateMany(this.inputValidator.validateUpdateManyArgs(this.model, normalizedArgs)),
)
.with('updateManyAndReturn', () =>
this.runUpdateManyAndReturn(
this.inputValidator.validateUpdateManyAndReturnArgs(this.model, normalizeArgs),
this.inputValidator.validateUpdateManyAndReturnArgs(this.model, normalizedArgs),
),
)
.with('upsert', () => this.runUpsert(this.inputValidator.validateUpsertArgs(this.model, normalizeArgs)))
.with('upsert', () => this.runUpsert(this.inputValidator.validateUpsertArgs(this.model, normalizedArgs)))
.exhaustive();
}

Expand Down
6 changes: 1 addition & 5 deletions packages/runtime/src/client/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ export class QueryError extends Error {
/**
* Error thrown when an internal error occurs.
*/
export class InternalError extends Error {
constructor(message: string) {
super(message);
}
}
export class InternalError extends Error {}

/**
* Error thrown when an entity is not found.
Expand Down