@samoa-house-lib/shl-types 1.8.3 → 1.9.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 -3
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -15,12 +15,20 @@ export type ColumnName = z.infer<typeof dbColumnNameSchema>
|
|
|
15
15
|
export type ShlID = z.infer<typeof shlIdSchema>
|
|
16
16
|
export type Name = z.infer<typeof nameSchema>
|
|
17
17
|
export type Terms = z.infer<typeof termsSchema>
|
|
18
|
+
export type SearchTitle = z.infer<typeof searchableTitleSchema>
|
|
18
19
|
export type Section = z.infer<typeof sectionSchema>
|
|
19
20
|
export type TextType = z.infer<typeof textTypeSchema>
|
|
20
21
|
export type Condition = z.infer<typeof conditionSchema>
|
|
21
22
|
export type SearchParameter = z.infer<typeof searchParameterSchema>
|
|
22
23
|
|
|
23
24
|
export const shlIdSchema = z.string().min(3).brand("SamoaHouseLibraryID")
|
|
25
|
+
export const searchableTitleSchema = z.string().toLowerCase()
|
|
26
|
+
.transform((title) => {
|
|
27
|
+
title
|
|
28
|
+
.replace("_", " ")
|
|
29
|
+
.replace(" & ", " and ")
|
|
30
|
+
.replace(/[^a-zA-Z0-9 ]/g, "") // Remove special characters
|
|
31
|
+
})
|
|
24
32
|
|
|
25
33
|
export const nameSchema = z.string().transform((val) => {
|
|
26
34
|
const initial = val.charAt(0).toUpperCase()
|
|
@@ -56,9 +64,7 @@ export const addBookRequest = z.object({
|
|
|
56
64
|
|
|
57
65
|
export const newDbEntrySchema = addBookRequest.extend({
|
|
58
66
|
shl_id: shlIdSchema,
|
|
59
|
-
searchable_title:
|
|
60
|
-
return title.replace(/[^a-zA-Z0-9 ]/g, "") // Remove special characters
|
|
61
|
-
})
|
|
67
|
+
searchable_title: searchableTitleSchema
|
|
62
68
|
})
|
|
63
69
|
|
|
64
70
|
export const dbEntrySchema = newDbEntrySchema.extend({
|