@samoa-house-lib/shl-types 1.10.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/types.ts +9 -5
- package/utils/unionBuilder.ts +0 -12
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
ConditionVariant,
|
|
6
6
|
ColumnNames
|
|
7
7
|
} from "./constants"
|
|
8
|
-
import { unionFromEnum } from '../utils/unionBuilder'
|
|
9
8
|
|
|
10
9
|
// General
|
|
11
10
|
export type ColumnName = z.infer<typeof dbColumnNameSchema>
|
|
@@ -43,6 +42,7 @@ export const shlIdSchema = z.string()
|
|
|
43
42
|
.brand("SamoaHouseLibraryID")
|
|
44
43
|
|
|
45
44
|
export const nameSchema = z.string()
|
|
45
|
+
.max(200)
|
|
46
46
|
.transform((val) => {
|
|
47
47
|
const initial = val.charAt(0).toUpperCase()
|
|
48
48
|
return initial.concat(val.slice(1, val.length))
|
|
@@ -88,11 +88,15 @@ export const searchableTitleSchema = titleSchema
|
|
|
88
88
|
))
|
|
89
89
|
.brand("SamoaHouseLibrarySearchableTitle")
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
/**
|
|
92
|
+
* NOTE z.nativeEnum has been replaced with z.enum in zod v4
|
|
93
|
+
* Update to .enum when bumping zod version.
|
|
94
|
+
*/
|
|
95
|
+
export const sectionSchema = z.nativeEnum(SectionVariant)
|
|
96
|
+
export const textTypeSchema = z.nativeEnum(TextVariant)
|
|
97
|
+
export const conditionSchema = z.nativeEnum(ConditionVariant)
|
|
94
98
|
|
|
95
|
-
export const dbColumnNameSchema =
|
|
99
|
+
export const dbColumnNameSchema = z.nativeEnum(ColumnNames)
|
|
96
100
|
|
|
97
101
|
export const addBookRequest = z.object({
|
|
98
102
|
donor_first_name: nameSchema.optional(),
|
package/utils/unionBuilder.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod'
|
|
2
|
-
|
|
3
|
-
type NonEmptyStringArray = [z.ZodLiteral<string>, z.ZodLiteral<string>, ...z.ZodLiteral<string>[]]
|
|
4
|
-
|
|
5
|
-
export const unionFromEnum = (enumerable: object): z.ZodUnion<NonEmptyStringArray> => {
|
|
6
|
-
return z.union(
|
|
7
|
-
Object.values(enumerable)
|
|
8
|
-
.map(
|
|
9
|
-
(val) => z.literal(val as z.Primitive)
|
|
10
|
-
) as NonEmptyStringArray
|
|
11
|
-
)
|
|
12
|
-
}
|