-
-
Notifications
You must be signed in to change notification settings - Fork 104
merge dev to main (v2.5.2) #1722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ab261ae
8b56d7d
1395892
1ea8e55
7880bad
f2a3686
57652a1
cb68815
738bba6
64198a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ plugins { | |
} | ||
|
||
group = "dev.zenstack" | ||
version = "2.5.1" | ||
version = "2.5.2" | ||
|
||
repositories { | ||
mavenCentral() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import semver from 'semver'; | ||
import { PRISMA_MINIMUM_VERSION } from '../../constants'; | ||
import { isDelegateModel, type ModelMeta } from '../../cross'; | ||
import type { EnhancementContext, EnhancementKind, EnhancementOptions, ZodSchemas } from '../../types'; | ||
import type { | ||
DbClientContract, | ||
EnhancementContext, | ||
EnhancementKind, | ||
EnhancementOptions, | ||
ZodSchemas, | ||
} from '../../types'; | ||
import { withDefaultAuth } from './default-auth'; | ||
import { withDelegate } from './delegate'; | ||
import { Logger } from './logger'; | ||
import { withOmit } from './omit'; | ||
import { withPassword } from './password'; | ||
import { withPolicy } from './policy'; | ||
import { policyProcessIncludeRelationPayload, withPolicy } from './policy'; | ||
import type { PolicyDef } from './types'; | ||
|
||
/** | ||
|
@@ -41,6 +47,18 @@ export type InternalEnhancementOptions = EnhancementOptions & { | |
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
prismaModule: any; | ||
|
||
/** | ||
* A callback shared among enhancements to process the payload for including a relation | ||
* field. e.g.: `{ author: true }`. | ||
*/ | ||
processIncludeRelationPayload?: ( | ||
prisma: DbClientContract, | ||
model: string, | ||
payload: unknown, | ||
options: InternalEnhancementOptions, | ||
context: EnhancementContext | undefined | ||
) => Promise<void>; | ||
Comment on lines
+55
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify a more precise type for the The If there is a defined type that represents the structure of the payload (e.g., processIncludeRelationPayload?: (
prisma: DbClientContract,
model: string,
- payload: unknown,
+ payload: IncludeRelationPayload,
options: InternalEnhancementOptions,
context: EnhancementContext | undefined
) => Promise<void>;
|
||
}; | ||
|
||
/** | ||
|
@@ -89,7 +107,7 @@ export function createEnhancement<DbClient extends object>( | |
'Your ZModel contains delegate models but "delegate" enhancement kind is not enabled. This may result in unexpected behavior.' | ||
); | ||
} else { | ||
result = withDelegate(result, options); | ||
result = withDelegate(result, options, context); | ||
} | ||
} | ||
|
||
|
@@ -103,6 +121,16 @@ export function createEnhancement<DbClient extends object>( | |
// 'policy' and 'validation' enhancements are both enabled by `withPolicy` | ||
if (kinds.includes('policy') || kinds.includes('validation')) { | ||
result = withPolicy(result, options, context); | ||
|
||
// if any enhancement is to introduce an inclusion of a relation field, the | ||
// inclusion payload must be processed by the policy enhancement for injecting | ||
// access control rules | ||
|
||
// TODO: this is currently a global callback shared among all enhancements, which | ||
// is far from ideal | ||
|
||
options.processIncludeRelationPayload = policyProcessIncludeRelationPayload; | ||
|
||
if (kinds.includes('policy') && hasDefaultAuth) { | ||
// @default(auth()) proxy | ||
result = withDefaultAuth(result, options, context); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Changelog is severely outdated and missing version 2.5.2
The changelog has not been updated to include version 2.5.2 or any other 2.x versions. In fact, the most recent entry in the main CHANGELOG.md file is for version 0.5.0, dated 2022-12-15. This significant gap in documentation is a critical issue that needs immediate attention.
Action items:
Analysis chain
LGTM!
The version update aligns with the PR objective of merging dev to main for v2.5.2.
Please verify that the changelog has been updated to reflect the changes included in this release.
Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 433
Script:
Length of output: 4639