-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 🚚 move functions to separate files
- Loading branch information
Showing
21 changed files
with
1,025 additions
and
934 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
import * as _prisma_client_runtime_library from '@prisma/client/runtime/library'; | ||
import { Prisma } from '@prisma/client'; | ||
import { PureAbility, AbilityTuple } from '@casl/ability'; | ||
import { PrismaQuery } from '@casl/prisma'; | ||
|
||
type DefaultCaslAction = "create" | "read" | "update" | "delete"; | ||
type PrismaCaslOperation = 'create' | 'createMany' | 'createManyAndReturn' | 'upsert' | 'findFirst' | 'findFirstOrThrow' | 'findMany' | 'findUnique' | 'findUniqueOrThrow' | 'aggregate' | 'count' | 'groupBy' | 'update' | 'updateMany' | 'delete' | 'deleteMany'; | ||
declare const caslOperationDict: Record<PrismaCaslOperation, { | ||
action: DefaultCaslAction; | ||
dataQuery: boolean; | ||
whereQuery: boolean; | ||
includeSelectQuery: boolean; | ||
}>; | ||
/** | ||
* enrich a prisma client to check for CASL abilities even in nested queries | ||
* | ||
* `client.$extends(useCaslAbilities(build()))` | ||
* | ||
* https://casl.js.org/v6/en/package/casl-prisma | ||
* | ||
* | ||
* @param abilities CASL prisma abilities | ||
* @returns enriched prisma client | ||
*/ | ||
declare const useCaslAbilities: (abilities: PureAbility<AbilityTuple, PrismaQuery>) => (client: any) => { | ||
$extends: { | ||
extArgs: _prisma_client_runtime_library.InternalArgs<unknown, unknown, {}, unknown>; | ||
}; | ||
}; | ||
declare function applyCaslToQuery(operation: any, args: any, abilities: PureAbility<AbilityTuple, PrismaQuery>, model: Prisma.ModelName): any; | ||
declare function applyDataQuery(abilities: PureAbility<AbilityTuple, PrismaQuery>, args: any, action: string, model: string): any; | ||
declare function applyWhereQuery(abilities: PureAbility<AbilityTuple, PrismaQuery>, args: any, action: string, model: string, relation?: string): any; | ||
declare const applySelectPermittedFields: (abilities: PureAbility<AbilityTuple, PrismaQuery>, args: any, model: string) => any; | ||
declare const applyIncludeSelectQuery: (abilities: PureAbility<AbilityTuple, PrismaQuery>, args: any, model: string) => any; | ||
declare function capitalizeFirstLetter(string: string): string; | ||
declare function isSubset(obj1: any, obj2: any): boolean; | ||
|
||
export { type PrismaCaslOperation, applyCaslToQuery, applyDataQuery, applyIncludeSelectQuery, applySelectPermittedFields, applyWhereQuery, capitalizeFirstLetter, caslOperationDict, isSubset, useCaslAbilities }; | ||
export { useCaslAbilities }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
import * as _prisma_client_runtime_library from '@prisma/client/runtime/library'; | ||
import { Prisma } from '@prisma/client'; | ||
import { PureAbility, AbilityTuple } from '@casl/ability'; | ||
import { PrismaQuery } from '@casl/prisma'; | ||
|
||
type DefaultCaslAction = "create" | "read" | "update" | "delete"; | ||
type PrismaCaslOperation = 'create' | 'createMany' | 'createManyAndReturn' | 'upsert' | 'findFirst' | 'findFirstOrThrow' | 'findMany' | 'findUnique' | 'findUniqueOrThrow' | 'aggregate' | 'count' | 'groupBy' | 'update' | 'updateMany' | 'delete' | 'deleteMany'; | ||
declare const caslOperationDict: Record<PrismaCaslOperation, { | ||
action: DefaultCaslAction; | ||
dataQuery: boolean; | ||
whereQuery: boolean; | ||
includeSelectQuery: boolean; | ||
}>; | ||
/** | ||
* enrich a prisma client to check for CASL abilities even in nested queries | ||
* | ||
* `client.$extends(useCaslAbilities(build()))` | ||
* | ||
* https://casl.js.org/v6/en/package/casl-prisma | ||
* | ||
* | ||
* @param abilities CASL prisma abilities | ||
* @returns enriched prisma client | ||
*/ | ||
declare const useCaslAbilities: (abilities: PureAbility<AbilityTuple, PrismaQuery>) => (client: any) => { | ||
$extends: { | ||
extArgs: _prisma_client_runtime_library.InternalArgs<unknown, unknown, {}, unknown>; | ||
}; | ||
}; | ||
declare function applyCaslToQuery(operation: any, args: any, abilities: PureAbility<AbilityTuple, PrismaQuery>, model: Prisma.ModelName): any; | ||
declare function applyDataQuery(abilities: PureAbility<AbilityTuple, PrismaQuery>, args: any, action: string, model: string): any; | ||
declare function applyWhereQuery(abilities: PureAbility<AbilityTuple, PrismaQuery>, args: any, action: string, model: string, relation?: string): any; | ||
declare const applySelectPermittedFields: (abilities: PureAbility<AbilityTuple, PrismaQuery>, args: any, model: string) => any; | ||
declare const applyIncludeSelectQuery: (abilities: PureAbility<AbilityTuple, PrismaQuery>, args: any, model: string) => any; | ||
declare function capitalizeFirstLetter(string: string): string; | ||
declare function isSubset(obj1: any, obj2: any): boolean; | ||
|
||
export { type PrismaCaslOperation, applyCaslToQuery, applyDataQuery, applyIncludeSelectQuery, applySelectPermittedFields, applyWhereQuery, capitalizeFirstLetter, caslOperationDict, isSubset, useCaslAbilities }; | ||
export { useCaslAbilities }; |
Oops, something went wrong.