Skip to content

Commit 9d6a9c4

Browse files
Merge pull request #15 from peek-travel/feat/timeslot-inherited-resource-allocations
feat: use inheritedResourceAllocations for timeslot assigned resources
2 parents 96fdc24 + a971334 commit 9d6a9c4

7 files changed

Lines changed: 22 additions & 22 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@peektravel/app-utilities",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"description": "GraphQL JS mapping utilities extracted from the Peek Pro Autopilot connector.",
55
"license": "MIT",
66
"repository": {

src/internal/timeslots/timeslot-converter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function fromTimeslotNode(
5555
durationMin: node.minuteLength ?? 0,
5656
date: node.date || "",
5757
startTime: node.start ?? null,
58-
assignedResources: mapAssignedResources(node.resourceAllocations),
58+
assignedResources: mapAssignedResources(node.inheritedResourceAllocations),
5959
};
6060
}
6161

@@ -69,11 +69,11 @@ function mapAssignedResources(
6969
return allocations.map((allocation) => {
7070
const pool = allocation.resourcePool;
7171
return {
72-
id: pool?.id || "",
7372
name: pool?.name || "",
7473
capacity: pool?.capacity ?? 0,
7574
category: pool?.category || "",
7675
quantity: allocation.quantity ?? 0,
76+
status: allocation.status || "",
7777
accountUserId: pool?.accountUser?.id ?? null,
7878
};
7979
});

src/internal/timeslots/timeslot-queries.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export const TIMESLOTS_QUERY = `
2020
minuteLength
2121
status
2222
date
23-
resourceAllocations {
23+
inheritedResourceAllocations {
2424
quantity
25+
status
2526
resourcePool {
26-
id
2727
name
2828
category
2929
capacity
@@ -60,10 +60,10 @@ export const TIMESLOT_BY_ID_QUERY = `
6060
minuteLength
6161
status
6262
date
63-
resourceAllocations {
63+
inheritedResourceAllocations {
6464
quantity
65+
status
6566
resourcePool {
66-
id
6767
name
6868
category
6969
capacity
@@ -99,11 +99,11 @@ export const UPDATE_TIMESLOT_MUTATION = `
9999
}
100100
`;
101101

102-
/** A single resource allocation on a timeslot node. */
102+
/** A single inherited resource allocation on a timeslot node. */
103103
export interface TimeslotResourceAllocationNode {
104104
quantity: number | null;
105+
status: string | null;
105106
resourcePool: {
106-
id: string;
107107
name: string;
108108
category: string;
109109
capacity: number | null;
@@ -124,7 +124,7 @@ export interface TimeslotNode {
124124
status: string | null;
125125
date: string | null;
126126
start?: string | null;
127-
resourceAllocations: TimeslotResourceAllocationNode[] | null;
127+
inheritedResourceAllocations: TimeslotResourceAllocationNode[] | null;
128128
}
129129

130130
/** `data` payload of {@link TIMESLOTS_QUERY}. */

src/models/timeslot.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ export interface Timeslot {
3434

3535
/** A resource allocated to a {@link Timeslot}. */
3636
export interface AssignedResource {
37-
/** Resource pool id. */
38-
id: string;
3937
/** Resource pool name. */
4038
name: string;
4139
/** Resource pool capacity. */
@@ -44,6 +42,8 @@ export interface AssignedResource {
4442
category: string;
4543
/** Allocated quantity. */
4644
quantity: number;
45+
/** Allocation status (e.g. `"ACTIVE"`). */
46+
status: string;
4747
/** Backing account user id, or null. */
4848
accountUserId: string | null;
4949
}

test/timeslots/timeslot-converter.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ const fullNode: TimeslotNode = {
1818
status: "OPEN",
1919
date: "2026-01-02",
2020
start: "2026-01-02T10:00:00Z",
21-
resourceAllocations: [
21+
inheritedResourceAllocations: [
2222
{
2323
quantity: 1,
24+
status: "ACTIVE",
2425
resourcePool: {
25-
id: "pool-1",
2626
name: "Ada",
2727
category: "guide",
2828
capacity: 5,
@@ -49,11 +49,11 @@ describe("fromTimeslotNode", () => {
4949
startTime: "2026-01-02T10:00:00Z",
5050
assignedResources: [
5151
{
52-
id: "pool-1",
5352
name: "Ada",
5453
capacity: 5,
5554
category: "guide",
5655
quantity: 1,
56+
status: "ACTIVE",
5757
accountUserId: "u1",
5858
},
5959
],
@@ -90,7 +90,7 @@ describe("fromTimeslotNode", () => {
9090
minuteLength: null,
9191
status: null,
9292
date: null,
93-
resourceAllocations: [{ quantity: null, resourcePool: null }],
93+
inheritedResourceAllocations: [{ quantity: null, status: null, resourcePool: null }],
9494
} as unknown as TimeslotNode;
9595

9696
expect(fromTimeslotNode(node, "act-1")).toEqual({
@@ -107,13 +107,13 @@ describe("fromTimeslotNode", () => {
107107
date: "",
108108
startTime: null,
109109
assignedResources: [
110-
{ id: "", name: "", capacity: 0, category: "", quantity: 0, accountUserId: null },
110+
{ name: "", capacity: 0, category: "", quantity: 0, status: "", accountUserId: null },
111111
],
112112
});
113113
});
114114

115-
it("treats missing resourceAllocations as no assigned resources", () => {
116-
const node = { ...fullNode, resourceAllocations: null } as unknown as TimeslotNode;
115+
it("treats missing inheritedResourceAllocations as no assigned resources", () => {
116+
const node = { ...fullNode, inheritedResourceAllocations: null } as unknown as TimeslotNode;
117117
expect(fromTimeslotNode(node, "act-1").assignedResources).toEqual([]);
118118
});
119119
});

test/timeslots/timeslot-service.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const timeslotNode = {
8989
minuteLength: 60,
9090
status: "OPEN",
9191
date: "2026-01-02",
92-
resourceAllocations: [],
92+
inheritedResourceAllocations: [],
9393
};
9494

9595
describe("TimeslotService.getForDay", () => {

0 commit comments

Comments
 (0)