-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Drop older
timeStamp
field support (#33734)
- Loading branch information
Showing
5 changed files
with
12 additions
and
58 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
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
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
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,34 +1,16 @@ | ||
import { z } from 'zod'; | ||
|
||
const invalidFieldsMsg = | ||
'Cache object should have `etag` or `lastModified` fields'; | ||
|
||
export const HttpCacheSchema = z | ||
.object({ | ||
// TODO: remove this migration part during the Christmas eve 2024 | ||
timeStamp: z.string().optional(), | ||
timestamp: z.string().optional(), | ||
}) | ||
.passthrough() | ||
.transform((data) => { | ||
if (data.timeStamp) { | ||
data.timestamp = data.timeStamp; | ||
delete data.timeStamp; | ||
} | ||
return data; | ||
etag: z.string().optional(), | ||
lastModified: z.string().optional(), | ||
httpResponse: z.unknown(), | ||
timestamp: z.string(), | ||
}) | ||
.pipe( | ||
z | ||
.object({ | ||
etag: z.string().optional(), | ||
lastModified: z.string().optional(), | ||
httpResponse: z.unknown(), | ||
timestamp: z.string(), | ||
}) | ||
.refine( | ||
({ etag, lastModified }) => etag ?? lastModified, | ||
invalidFieldsMsg, | ||
), | ||
.refine( | ||
({ etag, lastModified }) => etag ?? lastModified, | ||
'Cache object should have `etag` or `lastModified` fields', | ||
) | ||
.nullable() | ||
.catch(null); | ||
export type HttpCache = z.infer<typeof HttpCacheSchema>; |
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