@voyantjs/resources 0.1.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/LICENSE +109 -0
- package/README.md +34 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/routes.d.ts +1214 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +330 -0
- package/dist/schema.d.ts +1149 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +164 -0
- package/dist/service.d.ts +372 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +287 -0
- package/dist/validation.d.ts +335 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +111 -0
- package/package.json +51 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { booleanQueryParam } from "@voyantjs/db/helpers";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const paginationSchema = z.object({
|
|
4
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
5
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
6
|
+
});
|
|
7
|
+
const isoDateSchema = z.string().date();
|
|
8
|
+
const isoDateTimeSchema = z.string().datetime();
|
|
9
|
+
export const resourceKindSchema = z.enum(["guide", "vehicle", "room", "boat", "equipment", "other"]);
|
|
10
|
+
export const resourceAllocationModeSchema = z.enum(["shared", "exclusive"]);
|
|
11
|
+
export const resourceAssignmentStatusSchema = z.enum([
|
|
12
|
+
"reserved",
|
|
13
|
+
"assigned",
|
|
14
|
+
"released",
|
|
15
|
+
"cancelled",
|
|
16
|
+
"completed",
|
|
17
|
+
]);
|
|
18
|
+
export const resourceCoreSchema = z.object({
|
|
19
|
+
supplierId: z.string().nullable().optional(),
|
|
20
|
+
facilityId: z.string().nullable().optional(),
|
|
21
|
+
kind: resourceKindSchema,
|
|
22
|
+
name: z.string().min(1),
|
|
23
|
+
code: z.string().nullable().optional(),
|
|
24
|
+
capacity: z.number().int().min(0).nullable().optional(),
|
|
25
|
+
active: z.boolean().default(true),
|
|
26
|
+
notes: z.string().nullable().optional(),
|
|
27
|
+
});
|
|
28
|
+
export const insertResourceSchema = resourceCoreSchema;
|
|
29
|
+
export const updateResourceSchema = resourceCoreSchema.partial();
|
|
30
|
+
export const resourceListQuerySchema = paginationSchema.extend({
|
|
31
|
+
supplierId: z.string().optional(),
|
|
32
|
+
facilityId: z.string().optional(),
|
|
33
|
+
kind: resourceKindSchema.optional(),
|
|
34
|
+
active: booleanQueryParam.optional(),
|
|
35
|
+
});
|
|
36
|
+
export const resourcePoolCoreSchema = z.object({
|
|
37
|
+
productId: z.string().nullable().optional(),
|
|
38
|
+
kind: resourceKindSchema,
|
|
39
|
+
name: z.string().min(1),
|
|
40
|
+
sharedCapacity: z.number().int().min(0).nullable().optional(),
|
|
41
|
+
active: z.boolean().default(true),
|
|
42
|
+
notes: z.string().nullable().optional(),
|
|
43
|
+
});
|
|
44
|
+
export const insertResourcePoolSchema = resourcePoolCoreSchema;
|
|
45
|
+
export const updateResourcePoolSchema = resourcePoolCoreSchema.partial();
|
|
46
|
+
export const resourcePoolListQuerySchema = paginationSchema.extend({
|
|
47
|
+
productId: z.string().optional(),
|
|
48
|
+
kind: resourceKindSchema.optional(),
|
|
49
|
+
active: booleanQueryParam.optional(),
|
|
50
|
+
});
|
|
51
|
+
export const insertResourcePoolMemberSchema = z.object({
|
|
52
|
+
poolId: z.string(),
|
|
53
|
+
resourceId: z.string(),
|
|
54
|
+
});
|
|
55
|
+
export const resourcePoolMemberListQuerySchema = paginationSchema.extend({
|
|
56
|
+
poolId: z.string().optional(),
|
|
57
|
+
resourceId: z.string().optional(),
|
|
58
|
+
});
|
|
59
|
+
export const resourceRequirementCoreSchema = z.object({
|
|
60
|
+
poolId: z.string(),
|
|
61
|
+
productId: z.string(),
|
|
62
|
+
availabilityRuleId: z.string().nullable().optional(),
|
|
63
|
+
startTimeId: z.string().nullable().optional(),
|
|
64
|
+
quantityRequired: z.number().int().min(1).default(1),
|
|
65
|
+
allocationMode: resourceAllocationModeSchema.default("shared"),
|
|
66
|
+
priority: z.number().int().default(0),
|
|
67
|
+
});
|
|
68
|
+
export const insertResourceRequirementSchema = resourceRequirementCoreSchema;
|
|
69
|
+
export const updateResourceRequirementSchema = resourceRequirementCoreSchema.partial();
|
|
70
|
+
export const resourceRequirementListQuerySchema = paginationSchema.extend({
|
|
71
|
+
poolId: z.string().optional(),
|
|
72
|
+
productId: z.string().optional(),
|
|
73
|
+
availabilityRuleId: z.string().optional(),
|
|
74
|
+
startTimeId: z.string().optional(),
|
|
75
|
+
});
|
|
76
|
+
export const insertResourceAllocationSchema = insertResourceRequirementSchema;
|
|
77
|
+
export const updateResourceAllocationSchema = updateResourceRequirementSchema;
|
|
78
|
+
export const resourceAllocationListQuerySchema = resourceRequirementListQuerySchema;
|
|
79
|
+
export const resourceSlotAssignmentCoreSchema = z.object({
|
|
80
|
+
slotId: z.string(),
|
|
81
|
+
poolId: z.string().nullable().optional(),
|
|
82
|
+
resourceId: z.string().nullable().optional(),
|
|
83
|
+
bookingId: z.string().nullable().optional(),
|
|
84
|
+
status: resourceAssignmentStatusSchema.default("reserved"),
|
|
85
|
+
assignedBy: z.string().nullable().optional(),
|
|
86
|
+
releasedAt: isoDateTimeSchema.nullable().optional(),
|
|
87
|
+
notes: z.string().nullable().optional(),
|
|
88
|
+
});
|
|
89
|
+
export const insertResourceSlotAssignmentSchema = resourceSlotAssignmentCoreSchema;
|
|
90
|
+
export const updateResourceSlotAssignmentSchema = resourceSlotAssignmentCoreSchema.partial();
|
|
91
|
+
export const resourceSlotAssignmentListQuerySchema = paginationSchema.extend({
|
|
92
|
+
slotId: z.string().optional(),
|
|
93
|
+
poolId: z.string().optional(),
|
|
94
|
+
resourceId: z.string().optional(),
|
|
95
|
+
bookingId: z.string().optional(),
|
|
96
|
+
status: resourceAssignmentStatusSchema.optional(),
|
|
97
|
+
});
|
|
98
|
+
export const resourceCloseoutCoreSchema = z.object({
|
|
99
|
+
resourceId: z.string(),
|
|
100
|
+
dateLocal: isoDateSchema,
|
|
101
|
+
startsAt: isoDateTimeSchema.nullable().optional(),
|
|
102
|
+
endsAt: isoDateTimeSchema.nullable().optional(),
|
|
103
|
+
reason: z.string().nullable().optional(),
|
|
104
|
+
createdBy: z.string().nullable().optional(),
|
|
105
|
+
});
|
|
106
|
+
export const insertResourceCloseoutSchema = resourceCloseoutCoreSchema;
|
|
107
|
+
export const updateResourceCloseoutSchema = resourceCloseoutCoreSchema.partial();
|
|
108
|
+
export const resourceCloseoutListQuerySchema = paginationSchema.extend({
|
|
109
|
+
resourceId: z.string().optional(),
|
|
110
|
+
dateLocal: isoDateSchema.optional(),
|
|
111
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/resources",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./schema": {
|
|
12
|
+
"types": "./dist/schema.d.ts",
|
|
13
|
+
"import": "./dist/schema.js"
|
|
14
|
+
},
|
|
15
|
+
"./validation": {
|
|
16
|
+
"types": "./dist/validation.d.ts",
|
|
17
|
+
"import": "./dist/validation.js"
|
|
18
|
+
},
|
|
19
|
+
"./routes": {
|
|
20
|
+
"types": "./dist/routes.d.ts",
|
|
21
|
+
"import": "./dist/routes.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"drizzle-orm": "^0.45.2",
|
|
26
|
+
"hono": "^4.12.10",
|
|
27
|
+
"zod": "^4.3.6",
|
|
28
|
+
"@voyantjs/hono": "0.1.0",
|
|
29
|
+
"@voyantjs/db": "0.1.0",
|
|
30
|
+
"@voyantjs/core": "0.1.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"typescript": "^6.0.2",
|
|
34
|
+
"@voyantjs/voyant-typescript-config": "0.1.0"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"lint": "biome check src/",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"build": "tsc -p tsconfig.json",
|
|
47
|
+
"clean": "rm -rf dist"
|
|
48
|
+
},
|
|
49
|
+
"main": "./dist/index.js",
|
|
50
|
+
"types": "./dist/index.d.ts"
|
|
51
|
+
}
|