diff --git a/generate-routes.ts b/generate-routes.ts index bb08c85..65fd5a4 100644 --- a/generate-routes.ts +++ b/generate-routes.ts @@ -31,7 +31,7 @@ async function main(): Promise { ]) } -const openapiResponseKeyProp = 'x-fern-sdk-return-value' +const openapiResponseKeyProp = 'x-response-key' const routePaths = [ '/access_codes', @@ -124,9 +124,9 @@ interface ClassMeta { } const createRoutes = (): Route[] => { - const paths = Object.keys(openapi.paths) + const allOpenapiPaths = Object.keys(openapi.paths) - const unmatchedEndpointPaths = paths + const unmatchedEndpointPaths = allOpenapiPaths .filter( (path) => !routePaths.some((routePath) => isEndpointUnderRoute(path, routePath)), @@ -141,19 +141,42 @@ const createRoutes = (): Route[] => { ) } - return routePaths.map(createRoute) -} + const routesToGenerate = routePaths.filter( + (routePath) => + hasAtLeastOneDocumentedEndpoint(routePath) || isNamespaceRoute(routePath), + ) -const createRoute = (routePath: (typeof routePaths)[number]): Route => { - const endpointPaths = Object.keys(openapi.paths).filter((path) => - isEndpointUnderRoute(path, routePath), + return routesToGenerate.map((routePath) => + createRoute(routePath, routesToGenerate), ) +} + +const createRoute = ( + routePath: (typeof routePaths)[number], + documentedRoutePaths: ReadonlyArray<(typeof routePaths)[number]>, +): Route => { + const endpointPaths = Object.entries(openapi.paths) + .filter(([path, pathSchema]) => { + if (!isEndpointUnderRoute(path, routePath)) { + return false + } + + return 'post' in pathSchema && !('x-undocumented' in pathSchema.post) + }) + .map(([path]) => path) const namespace = routePath.split('/').join('_').slice(1) + const subresources = (routePathSubresources[routePath] ?? []).filter( + (subresource) => { + const subresourcePath = `${routePath}/${subresource}` + return documentedRoutePaths.some((path) => path === subresourcePath) + }, + ) + return { namespace, - subresources: routePathSubresources[routePath] ?? [], + subresources, endpoints: endpointPaths.map((endpointPath) => createEndpoint(namespace, routePath, endpointPath), ), @@ -245,6 +268,46 @@ const isEndpointUnderRoute = ( endpointPath.startsWith(routePath) && endpointPath.split('/').length - 1 === routePath.split('/').length +const hasAtLeastOneDocumentedEndpoint = ( + routePath: (typeof routePaths)[number], +): boolean => { + const endpointsUnderRoute = Object.keys(openapi.paths).filter((path) => + isEndpointUnderRoute(path, routePath), + ) + + if (endpointsUnderRoute.length === 0) { + return false + } + + return endpointsUnderRoute.some((path) => { + if (!isOpenapiPath(path)) return false + + const pathSchema = openapi.paths[path] + if (!('post' in pathSchema)) return false + + return !('x-undocumented' in pathSchema.post) + }) +} + +/** + * Determines if a route is a namespace route by checking if it has defined subresources + * and if any of those subresources have corresponding route paths. + * (e.g., "/acs" which contains "/acs/users", "/acs/systems", etc.) + * These routes should be generated even if they don't have direct endpoints themselves. + */ +function isNamespaceRoute(routePath: (typeof routePaths)[number]): boolean { + const subresources = routePathSubresources[routePath] ?? [] + if (subresources.length === 0) { + return false + } + + return subresources.some((subresource) => { + const subresourcePath = + `${routePath}/${subresource}` as (typeof routePaths)[number] + return routePaths.includes(subresourcePath) + }) +} + const renderRoute = (route: Route, { constructors }: ClassMeta): string => ` /* * Automatically generated by generate-routes.ts. @@ -386,9 +449,7 @@ const renderClassMethodOptions = ({ resource, }: Pick): string => { if (resource === 'action_attempt') { - return `options: ${renderClassMethodOptionsTypeDef({ - resource, - })} = {},` + return `options: ${renderClassMethodOptionsTypeDef({ resource })} = {},` } return '' } diff --git a/src/lib/seam/connect/routes/acs-access-groups-unmanaged.ts b/src/lib/seam/connect/routes/acs-access-groups-unmanaged.ts deleted file mode 100644 index 9498728..0000000 --- a/src/lib/seam/connect/routes/acs-access-groups-unmanaged.ts +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Automatically generated by generate-routes.ts. - * Do not edit this file or add other files to this directory. - */ - -import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' - -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 { 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' - -import { SeamHttpClientSessions } from './client-sessions.js' - -export class SeamHttpAcsAccessGroupsUnmanaged { - client: Client - readonly defaults: Required - - constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { - const options = parseOptions(apiKeyOrOptions) - this.client = 'client' in options ? options.client : createClient(options) - this.defaults = limitToSeamHttpRequestOptions(options) - } - - static fromClient( - client: SeamHttpOptionsWithClient['client'], - options: Omit = {}, - ): SeamHttpAcsAccessGroupsUnmanaged { - const constructorOptions = { ...options, client } - if (!isSeamHttpOptionsWithClient(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing client') - } - return new SeamHttpAcsAccessGroupsUnmanaged(constructorOptions) - } - - static fromApiKey( - apiKey: SeamHttpOptionsWithApiKey['apiKey'], - options: Omit = {}, - ): SeamHttpAcsAccessGroupsUnmanaged { - const constructorOptions = { ...options, apiKey } - if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing apiKey') - } - return new SeamHttpAcsAccessGroupsUnmanaged(constructorOptions) - } - - static fromClientSessionToken( - clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], - options: Omit< - SeamHttpOptionsWithClientSessionToken, - 'clientSessionToken' - > = {}, - ): SeamHttpAcsAccessGroupsUnmanaged { - const constructorOptions = { ...options, clientSessionToken } - if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') - } - return new SeamHttpAcsAccessGroupsUnmanaged(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 SeamHttp.fromPublishableKey', - ) - } - const client = createClient(clientOptions) - const clientSessions = SeamHttpClientSessions.fromClient(client) - const { token } = await clientSessions.getOrCreate({ - user_identifier_key: userIdentifierKey, - }) - return SeamHttpAcsAccessGroupsUnmanaged.fromClientSessionToken( - token, - options, - ) - } - - static fromConsoleSessionToken( - consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], - workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithConsoleSessionToken, - 'consoleSessionToken' | 'workspaceId' - > = {}, - ): SeamHttpAcsAccessGroupsUnmanaged { - const constructorOptions = { ...options, consoleSessionToken, workspaceId } - if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing consoleSessionToken or workspaceId', - ) - } - return new SeamHttpAcsAccessGroupsUnmanaged(constructorOptions) - } - - static fromPersonalAccessToken( - personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], - workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithPersonalAccessToken, - 'personalAccessToken' | 'workspaceId' - > = {}, - ): SeamHttpAcsAccessGroupsUnmanaged { - const constructorOptions = { ...options, personalAccessToken, workspaceId } - if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing personalAccessToken or workspaceId', - ) - } - return new SeamHttpAcsAccessGroupsUnmanaged(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() - } - - get( - body?: AcsAccessGroupsUnmanagedGetParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/acs/access_groups/unmanaged/get', - method: 'post', - body, - responseKey: 'acs_access_group', - }) - } - - list( - body?: AcsAccessGroupsUnmanagedListParams, - ): SeamHttpRequest< - AcsAccessGroupsUnmanagedListResponse, - 'acs_access_groups' - > { - return new SeamHttpRequest(this, { - pathname: '/acs/access_groups/unmanaged/list', - method: 'post', - body, - responseKey: 'acs_access_groups', - }) - } -} - -export type AcsAccessGroupsUnmanagedGetParams = - RouteRequestBody<'/acs/access_groups/unmanaged/get'> - -export type AcsAccessGroupsUnmanagedGetResponse = SetNonNullable< - Required> -> - -export type AcsAccessGroupsUnmanagedGetOptions = never - -export type AcsAccessGroupsUnmanagedListParams = - RouteRequestBody<'/acs/access_groups/unmanaged/list'> - -export type AcsAccessGroupsUnmanagedListResponse = SetNonNullable< - Required> -> - -export type AcsAccessGroupsUnmanagedListOptions = never diff --git a/src/lib/seam/connect/routes/acs-access-groups.ts b/src/lib/seam/connect/routes/acs-access-groups.ts index fbf1fb2..940cbd7 100644 --- a/src/lib/seam/connect/routes/acs-access-groups.ts +++ b/src/lib/seam/connect/routes/acs-access-groups.ts @@ -34,7 +34,6 @@ 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' -import { SeamHttpAcsAccessGroupsUnmanaged } from './acs-access-groups-unmanaged.js' import { SeamHttpClientSessions } from './client-sessions.js' export class SeamHttpAcsAccessGroups { @@ -162,13 +161,6 @@ export class SeamHttpAcsAccessGroups { await clientSessions.get() } - get unmanaged(): SeamHttpAcsAccessGroupsUnmanaged { - return SeamHttpAcsAccessGroupsUnmanaged.fromClient( - this.client, - this.defaults, - ) - } - addUser(body?: AcsAccessGroupsAddUserBody): SeamHttpRequest { return new SeamHttpRequest(this, { pathname: '/acs/access_groups/add_user', diff --git a/src/lib/seam/connect/routes/acs-credential-pools.ts b/src/lib/seam/connect/routes/acs-credential-pools.ts deleted file mode 100644 index 8b6c62f..0000000 --- a/src/lib/seam/connect/routes/acs-credential-pools.ts +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Automatically generated by generate-routes.ts. - * Do not edit this file or add other files to this directory. - */ - -import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' - -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 { 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' - -import { SeamHttpClientSessions } from './client-sessions.js' - -export class SeamHttpAcsCredentialPools { - client: Client - readonly defaults: Required - - constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { - const options = parseOptions(apiKeyOrOptions) - this.client = 'client' in options ? options.client : createClient(options) - this.defaults = limitToSeamHttpRequestOptions(options) - } - - static fromClient( - client: SeamHttpOptionsWithClient['client'], - options: Omit = {}, - ): SeamHttpAcsCredentialPools { - const constructorOptions = { ...options, client } - if (!isSeamHttpOptionsWithClient(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing client') - } - return new SeamHttpAcsCredentialPools(constructorOptions) - } - - static fromApiKey( - apiKey: SeamHttpOptionsWithApiKey['apiKey'], - options: Omit = {}, - ): SeamHttpAcsCredentialPools { - const constructorOptions = { ...options, apiKey } - if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing apiKey') - } - return new SeamHttpAcsCredentialPools(constructorOptions) - } - - static fromClientSessionToken( - clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], - options: Omit< - SeamHttpOptionsWithClientSessionToken, - 'clientSessionToken' - > = {}, - ): SeamHttpAcsCredentialPools { - const constructorOptions = { ...options, clientSessionToken } - if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') - } - return new SeamHttpAcsCredentialPools(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 SeamHttp.fromPublishableKey', - ) - } - const client = createClient(clientOptions) - const clientSessions = SeamHttpClientSessions.fromClient(client) - const { token } = await clientSessions.getOrCreate({ - user_identifier_key: userIdentifierKey, - }) - return SeamHttpAcsCredentialPools.fromClientSessionToken(token, options) - } - - static fromConsoleSessionToken( - consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], - workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithConsoleSessionToken, - 'consoleSessionToken' | 'workspaceId' - > = {}, - ): SeamHttpAcsCredentialPools { - const constructorOptions = { ...options, consoleSessionToken, workspaceId } - if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing consoleSessionToken or workspaceId', - ) - } - return new SeamHttpAcsCredentialPools(constructorOptions) - } - - static fromPersonalAccessToken( - personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], - workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithPersonalAccessToken, - 'personalAccessToken' | 'workspaceId' - > = {}, - ): SeamHttpAcsCredentialPools { - const constructorOptions = { ...options, personalAccessToken, workspaceId } - if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing personalAccessToken or workspaceId', - ) - } - return new SeamHttpAcsCredentialPools(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( - body?: AcsCredentialPoolsListParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/acs/credential_pools/list', - method: 'post', - body, - responseKey: 'acs_credential_pools', - }) - } -} - -export type AcsCredentialPoolsListParams = - RouteRequestBody<'/acs/credential_pools/list'> - -export type AcsCredentialPoolsListResponse = SetNonNullable< - Required> -> - -export type AcsCredentialPoolsListOptions = never diff --git a/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts b/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts deleted file mode 100644 index f681b6b..0000000 --- a/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Automatically generated by generate-routes.ts. - * Do not edit this file or add other files to this directory. - */ - -import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' - -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 { 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' - -import { SeamHttpClientSessions } from './client-sessions.js' - -export class SeamHttpAcsCredentialProvisioningAutomations { - client: Client - readonly defaults: Required - - constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { - const options = parseOptions(apiKeyOrOptions) - this.client = 'client' in options ? options.client : createClient(options) - this.defaults = limitToSeamHttpRequestOptions(options) - } - - static fromClient( - client: SeamHttpOptionsWithClient['client'], - options: Omit = {}, - ): SeamHttpAcsCredentialProvisioningAutomations { - const constructorOptions = { ...options, client } - if (!isSeamHttpOptionsWithClient(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing client') - } - return new SeamHttpAcsCredentialProvisioningAutomations(constructorOptions) - } - - static fromApiKey( - apiKey: SeamHttpOptionsWithApiKey['apiKey'], - options: Omit = {}, - ): SeamHttpAcsCredentialProvisioningAutomations { - const constructorOptions = { ...options, apiKey } - if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing apiKey') - } - return new SeamHttpAcsCredentialProvisioningAutomations(constructorOptions) - } - - static fromClientSessionToken( - clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], - options: Omit< - SeamHttpOptionsWithClientSessionToken, - 'clientSessionToken' - > = {}, - ): SeamHttpAcsCredentialProvisioningAutomations { - const constructorOptions = { ...options, clientSessionToken } - if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') - } - return new SeamHttpAcsCredentialProvisioningAutomations(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 SeamHttp.fromPublishableKey', - ) - } - const client = createClient(clientOptions) - const clientSessions = SeamHttpClientSessions.fromClient(client) - const { token } = await clientSessions.getOrCreate({ - user_identifier_key: userIdentifierKey, - }) - return SeamHttpAcsCredentialProvisioningAutomations.fromClientSessionToken( - token, - options, - ) - } - - static fromConsoleSessionToken( - consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], - workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithConsoleSessionToken, - 'consoleSessionToken' | 'workspaceId' - > = {}, - ): SeamHttpAcsCredentialProvisioningAutomations { - const constructorOptions = { ...options, consoleSessionToken, workspaceId } - if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing consoleSessionToken or workspaceId', - ) - } - return new SeamHttpAcsCredentialProvisioningAutomations(constructorOptions) - } - - static fromPersonalAccessToken( - personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], - workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithPersonalAccessToken, - 'personalAccessToken' | 'workspaceId' - > = {}, - ): SeamHttpAcsCredentialProvisioningAutomations { - const constructorOptions = { ...options, personalAccessToken, workspaceId } - if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing personalAccessToken or workspaceId', - ) - } - return new SeamHttpAcsCredentialProvisioningAutomations(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() - } - - launch( - body?: AcsCredentialProvisioningAutomationsLaunchBody, - ): SeamHttpRequest< - AcsCredentialProvisioningAutomationsLaunchResponse, - 'acs_credential_provisioning_automation' - > { - return new SeamHttpRequest(this, { - pathname: '/acs/credential_provisioning_automations/launch', - method: 'post', - body, - responseKey: 'acs_credential_provisioning_automation', - }) - } -} - -export type AcsCredentialProvisioningAutomationsLaunchBody = - RouteRequestBody<'/acs/credential_provisioning_automations/launch'> - -export type AcsCredentialProvisioningAutomationsLaunchResponse = SetNonNullable< - Required> -> - -export type AcsCredentialProvisioningAutomationsLaunchOptions = never diff --git a/src/lib/seam/connect/routes/acs-credentials-unmanaged.ts b/src/lib/seam/connect/routes/acs-credentials-unmanaged.ts deleted file mode 100644 index 75bccd4..0000000 --- a/src/lib/seam/connect/routes/acs-credentials-unmanaged.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Automatically generated by generate-routes.ts. - * Do not edit this file or add other files to this directory. - */ - -import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' - -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 { 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' - -import { SeamHttpClientSessions } from './client-sessions.js' - -export class SeamHttpAcsCredentialsUnmanaged { - client: Client - readonly defaults: Required - - constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { - const options = parseOptions(apiKeyOrOptions) - this.client = 'client' in options ? options.client : createClient(options) - this.defaults = limitToSeamHttpRequestOptions(options) - } - - static fromClient( - client: SeamHttpOptionsWithClient['client'], - options: Omit = {}, - ): SeamHttpAcsCredentialsUnmanaged { - const constructorOptions = { ...options, client } - if (!isSeamHttpOptionsWithClient(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing client') - } - return new SeamHttpAcsCredentialsUnmanaged(constructorOptions) - } - - static fromApiKey( - apiKey: SeamHttpOptionsWithApiKey['apiKey'], - options: Omit = {}, - ): SeamHttpAcsCredentialsUnmanaged { - const constructorOptions = { ...options, apiKey } - if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing apiKey') - } - return new SeamHttpAcsCredentialsUnmanaged(constructorOptions) - } - - static fromClientSessionToken( - clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], - options: Omit< - SeamHttpOptionsWithClientSessionToken, - 'clientSessionToken' - > = {}, - ): SeamHttpAcsCredentialsUnmanaged { - const constructorOptions = { ...options, clientSessionToken } - if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') - } - return new SeamHttpAcsCredentialsUnmanaged(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 SeamHttp.fromPublishableKey', - ) - } - const client = createClient(clientOptions) - const clientSessions = SeamHttpClientSessions.fromClient(client) - const { token } = await clientSessions.getOrCreate({ - user_identifier_key: userIdentifierKey, - }) - return SeamHttpAcsCredentialsUnmanaged.fromClientSessionToken( - token, - options, - ) - } - - static fromConsoleSessionToken( - consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], - workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithConsoleSessionToken, - 'consoleSessionToken' | 'workspaceId' - > = {}, - ): SeamHttpAcsCredentialsUnmanaged { - const constructorOptions = { ...options, consoleSessionToken, workspaceId } - if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing consoleSessionToken or workspaceId', - ) - } - return new SeamHttpAcsCredentialsUnmanaged(constructorOptions) - } - - static fromPersonalAccessToken( - personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], - workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithPersonalAccessToken, - 'personalAccessToken' | 'workspaceId' - > = {}, - ): SeamHttpAcsCredentialsUnmanaged { - const constructorOptions = { ...options, personalAccessToken, workspaceId } - if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing personalAccessToken or workspaceId', - ) - } - return new SeamHttpAcsCredentialsUnmanaged(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() - } - - get( - body?: AcsCredentialsUnmanagedGetParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/acs/credentials/unmanaged/get', - method: 'post', - body, - responseKey: 'acs_credential', - }) - } - - list( - body?: AcsCredentialsUnmanagedListParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/acs/credentials/unmanaged/list', - method: 'post', - body, - responseKey: 'acs_credentials', - }) - } -} - -export type AcsCredentialsUnmanagedGetParams = - RouteRequestBody<'/acs/credentials/unmanaged/get'> - -export type AcsCredentialsUnmanagedGetResponse = SetNonNullable< - Required> -> - -export type AcsCredentialsUnmanagedGetOptions = never - -export type AcsCredentialsUnmanagedListParams = - RouteRequestBody<'/acs/credentials/unmanaged/list'> - -export type AcsCredentialsUnmanagedListResponse = SetNonNullable< - Required> -> - -export type AcsCredentialsUnmanagedListOptions = never diff --git a/src/lib/seam/connect/routes/acs-credentials.ts b/src/lib/seam/connect/routes/acs-credentials.ts index 21175f7..11f43d5 100644 --- a/src/lib/seam/connect/routes/acs-credentials.ts +++ b/src/lib/seam/connect/routes/acs-credentials.ts @@ -34,7 +34,6 @@ 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' -import { SeamHttpAcsCredentialsUnmanaged } from './acs-credentials-unmanaged.js' import { SeamHttpClientSessions } from './client-sessions.js' export class SeamHttpAcsCredentials { @@ -162,13 +161,6 @@ export class SeamHttpAcsCredentials { await clientSessions.get() } - get unmanaged(): SeamHttpAcsCredentialsUnmanaged { - return SeamHttpAcsCredentialsUnmanaged.fromClient( - this.client, - this.defaults, - ) - } - assign(body?: AcsCredentialsAssignBody): SeamHttpRequest { return new SeamHttpRequest(this, { pathname: '/acs/credentials/assign', @@ -189,20 +181,6 @@ export class SeamHttpAcsCredentials { }) } - createOfflineCode( - body?: AcsCredentialsCreateOfflineCodeBody, - ): SeamHttpRequest< - AcsCredentialsCreateOfflineCodeResponse, - 'acs_credential' - > { - return new SeamHttpRequest(this, { - pathname: '/acs/credentials/create_offline_code', - method: 'post', - body, - responseKey: 'acs_credential', - }) - } - delete(body?: AcsCredentialsDeleteParams): SeamHttpRequest { return new SeamHttpRequest(this, { pathname: '/acs/credentials/delete', @@ -287,15 +265,6 @@ export type AcsCredentialsCreateResponse = SetNonNullable< export type AcsCredentialsCreateOptions = never -export type AcsCredentialsCreateOfflineCodeBody = - RouteRequestBody<'/acs/credentials/create_offline_code'> - -export type AcsCredentialsCreateOfflineCodeResponse = SetNonNullable< - Required> -> - -export type AcsCredentialsCreateOfflineCodeOptions = never - export type AcsCredentialsDeleteParams = RouteRequestBody<'/acs/credentials/delete'> diff --git a/src/lib/seam/connect/routes/acs-users-unmanaged.ts b/src/lib/seam/connect/routes/acs-users-unmanaged.ts deleted file mode 100644 index 39c47d6..0000000 --- a/src/lib/seam/connect/routes/acs-users-unmanaged.ts +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Automatically generated by generate-routes.ts. - * Do not edit this file or add other files to this directory. - */ - -import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' - -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 { 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' - -import { SeamHttpClientSessions } from './client-sessions.js' - -export class SeamHttpAcsUsersUnmanaged { - client: Client - readonly defaults: Required - - constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { - const options = parseOptions(apiKeyOrOptions) - this.client = 'client' in options ? options.client : createClient(options) - this.defaults = limitToSeamHttpRequestOptions(options) - } - - static fromClient( - client: SeamHttpOptionsWithClient['client'], - options: Omit = {}, - ): SeamHttpAcsUsersUnmanaged { - const constructorOptions = { ...options, client } - if (!isSeamHttpOptionsWithClient(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing client') - } - return new SeamHttpAcsUsersUnmanaged(constructorOptions) - } - - static fromApiKey( - apiKey: SeamHttpOptionsWithApiKey['apiKey'], - options: Omit = {}, - ): SeamHttpAcsUsersUnmanaged { - const constructorOptions = { ...options, apiKey } - if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing apiKey') - } - return new SeamHttpAcsUsersUnmanaged(constructorOptions) - } - - static fromClientSessionToken( - clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], - options: Omit< - SeamHttpOptionsWithClientSessionToken, - 'clientSessionToken' - > = {}, - ): SeamHttpAcsUsersUnmanaged { - const constructorOptions = { ...options, clientSessionToken } - if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') - } - return new SeamHttpAcsUsersUnmanaged(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 SeamHttp.fromPublishableKey', - ) - } - const client = createClient(clientOptions) - const clientSessions = SeamHttpClientSessions.fromClient(client) - const { token } = await clientSessions.getOrCreate({ - user_identifier_key: userIdentifierKey, - }) - return SeamHttpAcsUsersUnmanaged.fromClientSessionToken(token, options) - } - - static fromConsoleSessionToken( - consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], - workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithConsoleSessionToken, - 'consoleSessionToken' | 'workspaceId' - > = {}, - ): SeamHttpAcsUsersUnmanaged { - const constructorOptions = { ...options, consoleSessionToken, workspaceId } - if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing consoleSessionToken or workspaceId', - ) - } - return new SeamHttpAcsUsersUnmanaged(constructorOptions) - } - - static fromPersonalAccessToken( - personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], - workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithPersonalAccessToken, - 'personalAccessToken' | 'workspaceId' - > = {}, - ): SeamHttpAcsUsersUnmanaged { - const constructorOptions = { ...options, personalAccessToken, workspaceId } - if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing personalAccessToken or workspaceId', - ) - } - return new SeamHttpAcsUsersUnmanaged(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() - } - - get( - body?: AcsUsersUnmanagedGetParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/acs/users/unmanaged/get', - method: 'post', - body, - responseKey: 'acs_user', - }) - } - - list( - body?: AcsUsersUnmanagedListParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/acs/users/unmanaged/list', - method: 'post', - body, - responseKey: 'acs_users', - }) - } -} - -export type AcsUsersUnmanagedGetParams = - RouteRequestBody<'/acs/users/unmanaged/get'> - -export type AcsUsersUnmanagedGetResponse = SetNonNullable< - Required> -> - -export type AcsUsersUnmanagedGetOptions = never - -export type AcsUsersUnmanagedListParams = - RouteRequestBody<'/acs/users/unmanaged/list'> - -export type AcsUsersUnmanagedListResponse = SetNonNullable< - Required> -> - -export type AcsUsersUnmanagedListOptions = never diff --git a/src/lib/seam/connect/routes/acs-users.ts b/src/lib/seam/connect/routes/acs-users.ts index 5b6aec7..eaf12df 100644 --- a/src/lib/seam/connect/routes/acs-users.ts +++ b/src/lib/seam/connect/routes/acs-users.ts @@ -34,7 +34,6 @@ 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' -import { SeamHttpAcsUsersUnmanaged } from './acs-users-unmanaged.js' import { SeamHttpClientSessions } from './client-sessions.js' export class SeamHttpAcsUsers { @@ -162,10 +161,6 @@ export class SeamHttpAcsUsers { await clientSessions.get() } - get unmanaged(): SeamHttpAcsUsersUnmanaged { - return SeamHttpAcsUsersUnmanaged.fromClient(this.client, this.defaults) - } - addToAccessGroup( body?: AcsUsersAddToAccessGroupBody, ): SeamHttpRequest { diff --git a/src/lib/seam/connect/routes/acs.ts b/src/lib/seam/connect/routes/acs.ts index a504520..c16fc82 100644 --- a/src/lib/seam/connect/routes/acs.ts +++ b/src/lib/seam/connect/routes/acs.ts @@ -32,8 +32,6 @@ import type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' import { SeamHttpAcsAccessGroups } from './acs-access-groups.js' -import { SeamHttpAcsCredentialPools } from './acs-credential-pools.js' -import { SeamHttpAcsCredentialProvisioningAutomations } from './acs-credential-provisioning-automations.js' import { SeamHttpAcsCredentials } from './acs-credentials.js' import { SeamHttpAcsEncoders } from './acs-encoders.js' import { SeamHttpAcsEntrances } from './acs-entrances.js' @@ -170,17 +168,6 @@ export class SeamHttpAcs { return SeamHttpAcsAccessGroups.fromClient(this.client, this.defaults) } - get credentialPools(): SeamHttpAcsCredentialPools { - return SeamHttpAcsCredentialPools.fromClient(this.client, this.defaults) - } - - get credentialProvisioningAutomations(): SeamHttpAcsCredentialProvisioningAutomations { - return SeamHttpAcsCredentialProvisioningAutomations.fromClient( - this.client, - this.defaults, - ) - } - get credentials(): SeamHttpAcsCredentials { return SeamHttpAcsCredentials.fromClient(this.client, this.defaults) } diff --git a/src/lib/seam/connect/routes/devices.ts b/src/lib/seam/connect/routes/devices.ts index 2b1b3e8..679ee39 100644 --- a/src/lib/seam/connect/routes/devices.ts +++ b/src/lib/seam/connect/routes/devices.ts @@ -171,15 +171,6 @@ export class SeamHttpDevices { return SeamHttpDevicesSimulate.fromClient(this.client, this.defaults) } - delete(body?: DevicesDeleteParams): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/devices/delete', - method: 'post', - body, - responseKey: undefined, - }) - } - get(body?: DevicesGetParams): SeamHttpRequest { return new SeamHttpRequest(this, { pathname: '/devices/get', @@ -221,14 +212,6 @@ export class SeamHttpDevices { } } -export type DevicesDeleteParams = RouteRequestBody<'/devices/delete'> - -export type DevicesDeleteResponse = SetNonNullable< - Required> -> - -export type DevicesDeleteOptions = never - export type DevicesGetParams = RouteRequestBody<'/devices/get'> export type DevicesGetResponse = SetNonNullable< diff --git a/src/lib/seam/connect/routes/index.ts b/src/lib/seam/connect/routes/index.ts index 9631da8..dca9380 100644 --- a/src/lib/seam/connect/routes/index.ts +++ b/src/lib/seam/connect/routes/index.ts @@ -3,17 +3,12 @@ export * from './access-codes-simulate.js' export * from './access-codes-unmanaged.js' export * from './acs.js' export * from './acs-access-groups.js' -export * from './acs-access-groups-unmanaged.js' -export * from './acs-credential-pools.js' -export * from './acs-credential-provisioning-automations.js' export * from './acs-credentials.js' -export * from './acs-credentials-unmanaged.js' export * from './acs-encoders.js' export * from './acs-encoders-simulate.js' export * from './acs-entrances.js' export * from './acs-systems.js' export * from './acs-users.js' -export * from './acs-users-unmanaged.js' export * from './action-attempts.js' export * from './bridges.js' export * from './client-sessions.js' @@ -33,7 +28,6 @@ export * from './phones-simulate.js' export * from './thermostats.js' export * from './thermostats-schedules.js' export * from './thermostats-simulate.js' -export * from './unstable-locations.js' export * from './user-identities.js' export * from './user-identities-enrollment-automations.js' export * from './webhooks.js' diff --git a/src/lib/seam/connect/routes/thermostats.ts b/src/lib/seam/connect/routes/thermostats.ts index 1ba4615..124e989 100644 --- a/src/lib/seam/connect/routes/thermostats.ts +++ b/src/lib/seam/connect/routes/thermostats.ts @@ -222,17 +222,6 @@ export class SeamHttpThermostats { }) } - get( - body?: ThermostatsGetParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/thermostats/get', - method: 'post', - body, - responseKey: 'thermostat', - }) - } - heat( body?: ThermostatsHeatBody, options: Pick = {}, @@ -384,14 +373,6 @@ export type ThermostatsDeleteClimatePresetResponse = SetNonNullable< export type ThermostatsDeleteClimatePresetOptions = never -export type ThermostatsGetParams = RouteRequestBody<'/thermostats/get'> - -export type ThermostatsGetResponse = SetNonNullable< - Required> -> - -export type ThermostatsGetOptions = never - export type ThermostatsHeatBody = RouteRequestBody<'/thermostats/heat'> export type ThermostatsHeatResponse = SetNonNullable< diff --git a/src/lib/seam/connect/routes/unstable-locations.ts b/src/lib/seam/connect/routes/unstable-locations.ts deleted file mode 100644 index 000cdd8..0000000 --- a/src/lib/seam/connect/routes/unstable-locations.ts +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Automatically generated by generate-routes.ts. - * Do not edit this file or add other files to this directory. - */ - -import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' - -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 { 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' - -import { SeamHttpClientSessions } from './client-sessions.js' - -export class SeamHttpUnstableLocations { - client: Client - readonly defaults: Required - - constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { - const options = parseOptions(apiKeyOrOptions) - this.client = 'client' in options ? options.client : createClient(options) - this.defaults = limitToSeamHttpRequestOptions(options) - } - - static fromClient( - client: SeamHttpOptionsWithClient['client'], - options: Omit = {}, - ): SeamHttpUnstableLocations { - const constructorOptions = { ...options, client } - if (!isSeamHttpOptionsWithClient(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing client') - } - return new SeamHttpUnstableLocations(constructorOptions) - } - - static fromApiKey( - apiKey: SeamHttpOptionsWithApiKey['apiKey'], - options: Omit = {}, - ): SeamHttpUnstableLocations { - const constructorOptions = { ...options, apiKey } - if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing apiKey') - } - return new SeamHttpUnstableLocations(constructorOptions) - } - - static fromClientSessionToken( - clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], - options: Omit< - SeamHttpOptionsWithClientSessionToken, - 'clientSessionToken' - > = {}, - ): SeamHttpUnstableLocations { - const constructorOptions = { ...options, clientSessionToken } - if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') - } - return new SeamHttpUnstableLocations(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 SeamHttp.fromPublishableKey', - ) - } - const client = createClient(clientOptions) - const clientSessions = SeamHttpClientSessions.fromClient(client) - const { token } = await clientSessions.getOrCreate({ - user_identifier_key: userIdentifierKey, - }) - return SeamHttpUnstableLocations.fromClientSessionToken(token, options) - } - - static fromConsoleSessionToken( - consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], - workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithConsoleSessionToken, - 'consoleSessionToken' | 'workspaceId' - > = {}, - ): SeamHttpUnstableLocations { - const constructorOptions = { ...options, consoleSessionToken, workspaceId } - if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing consoleSessionToken or workspaceId', - ) - } - return new SeamHttpUnstableLocations(constructorOptions) - } - - static fromPersonalAccessToken( - personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], - workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithPersonalAccessToken, - 'personalAccessToken' | 'workspaceId' - > = {}, - ): SeamHttpUnstableLocations { - const constructorOptions = { ...options, personalAccessToken, workspaceId } - if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing personalAccessToken or workspaceId', - ) - } - return new SeamHttpUnstableLocations(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() - } - - addDevices( - body?: UnstableLocationsAddDevicesBody, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/unstable_locations/add_devices', - method: 'post', - body, - responseKey: undefined, - }) - } - - create( - body?: UnstableLocationsCreateBody, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/unstable_locations/create', - method: 'post', - body, - responseKey: 'location', - }) - } - - delete( - body?: UnstableLocationsDeleteParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/unstable_locations/delete', - method: 'post', - body, - responseKey: undefined, - }) - } - - get( - body?: UnstableLocationsGetParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/unstable_locations/get', - method: 'post', - body, - responseKey: 'location', - }) - } - - list( - body?: UnstableLocationsListParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/unstable_locations/list', - method: 'post', - body, - responseKey: 'locations', - }) - } - - removeDevices( - body?: UnstableLocationsRemoveDevicesParams, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/unstable_locations/remove_devices', - method: 'post', - body, - responseKey: undefined, - }) - } - - update( - body?: UnstableLocationsUpdateBody, - ): SeamHttpRequest { - return new SeamHttpRequest(this, { - pathname: '/unstable_locations/update', - method: 'post', - body, - responseKey: 'location', - }) - } -} - -export type UnstableLocationsAddDevicesBody = - RouteRequestBody<'/unstable_locations/add_devices'> - -export type UnstableLocationsAddDevicesResponse = SetNonNullable< - Required> -> - -export type UnstableLocationsAddDevicesOptions = never - -export type UnstableLocationsCreateBody = - RouteRequestBody<'/unstable_locations/create'> - -export type UnstableLocationsCreateResponse = SetNonNullable< - Required> -> - -export type UnstableLocationsCreateOptions = never - -export type UnstableLocationsDeleteParams = - RouteRequestBody<'/unstable_locations/delete'> - -export type UnstableLocationsDeleteResponse = SetNonNullable< - Required> -> - -export type UnstableLocationsDeleteOptions = never - -export type UnstableLocationsGetParams = - RouteRequestBody<'/unstable_locations/get'> - -export type UnstableLocationsGetResponse = SetNonNullable< - Required> -> - -export type UnstableLocationsGetOptions = never - -export type UnstableLocationsListParams = - RouteRequestBody<'/unstable_locations/list'> - -export type UnstableLocationsListResponse = SetNonNullable< - Required> -> - -export type UnstableLocationsListOptions = never - -export type UnstableLocationsRemoveDevicesParams = - RouteRequestBody<'/unstable_locations/remove_devices'> - -export type UnstableLocationsRemoveDevicesResponse = SetNonNullable< - Required> -> - -export type UnstableLocationsRemoveDevicesOptions = never - -export type UnstableLocationsUpdateBody = - RouteRequestBody<'/unstable_locations/update'> - -export type UnstableLocationsUpdateResponse = SetNonNullable< - Required> -> - -export type UnstableLocationsUpdateOptions = never