Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
seambot authored Nov 6, 2024
1 parent f9fb998 commit 94d3465
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 186 deletions.
8 changes: 4 additions & 4 deletions src/lib/seam/connect/models/action-attempts/action-attempt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { z } from 'zod'

import { activate_climate_preset_action_attempt } from './activate-climate-preset.js'
import { deprecated_action_attempts } from './deprecated.js'
import { encode_card_action_attempt } from './encode-card.js'
import { encode_credential_action_attempt } from './encode-credential.js'
import { lock_door_action_attempt } from './lock-door.js'
import { reset_sandbox_workspace_action_attempt } from './reset-sandbox-workspace.js'
import { scan_card_action_attempt } from './scan-card.js'
import { scan_credential_action_attempt } from './scan-credential.js'
import { set_cool_action_attempt } from './set-cool.js'
import { set_fan_mode_action_attempt } from './set-fan-mode.js'
import { set_heat_action_attempt } from './set-heat.js'
Expand All @@ -16,8 +16,8 @@ import { unlock_door_action_attempt } from './unlock-door.js'
export const action_attempt = z.union([
...lock_door_action_attempt.options,
...unlock_door_action_attempt.options,
...scan_card_action_attempt.options,
...encode_card_action_attempt.options,
...scan_credential_action_attempt.options,
...encode_credential_action_attempt.options,
...reset_sandbox_workspace_action_attempt.options,
...set_cool_action_attempt.options,
...set_heat_action_attempt.options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
common_succeeded_action_attempt,
} from './common.js'

const action_type = z.literal('ENCODE_CARD')
const action_type = z.literal('ENCODE_CREDENTIAL')

const no_card_on_encoder_error = z.object({
type: z.literal('no_card_on_encoder'),
Expand All @@ -31,21 +31,23 @@ const error = z.union([

const result = acs_credential.or(unmanaged_acs_credential)

export const encode_card_action_attempt = z.discriminatedUnion('status', [
export const encode_credential_action_attempt = z.discriminatedUnion('status', [
common_pending_action_attempt
.extend({
action_type,
})
.describe('Encoding card data from physical encoder.'),
.describe('Encoding credential data from physical encoder.'),
common_succeeded_action_attempt
.extend({
action_type,
result,
})
.describe('Encoding card data from physical encoder succeeded.'),
.describe('Encoding credential data from physical encoder succeeded.'),
common_failed_action_attempt
.extend({ action_type, error })
.describe('Encoding card data from physical encoder failed.'),
.describe('Encoding credential data from physical encoder failed.'),
])

export type EncodeCardActionAttempt = z.infer<typeof encode_card_action_attempt>
export type EncodeCredentialActionAttempt = z.infer<
typeof encode_credential_action_attempt
>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
common_succeeded_action_attempt,
} from './common.js'

const action_type = z.literal('SCAN_CARD')
const action_type = z.literal('SCAN_CREDENTIAL')

const no_card_on_encoder_error = z.object({
type: z.literal('no_card_on_encoder'),
Expand All @@ -33,29 +33,31 @@ const acs_credential_on_seam = acs_credential.or(unmanaged_acs_credential)

const result = z.object({
acs_credential_on_encoder: acs_credential_on_encoder.describe(
'Snapshot of the card data read from the physical encoder.',
'Snapshot of credential data read from physical encoder.',
),
acs_credential_on_seam: acs_credential_on_seam
.nullable()
.describe('Matching acs_credential currently encoded on this card.'),
warnings: z.array(warning),
})

export const scan_card_action_attempt = z.discriminatedUnion('status', [
export const scan_credential_action_attempt = z.discriminatedUnion('status', [
common_pending_action_attempt
.extend({
action_type,
})
.describe('Reading card data from physical encoder.'),
.describe('Reading credential data from physical encoder.'),
common_succeeded_action_attempt
.extend({
action_type,
result,
})
.describe('Reading card data from physical encoder succeeded.'),
.describe('Reading credential data from physical encoder succeeded.'),
common_failed_action_attempt
.extend({ action_type, error })
.describe('Reading card data from physical encoder failed.'),
.describe('Reading credential data from physical encoder failed.'),
])

export type ScanCardActionAttempt = z.infer<typeof scan_card_action_attempt>
export type ScanCredentialActionAttempt = z.infer<
typeof scan_credential_action_attempt
>
71 changes: 46 additions & 25 deletions src/lib/seam/connect/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1355,15 +1355,15 @@ export default {
type: 'object',
},
{
description: 'Reading card data from physical encoder.',
description: 'Reading credential data from physical encoder.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['SCAN_CARD'], type: 'string' },
action_type: { enum: ['SCAN_CREDENTIAL'], type: 'string' },
error: { nullable: true },
result: { nullable: true },
status: { enum: ['pending'], type: 'string' },
Expand All @@ -1378,21 +1378,22 @@ export default {
type: 'object',
},
{
description: 'Reading card data from physical encoder succeeded.',
description:
'Reading credential data from physical encoder succeeded.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['SCAN_CARD'], type: 'string' },
action_type: { enum: ['SCAN_CREDENTIAL'], type: 'string' },
error: { nullable: true },
result: {
properties: {
acs_credential_on_encoder: {
description:
'Snapshot of the card data read from the physical encoder.',
'Snapshot of credential data read from physical encoder.',
properties: {
card_number: {
description:
Expand Down Expand Up @@ -1864,15 +1865,16 @@ export default {
type: 'object',
},
{
description: 'Reading card data from physical encoder failed.',
description:
'Reading credential data from physical encoder failed.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['SCAN_CARD'], type: 'string' },
action_type: { enum: ['SCAN_CREDENTIAL'], type: 'string' },
error: {
oneOf: [
{
Expand Down Expand Up @@ -1917,15 +1919,15 @@ export default {
type: 'object',
},
{
description: 'Encoding card data from physical encoder.',
description: 'Encoding credential data from physical encoder.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['ENCODE_CARD'], type: 'string' },
action_type: { enum: ['ENCODE_CREDENTIAL'], type: 'string' },
error: { nullable: true },
result: { nullable: true },
status: { enum: ['pending'], type: 'string' },
Expand All @@ -1940,15 +1942,16 @@ export default {
type: 'object',
},
{
description: 'Encoding card data from physical encoder succeeded.',
description:
'Encoding credential data from physical encoder succeeded.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['ENCODE_CARD'], type: 'string' },
action_type: { enum: ['ENCODE_CREDENTIAL'], type: 'string' },
error: { nullable: true },
result: {
description:
Expand Down Expand Up @@ -2316,15 +2319,16 @@ export default {
type: 'object',
},
{
description: 'Encoding card data from physical encoder failed.',
description:
'Encoding credential data from physical encoder failed.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['ENCODE_CARD'], type: 'string' },
action_type: { enum: ['ENCODE_CREDENTIAL'], type: 'string' },
error: {
oneOf: [
{
Expand Down Expand Up @@ -9201,16 +9205,25 @@ export default {
'x-title': 'Update a Credential',
},
},
'/acs/encoders/encode_card': {
'/acs/encoders/encode_credential': {
post: {
operationId: 'acsEncodersEncodeCardPost',
operationId: 'acsEncodersEncodeCredentialPost',
requestBody: {
content: {
'application/json': {
schema: {
properties: {
acs_credential_id: { format: 'uuid', type: 'string' },
device_id: { format: 'uuid', type: 'string' },
acs_credential_id: {
description:
'ID of the acs_credential to encode on a physical card.',
format: 'uuid',
type: 'string',
},
device_id: {
description: 'ID of the encoder to use for the encoding.',
format: 'uuid',
type: 'string',
},
},
required: ['device_id', 'acs_credential_id'],
type: 'object',
Expand Down Expand Up @@ -9244,10 +9257,10 @@ export default {
{ console_session: [] },
{ api_key: [] },
],
summary: '/acs/encoders/encode_card',
summary: '/acs/encoders/encode_credential',
tags: ['/acs'],
'x-fern-sdk-group-name': ['acs', 'encoders'],
'x-fern-sdk-method-name': 'encode_card',
'x-fern-sdk-method-name': 'encode_credential',
'x-fern-sdk-return-value': 'action_attempt',
'x-response-key': 'action_attempt',
'x-undocumented': 'Encoding a card is currently unimplemented.',
Expand Down Expand Up @@ -9339,16 +9352,24 @@ export default {
'x-undocumented': 'Encoders are in alpha.',
},
},
'/acs/encoders/scan_card': {
'/acs/encoders/scan_credential': {
post: {
operationId: 'acsEncodersScanCardPost',
operationId: 'acsEncodersScanCredentialPost',
requestBody: {
content: {
'application/json': {
schema: {
properties: {
acs_system_id: { format: 'uuid', type: 'string' },
device_id: { format: 'uuid', type: 'string' },
acs_system_id: {
description: 'ID of the acs_system the encoder belongs to.',
format: 'uuid',
type: 'string',
},
device_id: {
description: 'ID of the encoder to use for the scan.',
format: 'uuid',
type: 'string',
},
},
required: ['acs_system_id', 'device_id'],
type: 'object',
Expand Down Expand Up @@ -9382,10 +9403,10 @@ export default {
{ console_session: [] },
{ api_key: [] },
],
summary: '/acs/encoders/scan_card',
summary: '/acs/encoders/scan_credential',
tags: ['/acs'],
'x-fern-sdk-group-name': ['acs', 'encoders'],
'x-fern-sdk-method-name': 'scan_card',
'x-fern-sdk-method-name': 'scan_credential',
'x-fern-sdk-return-value': 'action_attempt',
'x-response-key': 'action_attempt',
'x-undocumented': 'Reading a card is currently unimplemented.',
Expand Down
Loading

0 comments on commit 94d3465

Please sign in to comment.