@samoa-house-lib/shl-types 1.6.3 → 1.7.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/constants.ts +4 -4
- package/src/types.ts +29 -23
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -75,13 +75,9 @@ export enum SectionVariant {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export enum ColumnNames {
|
|
78
|
-
ID = 'id',
|
|
79
|
-
RUNNING_NUMBER = 'running_number',
|
|
80
78
|
DONOR_FIRST_NAME = 'donor_first_name',
|
|
81
79
|
DONOR_LAST_NAME = 'donor_last_name',
|
|
82
|
-
SHL_ID = 'shl_id',
|
|
83
80
|
TERMS = 'terms',
|
|
84
|
-
SEARCH_TITLE = 'searchable_title',
|
|
85
81
|
TITLE = 'title',
|
|
86
82
|
AUTHOR_FIRST_NAME = 'author_first_name',
|
|
87
83
|
AUTHOR_LAST_NAME = 'author_last_name',
|
|
@@ -95,6 +91,10 @@ export enum SectionVariant {
|
|
|
95
91
|
NOTES = 'notes',
|
|
96
92
|
SPECIAL_CONDITION = 'special_conditions',
|
|
97
93
|
CONDITION = 'condition',
|
|
94
|
+
SHL_ID = 'shl_id',
|
|
95
|
+
SEARCH_TITLE = 'searchable_title',
|
|
96
|
+
ID = 'id',
|
|
97
|
+
RUNNING_NUMBER = 'running_number',
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
export enum Responses {
|
package/src/types.ts
CHANGED
|
@@ -18,12 +18,13 @@ export type Terms = z.infer<typeof termsSchema>
|
|
|
18
18
|
export type Section = z.infer<typeof sectionSchema>
|
|
19
19
|
export type TextType = z.infer<typeof textTypeSchema>
|
|
20
20
|
export type Condition = z.infer<typeof conditionSchema>
|
|
21
|
+
export type SearchParameter = z.infer<typeof searchParameterSchema>
|
|
21
22
|
|
|
22
23
|
export const shlIdSchema = z.string().min(3).brand("SamoaHouseLibraryID")
|
|
23
24
|
|
|
24
25
|
export const nameSchema = z.string().transform((val) => {
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const initial = val.charAt(0).toUpperCase()
|
|
27
|
+
return initial.concat(val.slice(1, val.length))
|
|
27
28
|
})
|
|
28
29
|
|
|
29
30
|
export const termsSchema = z.union([z.literal("D"), z.literal("R")]).optional()
|
|
@@ -50,27 +51,32 @@ export const addBookRequest = z.object({
|
|
|
50
51
|
notes: z.string().max(100).optional().nullable(),
|
|
51
52
|
special_conditions: z.string().optional().nullable(),
|
|
52
53
|
condition: conditionSchema.optional()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
export const newDbEntrySchema = addBookRequest.extend({
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
export const dbEntrySchema = newDbEntrySchema.extend({
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
export const newDbEntrySchema = addBookRequest.extend({
|
|
57
|
+
shl_id: shlIdSchema,
|
|
58
|
+
searchable_title: z.string().toLowerCase()
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
export const dbEntrySchema = newDbEntrySchema.extend({
|
|
61
62
|
id: z.number(),
|
|
62
63
|
running_number: z.number()
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
export const bookBatchSchema = z.array(dbEntrySchema)
|
|
66
|
-
|
|
67
|
-
export const responseSchema = z.object({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
export const bookBatchSchema = z.array(dbEntrySchema)
|
|
67
|
+
|
|
68
|
+
export const responseSchema = z.object({
|
|
69
|
+
message: z.string(),
|
|
70
|
+
data: bookBatchSchema.nullable()
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
export const updateRequestSchema = z.object({
|
|
74
|
+
colName: dbColumnNameSchema,
|
|
75
|
+
colValue: z.string(),
|
|
76
|
+
id: shlIdSchema
|
|
77
|
+
})
|
|
71
78
|
|
|
72
|
-
export const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
})
|
|
79
|
+
export const searchParameterSchema = z.object({
|
|
80
|
+
searchColumn: z.array(dbColumnNameSchema).nullable(),
|
|
81
|
+
searchValue: z.array(z.string()).nullable()
|
|
82
|
+
})
|