diff --git a/package-lock.json b/package-lock.json index 324b4418..b146ac1e 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.4.4", - "@seamapi/types": "1.469.0", + "@seamapi/types": "1.470.0", "@swc/core": "^1.11.29", "@types/eslint": "^8.44.2", "@types/jsonwebtoken": "^9.0.6", @@ -50,7 +50,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.469.0" + "@seamapi/types": "^1.470.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -1216,9 +1216,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.469.0", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.469.0.tgz", - "integrity": "sha512-PFbPByD/o8aXJw33LZq/b0Dz1FGKyWgSu1jafcrE+JB/NQysFOt9vIGRNCbMn9HMykGdxNvcpLeqHkGfI++Kmg==", + "version": "1.470.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.470.0.tgz", + "integrity": "sha512-fCM2G6ZonQBhgDKKaYsaCQiwcFY+4O4L28w4HFQnMAZHrZIVY2R0p/udfRBry/buMm16+UCKayIDxlF41ayzog==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 8c171ef3..dbcda94a 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.469.0" + "@seamapi/types": "^1.470.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -101,7 +101,7 @@ "@seamapi/blueprint": "^0.51.1", "@seamapi/fake-seam-connect": "^1.77.0", "@seamapi/smith": "^0.4.4", - "@seamapi/types": "1.469.0", + "@seamapi/types": "1.470.0", "@swc/core": "^1.11.29", "@types/eslint": "^8.44.2", "@types/jsonwebtoken": "^9.0.6", diff --git a/src/lib/seam/connect/routes/index.ts b/src/lib/seam/connect/routes/index.ts index 27f8a963..78d05d04 100644 --- a/src/lib/seam/connect/routes/index.ts +++ b/src/lib/seam/connect/routes/index.ts @@ -26,8 +26,6 @@ export * from './seam-http-endpoints-without-workspace.js' export * from './seam-http-without-workspace.js' export * from './spaces/index.js' export * from './thermostats/index.js' -export * from './unstable-access-grants/index.js' -export * from './unstable-access-methods/index.js' export * from './unstable-locations/index.js' export * from './unstable-partner/index.js' export * from './user-identities/index.js' diff --git a/src/lib/seam/connect/routes/seam-http-endpoints.ts b/src/lib/seam/connect/routes/seam-http-endpoints.ts index 6390a948..2f4b351a 100644 --- a/src/lib/seam/connect/routes/seam-http-endpoints.ts +++ b/src/lib/seam/connect/routes/seam-http-endpoints.ts @@ -707,33 +707,6 @@ import { type ThermostatsSimulateTemperatureReachedParameters, type ThermostatsSimulateTemperatureReachedRequest, } from './thermostats/simulate/index.js' -import { - SeamHttpUnstableAccessGrants, - type UnstableAccessGrantsCreateOptions, - type UnstableAccessGrantsCreateParameters, - type UnstableAccessGrantsCreateRequest, - type UnstableAccessGrantsDeleteOptions, - type UnstableAccessGrantsDeleteParameters, - type UnstableAccessGrantsDeleteRequest, - type UnstableAccessGrantsGetOptions, - type UnstableAccessGrantsGetParameters, - type UnstableAccessGrantsGetRequest, - type UnstableAccessGrantsListOptions, - type UnstableAccessGrantsListParameters, - type UnstableAccessGrantsListRequest, -} from './unstable-access-grants/index.js' -import { - SeamHttpUnstableAccessMethods, - type UnstableAccessMethodsDeleteOptions, - type UnstableAccessMethodsDeleteParameters, - type UnstableAccessMethodsDeleteRequest, - type UnstableAccessMethodsGetOptions, - type UnstableAccessMethodsGetParameters, - type UnstableAccessMethodsGetRequest, - type UnstableAccessMethodsListOptions, - type UnstableAccessMethodsListParameters, - type UnstableAccessMethodsListRequest, -} from './unstable-access-methods/index.js' import { SeamHttpUnstableLocations, type UnstableLocationsAddAcsEntrancesOptions, @@ -3485,132 +3458,6 @@ export class SeamHttpEndpoints { } } - get ['/unstable_access_grants/create'](): ( - parameters?: UnstableAccessGrantsCreateParameters, - options?: UnstableAccessGrantsCreateOptions, - ) => UnstableAccessGrantsCreateRequest { - const { client, defaults } = this - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return function unstableAccessGrantsCreate( - ...args: Parameters - ): ReturnType { - const seam = SeamHttpUnstableAccessGrants.fromClient(client, defaults) - return seam.create(...args) - } - } - - get ['/unstable_access_grants/delete'](): ( - parameters?: UnstableAccessGrantsDeleteParameters, - options?: UnstableAccessGrantsDeleteOptions, - ) => UnstableAccessGrantsDeleteRequest { - const { client, defaults } = this - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return function unstableAccessGrantsDelete( - ...args: Parameters - ): ReturnType { - const seam = SeamHttpUnstableAccessGrants.fromClient(client, defaults) - return seam.delete(...args) - } - } - - get ['/unstable_access_grants/get'](): ( - parameters?: UnstableAccessGrantsGetParameters, - options?: UnstableAccessGrantsGetOptions, - ) => UnstableAccessGrantsGetRequest { - const { client, defaults } = this - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return function unstableAccessGrantsGet( - ...args: Parameters - ): ReturnType { - const seam = SeamHttpUnstableAccessGrants.fromClient(client, defaults) - return seam.get(...args) - } - } - - get ['/unstable_access_grants/list'](): ( - parameters?: UnstableAccessGrantsListParameters, - options?: UnstableAccessGrantsListOptions, - ) => UnstableAccessGrantsListRequest { - const { client, defaults } = this - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return function unstableAccessGrantsList( - ...args: Parameters - ): ReturnType { - const seam = SeamHttpUnstableAccessGrants.fromClient(client, defaults) - return seam.list(...args) - } - } - - get ['/unstable_access_methods/delete'](): ( - parameters?: UnstableAccessMethodsDeleteParameters, - options?: UnstableAccessMethodsDeleteOptions, - ) => UnstableAccessMethodsDeleteRequest { - const { client, defaults } = this - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return function unstableAccessMethodsDelete( - ...args: Parameters - ): ReturnType { - const seam = SeamHttpUnstableAccessMethods.fromClient(client, defaults) - return seam.delete(...args) - } - } - - get ['/unstable_access_methods/get'](): ( - parameters?: UnstableAccessMethodsGetParameters, - options?: UnstableAccessMethodsGetOptions, - ) => UnstableAccessMethodsGetRequest { - const { client, defaults } = this - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return function unstableAccessMethodsGet( - ...args: Parameters - ): ReturnType { - const seam = SeamHttpUnstableAccessMethods.fromClient(client, defaults) - return seam.get(...args) - } - } - - get ['/unstable_access_methods/list'](): ( - parameters?: UnstableAccessMethodsListParameters, - options?: UnstableAccessMethodsListOptions, - ) => UnstableAccessMethodsListRequest { - const { client, defaults } = this - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return function unstableAccessMethodsList( - ...args: Parameters - ): ReturnType { - const seam = SeamHttpUnstableAccessMethods.fromClient(client, defaults) - return seam.list(...args) - } - } - get ['/unstable_locations/add_acs_entrances'](): ( parameters?: UnstableLocationsAddAcsEntrancesParameters, options?: UnstableLocationsAddAcsEntrancesOptions, @@ -4344,10 +4191,6 @@ export type SeamHttpEndpointQueryPaths = | '/thermostats/list' | '/thermostats/schedules/get' | '/thermostats/schedules/list' - | '/unstable_access_grants/get' - | '/unstable_access_grants/list' - | '/unstable_access_methods/get' - | '/unstable_access_methods/list' | '/unstable_locations/get' | '/unstable_locations/list' | '/unstable_partner/building_blocks/generate_magic_link' @@ -4476,9 +4319,6 @@ export type SeamHttpEndpointMutationPaths = | '/thermostats/schedules/update' | '/thermostats/simulate/hvac_mode_adjusted' | '/thermostats/simulate/temperature_reached' - | '/unstable_access_grants/create' - | '/unstable_access_grants/delete' - | '/unstable_access_methods/delete' | '/unstable_locations/add_acs_entrances' | '/unstable_locations/add_devices' | '/unstable_locations/create' diff --git a/src/lib/seam/connect/routes/seam-http.ts b/src/lib/seam/connect/routes/seam-http.ts index 3db87d13..d928ec1d 100644 --- a/src/lib/seam/connect/routes/seam-http.ts +++ b/src/lib/seam/connect/routes/seam-http.ts @@ -50,8 +50,6 @@ import { SeamHttpNoiseSensors } from './noise-sensors/index.js' import { SeamHttpPhones } from './phones/index.js' import { SeamHttpSpaces } from './spaces/index.js' import { SeamHttpThermostats } from './thermostats/index.js' -import { SeamHttpUnstableAccessGrants } from './unstable-access-grants/index.js' -import { SeamHttpUnstableAccessMethods } from './unstable-access-methods/index.js' import { SeamHttpUnstableLocations } from './unstable-locations/index.js' import { SeamHttpUnstablePartner } from './unstable-partner/index.js' import { SeamHttpUserIdentities } from './user-identities/index.js' @@ -257,14 +255,6 @@ export class SeamHttp { return SeamHttpThermostats.fromClient(this.client, this.defaults) } - get unstableAccessGrants(): SeamHttpUnstableAccessGrants { - return SeamHttpUnstableAccessGrants.fromClient(this.client, this.defaults) - } - - get unstableAccessMethods(): SeamHttpUnstableAccessMethods { - return SeamHttpUnstableAccessMethods.fromClient(this.client, this.defaults) - } - get unstableLocations(): SeamHttpUnstableLocations { return SeamHttpUnstableLocations.fromClient(this.client, this.defaults) } diff --git a/src/lib/seam/connect/routes/unstable-access-grants/index.ts b/src/lib/seam/connect/routes/unstable-access-grants/index.ts deleted file mode 100644 index a946de18..00000000 --- a/src/lib/seam/connect/routes/unstable-access-grants/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* - * Automatically generated by codegen/smith.ts. - * Do not edit this file or add other files to this directory. - */ - -export * from './unstable-access-grants.js' diff --git a/src/lib/seam/connect/routes/unstable-access-grants/unstable-access-grants.ts b/src/lib/seam/connect/routes/unstable-access-grants/unstable-access-grants.ts deleted file mode 100644 index 945843d5..00000000 --- a/src/lib/seam/connect/routes/unstable-access-grants/unstable-access-grants.ts +++ /dev/null @@ -1,333 +0,0 @@ -/* - * 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 SeamHttpUnstableAccessGrants { - 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 = {}, - ): SeamHttpUnstableAccessGrants { - const constructorOptions = { ...options, client } - if (!isSeamHttpOptionsWithClient(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing client') - } - return new SeamHttpUnstableAccessGrants(constructorOptions) - } - - static fromApiKey( - apiKey: SeamHttpOptionsWithApiKey['apiKey'], - options: Omit = {}, - ): SeamHttpUnstableAccessGrants { - const constructorOptions = { ...options, apiKey } - if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing apiKey') - } - return new SeamHttpUnstableAccessGrants(constructorOptions) - } - - static fromClientSessionToken( - clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], - options: Omit< - SeamHttpOptionsWithClientSessionToken, - 'clientSessionToken' - > = {}, - ): SeamHttpUnstableAccessGrants { - const constructorOptions = { ...options, clientSessionToken } - if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') - } - return new SeamHttpUnstableAccessGrants(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 SeamHttpUnstableAccessGrants.fromPublishableKey', - ) - } - const client = createClient(clientOptions) - const clientSessions = SeamHttpClientSessions.fromClient(client) - const { token } = await clientSessions.getOrCreate({ - user_identifier_key: userIdentifierKey, - }) - return SeamHttpUnstableAccessGrants.fromClientSessionToken(token, options) - } - - static fromConsoleSessionToken( - consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], - workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithConsoleSessionToken, - 'consoleSessionToken' | 'workspaceId' - > = {}, - ): SeamHttpUnstableAccessGrants { - const constructorOptions = { ...options, consoleSessionToken, workspaceId } - if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing consoleSessionToken or workspaceId', - ) - } - return new SeamHttpUnstableAccessGrants(constructorOptions) - } - - static fromPersonalAccessToken( - personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], - workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithPersonalAccessToken, - 'personalAccessToken' | 'workspaceId' - > = {}, - ): SeamHttpUnstableAccessGrants { - const constructorOptions = { ...options, personalAccessToken, workspaceId } - if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing personalAccessToken or workspaceId', - ) - } - return new SeamHttpUnstableAccessGrants(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() - } - - create( - parameters?: UnstableAccessGrantsCreateParameters, - options: UnstableAccessGrantsCreateOptions = {}, - ): UnstableAccessGrantsCreateRequest { - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return new SeamHttpRequest(this, { - pathname: '/unstable_access_grants/create', - method: 'POST', - body: parameters, - responseKey: 'access_grant', - options, - }) - } - - delete( - parameters?: UnstableAccessGrantsDeleteParameters, - options: UnstableAccessGrantsDeleteOptions = {}, - ): UnstableAccessGrantsDeleteRequest { - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return new SeamHttpRequest(this, { - pathname: '/unstable_access_grants/delete', - method: 'POST', - body: parameters, - responseKey: undefined, - options, - }) - } - - get( - parameters?: UnstableAccessGrantsGetParameters, - options: UnstableAccessGrantsGetOptions = {}, - ): UnstableAccessGrantsGetRequest { - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return new SeamHttpRequest(this, { - pathname: '/unstable_access_grants/get', - method: 'POST', - body: parameters, - responseKey: 'access_grant', - options, - }) - } - - list( - parameters?: UnstableAccessGrantsListParameters, - options: UnstableAccessGrantsListOptions = {}, - ): UnstableAccessGrantsListRequest { - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return new SeamHttpRequest(this, { - pathname: '/unstable_access_grants/list', - method: 'POST', - body: parameters, - responseKey: 'access_grants', - options, - }) - } -} - -export type UnstableAccessGrantsCreateParameters = - RouteRequestBody<'/unstable_access_grants/create'> - -/** - * @deprecated Use UnstableAccessGrantsCreateParameters instead. - */ -export type UnstableAccessGrantsCreateBody = - UnstableAccessGrantsCreateParameters - -/** - * @deprecated Use UnstableAccessGrantsCreateRequest instead. - */ -export type UnstableAccessGrantsCreateResponse = SetNonNullable< - Required> -> - -export type UnstableAccessGrantsCreateRequest = SeamHttpRequest< - UnstableAccessGrantsCreateResponse, - 'access_grant' -> - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface UnstableAccessGrantsCreateOptions {} - -export type UnstableAccessGrantsDeleteParameters = - RouteRequestBody<'/unstable_access_grants/delete'> - -/** - * @deprecated Use UnstableAccessGrantsDeleteParameters instead. - */ -export type UnstableAccessGrantsDeleteParams = - UnstableAccessGrantsDeleteParameters - -/** - * @deprecated Use UnstableAccessGrantsDeleteRequest instead. - */ -export type UnstableAccessGrantsDeleteResponse = SetNonNullable< - Required> -> - -export type UnstableAccessGrantsDeleteRequest = SeamHttpRequest - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface UnstableAccessGrantsDeleteOptions {} - -export type UnstableAccessGrantsGetParameters = - RouteRequestBody<'/unstable_access_grants/get'> - -/** - * @deprecated Use UnstableAccessGrantsGetParameters instead. - */ -export type UnstableAccessGrantsGetParams = UnstableAccessGrantsGetParameters - -/** - * @deprecated Use UnstableAccessGrantsGetRequest instead. - */ -export type UnstableAccessGrantsGetResponse = SetNonNullable< - Required> -> - -export type UnstableAccessGrantsGetRequest = SeamHttpRequest< - UnstableAccessGrantsGetResponse, - 'access_grant' -> - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface UnstableAccessGrantsGetOptions {} - -export type UnstableAccessGrantsListParameters = - RouteRequestBody<'/unstable_access_grants/list'> - -/** - * @deprecated Use UnstableAccessGrantsListParameters instead. - */ -export type UnstableAccessGrantsListParams = UnstableAccessGrantsListParameters - -/** - * @deprecated Use UnstableAccessGrantsListRequest instead. - */ -export type UnstableAccessGrantsListResponse = SetNonNullable< - Required> -> - -export type UnstableAccessGrantsListRequest = SeamHttpRequest< - UnstableAccessGrantsListResponse, - 'access_grants' -> - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface UnstableAccessGrantsListOptions {} diff --git a/src/lib/seam/connect/routes/unstable-access-methods/index.ts b/src/lib/seam/connect/routes/unstable-access-methods/index.ts deleted file mode 100644 index 39bdb594..00000000 --- a/src/lib/seam/connect/routes/unstable-access-methods/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* - * Automatically generated by codegen/smith.ts. - * Do not edit this file or add other files to this directory. - */ - -export * from './unstable-access-methods.js' diff --git a/src/lib/seam/connect/routes/unstable-access-methods/unstable-access-methods.ts b/src/lib/seam/connect/routes/unstable-access-methods/unstable-access-methods.ts deleted file mode 100644 index 41da6b3f..00000000 --- a/src/lib/seam/connect/routes/unstable-access-methods/unstable-access-methods.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* - * 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 SeamHttpUnstableAccessMethods { - 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 = {}, - ): SeamHttpUnstableAccessMethods { - const constructorOptions = { ...options, client } - if (!isSeamHttpOptionsWithClient(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing client') - } - return new SeamHttpUnstableAccessMethods(constructorOptions) - } - - static fromApiKey( - apiKey: SeamHttpOptionsWithApiKey['apiKey'], - options: Omit = {}, - ): SeamHttpUnstableAccessMethods { - const constructorOptions = { ...options, apiKey } - if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing apiKey') - } - return new SeamHttpUnstableAccessMethods(constructorOptions) - } - - static fromClientSessionToken( - clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], - options: Omit< - SeamHttpOptionsWithClientSessionToken, - 'clientSessionToken' - > = {}, - ): SeamHttpUnstableAccessMethods { - const constructorOptions = { ...options, clientSessionToken } - if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') - } - return new SeamHttpUnstableAccessMethods(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 SeamHttpUnstableAccessMethods.fromPublishableKey', - ) - } - const client = createClient(clientOptions) - const clientSessions = SeamHttpClientSessions.fromClient(client) - const { token } = await clientSessions.getOrCreate({ - user_identifier_key: userIdentifierKey, - }) - return SeamHttpUnstableAccessMethods.fromClientSessionToken(token, options) - } - - static fromConsoleSessionToken( - consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], - workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithConsoleSessionToken, - 'consoleSessionToken' | 'workspaceId' - > = {}, - ): SeamHttpUnstableAccessMethods { - const constructorOptions = { ...options, consoleSessionToken, workspaceId } - if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing consoleSessionToken or workspaceId', - ) - } - return new SeamHttpUnstableAccessMethods(constructorOptions) - } - - static fromPersonalAccessToken( - personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], - workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], - options: Omit< - SeamHttpOptionsWithPersonalAccessToken, - 'personalAccessToken' | 'workspaceId' - > = {}, - ): SeamHttpUnstableAccessMethods { - const constructorOptions = { ...options, personalAccessToken, workspaceId } - if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { - throw new SeamHttpInvalidOptionsError( - 'Missing personalAccessToken or workspaceId', - ) - } - return new SeamHttpUnstableAccessMethods(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() - } - - delete( - parameters?: UnstableAccessMethodsDeleteParameters, - options: UnstableAccessMethodsDeleteOptions = {}, - ): UnstableAccessMethodsDeleteRequest { - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return new SeamHttpRequest(this, { - pathname: '/unstable_access_methods/delete', - method: 'POST', - body: parameters, - responseKey: undefined, - options, - }) - } - - get( - parameters?: UnstableAccessMethodsGetParameters, - options: UnstableAccessMethodsGetOptions = {}, - ): UnstableAccessMethodsGetRequest { - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return new SeamHttpRequest(this, { - pathname: '/unstable_access_methods/get', - method: 'POST', - body: parameters, - responseKey: 'access_method', - options, - }) - } - - list( - parameters?: UnstableAccessMethodsListParameters, - options: UnstableAccessMethodsListOptions = {}, - ): UnstableAccessMethodsListRequest { - if (!this.defaults.isUndocumentedApiEnabled) { - throw new Error( - 'Cannot use undocumented API without isUndocumentedApiEnabled', - ) - } - return new SeamHttpRequest(this, { - pathname: '/unstable_access_methods/list', - method: 'POST', - body: parameters, - responseKey: 'access_methods', - options, - }) - } -} - -export type UnstableAccessMethodsDeleteParameters = - RouteRequestBody<'/unstable_access_methods/delete'> - -/** - * @deprecated Use UnstableAccessMethodsDeleteParameters instead. - */ -export type UnstableAccessMethodsDeleteParams = - UnstableAccessMethodsDeleteParameters - -/** - * @deprecated Use UnstableAccessMethodsDeleteRequest instead. - */ -export type UnstableAccessMethodsDeleteResponse = SetNonNullable< - Required> -> - -export type UnstableAccessMethodsDeleteRequest = SeamHttpRequest< - void, - undefined -> - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface UnstableAccessMethodsDeleteOptions {} - -export type UnstableAccessMethodsGetParameters = - RouteRequestBody<'/unstable_access_methods/get'> - -/** - * @deprecated Use UnstableAccessMethodsGetParameters instead. - */ -export type UnstableAccessMethodsGetParams = UnstableAccessMethodsGetParameters - -/** - * @deprecated Use UnstableAccessMethodsGetRequest instead. - */ -export type UnstableAccessMethodsGetResponse = SetNonNullable< - Required> -> - -export type UnstableAccessMethodsGetRequest = SeamHttpRequest< - UnstableAccessMethodsGetResponse, - 'access_method' -> - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface UnstableAccessMethodsGetOptions {} - -export type UnstableAccessMethodsListParameters = - RouteRequestBody<'/unstable_access_methods/list'> - -/** - * @deprecated Use UnstableAccessMethodsListParameters instead. - */ -export type UnstableAccessMethodsListParams = - UnstableAccessMethodsListParameters - -/** - * @deprecated Use UnstableAccessMethodsListRequest instead. - */ -export type UnstableAccessMethodsListResponse = SetNonNullable< - Required> -> - -export type UnstableAccessMethodsListRequest = SeamHttpRequest< - UnstableAccessMethodsListResponse, - 'access_methods' -> - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface UnstableAccessMethodsListOptions {}