Skip to content

Commit

Permalink
fix: Connect webview connected_account_id is nullable (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
seambot authored Apr 3, 2024
1 parent 6d06de7 commit 8d8cde4
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 31 deletions.
2 changes: 2 additions & 0 deletions src/lib/seam/connect/internal/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export {
climate_setting,
climate_setting_schedule,
common_device_properties,
connect_webview_device_selection_mode,
custom_metadata_input,
device_capability_flags,
device_metadata,
dormakaba_oracode_time_slot,
enrollment_automation,
fan_mode_setting,
Expand Down
1 change: 1 addition & 0 deletions src/lib/seam/connect/models/acs/entrance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const acs_entrance = z.object({
})
.nullable(),
})

export type AcsEntranceLatchMetadata = z.infer<
typeof acs_entrance_latch_metadata
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import { z } from 'zod'

import { custom_metadata } from './custom-metadata.js'
import { custom_metadata } from '../custom-metadata.js'

export const connect_webview_device_selection_mode = z.enum([
'none',
'single',
'multiple',
])

export const connect_webview = z.object({
connect_webview_id: z.string().uuid(),
connected_account_id: z.string().uuid().optional(),
url: z.string().url(),
workspace_id: z.string().uuid(),
device_selection_mode: z.enum(['none', 'single', 'multiple']),
created_at: z.string().datetime(),
connected_account_id: z.string().uuid().nullable(),
url: z.string().url(),
device_selection_mode: connect_webview_device_selection_mode,

// TODO: Use enum value.
accepted_providers: z.array(z.string()),

// TODO: Use enum value.
accepted_devices: z.array(z.string()),

any_provider_allowed: z.boolean(),
any_device_allowed: z.boolean(),
created_at: z.string().datetime(),
login_successful: z.boolean(),
status: z.enum(['pending', 'failed', 'authorized']),
custom_redirect_url: z.string().url().nullable(),
Expand Down
1 change: 1 addition & 0 deletions src/lib/seam/connect/models/connect-webviews/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './connect-webview.js'
9 changes: 0 additions & 9 deletions src/lib/seam/connect/models/devices/managed-device.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { SetRequired, Simplify } from 'type-fest'
import { z } from 'zod'

import { schemas as devicedb_schemas } from '@seamapi/types/devicedb'
Expand Down Expand Up @@ -229,11 +228,3 @@ export const managed_device = z
.merge(device_capability_flags)

export type ManagedDevice = z.infer<typeof managed_device>

export type ManagedDeviceWithBackendMetadata<
MetadataKey extends keyof z.infer<typeof device_metadata>,
> = Simplify<
ManagedDevice & {
properties: SetRequired<ManagedDevice['properties'], MetadataKey>
}
>
2 changes: 1 addition & 1 deletion src/lib/seam/connect/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './access-codes/index.js'
export * from './acs/index.js'
export * from './capability-properties/index.js'
export * from './connect-webview.js'
export * from './connect-webviews/index.js'
export * from './custom-metadata.js'
export * from './devices/index.js'
export * from './network.js'
Expand Down
18 changes: 13 additions & 5 deletions src/lib/seam/connect/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,11 @@ export default {
},
automatically_manage_new_devices: { type: 'boolean' },
connect_webview_id: { format: 'uuid', type: 'string' },
connected_account_id: { format: 'uuid', type: 'string' },
connected_account_id: {
format: 'uuid',
nullable: true,
type: 'string',
},
created_at: { format: 'date-time', type: 'string' },
custom_metadata: {
additionalProperties: {
Expand Down Expand Up @@ -465,14 +469,15 @@ export default {
},
required: [
'connect_webview_id',
'url',
'workspace_id',
'created_at',
'connected_account_id',
'url',
'device_selection_mode',
'accepted_providers',
'accepted_devices',
'any_provider_allowed',
'any_device_allowed',
'created_at',
'login_successful',
'status',
'custom_redirect_url',
Expand Down Expand Up @@ -7234,7 +7239,10 @@ export default {
},
type: 'array',
},
automatically_manage_new_devices: { type: 'boolean' },
automatically_manage_new_devices: {
default: true,
type: 'boolean',
},
custom_metadata: {
additionalProperties: {
nullable: true,
Expand Down Expand Up @@ -7263,7 +7271,7 @@ export default {
],
type: 'string',
},
wait_for_device_creation: { type: 'boolean' },
wait_for_device_creation: { default: false, type: 'boolean' },
},
type: 'object',
},
Expand Down
22 changes: 11 additions & 11 deletions src/lib/seam/connect/route-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2025,23 +2025,23 @@ export interface Routes {
)
| undefined
custom_metadata?: Record<string, string | boolean | null> | undefined
automatically_manage_new_devices?: boolean | undefined
wait_for_device_creation?: boolean | undefined
automatically_manage_new_devices?: boolean
wait_for_device_creation?: boolean
}
commonParams: {}
formData: {}
jsonResponse: {
connect_webview: {
connect_webview_id: string
connected_account_id?: string | undefined
url: string
workspace_id: string
created_at: string
connected_account_id: string | null
url: string
device_selection_mode: 'none' | 'single' | 'multiple'
accepted_providers: string[]
accepted_devices: string[]
any_provider_allowed: boolean
any_device_allowed: boolean
created_at: string
login_successful: boolean
status: 'pending' | 'failed' | 'authorized'
custom_redirect_url: string | null
Expand Down Expand Up @@ -2077,15 +2077,15 @@ export interface Routes {
jsonResponse: {
connect_webview: {
connect_webview_id: string
connected_account_id?: string | undefined
url: string
workspace_id: string
created_at: string
connected_account_id: string | null
url: string
device_selection_mode: 'none' | 'single' | 'multiple'
accepted_providers: string[]
accepted_devices: string[]
any_provider_allowed: boolean
any_device_allowed: boolean
created_at: string
login_successful: boolean
status: 'pending' | 'failed' | 'authorized'
custom_redirect_url: string | null
Expand All @@ -2112,15 +2112,15 @@ export interface Routes {
jsonResponse: {
connect_webviews: Array<{
connect_webview_id: string
connected_account_id?: string | undefined
url: string
workspace_id: string
created_at: string
connected_account_id: string | null
url: string
device_selection_mode: 'none' | 'single' | 'multiple'
accepted_providers: string[]
accepted_devices: string[]
any_provider_allowed: boolean
any_device_allowed: boolean
created_at: string
login_successful: boolean
status: 'pending' | 'failed' | 'authorized'
custom_redirect_url: string | null
Expand Down

0 comments on commit 8d8cde4

Please sign in to comment.