Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@peektravel/app-utilities",
"version": "0.2.6",
"version": "0.2.7",
"description": "GraphQL JS mapping utilities extracted from the Peek Pro Autopilot connector.",
"license": "MIT",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions src/internal/timeslots/timeslot-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function fromTimeslotNode(
durationMin: node.minuteLength ?? 0,
date: node.date || "",
startTime: node.start ?? null,
assignedResources: mapAssignedResources(node.resourceAllocations),
assignedResources: mapAssignedResources(node.inheritedResourceAllocations),
};
}

Expand All @@ -69,11 +69,11 @@ function mapAssignedResources(
return allocations.map((allocation) => {
const pool = allocation.resourcePool;
return {
id: pool?.id || "",
name: pool?.name || "",
capacity: pool?.capacity ?? 0,
category: pool?.category || "",
quantity: allocation.quantity ?? 0,
status: allocation.status || "",
accountUserId: pool?.accountUser?.id ?? null,
};
});
Expand Down
14 changes: 7 additions & 7 deletions src/internal/timeslots/timeslot-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export const TIMESLOTS_QUERY = `
minuteLength
status
date
resourceAllocations {
inheritedResourceAllocations {
quantity
status
resourcePool {
id
name
category
capacity
Expand Down Expand Up @@ -60,10 +60,10 @@ export const TIMESLOT_BY_ID_QUERY = `
minuteLength
status
date
resourceAllocations {
inheritedResourceAllocations {
quantity
status
resourcePool {
id
name
category
capacity
Expand Down Expand Up @@ -99,11 +99,11 @@ export const UPDATE_TIMESLOT_MUTATION = `
}
`;

/** A single resource allocation on a timeslot node. */
/** A single inherited resource allocation on a timeslot node. */
export interface TimeslotResourceAllocationNode {
quantity: number | null;
status: string | null;
resourcePool: {
id: string;
name: string;
category: string;
capacity: number | null;
Expand All @@ -124,7 +124,7 @@ export interface TimeslotNode {
status: string | null;
date: string | null;
start?: string | null;
resourceAllocations: TimeslotResourceAllocationNode[] | null;
inheritedResourceAllocations: TimeslotResourceAllocationNode[] | null;
}

/** `data` payload of {@link TIMESLOTS_QUERY}. */
Expand Down
4 changes: 2 additions & 2 deletions src/models/timeslot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export interface Timeslot {

/** A resource allocated to a {@link Timeslot}. */
export interface AssignedResource {
/** Resource pool id. */
id: string;
/** Resource pool name. */
name: string;
/** Resource pool capacity. */
Expand All @@ -44,6 +42,8 @@ export interface AssignedResource {
category: string;
/** Allocated quantity. */
quantity: number;
/** Allocation status (e.g. `"ACTIVE"`). */
status: string;
/** Backing account user id, or null. */
accountUserId: string | null;
}
Expand Down
14 changes: 7 additions & 7 deletions test/timeslots/timeslot-converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const fullNode: TimeslotNode = {
status: "OPEN",
date: "2026-01-02",
start: "2026-01-02T10:00:00Z",
resourceAllocations: [
inheritedResourceAllocations: [
{
quantity: 1,
status: "ACTIVE",
resourcePool: {
id: "pool-1",
name: "Ada",
category: "guide",
capacity: 5,
Expand All @@ -49,11 +49,11 @@ describe("fromTimeslotNode", () => {
startTime: "2026-01-02T10:00:00Z",
assignedResources: [
{
id: "pool-1",
name: "Ada",
capacity: 5,
category: "guide",
quantity: 1,
status: "ACTIVE",
accountUserId: "u1",
},
],
Expand Down Expand Up @@ -90,7 +90,7 @@ describe("fromTimeslotNode", () => {
minuteLength: null,
status: null,
date: null,
resourceAllocations: [{ quantity: null, resourcePool: null }],
inheritedResourceAllocations: [{ quantity: null, status: null, resourcePool: null }],
} as unknown as TimeslotNode;

expect(fromTimeslotNode(node, "act-1")).toEqual({
Expand All @@ -107,13 +107,13 @@ describe("fromTimeslotNode", () => {
date: "",
startTime: null,
assignedResources: [
{ id: "", name: "", capacity: 0, category: "", quantity: 0, accountUserId: null },
{ name: "", capacity: 0, category: "", quantity: 0, status: "", accountUserId: null },
],
});
});

it("treats missing resourceAllocations as no assigned resources", () => {
const node = { ...fullNode, resourceAllocations: null } as unknown as TimeslotNode;
it("treats missing inheritedResourceAllocations as no assigned resources", () => {
const node = { ...fullNode, inheritedResourceAllocations: null } as unknown as TimeslotNode;
expect(fromTimeslotNode(node, "act-1").assignedResources).toEqual([]);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/timeslots/timeslot-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const timeslotNode = {
minuteLength: 60,
status: "OPEN",
date: "2026-01-02",
resourceAllocations: [],
inheritedResourceAllocations: [],
};

describe("TimeslotService.getForDay", () => {
Expand Down
Loading