Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-warehouse): add 2 missing tables to the EZOfficeInventory source (#124569)

Tom Owers0ee77d1d3dca
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index bbfe2e548b73..04edea01f8d9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -4449,7 +4449,7 @@ Note: The official EAS CLI generated GraphQL types supplied collection fields an
## EZOfficeInventory — gaps
-Today (12): `asset_checkout_history`, `asset_stocks`, `assets`, `groups`, `inventories`, `locations`, `member_stock_histories`, `members`, `purchase_orders`, `teams`, `vendors`, `work_orders`
+Today (14): `asset_checkout_history`, `asset_stocks`, `assets`, `custom_roles`, `groups`, `inventories`, `locations`, `member_stock_histories`, `members`, `purchase_orders`, `reservation_requests`, `teams`, `vendors`, `work_orders`
Diffed against: <https://ezo.io/ezofficeinventory/developers/>
@@ -4457,10 +4457,10 @@ Diffed against: <https://ezo.io/ezofficeinventory/developers/>
- [x] `GET /tasks.api (work orders) and /tasks/filter` — work orders with state, assignee and duration - a core analytical object with no coverage at all (high) — added as `work_orders`. `/tasks/filter` does not exist; the list endpoint takes a `filter` query param, and the table syncs the unfiltered list.
- [ ] `GET /services.api` — service/maintenance records per asset, the basis for downtime and maintenance-cost reporting (high). Not readable: `assets/{id}/services.api` is POST/PUT only and v2 has no services resource, so there is no list endpoint to sync. The closest GET returns assets being serviced, not service records.
- [x] `GET /teams.api` — team lookup resolving the team IDs carried on members and assignments (high) — added as `teams`
-- [ ] `GET /custom_roles.api` — role lookup resolving the role reference on every member row already synced (medium)
-- [ ] `GET /task_types.api` — work order type lookup, the primary breakdown dimension for work orders (medium)
-- [ ] `GET /reservation_requests.api and /checkout_requests/filter.api` — reservations and booking requests - forward-looking demand against the asset pool (medium)
-- [ ] `GET /baskets.api (carts)` — cart records grouping multi-item checkouts, needed to reconstruct a checkout event from its line items (medium)
+- [x] `GET /custom_roles.api` — role lookup resolving the role reference on every member row already synced (medium) — added as `custom_roles` (v2 `/api/v2/custom_roles`)
+- [ ] `GET /task_types.api` — work order type lookup, the primary breakdown dimension for work orders (medium). Not added: v2 has no task types resource and the v1 docs give no response envelope. Each `work_orders` row already carries `task_type` and `task_type_id`.
+- [x] `GET /reservation_requests.api and /checkout_requests/filter.api` — reservations and booking requests - forward-looking demand against the asset pool (medium) — added as `reservation_requests` (fan-out over members, v2 `/api/v2/members/{id}/reservation_requests`). `/checkout_requests/filter.api` is v1 only and returns requests that start on one given date, so it is not a table.
+- [ ] `GET /baskets.api (carts)` — cart records grouping multi-item checkouts, needed to reconstruct a checkout event from its line items (medium). Not added: v2 has no carts resource and the v1 docs give no response envelope. Reservation and history rows carry `basket_id`.
- [ ] `GET /bundles.api` — asset bundle definitions and their membership, a grouping dimension for utilization (medium)
- [ ] `GET /projects.api` — projects that assets, carts and checkouts are linked to - a cost-attribution dimension (medium)
- [ ] `GET /depreciation_methods.api` — depreciation method lookup for asset valuation reporting (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/canonical_descriptions.py
index 2168ebb00ac0..6d69090c3f72 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/canonical_descriptions.py
@@ -3,7 +3,8 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.can
)
_DOCS_URL = "https://ezo.io/ezofficeinventory/developers/"
-# Work orders and the history sub-resources are documented on the v2 reference only.
+# Work orders, custom roles, reservation requests and the history sub-resources are documented on
+# the v2 reference only.
_DOCS_URL_V2 = "https://ezo.io/ezofficeinventory/api-v2/"
CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
@@ -207,6 +208,58 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"updated_at": "Timestamp when the transaction was last updated.",
},
},
+ "reservation_requests": {
+ "description": (
+ "Reservation requests made by a member — bookings of assets, stock or bundles for a "
+ "future period, with their approval status."
+ ),
+ "docs_url": _DOCS_URL_V2,
+ "columns": {
+ "member_id": "Identifier of the member this request belongs to, taken from the parent member record.",
+ "id": "Identifier of the reservation request.",
+ "reservable_id": "Identifier of the item being reserved.",
+ "reservable_type": "Kind of item being reserved (e.g. Asset).",
+ "resource_id": "Identifier of the member or location the item is reserved for.",
+ "resource_type": "Whether the item is reserved for a member or a location.",
+ "status": "Status of the request (e.g. pending, approved, denied, fulfilled).",
+ "from_date": "Start of the reserved period.",
+ "to_date": "End of the reserved period.",
+ "quantity": "Quantity reserved, for quantity-tracked items.",
+ "price": "Price recorded on the reservation.",
+ "location_id": "Identifier of the location the item is reserved from.",
+ "reserved_to_location_id": "Identifier of the location the item is reserved to.",
+ "basket_id": "Identifier of the cart the reservation was made through.",
+ "package_id": "Identifier of the bundle the reservation was made through.",
+ "project_id": "Identifier of the project the reservation is linked to.",
+ "recurring_reservation_id": "Identifier of the recurring reservation this request belongs to.",
+ "denied_reason": "Reason given when the request was denied.",
+ "action_taken_by_id": "Identifier of the member who approved or denied the request.",
+ "approved_or_denied_at": "Timestamp when the request was approved or denied.",
+ "created_by_id": "Identifier of the member who created the request.",
+ "creation_source": "Where the request was created (e.g. web).",
+ "created_at": "Timestamp when the request was created.",
+ "updated_at": "Timestamp when the request was last updated.",
+ },
+ },
+ "custom_roles": {
+ "description": "Custom roles that set what members can see and do. Resolves the role on each member.",
+ "docs_url": _DOCS_URL_V2,
+ "columns": {
+ "id": "Unique identifier for the custom role.",
+ "name": "Display name of the custom role.",
+ "description": "Short description of the custom role.",
+ "base_role_id": "Identifier of the built-in role the custom role extends.",
+ "visibility": "Which items members with this role can see (e.g. limited to groups).",
+ "users_visibility": "Which members people with this role can see.",
+ "system_generated": "Whether the role was created by EZOfficeInventory rather than by a user.",
+ "group_ids": "Identifiers of the asset groups the role is limited to.",
+ "location_ids": "Identifiers of the locations the role is limited to.",
+ "team_ids": "Identifiers of the teams the role is limited to.",
+ "created_by_id": "Identifier of the member who created the role.",
+ "created_at": "Timestamp when the role was created.",
+ "updated_at": "Timestamp when the role was last updated.",
+ },
+ },
"purchase_orders": {
"description": "Purchase orders raised for procuring assets and inventory.",
"docs_url": _DOCS_URL,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/ezofficeinventory.com.mdx b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/ezofficeinventory.com.mdx
index 7dd7906131c0..e47b0e98b6f1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/ezofficeinventory.com.mdx
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/ezofficeinventory.com.mdx
@@ -58,10 +58,10 @@ limit (~60 requests/minute) and backs off automatically on rate-limit responses.
<SourceTables />
-`asset_checkout_history` and `member_stock_histories` are turned off by default. EZOfficeInventory
-serves check-in and check-out history one item at a time, so these two tables need a request per asset
-or per member and are slow to sync on large accounts. Turn them on if you want to report on
-utilization or stock movement over time.
+`asset_checkout_history`, `member_stock_histories` and `reservation_requests` are turned off by
+default. EZOfficeInventory serves history and reservation requests one item at a time, so these tables
+need a request per asset or per member and are slow to sync on large accounts. Turn them on if you
+want to report on utilization, stock movement or upcoming reservations.
## Troubleshooting
@@ -70,7 +70,7 @@ utilization or stock movement over time.
`https://` prefix or `.ezofficeinventory.com` suffix).
- **Syncs are slow on large accounts**: EZOfficeInventory enforces a fair-use limit of roughly 60
requests per minute (lower on trial accounts). The connector throttles to stay within it, so large
- asset or inventory tables can take a while on the first sync. The two history tables are the slowest,
- because the API only serves history one item at a time.
+ asset or inventory tables can take a while on the first sync. The history and reservation request
+ tables are the slowest, because the API only serves them one item at a time.
<TroubleshootingLink />
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/settings.py
index 65fa3b5356ea..e714d33f71b7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/settings.py
@@ -74,6 +74,16 @@ _MEMBER_STOCK_HISTORY_FANOUT = DependentEndpointConfig(
child_response_actions=_PARENT_GONE,
)
+_MEMBER_RESERVATION_REQUEST_FANOUT = DependentEndpointConfig(
+ parent_name="members",
+ resolve_param="member_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "member_id"},
+ parent_params={"per_page": PAGE_SIZE},
+ child_response_actions=_PARENT_GONE,
+)
+
# EZOfficeInventory exposes no general server-side `updated_after`/`created_after` cursor on its
# core listing endpoints, and its per-asset history endpoints only paginate (no server-side date
@@ -182,11 +192,12 @@ ENDPOINTS = tuple(EZOFFICEINVENTORY_ENDPOINTS.keys())
# (`checked_out_assets`, `subgroups`, `labels`, `custom_fields`) have no flat v2 list equivalent
# and stay v1-only — pinned v1 sources keep serving them.
#
-# Work orders and the two history tables are v2-only. v1 reaches the same records through
-# `tasks.api`, `assets/<id>/history_paginate.api` and `members/<id>/checkin_checkout_history*.api`,
-# but the v1 docs give no response envelope for any of them, and a guessed `data_selector` yields
-# an empty table rather than an error. The v2 OpenAPI spec names all three, so they are wired
-# there only.
+# Work orders, custom roles, reservation requests and the two history tables are v2-only. v1
+# reaches the same records through `tasks.api`, `assets/<id>/history_paginate.api`,
+# `members/<id>/checkin_checkout_history*.api`, `custom_roles.api` and
+# `members/<id>/reservation_requests.api`, but the v1 docs give no response envelope for any of
+# them, and a guessed `data_selector` yields an empty table rather than an error. The v2 OpenAPI
+# spec names every envelope, so they are wired there only.
EZOFFICEINVENTORY_V2_ENDPOINTS: dict[str, EZOfficeInventoryEndpointConfig] = {
"assets": EZOfficeInventoryEndpointConfig(
name="assets",
@@ -251,6 +262,24 @@ EZOFFICEINVENTORY_V2_ENDPOINTS: dict[str, EZOfficeInventoryEndpointConfig] = {
# One request per member, so it is opt-in rather than on by default.
should_sync_default=False,
),
+ "reservation_requests": EZOfficeInventoryEndpointConfig(
+ name="reservation_requests",
+ path="api/v2/members/{member_id}/reservation_requests",
+ # The v2 spec names this envelope in the singular.
+ data_selector="reservation_request",
+ primary_keys=["member_id", "id"],
+ partition_key="created_at",
+ fanout=_MEMBER_RESERVATION_REQUEST_FANOUT,
+ # One request per member, so it is opt-in rather than on by default.
+ should_sync_default=False,
+ ),
+ "custom_roles": EZOfficeInventoryEndpointConfig(
+ name="custom_roles",
+ path="api/v2/custom_roles",
+ data_selector="custom_roles",
+ primary_keys=["id"],
+ partition_key="created_at",
+ ),
"locations": EZOfficeInventoryEndpointConfig(
name="locations",
path="api/v2/locations",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/tests/test_ezofficeinventory.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/tests/test_ezofficeinventory.py
index 44508fbb8cfb..47df55430b0c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/tests/test_ezofficeinventory.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ezofficeinventory/tests/test_ezofficeinventory.py
@@ -184,27 +184,44 @@ class TestV2Pagination:
class TestHistoryFanout:
- """The history tables are per-item sub-resources fanned out over their list endpoint."""
+ """The history and reservation tables are per-item sub-resources fanned out over their list endpoint."""
- def test_fetches_each_parent_and_injects_parent_id(self) -> None:
+ @pytest.mark.parametrize(
+ ("endpoint", "parent_key", "child_key", "child_path", "parent_id_column"),
+ [
+ ("asset_checkout_history", "assets", "histories", "/api/v2/assets/{}/history", "asset_id"),
+ ("member_stock_histories", "members", "stock_histories", "/api/v2/members/{}/stock_histories", "member_id"),
+ # The v2 spec names this envelope in the singular; the plural would sync an empty table.
+ (
+ "reservation_requests",
+ "members",
+ "reservation_request",
+ "/api/v2/members/{}/reservation_requests",
+ "member_id",
+ ),
+ ],
+ )
+ def test_fetches_each_parent_and_injects_parent_id(
+ self, endpoint: str, parent_key: str, child_key: str, child_path: str, parent_id_column: str
+ ) -> None:
result = _driver().run(
- "asset_checkout_history",
+ endpoint,
[
ScriptedResponse(
- json={"assets": [{"id": 1, "identifier": "A1"}, {"id": 2, "identifier": "A2"}], "metadata": {}}
+ json={parent_key: [{"id": 1, "identifier": "A1"}, {"id": 2, "identifier": "A2"}], "metadata": {}}
),
- ScriptedResponse(json={"histories": [{"id": 10}], "metadata": {}}),
- ScriptedResponse(json={"histories": [{"id": 20}], "metadata": {}}),
+ ScriptedResponse(json={child_key: [{"id": 10}], "metadata": {}}),
+ ScriptedResponse(json={child_key: [{"id": 20}], "metadata": {}}),
],
api_version=EZOFFICEINVENTORY_API_VERSION_V2,
)
assert result.raised is None
# The child path binds the parent's record id, not its identification number.
- assert result.paths[1:] == ["/api/v2/assets/1/history", "/api/v2/assets/2/history"]
- # A history row carries no back-reference to its asset, so the parent id is injected —
- # without it the composite primary key would collapse every asset's history together.
- assert result.rows == [{"id": 10, "asset_id": 1}, {"id": 20, "asset_id": 2}]
+ assert result.paths[1:] == [child_path.format(1), child_path.format(2)]
+ # A child row carries no back-reference to its parent, so the parent id is injected —
+ # without it the composite primary key would collapse every parent's rows together.
+ assert result.rows == [{"id": 10, parent_id_column: 1}, {"id": 20, parent_id_column: 2}]
def test_child_pages_are_followed_per_parent(self) -> None:
next_url = "https://acme.ezofficeinventory.com/api/v2/assets/1/history?page=2"