Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
seambot committed Nov 17, 2023
1 parent 4f8aa43 commit 7c523b0
Show file tree
Hide file tree
Showing 9 changed files with 601 additions and 74 deletions.
313 changes: 276 additions & 37 deletions src/lib/seam/connect/openapi.ts

Large diffs are not rendered by default.

199 changes: 185 additions & 14 deletions src/lib/seam/connect/route-types.ts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/lib/seam/connect/unstable/model-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export type {
AcsAccessGroupExternalType,
AcsCredential,
AcsCredentialExternalType,
AcsCredentialPool,
AcsCredentialPoolExternalType,
AcsSystem,
AcsSystemExternalType,
AcsUser,
Expand Down
134 changes: 113 additions & 21 deletions src/lib/seam/connect/unstable/models/access-codes/managed-access-code.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,119 @@
import { z } from 'zod'

export const managed_access_code = z.object({
common_code_key: z.string().nullable(),
is_scheduled_on_device: z.boolean().optional(),
type: z.enum(['time_bound', 'ongoing']),
is_waiting_for_code_assignment: z.boolean().optional(),
access_code_id: z.string().uuid(),
device_id: z.string().uuid(),
name: z.string().nullable(),
code: z.string().nullable(),
created_at: z.string().datetime(),
errors: z.any(),
warnings: z.any(),
is_managed: z.literal(true),
starts_at: z.string().datetime().nullable().optional(),
ends_at: z.string().datetime().nullable().optional(),
status: z.enum(['setting', 'set', 'unset', 'removing', 'unknown']),
is_backup_access_code_available: z.boolean(),
is_backup: z.boolean().optional(),
pulled_backup_access_code_id: z.string().uuid().nullable().optional(),
is_external_modification_allowed: z.boolean(),
is_one_time_use: z.boolean(),
is_offline_access_code: z.boolean(),
common_code_key: z
.string()
.nullable()
.describe(
'Unique identifier for a group of access codes that share the same code.',
),
is_scheduled_on_device: z
.boolean()
.optional()
.describe(
'Indicates whether the code is set on the device according to a preconfigured schedule.',
),
type: z
.enum(['time_bound', 'ongoing'])
.describe(
'Nature of the access code. Values are "ongoing" for access codes that are active continuously until deactivated manually or "time_bound" for access codes that have a specific duration.',
),
is_waiting_for_code_assignment: z
.boolean()
.optional()
.describe(
'Indicates whether the access code is waiting for a code assignment.',
),
access_code_id: z
.string()
.uuid()
.describe('Unique identifier for the access code.'),
device_id: z
.string()
.uuid()
.describe(
'Unique identifier for the device associated with the access code.',
),
name: z
.string()
.nullable()
.describe(
'Name of the access code. Enables administrators and users to identify the access code easily, especially when there are numerous access codes.',
),
code: z
.string()
.nullable()
.describe(
'Code used for access. Typically, a numeric or alphanumeric string.',
),
created_at: z
.string()
.datetime()
.describe('Date and time at which the access code was created.'),
errors: z
.any()
.describe(
'Collection of errors associated with the access code, structured in a dictionary format. A unique "error_code" keys each error. Each error entry is an object containing two fields: "message" and "created_at." "message" is a string that describes the error. "created_at" is a date that indicates when the error was generated. This structure enables detailed tracking and timely response to critical issues.',
),
warnings: z
.any()
.describe(
'Collection of warnings associated with the access code, structured in a dictionary format. A unique "warning_code" keys each warning. Each warning entry is an object containing two fields: "message" and "created_at." "message" is a string that describes the warning. "created_at" is a date that indicates when the warning was generated. This structure enables detailed tracking and timely response to potential issues that are not critical but that may require attention.',
),
is_managed: z
.literal(true)
.describe('Indicates whether Seam manages the access code.'),
starts_at: z
.string()
.datetime()
.nullable()
.optional()
.describe(
'Date and time at which the time-bound access code becomes active.',
),
ends_at: z
.string()
.datetime()
.nullable()
.optional()
.describe(
'Date and time after which the time-bound access code becomes inactive.',
),
status: z.enum(['setting', 'set', 'unset', 'removing', 'unknown']).describe(`
Current status of the access code within the operational lifecycle. Values are "setting," a transitional phase that indicates that the code is being configured or activated; "set", which indicates that the code is active and operational; "unset," which indicates a deactivated or unused state, either before activation or after deliberate deactivation; "removing," which indicates a transitional period in which the code is being deleted or made inactive; and "unknown," which indicates an indeterminate state, due to reasons such as system errors or incomplete data, that highlights a potential need for system review or troubleshooting.
`),
is_backup_access_code_available: z
.boolean()
.describe(
'Indicates whether a backup access code is available for use if the primary access code is lost or compromised.',
),
is_backup: z
.boolean()
.optional()
.describe('Indicates whether the access code is a backup code.'),
pulled_backup_access_code_id: z
.string()
.uuid()
.nullable()
.optional()
.describe(
'Identifier of the pulled backup access code. Used to associate the pulled backup access code with the original access code.',
),
is_external_modification_allowed: z
.boolean()
.describe(
'Indicates whether changes to the access code from external sources are permitted.',
),
is_one_time_use: z
.boolean()
.describe(
'Indicates whether the access code can only be used once. If "true," the code becomes invalid after the first use.',
),
is_offline_access_code: z
.boolean()
.describe(
'Indicates whether the access code is intended for use in offline scenarios. If "true," this code can be created on a device without a network connection.',
),
})

export type ManagedAccessCode = z.infer<typeof managed_access_code>
3 changes: 2 additions & 1 deletion src/lib/seam/connect/unstable/models/acs/credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from 'zod'
export const acs_credential_external_type = z.enum([
'pti_card',
'brivo_credential',
'hid_cm_credential',
'hid_credential',
])

export type AcsCredentialExternalType = z.infer<
Expand All @@ -13,6 +13,7 @@ export type AcsCredentialExternalType = z.infer<
export const acs_credential = z.object({
acs_credential_id: z.string().uuid(),
acs_user_id: z.string().uuid().optional(),
acs_credential_pool_id: z.string().uuid().optional(),
acs_system_id: z.string().uuid(),
display_name: z.string().nonempty(),
code: z.string().nullable(),
Expand Down
19 changes: 19 additions & 0 deletions src/lib/seam/connect/unstable/models/acs/credential_pool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { z } from 'zod'

export const acs_credential_pool_external_type = z.enum(['hid_part_number'])

export type AcsCredentialPoolExternalType = z.infer<
typeof acs_credential_pool_external_type
>

export const acs_credential_pool = z.object({
acs_credential_pool_id: z.string().uuid(),
acs_system_id: z.string().uuid(),
display_name: z.string().nonempty(),
external_type: acs_credential_pool_external_type,
external_type_display_name: z.string(),
created_at: z.string().datetime(),
workspace_id: z.string().uuid(),
})

export type AcsCredentialPool = z.output<typeof acs_credential_pool>
1 change: 1 addition & 0 deletions src/lib/seam/connect/unstable/models/acs/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './access_group.js'
export * from './credential.js'
export * from './credential_pool.js'
export * from './entrance.js'
export * from './system.js'
export * from './user.js'
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const common_device_properties = z.object({
manufacturer_display_name: z.string(),

offline_access_codes_supported: z.boolean().optional(),
access_codes_supported: z.boolean().optional(),
online_access_codes_supported: z.boolean().optional(),
accessory_keypad_supported: z.boolean().optional(),
}),
has_direct_power: z.boolean().optional(),
Expand Down
2 changes: 2 additions & 0 deletions src/lib/seam/connect/unstable/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export {
acs_access_group_external_type,
acs_credential,
acs_credential_external_type,
acs_credential_pool,
acs_credential_pool_external_type,
acs_entrance,
acs_system,
acs_system_external_type,
Expand Down

0 comments on commit 7c523b0

Please sign in to comment.