diff --git a/package-lock.json b/package-lock.json index d293ccf9..f902bdf9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@seamapi/blueprint": "^0.51.1", "@seamapi/fake-seam-connect": "^1.77.0", "@seamapi/smith": "^0.5.2", - "@seamapi/types": "1.530.0", + "@seamapi/types": "1.560.0", "@swc/core": "^1.11.29", "@types/jsonwebtoken": "^9.0.6", "@types/node": "^22.15.21", @@ -49,7 +49,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.530.0" + "@seamapi/types": "^1.560.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -1371,9 +1371,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.530.0", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.530.0.tgz", - "integrity": "sha512-1oFj4M/DPZ7thiVSKHZh91WhX/CO5CZKI6DSww1T7+BB9pASc/xmlUq+4evqHaEvbBvZg4ScybUDYIrTrK8SYQ==", + "version": "1.560.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.560.0.tgz", + "integrity": "sha512-YzuMhXcs1nv8pQmM2McktaV1jwBKsX5sen65qY8P0P9JlC4mKfRspV1AACIKEzH+dY9CUC7VvsPstESRttbkgQ==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 5e0c3f52..401a40c9 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.530.0" + "@seamapi/types": "^1.560.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -102,7 +102,7 @@ "@seamapi/blueprint": "^0.51.1", "@seamapi/fake-seam-connect": "^1.77.0", "@seamapi/smith": "^0.5.2", - "@seamapi/types": "1.530.0", + "@seamapi/types": "1.560.0", "@swc/core": "^1.11.29", "@types/jsonwebtoken": "^9.0.6", "@types/node": "^22.15.21", diff --git a/src/lib/seam/connect/routes/seam-http-endpoints.ts b/src/lib/seam/connect/routes/seam-http-endpoints.ts index 62b6cbd0..8e2a2688 100644 --- a/src/lib/seam/connect/routes/seam-http-endpoints.ts +++ b/src/lib/seam/connect/routes/seam-http-endpoints.ts @@ -584,6 +584,12 @@ import { type SeamCustomerV1PortalsGetRequest, SeamHttpSeamCustomerV1Portals, } from './seam/customer/v1/portals/index.js' +import { + type SeamCustomerV1ReservationsListOptions, + type SeamCustomerV1ReservationsListParameters, + type SeamCustomerV1ReservationsListRequest, + SeamHttpSeamCustomerV1Reservations, +} from './seam/customer/v1/reservations/index.js' import { type SeamCustomerV1SettingsGetOptions, type SeamCustomerV1SettingsGetParameters, @@ -2985,6 +2991,27 @@ export class SeamHttpEndpoints { } } + get '/seam/customer/v1/reservations/list'(): ( + parameters?: SeamCustomerV1ReservationsListParameters, + options?: SeamCustomerV1ReservationsListOptions, + ) => SeamCustomerV1ReservationsListRequest { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamCustomerV1ReservationsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1Reservations.fromClient( + client, + defaults, + ) + return seam.list(...args) + } + } + get '/seam/customer/v1/settings/get'(): ( parameters?: SeamCustomerV1SettingsGetParameters, options?: SeamCustomerV1SettingsGetOptions, @@ -4172,6 +4199,7 @@ export type SeamHttpEndpointQueryPaths = | '/seam/customer/v1/automations/get' | '/seam/customer/v1/events/list' | '/seam/customer/v1/portals/get' + | '/seam/customer/v1/reservations/list' | '/seam/customer/v1/settings/get' | '/seam/partner/v1/building_blocks/spaces/auto_map' | '/spaces/get' @@ -4209,6 +4237,7 @@ export type SeamHttpEndpointPaginatedQueryPaths = | '/devices/list' | '/seam/console/v1/timelines/get' | '/seam/customer/v1/automation_runs/list' + | '/seam/customer/v1/reservations/list' export type SeamHttpEndpointMutationPaths = | '/access_codes/create' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/index.ts index 71ee67ad..fb0b2d2f 100644 --- a/src/lib/seam/connect/routes/seam/customer/v1/index.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/index.ts @@ -7,5 +7,6 @@ export * from './automation-runs/index.js' export * from './automations/index.js' export * from './events/index.js' export * from './portals/index.js' +export * from './reservations/index.js' export * from './settings/index.js' export * from './v1.js' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/reservations/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/reservations/index.ts new file mode 100644 index 00000000..72e7f4fc --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/reservations/index.ts @@ -0,0 +1,6 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +export * from './reservations.js' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/reservations/reservations.ts b/src/lib/seam/connect/routes/seam/customer/v1/reservations/reservations.ts new file mode 100644 index 00000000..cfa6c09c --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/reservations/reservations.ts @@ -0,0 +1,214 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' + +import { seamApiLtsVersion } from 'lib/lts-version.js' +import { + getAuthHeadersForClientSessionToken, + warnOnInsecureuserIdentifierKey, +} from 'lib/seam/connect/auth.js' +import { type Client, createClient } from 'lib/seam/connect/client.js' +import { + isSeamHttpOptionsWithApiKey, + isSeamHttpOptionsWithClient, + isSeamHttpOptionsWithClientSessionToken, + isSeamHttpOptionsWithConsoleSessionToken, + isSeamHttpOptionsWithPersonalAccessToken, + type SeamHttpFromPublishableKeyOptions, + SeamHttpInvalidOptionsError, + type SeamHttpOptions, + type SeamHttpOptionsWithApiKey, + type SeamHttpOptionsWithClient, + type SeamHttpOptionsWithClientSessionToken, + type SeamHttpOptionsWithConsoleSessionToken, + type SeamHttpOptionsWithPersonalAccessToken, + type SeamHttpRequestOptions, +} from 'lib/seam/connect/options.js' +import { + limitToSeamHttpRequestOptions, + parseOptions, +} from 'lib/seam/connect/parse-options.js' +import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' +import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' +import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' +import type { SetNonNullable } from 'lib/types.js' + +export class SeamHttpSeamCustomerV1Reservations { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { + const options = parseOptions(apiKeyOrOptions) + if (!options.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + this.client = 'client' in options ? options.client : createClient(options) + this.defaults = limitToSeamHttpRequestOptions(options) + } + + static fromClient( + client: SeamHttpOptionsWithClient['client'], + options: Omit = {}, + ): SeamHttpSeamCustomerV1Reservations { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamCustomerV1Reservations(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamCustomerV1Reservations { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamCustomerV1Reservations(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamCustomerV1Reservations { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamCustomerV1Reservations(constructorOptions) + } + + static async fromPublishableKey( + publishableKey: string, + userIdentifierKey: string, + options: SeamHttpFromPublishableKeyOptions = {}, + ): Promise { + warnOnInsecureuserIdentifierKey(userIdentifierKey) + const clientOptions = parseOptions({ ...options, publishableKey }) + if (isSeamHttpOptionsWithClient(clientOptions)) { + throw new SeamHttpInvalidOptionsError( + 'The client option cannot be used with SeamHttpSeamCustomerV1Reservations.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamCustomerV1Reservations.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1Reservations { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1Reservations(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1Reservations { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1Reservations(constructorOptions) + } + + createPaginator( + request: SeamHttpRequest, + ): SeamPaginator { + return new SeamPaginator(this, request) + } + + async updateClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + ): Promise { + const { headers } = this.client.defaults + const authHeaders = getAuthHeadersForClientSessionToken({ + clientSessionToken, + }) + for (const key of Object.keys(authHeaders)) { + if (headers[key] == null) { + throw new Error( + 'Cannot update a clientSessionToken on a client created without a clientSessionToken', + ) + } + } + this.client.defaults.headers = { ...headers, ...authHeaders } + const clientSessions = SeamHttpClientSessions.fromClient(this.client) + await clientSessions.get() + } + + list( + parameters?: SeamCustomerV1ReservationsListParameters, + options: SeamCustomerV1ReservationsListOptions = {}, + ): SeamCustomerV1ReservationsListRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/customer/v1/reservations/list', + method: 'POST', + body: parameters, + responseKey: 'reservations', + options, + }) + } +} + +export type SeamCustomerV1ReservationsListParameters = + RouteRequestBody<'/seam/customer/v1/reservations/list'> + +/** + * @deprecated Use SeamCustomerV1ReservationsListParameters instead. + */ +export type SeamCustomerV1ReservationsListParams = + SeamCustomerV1ReservationsListParameters + +/** + * @deprecated Use SeamCustomerV1ReservationsListRequest instead. + */ +export type SeamCustomerV1ReservationsListResponse = SetNonNullable< + Required> +> + +export type SeamCustomerV1ReservationsListRequest = SeamHttpRequest< + SeamCustomerV1ReservationsListResponse, + 'reservations' +> + +export interface SeamCustomerV1ReservationsListOptions {} diff --git a/src/lib/seam/connect/routes/seam/customer/v1/v1.ts b/src/lib/seam/connect/routes/seam/customer/v1/v1.ts index ee9d6a51..fc8a7128 100644 --- a/src/lib/seam/connect/routes/seam/customer/v1/v1.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/v1.ts @@ -37,6 +37,7 @@ import { SeamHttpSeamCustomerV1AutomationRuns } from './automation-runs/index.js import { SeamHttpSeamCustomerV1Automations } from './automations/index.js' import { SeamHttpSeamCustomerV1Events } from './events/index.js' import { SeamHttpSeamCustomerV1Portals } from './portals/index.js' +import { SeamHttpSeamCustomerV1Reservations } from './reservations/index.js' import { SeamHttpSeamCustomerV1Settings } from './settings/index.js' export class SeamHttpSeamCustomerV1 { @@ -193,6 +194,13 @@ export class SeamHttpSeamCustomerV1 { return SeamHttpSeamCustomerV1Portals.fromClient(this.client, this.defaults) } + get reservations(): SeamHttpSeamCustomerV1Reservations { + return SeamHttpSeamCustomerV1Reservations.fromClient( + this.client, + this.defaults, + ) + } + get settings(): SeamHttpSeamCustomerV1Settings { return SeamHttpSeamCustomerV1Settings.fromClient(this.client, this.defaults) }