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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { lock_door_action_attempt } from './lock-door.js'
import { push_thermostat_programs_action_attempt } from './push-thermostat-programs.js'
import { reset_sandbox_workspace_action_attempt } from './reset-sandbox-workspace.js'
import { scan_credential_action_attempt } from './scan-credential.js'
import { scan_to_assign_credential_action_attempt } from './scan-to-assign-credential.js'
import { set_fan_mode_action_attempt } from './set-fan-mode.js'
import { set_hvac_mode_action_attempt } from './set-hvac-mode.js'
import { simulate_keypad_code_entry_action_attempt } from './simulate-keypad-code-entry.js'
Expand All @@ -19,6 +20,7 @@ export const action_attempt = z.union([
...unlock_door_action_attempt.options,
...scan_credential_action_attempt.options,
...encode_credential_action_attempt.options,
...scan_to_assign_credential_action_attempt.options,
...reset_sandbox_workspace_action_attempt.options,
...set_fan_mode_action_attempt.options,
...set_hvac_mode_action_attempt.options,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { z } from 'zod'

import { acs_credential } from '../acs/acs-credential.js'
import {
common_action_attempt_errors,
common_failed_action_attempt,
common_pending_action_attempt,
common_succeeded_action_attempt,
} from './common.js'

const action_type = z
.literal('SCAN_TO_ASSIGN_CREDENTIAL')
.describe(
'Action attempt to track the status of scanning a physical card and assigning the credential to an ACS user.',
)

const no_credential_on_encoder_error = z
.object({
type: z
.literal('no_credential_on_encoder')
.describe(
'Error type to indicate that there is no credential on the encoder.',
),
message: z
.string()
.describe(
'Detailed description of the error. Provides insights into the issue and potentially how to rectify it.',
),
})
.describe('Error to indicate that there is no credential on the encoder.')

const error = z.union([
...common_action_attempt_errors,
no_credential_on_encoder_error,
])

const result = acs_credential.describe(
'Result of a scan to assign attempt. If the attempt was successful, includes the credential data that was scanned and assigned.',
)

export const scan_to_assign_credential_action_attempt = z.discriminatedUnion(
'status',
[
common_pending_action_attempt
.extend({
action_type,
})
.describe(
'Scanning a physical card and assigning the credential is pending.',
),
common_succeeded_action_attempt
.extend({
action_type,
result,
})
.describe(
'Scanning a physical card and assigning the credential succeeded.',
),
common_failed_action_attempt
.extend({ action_type, error })
.describe(
'Scanning a physical card and assigning the credential failed.',
),
],
)

export type ScanToAssignCredentialActionAttempt = z.infer<
typeof scan_to_assign_credential_action_attempt
>
Loading
Loading