Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add lock capability flags #205

Merged
merged 2 commits into from
Jul 16, 2024
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
14 changes: 4 additions & 10 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
Expand Up @@ -69,7 +69,7 @@
"@godaddy/terminus": "^4.12.1",
"@seamapi/fake-devicedb": "^1.6.0",
"@seamapi/logger": "^1.9.2",
"@seamapi/types": "^1.121.0",
"@seamapi/types": "^1.200.0",
"@seamapi/url-search-params-serializer": "^1.1.0",
"@tsconfig/next": "^1.0.5",
"@types/lodash": "^4.14.202",
Expand Down
3 changes: 3 additions & 0 deletions src/lib/database/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ export interface DatabaseMethods {
workspace_id: string
name: string
properties?: Partial<Device["properties"]>
can_remotely_lock?: boolean
can_remotely_unlock?: boolean
can_program_online_access_codes?: boolean
errors?: Device["errors"]
warnings?: Device["warnings"]
created_at?: string
Expand Down
9 changes: 9 additions & 0 deletions src/lib/database/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ export const seedDatabase = (db: Database): Seed => {
device_type: "august_lock",
name: "Front Door",
workspace_id: seed.seed_workspace_1,
can_remotely_lock: true,
can_remotely_unlock: true,
can_program_online_access_codes: true,
properties: {
name: "Fake August Lock 1",
manufacturer: "august",
Expand All @@ -121,6 +124,9 @@ export const seedDatabase = (db: Database): Seed => {
device_type: "august_lock",
name: "Back Door",
workspace_id: seed.seed_workspace_1,
can_remotely_lock: true,
can_remotely_unlock: true,
can_program_online_access_codes: true,
properties: {
name: "Fake August Lock 2",
manufacturer: "august",
Expand Down Expand Up @@ -185,6 +191,9 @@ export const seedDatabase = (db: Database): Seed => {
device_type: "schlage_lock",
name: "Bathroom Door",
workspace_id: seed.seed_workspace_1,
can_remotely_lock: true,
can_remotely_unlock: true,
can_program_online_access_codes: true,
properties: {
locked: true,
},
Expand Down
67 changes: 38 additions & 29 deletions src/lib/zod/device.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { schemas } from "@seamapi/types/connect"
import { z } from "zod"

import { climate_setting } from "lib/zod/climate_setting.ts"
Expand Down Expand Up @@ -166,36 +167,44 @@ export const noise_sensor_device_properties = common_device_properties.extend({
.optional(),
})

export const device = z.object({
device_id: z.string(),
display_name: z.string(),
device_type,
capabilities_supported: z.array(z.string()),
properties: z.union([
common_device_properties,
lock_device_properties,
thermostat_device_properties,
noise_sensor_device_properties,
]),
location: z.any(),
connected_account_id: z.string().optional(),
is_managed: z.boolean(),
workspace_id: z.string(),
errors: z.array(
z.object({
error_code: z.string(),
message: z.string(),
}),
),
warnings: z.array(
z.object({
warning_code: z.string(),
message: z.string(),
export const device = z
.object({
device_id: z.string(),
display_name: z.string(),
device_type,
capabilities_supported: z.array(z.string()),
properties: z.union([
common_device_properties,
lock_device_properties,
thermostat_device_properties,
noise_sensor_device_properties,
]),
location: z.any(),
connected_account_id: z.string().optional(),
is_managed: z.boolean(),
workspace_id: z.string(),
errors: z.array(
z.object({
error_code: z.string(),
message: z.string(),
}),
),
warnings: z.array(
z.object({
warning_code: z.string(),
message: z.string(),
}),
),
created_at: z.string(),
custom_metadata,
})
.merge(
schemas.device.pick({
can_remotely_lock: true,
can_remotely_unlock: true,
can_program_online_access_codes: true,
}),
),
created_at: z.string(),
custom_metadata,
})
)

export const unmanaged_device = device
.pick({
Expand Down
24 changes: 24 additions & 0 deletions src/route-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,9 @@ export type Routes = {
custom_metadata: {
[x: string]: string | number | null | boolean
}
can_remotely_lock?: boolean | undefined
can_remotely_unlock?: boolean | undefined
can_program_online_access_codes?: boolean | undefined
}
ok: boolean
}
Expand Down Expand Up @@ -2519,6 +2522,9 @@ export type Routes = {
custom_metadata: {
[x: string]: string | number | null | boolean
}
can_remotely_lock?: boolean | undefined
can_remotely_unlock?: boolean | undefined
can_program_online_access_codes?: boolean | undefined
}[]
ok: boolean
}
Expand Down Expand Up @@ -3454,6 +3460,9 @@ export type Routes = {
custom_metadata: {
[x: string]: string | number | null | boolean
}
can_remotely_lock?: boolean | undefined
can_remotely_unlock?: boolean | undefined
can_program_online_access_codes?: boolean | undefined
}
device: {
device_id: string
Expand Down Expand Up @@ -3703,6 +3712,9 @@ export type Routes = {
custom_metadata: {
[x: string]: string | number | null | boolean
}
can_remotely_lock?: boolean | undefined
can_remotely_unlock?: boolean | undefined
can_program_online_access_codes?: boolean | undefined
}
ok: boolean
}
Expand Down Expand Up @@ -3994,6 +4006,9 @@ export type Routes = {
custom_metadata: {
[x: string]: string | number | null | boolean
}
can_remotely_lock?: boolean | undefined
can_remotely_unlock?: boolean | undefined
can_program_online_access_codes?: boolean | undefined
}[]
devices: {
device_id: string
Expand Down Expand Up @@ -4243,6 +4258,9 @@ export type Routes = {
custom_metadata: {
[x: string]: string | number | null | boolean
}
can_remotely_lock?: boolean | undefined
can_remotely_unlock?: boolean | undefined
can_program_online_access_codes?: boolean | undefined
}[]
ok: boolean
}
Expand Down Expand Up @@ -4966,6 +4984,9 @@ export type Routes = {
custom_metadata: {
[x: string]: string | number | null | boolean
}
can_remotely_lock?: boolean | undefined
can_remotely_unlock?: boolean | undefined
can_program_online_access_codes?: boolean | undefined
}
ok: boolean
}
Expand Down Expand Up @@ -5310,6 +5331,9 @@ export type Routes = {
custom_metadata: {
[x: string]: string | number | null | boolean
}
can_remotely_lock?: boolean | undefined
can_remotely_unlock?: boolean | undefined
can_program_online_access_codes?: boolean | undefined
}[]
ok: boolean
}
Expand Down
Loading