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
23 changes: 22 additions & 1 deletion codegen/lib/layout/api-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
mapResourceSample,
normalizePropertyFormatForDocs,
type ResourceSampleContext,
resourceSampleFilter,
} from './api-route.js'

const supportedSdks: SdkName[] = [
Expand Down Expand Up @@ -209,6 +210,7 @@ export function setEndpointLayoutContext(
endpoint,
resources,
actionAttempts,
pathMetadata,
).map(mapResourceSample)

const [primaryCodeSample, ...additionalCodeSamples] = endpoint.codeSamples
Expand Down Expand Up @@ -265,6 +267,7 @@ const getResourceSamples = (
endpoint: Endpoint,
resources: Resource[],
actionAttempts: ActionAttempt[],
pathMetadata: PathMetadata,
): ResourceSample[] => {
const { response } = endpoint

Expand All @@ -288,7 +291,25 @@ const getResourceSamples = (

if (resource == null) return []

const sample = resource.resourceSamples[0]
const endpointMetadata = pathMetadata[resource.routePath]
const endpointSample = resource.resourceSamples.filter(
resourceSampleFilter({
include: endpointMetadata?.include_groups,
exclude: endpointMetadata?.exclude_groups,
}),
)[0]

const parentMetadata =
endpoint.parentPath != null ? pathMetadata[endpoint.parentPath] : undefined
const parentSample = resource.resourceSamples.filter(
resourceSampleFilter({
include: parentMetadata?.include_groups,
exclude: parentMetadata?.exclude_groups,
}),
)[0]

const sample = parentSample ?? endpointSample

if (sample == null) return []

return [
Expand Down
38 changes: 21 additions & 17 deletions codegen/lib/layout/api-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ export const setApiRouteLayoutContext = (
? groupProperties(
legacyProperty.properties,
legacyProperty.propertyGroups,
{
include: metadata.include_groups,
exclude: metadata.exclude_groups,
},
groupOptions,
)
: null

Expand All @@ -210,24 +207,31 @@ export const setApiRouteLayoutContext = (
events: eventsByRoutePath.get(resource.routePath) ?? [],
endpoints: file.endpoints,
resourceSamples: resource.resourceSamples
.filter(({ title }) => {
if (groupOptions.include != null) {
return groupOptions.include.some((x) =>
title.toLowerCase().includes(x.split('_')[0]?.slice(0, -1) ?? ''),
)
}
if (groupOptions.exclude != null) {
return !groupOptions.exclude.some((x) =>
title.toLowerCase().includes(x.split('_')[0]?.slice(0, -1) ?? ''),
)
}
return true
})
.filter(resourceSampleFilter(groupOptions))
.map(mapResourceSample),
})
}
}

export const resourceSampleFilter =
(groupOptions: {
include: string[] | undefined
exclude: string[] | undefined
}) =>
({ title }: ResourceSample): boolean => {
if (groupOptions.include != null) {
return groupOptions.include.some((x) =>
title.toLowerCase().includes(x.split('_')[0]?.slice(0, -1) ?? ''),
)
}
if (groupOptions.exclude != null) {
return !groupOptions.exclude.some((x) =>
title.toLowerCase().includes(x.split('_')[0]?.slice(0, -1) ?? ''),
)
}
return true
}

const groupVariants = (
property: Property | null,
{
Expand Down
101 changes: 60 additions & 41 deletions docs/api/noise_sensors/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,55 +712,74 @@ Array of [devices](./../devices)

```json
{
"can_program_online_access_codes": true,
"can_remotely_lock": true,
"can_remotely_unlock": true,
"capabilities_supported": ["access_code", "lock"],
"connected_account_id": "8e3a4f1b-2c7d-4a9e-8b5f-3d2c1a0b9e8f",
"created_at": "2025-03-27T02:08:16.418Z",
"capabilities_supported": ["noise_detection"],
"connected_account_id": "9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d",
"created_at": "2025-05-16T16:54:17.946049Z",
"custom_metadata": { "id": "internalId1" },
"device_id": "a69569e1-133b-4a9d-b883-018641bfe543",
"device_type": "schlage_lock",
"display_name": "FRONT DOOR",
"device_id": "f1e2d3c4-b5a6-4d7c-8e9f-0a1b2c3d4e5f",
"device_type": "minut_sensor",
"display_name": "Living Room",
"errors": [],
"is_managed": true,
"location": { "location_name": "Front Door", "timezone": "America/New_York" },
"nickname": "Front Door",
"location": {
"location_name": "Jane's Test Home",
"timezone": "America/Los_Angeles"
},
"nickname": "Living Room",
"properties": {
"appearance": { "name": "FRONT DOOR" },
"battery": { "level": 0.48, "status": "good" },
"battery_level": 0.48,
"code_constraints": [{ "constraint_type": "name_length", "max_length": 9 }],
"has_native_entry_events": true,
"image_alt_text": "Schlage Sense Smart Deadbolt with Camelot Trim, Front",
"image_url": "https://connect.getseam.com/_next/image?url=https://connect.getseam.com/assets/images/devices/schlage_sense-smart-deadbolt-with-camelot-trim_front.png&q=75&w=128",
"locked": false,
"manufacturer": "schlage",
"model": {
"accessory_keypad_supported": false,
"can_connect_accessory_keypad": false,
"display_name": "Encode",
"has_built_in_keypad": true,
"manufacturer_display_name": "Schlage",
"offline_access_codes_supported": false,
"online_access_codes_supported": true
"appearance": { "name": "Living Room" },
"battery": { "level": 1, "status": "full" },
"battery_level": 1,
"currently_triggering_noise_threshold_ids": [],
"image_alt_text": "Minut Sensor",
"image_url": "https://connect.getseam.com/_next/image?url=https://connect.getseam.com/assets/images/devices/minut_gen-3_front.png&q=75&w=128",
"manufacturer": "minut",
"minut_metadata": {
"device_id": "770cd3153deca3dee0fe0614",
"device_location": { "latitude": 0, "longitude": 0 },
"device_name": "Living Room",
"home_address": {
"city": "San Francisco",
"country": "US",
"notes": "string",
"post_code": "44210",
"region": "San Francisco County",
"street_name1": "2258 24th Street",
"street_name2": ""
},
"home_id": "2978b6d5dba395ec08300e46",
"home_location": { "latitude": 0, "longitude": 0 },
"home_name": "Jane's Test Home",
"latest_sensor_values": {
"accelerometer_z": {
"time": "2025-06-16T16:54:17.946049Z",
"value": -1.00390625
},
"humidity": {
"time": "2025-06-16T16:54:17.946049Z",
"value": 31.110000610351562
},
"pressure": { "time": "2025-06-16T16:54:17.946049Z", "value": 101923 },
"sound": {
"time": "2025-06-16T16:54:17.946049Z",
"value": 47.7117919921875
},
"temperature": {
"time": "2025-06-16T16:54:17.946049Z",
"value": 21.270000457763672
}
}
},
"name": "FRONT DOOR",
"offline_access_codes_enabled": false,
"online": true,
"online_access_codes_enabled": true,
"schlage_metadata": {
"device_id": "a69569e1-133b-4a9d-b883-018641bfe543",
"device_name": "FRONT DOOR",
"model": "Encode"
"model": {
"display_name": "Noise Sensor",
"manufacturer_display_name": "Minut"
},
"serial_number": "34000000000531e0",
"supported_code_lengths": [4, 5, 6, 7, 8],
"supports_backup_access_code_pool": true,
"supports_offline_access_codes": false
"name": "Living Room",
"noise_level_decibels": 47.7117919921875,
"online": true
},
"warnings": [],
"workspace_id": "5d7f2e1a-9c8b-4f3e-8d2c-1a0b9e8f7c6d"
"workspace_id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d"
}
```
{% endtab %}
Expand Down
Loading
Loading