Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
refactor: replace zod schema deprecated function nonempty() with `m…
Browse files Browse the repository at this point in the history
…in(1)` (#69)

## 🎯 Changes

- replaced zod `nonempty()` function with `min(1)`

## ✅ Checklist

- [x] I have followed every step in the [contributing guide](https://github.com/saud-alnasser/cachescribe/blob/main/CONTRIBUTING.md).
- [x] If necessary, I have added or updated the tests related to the changes made.
- [x] If necessary, I have added documentation related to the changes made.
  • Loading branch information
saud-alnasser authored Feb 7, 2024
1 parent 821a001 commit b989033
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-eyes-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cachescribe": patch
---

resolved usage of zod deprecated functions.
19 changes: 11 additions & 8 deletions src/cache.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import superjson from 'superjson';
import slash from 'slash';
import fs from 'fs-extra';
import { hash, hashAlgorithms } from './hash';
import { join } from 'node:path';
import slash from 'slash';
import superjson from 'superjson';
import { z } from 'zod';
import { hash, hashAlgorithms } from './hash';

const CacheOptionsSchema = z.object({
/**
Expand All @@ -14,14 +14,14 @@ const CacheOptionsSchema = z.object({
* @default
* 'default'
*/
namespace: z.string().nonempty().optional(),
namespace: z.string().min(1).optional(),

/**
* directory that the snapshot file will be written in.
*
* @default node_modules/.cache/cachescribe
*/
directory: z.string().nonempty().optional(),
directory: z.string().min(1).optional(),

/**
* file extension to be used for the cache snapshot file.
Expand Down Expand Up @@ -98,7 +98,7 @@ const CacheEntrySchema = z.object({
/**
* key of the entry.
*/
key: z.string().nonempty(),
key: z.string().min(1),

/**
* duration in seconds for the time to live for the entry.
Expand Down Expand Up @@ -129,7 +129,7 @@ const CacheSnapshotSchema = z.object({
/**
* id of the snapshot file.
*/
id: z.string().nonempty(),
id: z.string().min(1),
}),

/**
Expand All @@ -145,7 +145,10 @@ const CacheEntryParamsSchema = z
entries: z
.array(
z
.object({ key: z.string().nonempty(), value: z.unknown() })
.object({
key: z.string().min(1),
value: z.unknown(),
})
.merge(CacheOptionsSchema.pick({ ttl: true }))
)
.nonempty()
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './hash';
export * from './cache';
export * from './hash';

0 comments on commit b989033

Please sign in to comment.