Skip to content
Open
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
@@ -1,6 +1,7 @@
import { z } from 'zod'

import { device_and_connected_account_error_options } from '../devices/index.js'
import { access_code_pending_mutations } from './pending-mutations.js'

const common_access_code_error = z.object({
message: z
Expand Down Expand Up @@ -714,6 +715,11 @@ export const access_code = z.object({
.describe(
'Metadata for a dormakaba Oracode managed access code. Only present for access codes from dormakaba Oracode devices.',
),
pending_mutations: z
.array(access_code_pending_mutations)
.describe(
'Collection of pending mutations for the access code. Indicates changes that Seam is in the process of pushing to the device.',
),
}).describe(`
---
route_path: /access_codes
Expand Down
24 changes: 21 additions & 3 deletions src/lib/seam/connect/models/access-codes/pending-mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,30 @@ export type AccessCodePendingMutation = z.infer<
typeof access_code_pending_mutations
>

// Internal fields stored in the DB but stripped from public API responses.
// Used to track the delete+recreate flow for providers that don't support
// in-place updates (e.g. Schlage, August).
const internal_recreate_fields = z.object({
must_be_recreated_on_device: z.boolean().optional(),
is_being_removed: z.boolean().optional(),
is_being_created: z.boolean().optional(),
})

const _access_code_pending_mutations_map = z.object({
creating: creating.optional().nullable(),
deleting: deleting.optional().nullable(),
updating_code: updating_code.optional().nullable(),
updating_name: updating_name.optional().nullable(),
updating_time_frame: updating_time_frame.optional().nullable(),
updating_code: updating_code
.merge(internal_recreate_fields)
.optional()
.nullable(),
updating_name: updating_name
.merge(internal_recreate_fields)
.optional()
.nullable(),
updating_time_frame: updating_time_frame
.merge(internal_recreate_fields)
.optional()
.nullable(),
})

export type AccessCodePendingMutationsMap = z.infer<
Expand Down
236 changes: 236 additions & 0 deletions src/lib/seam/connect/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,241 @@ export default {
nullable: true,
type: 'string',
},
pending_mutations: {
description:
'Collection of pending mutations for the access code. Indicates changes that Seam is in the process of pushing to the device.',
items: {
discriminator: { propertyName: 'mutation_code' },
oneOf: [
{
description:
'Seam is in the process of setting an access code on the device.',
properties: {
created_at: {
description:
'Date and time at which the mutation was created.',
format: 'date-time',
type: 'string',
},
message: {
description: 'Detailed description of the mutation.',
type: 'string',
},
mutation_code: {
description:
'Mutation code to indicate that Seam is in the process of setting an access code on the device.',
enum: ['creating'],
type: 'string',
},
},
required: ['created_at', 'message', 'mutation_code'],
type: 'object',
},
{
description:
'Seam is in the process of removing an access code from the device.',
properties: {
created_at: {
description:
'Date and time at which the mutation was created.',
format: 'date-time',
type: 'string',
},
message: {
description: 'Detailed description of the mutation.',
type: 'string',
},
mutation_code: {
description:
'Mutation code to indicate that Seam is in the process of removing an access code from the device.',
enum: ['deleting'],
type: 'string',
},
},
required: ['created_at', 'message', 'mutation_code'],
type: 'object',
},
{
description:
'Seam is in the process of pushing an updated PIN code to the device.',
properties: {
created_at: {
description:
'Date and time at which the mutation was created.',
format: 'date-time',
type: 'string',
},
from: {
description: 'Previous code configuration.',
properties: {
code: {
description: 'Previous PIN code.',
nullable: true,
type: 'string',
},
},
required: ['code'],
type: 'object',
},
message: {
description: 'Detailed description of the mutation.',
type: 'string',
},
mutation_code: {
description:
'Mutation code to indicate that Seam is in the process of pushing an updated PIN code to the device.',
enum: ['updating_code'],
type: 'string',
},
to: {
description: 'New code configuration.',
properties: {
code: {
description: 'New PIN code.',
nullable: true,
type: 'string',
},
},
required: ['code'],
type: 'object',
},
},
required: [
'created_at',
'message',
'mutation_code',
'from',
'to',
],
type: 'object',
},
{
description:
'Seam is in the process of pushing an updated access code name to the device.',
properties: {
created_at: {
description:
'Date and time at which the mutation was created.',
format: 'date-time',
type: 'string',
},
from: {
description: 'Previous name configuration.',
properties: {
name: {
description: 'Previous access code name.',
nullable: true,
type: 'string',
},
},
required: ['name'],
type: 'object',
},
message: {
description: 'Detailed description of the mutation.',
type: 'string',
},
mutation_code: {
description:
'Mutation code to indicate that Seam is in the process of pushing an updated access code name to the device.',
enum: ['updating_name'],
type: 'string',
},
to: {
description: 'New name configuration.',
properties: {
name: {
description: 'New access code name.',
nullable: true,
type: 'string',
},
},
required: ['name'],
type: 'object',
},
},
required: [
'created_at',
'message',
'mutation_code',
'from',
'to',
],
type: 'object',
},
{
description:
'Seam is in the process of pushing an updated time frame to the device.',
properties: {
created_at: {
description:
'Date and time at which the mutation was created.',
format: 'date-time',
type: 'string',
},
from: {
description: 'Previous time frame configuration.',
properties: {
ends_at: {
description: 'Previous end time for the access code.',
format: 'date-time',
nullable: true,
type: 'string',
},
starts_at: {
description:
'Previous start time for the access code.',
format: 'date-time',
nullable: true,
type: 'string',
},
},
required: ['starts_at', 'ends_at'],
type: 'object',
},
message: {
description: 'Detailed description of the mutation.',
type: 'string',
},
mutation_code: {
description:
'Mutation code to indicate that Seam is in the process of pushing updated access code time frame to the device.',
enum: ['updating_time_frame'],
type: 'string',
},
to: {
description: 'New time frame configuration.',
properties: {
ends_at: {
description: 'New end time for the access code.',
format: 'date-time',
nullable: true,
type: 'string',
},
starts_at: {
description: 'New start time for the access code.',
format: 'date-time',
nullable: true,
type: 'string',
},
},
required: ['starts_at', 'ends_at'],
type: 'object',
},
},
required: [
'created_at',
'message',
'mutation_code',
'from',
'to',
],
type: 'object',
},
],
},
type: 'array',
},
pulled_backup_access_code_id: {
description:
'Identifier of the pulled backup access code. Used to associate the pulled backup access code with the original access code.',
Expand Down Expand Up @@ -1815,6 +2050,7 @@ export default {
'is_external_modification_allowed',
'is_one_time_use',
'is_offline_access_code',
'pending_mutations',
],
type: 'object',
'x-route-path': '/access_codes',
Expand Down
Loading
Loading