diff --git a/src/lib/seam/connect/models/access-codes/managed-access-code.ts b/src/lib/seam/connect/models/access-codes/managed-access-code.ts index bcd5dc30..bc0ad676 100644 --- a/src/lib/seam/connect/models/access-codes/managed-access-code.ts +++ b/src/lib/seam/connect/models/access-codes/managed-access-code.ts @@ -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 @@ -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 diff --git a/src/lib/seam/connect/models/access-codes/pending-mutations.ts b/src/lib/seam/connect/models/access-codes/pending-mutations.ts index 56f3fd9b..3fc4c6f5 100644 --- a/src/lib/seam/connect/models/access-codes/pending-mutations.ts +++ b/src/lib/seam/connect/models/access-codes/pending-mutations.ts @@ -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< diff --git a/src/lib/seam/connect/openapi.ts b/src/lib/seam/connect/openapi.ts index 1cd25666..60b09db2 100644 --- a/src/lib/seam/connect/openapi.ts +++ b/src/lib/seam/connect/openapi.ts @@ -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.', @@ -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', diff --git a/src/lib/seam/connect/route-types.ts b/src/lib/seam/connect/route-types.ts index 1ed25ef8..cc44aa7b 100644 --- a/src/lib/seam/connect/route-types.ts +++ b/src/lib/seam/connect/route-types.ts @@ -2157,6 +2157,83 @@ export type Routes = { is_overridable?: boolean | undefined } | null) | undefined + /** Collection of pending mutations for the access code. Indicates changes that Seam is in the process of pushing to the device. */ + pending_mutations: ( + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of setting an access code on the device. */ + mutation_code: 'creating' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of removing an access code from the device. */ + mutation_code: 'deleting' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated PIN code to the device. */ + mutation_code: 'updating_code' + /** Previous code configuration. */ + from: { + /** Previous PIN code. */ + code: string | null + } + /** New code configuration. */ + to: { + /** New PIN code. */ + code: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated access code name to the device. */ + mutation_code: 'updating_name' + /** Previous name configuration. */ + from: { + /** Previous access code name. */ + name: string | null + } + /** New name configuration. */ + to: { + /** New access code name. */ + name: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing updated access code time frame to the device. */ + mutation_code: 'updating_time_frame' + /** Previous time frame configuration. */ + from: { + /** Previous start time for the access code. */ + starts_at: string | null + /** Previous end time for the access code. */ + ends_at: string | null + } + /** New time frame configuration. */ + to: { + /** New start time for the access code. */ + starts_at: string | null + /** New end time for the access code. */ + ends_at: string | null + } + } + )[] } } maxDuration: undefined @@ -2761,6 +2838,83 @@ export type Routes = { is_overridable?: boolean | undefined } | null) | undefined + /** Collection of pending mutations for the access code. Indicates changes that Seam is in the process of pushing to the device. */ + pending_mutations: ( + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of setting an access code on the device. */ + mutation_code: 'creating' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of removing an access code from the device. */ + mutation_code: 'deleting' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated PIN code to the device. */ + mutation_code: 'updating_code' + /** Previous code configuration. */ + from: { + /** Previous PIN code. */ + code: string | null + } + /** New code configuration. */ + to: { + /** New PIN code. */ + code: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated access code name to the device. */ + mutation_code: 'updating_name' + /** Previous name configuration. */ + from: { + /** Previous access code name. */ + name: string | null + } + /** New name configuration. */ + to: { + /** New access code name. */ + name: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing updated access code time frame to the device. */ + mutation_code: 'updating_time_frame' + /** Previous time frame configuration. */ + from: { + /** Previous start time for the access code. */ + starts_at: string | null + /** Previous end time for the access code. */ + ends_at: string | null + } + /** New time frame configuration. */ + to: { + /** New start time for the access code. */ + starts_at: string | null + /** New end time for the access code. */ + ends_at: string | null + } + } + )[] }[] } maxDuration: undefined @@ -4925,6 +5079,83 @@ export type Routes = { is_overridable?: boolean | undefined } | null) | undefined + /** Collection of pending mutations for the access code. Indicates changes that Seam is in the process of pushing to the device. */ + pending_mutations: ( + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of setting an access code on the device. */ + mutation_code: 'creating' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of removing an access code from the device. */ + mutation_code: 'deleting' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated PIN code to the device. */ + mutation_code: 'updating_code' + /** Previous code configuration. */ + from: { + /** Previous PIN code. */ + code: string | null + } + /** New code configuration. */ + to: { + /** New PIN code. */ + code: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated access code name to the device. */ + mutation_code: 'updating_name' + /** Previous name configuration. */ + from: { + /** Previous access code name. */ + name: string | null + } + /** New name configuration. */ + to: { + /** New access code name. */ + name: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing updated access code time frame to the device. */ + mutation_code: 'updating_time_frame' + /** Previous time frame configuration. */ + from: { + /** Previous start time for the access code. */ + starts_at: string | null + /** Previous end time for the access code. */ + ends_at: string | null + } + /** New time frame configuration. */ + to: { + /** New start time for the access code. */ + starts_at: string | null + /** New end time for the access code. */ + ends_at: string | null + } + } + )[] } } maxDuration: undefined @@ -5618,6 +5849,83 @@ export type Routes = { is_overridable?: boolean | undefined } | null) | undefined + /** Collection of pending mutations for the access code. Indicates changes that Seam is in the process of pushing to the device. */ + pending_mutations: ( + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of setting an access code on the device. */ + mutation_code: 'creating' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of removing an access code from the device. */ + mutation_code: 'deleting' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated PIN code to the device. */ + mutation_code: 'updating_code' + /** Previous code configuration. */ + from: { + /** Previous PIN code. */ + code: string | null + } + /** New code configuration. */ + to: { + /** New PIN code. */ + code: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated access code name to the device. */ + mutation_code: 'updating_name' + /** Previous name configuration. */ + from: { + /** Previous access code name. */ + name: string | null + } + /** New name configuration. */ + to: { + /** New access code name. */ + name: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing updated access code time frame to the device. */ + mutation_code: 'updating_time_frame' + /** Previous time frame configuration. */ + from: { + /** Previous start time for the access code. */ + starts_at: string | null + /** Previous end time for the access code. */ + ends_at: string | null + } + /** New time frame configuration. */ + to: { + /** New start time for the access code. */ + starts_at: string | null + /** New end time for the access code. */ + ends_at: string | null + } + } + )[] }[] /** Information about the current page of results. */ pagination: { @@ -6213,6 +6521,83 @@ export type Routes = { is_overridable?: boolean | undefined } | null) | undefined + /** Collection of pending mutations for the access code. Indicates changes that Seam is in the process of pushing to the device. */ + pending_mutations: ( + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of setting an access code on the device. */ + mutation_code: 'creating' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of removing an access code from the device. */ + mutation_code: 'deleting' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated PIN code to the device. */ + mutation_code: 'updating_code' + /** Previous code configuration. */ + from: { + /** Previous PIN code. */ + code: string | null + } + /** New code configuration. */ + to: { + /** New PIN code. */ + code: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated access code name to the device. */ + mutation_code: 'updating_name' + /** Previous name configuration. */ + from: { + /** Previous access code name. */ + name: string | null + } + /** New name configuration. */ + to: { + /** New access code name. */ + name: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing updated access code time frame to the device. */ + mutation_code: 'updating_time_frame' + /** Previous time frame configuration. */ + from: { + /** Previous start time for the access code. */ + starts_at: string | null + /** Previous end time for the access code. */ + ends_at: string | null + } + /** New time frame configuration. */ + to: { + /** New start time for the access code. */ + starts_at: string | null + /** New end time for the access code. */ + ends_at: string | null + } + } + )[] } /** Represents a smart lock [access code](https://docs.seam.co/latest/capability-guides/smart-locks/access-codes). @@ -6785,6 +7170,83 @@ export type Routes = { is_overridable?: boolean | undefined } | null) | undefined + /** Collection of pending mutations for the access code. Indicates changes that Seam is in the process of pushing to the device. */ + pending_mutations: ( + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of setting an access code on the device. */ + mutation_code: 'creating' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of removing an access code from the device. */ + mutation_code: 'deleting' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated PIN code to the device. */ + mutation_code: 'updating_code' + /** Previous code configuration. */ + from: { + /** Previous PIN code. */ + code: string | null + } + /** New code configuration. */ + to: { + /** New PIN code. */ + code: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated access code name to the device. */ + mutation_code: 'updating_name' + /** Previous name configuration. */ + from: { + /** Previous access code name. */ + name: string | null + } + /** New name configuration. */ + to: { + /** New access code name. */ + name: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing updated access code time frame to the device. */ + mutation_code: 'updating_time_frame' + /** Previous time frame configuration. */ + from: { + /** Previous start time for the access code. */ + starts_at: string | null + /** Previous end time for the access code. */ + ends_at: string | null + } + /** New time frame configuration. */ + to: { + /** New start time for the access code. */ + starts_at: string | null + /** New end time for the access code. */ + ends_at: string | null + } + } + )[] } } maxDuration: undefined @@ -118203,6 +118665,83 @@ export type Routes = { is_overridable?: boolean | undefined } | null) | undefined + /** Collection of pending mutations for the access code. Indicates changes that Seam is in the process of pushing to the device. */ + pending_mutations: ( + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of setting an access code on the device. */ + mutation_code: 'creating' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of removing an access code from the device. */ + mutation_code: 'deleting' + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated PIN code to the device. */ + mutation_code: 'updating_code' + /** Previous code configuration. */ + from: { + /** Previous PIN code. */ + code: string | null + } + /** New code configuration. */ + to: { + /** New PIN code. */ + code: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing an updated access code name to the device. */ + mutation_code: 'updating_name' + /** Previous name configuration. */ + from: { + /** Previous access code name. */ + name: string | null + } + /** New name configuration. */ + to: { + /** New access code name. */ + name: string | null + } + } + | { + /** Date and time at which the mutation was created. */ + created_at: string + /** Detailed description of the mutation. */ + message: string + /** Mutation code to indicate that Seam is in the process of pushing updated access code time frame to the device. */ + mutation_code: 'updating_time_frame' + /** Previous time frame configuration. */ + from: { + /** Previous start time for the access code. */ + starts_at: string | null + /** Previous end time for the access code. */ + ends_at: string | null + } + /** New time frame configuration. */ + to: { + /** New start time for the access code. */ + starts_at: string | null + /** New end time for the access code. */ + ends_at: string | null + } + } + )[] }[] | undefined thermostat_daily_programs?: