From 90af83374765a08f481e60956f882d89c2b8c369 Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Tue, 24 Jun 2025 14:35:43 -0700 Subject: [PATCH 1/7] Generate undocumented endpoints --- codegen/lib/connect.ts | 11 +++-------- codegen/lib/layouts/endpoints.ts | 6 +++--- codegen/lib/layouts/route.ts | 5 +---- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/codegen/lib/connect.ts b/codegen/lib/connect.ts index 9f7ea484..db319edc 100644 --- a/codegen/lib/connect.ts +++ b/codegen/lib/connect.ts @@ -28,14 +28,9 @@ export const connect = ( metalsmith: Metalsmith, ): void => { const metadata = metalsmith.metadata() as Metadata - const { blueprint } = metadata - - const namespaces = blueprint.namespaces.filter( - ({ isUndocumented }) => !isUndocumented, - ) - const routes = blueprint.routes.filter( - ({ isUndocumented }) => !isUndocumented, - ) + const { + blueprint: { namespaces, routes }, + } = metadata const nodes = [...namespaces, ...routes] diff --git a/codegen/lib/layouts/endpoints.ts b/codegen/lib/layouts/endpoints.ts index 549b4c76..0fc2b3fb 100644 --- a/codegen/lib/layouts/endpoints.ts +++ b/codegen/lib/layouts/endpoints.ts @@ -22,9 +22,9 @@ export const setEndpointsLayoutContext = ( file.className = getClassName('Endpoints') file.skipClientSessionImport = true file.endpoints = routes.flatMap((route) => - route.endpoints - .filter(({ isUndocumented }) => !isUndocumented) - .map((endpoint) => getEndpointLayoutContext(endpoint, route)), + route.endpoints.map((endpoint) => + getEndpointLayoutContext(endpoint, route), + ), ) file.routeImports = routes.map((route) => { return { diff --git a/codegen/lib/layouts/route.ts b/codegen/lib/layouts/route.ts index 17ad3645..d875c897 100644 --- a/codegen/lib/layouts/route.ts +++ b/codegen/lib/layouts/route.ts @@ -49,10 +49,7 @@ export const setRouteLayoutContext = ( file.endpoints = [] if (node != null && 'endpoints' in node) { - const endpoints = node.endpoints.filter( - ({ isUndocumented }) => !isUndocumented, - ) - file.endpoints = endpoints.map((endpoint) => + file.endpoints = node.endpoints.map((endpoint) => getEndpointLayoutContext(endpoint, node), ) } From fa66d223de7a2c1a10a91bc034c47e5ac1af008e Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Tue, 24 Jun 2025 14:36:48 -0700 Subject: [PATCH 2/7] Add isUndocumented to context --- codegen/lib/layouts/route.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/codegen/lib/layouts/route.ts b/codegen/lib/layouts/route.ts index d875c897..b00c1867 100644 --- a/codegen/lib/layouts/route.ts +++ b/codegen/lib/layouts/route.ts @@ -30,12 +30,14 @@ export interface EndpointLayoutContext { returnsActionAttempt: boolean returnsVoid: boolean isOptionalParamsOk: boolean + isUndocumented: boolean } export interface SubrouteLayoutContext { methodName: string className: string fileName: string + isUndocumented: boolean } export const setRouteLayoutContext = ( @@ -61,12 +63,13 @@ export const setRouteLayoutContext = ( } const getSubrouteLayoutContext = ( - route: Pick, + route: Pick, ): SubrouteLayoutContext => { return { fileName: `${kebabCase(route.name)}/index.js`, methodName: camelCase(route.name), className: getClassName(route.path), + isUndocumented: route.isUndocumented, } } @@ -113,6 +116,7 @@ export const getEndpointLayoutContext = ( // UPSTREAM: Needs support in blueprint, fallback to true for now. // https://github.com/seamapi/blueprint/issues/205 isOptionalParamsOk: true, + isUndocumented: endpoint.isUndocumented, ...getResponseContext(endpoint), } } From 74bf4f4377bc30021b3943c87732179368177ba9 Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Tue, 24 Jun 2025 14:54:35 -0700 Subject: [PATCH 3/7] Add isUndocumentedApiEnabled option --- README.md | 13 +++++++++++++ codegen/layouts/endpoints.hbs | 5 +++++ codegen/layouts/partials/route-class-endpoint.hbs | 5 +++++ codegen/layouts/partials/route-class-methods.hbs | 5 +++++ src/lib/seam/connect/options.ts | 3 ++- src/lib/seam/connect/parse-options.ts | 2 ++ 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e1dd23f..715e0dd4 100644 --- a/README.md +++ b/README.md @@ -524,6 +524,19 @@ const seam = new SeamHttpEndpoints() const devices = await seam['/devices/list']() ``` +#### Enable undocumented API + +Pass the `isUndocumentedApiEnabled` option to allow using the undocumented API. +This API is used internally and is not directly supported. +Do not use the undocumented API in production environments. +Seam is not responsible for any issues you may encounter with the undocumented API. + +```ts +import { SeamHttp } from '@seamapi/http/connect' + +const seam = new SeamHttp({ isUndocumentedApiEnabled: true }) +``` + #### Inspecting the Request All client methods return an instance of `SeamHttpRequest`. diff --git a/codegen/layouts/endpoints.hbs b/codegen/layouts/endpoints.hbs index 7166fcdf..0e588c5e 100644 --- a/codegen/layouts/endpoints.hbs +++ b/codegen/layouts/endpoints.hbs @@ -21,6 +21,11 @@ export class SeamHttpEndpoints { get['{{path}}'](): {{className}}['{{methodName}}'] { const { client, defaults } = this + {{#if isUndocumented}} + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error('Cannot use undocumented API without isUndocumentedApiEnabled') + } + {{/if}} return function {{functionName}} (...args: Parameters<{{className}}['{{methodName}}']>): ReturnType<{{className}}['{{methodName}}']> { const seam = {{className}}.fromClient(client, defaults) diff --git a/codegen/layouts/partials/route-class-endpoint.hbs b/codegen/layouts/partials/route-class-endpoint.hbs index 37dd3508..cef70f9b 100644 --- a/codegen/layouts/partials/route-class-endpoint.hbs +++ b/codegen/layouts/partials/route-class-endpoint.hbs @@ -3,6 +3,11 @@ {{#if hasOptions}}options: {{optionsTypeName}} = {},{{/if}} ): SeamHttpRequest<{{#if returnsVoid}}void, undefined{{else}}{{responseTypeName}}, '{{responseKey}}'{{/if}}> { + {{#if isUndocumented}} + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error('Cannot use undocumented API without isUndocumentedApiEnabled') + } + {{/if}} return new SeamHttpRequest(this, { pathname: '{{path}}', method: '{{method}}', diff --git a/codegen/layouts/partials/route-class-methods.hbs b/codegen/layouts/partials/route-class-methods.hbs index f67a9208..9026a531 100644 --- a/codegen/layouts/partials/route-class-methods.hbs +++ b/codegen/layouts/partials/route-class-methods.hbs @@ -17,6 +17,11 @@ static fromClient( if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } + {{#if isUndocumented}} + if (!options.isUndocumentedApiEnabled) { + throw new Error('Cannot use undocumented API without isUndocumentedApiEnabled') + } + {{/if}} return new {{className}}(constructorOptions) } diff --git a/src/lib/seam/connect/options.ts b/src/lib/seam/connect/options.ts index 0b1308ac..e12d2356 100644 --- a/src/lib/seam/connect/options.ts +++ b/src/lib/seam/connect/options.ts @@ -22,6 +22,7 @@ interface SeamHttpCommonOptions extends ClientOptions, SeamHttpRequestOptions { export interface SeamHttpRequestOptions { waitForActionAttempt?: boolean | ResolveActionAttemptOptions + isUndocumentedApiEnabled?: boolean } export interface SeamHttpFromPublishableKeyOptions @@ -33,7 +34,7 @@ export interface SeamHttpMultiWorkspaceOptionsFromEnv extends SeamHttpCommonOptions {} export interface SeamHttpMultiWorkspaceOptionsWithClient - extends SeamHttpRequestOptions { + extends SeamHttpCommonOptions { client: Client } diff --git a/src/lib/seam/connect/parse-options.ts b/src/lib/seam/connect/parse-options.ts index 478f0efe..9b6e8146 100644 --- a/src/lib/seam/connect/parse-options.ts +++ b/src/lib/seam/connect/parse-options.ts @@ -64,6 +64,7 @@ const getNormalizedOptions = ( : apiKeyOrOptions const requestOptions = { + isUndocumentedApiEnabled: options.isUndocumentedApiEnabled ?? false, waitForActionAttempt: options.waitForActionAttempt ?? true, } @@ -181,6 +182,7 @@ export const isSeamHttpRequestOption = ( key: string, ): key is keyof SeamHttpRequestOptions => { const keys: Record = { + isUndocumentedApiEnabled: true, waitForActionAttempt: true, } return Object.keys(keys).includes(key) From d7a7cc089feb3ceda22d529bb92666a1e36fd07f Mon Sep 17 00:00:00 2001 From: Seam Bot Date: Tue, 24 Jun 2025 22:18:56 +0000 Subject: [PATCH 4/7] ci: Generate code --- .../routes/acs/access-groups/access-groups.ts | 9 + .../connect/routes/acs/access-groups/index.ts | 1 + .../acs/access-groups/unmanaged/index.ts | 6 + .../acs/access-groups/unmanaged/unmanaged.ts | 221 +++++ src/lib/seam/connect/routes/acs/acs.ts | 13 + .../acs/credential-pools/credential-pools.ts | 190 ++++ .../routes/acs/credential-pools/index.ts | 6 + .../credential-provisioning-automations.ts | 196 +++++ .../index.ts | 6 + .../routes/acs/credentials/credentials.ts | 37 + .../connect/routes/acs/credentials/index.ts | 1 + .../routes/acs/credentials/unmanaged/index.ts | 6 + .../acs/credentials/unmanaged/unmanaged.ts | 222 +++++ src/lib/seam/connect/routes/acs/index.ts | 2 + .../seam/connect/routes/acs/users/index.ts | 1 + .../routes/acs/users/unmanaged/index.ts | 6 + .../routes/acs/users/unmanaged/unmanaged.ts | 215 +++++ .../seam/connect/routes/acs/users/users.ts | 6 + .../seam/connect/routes/bridges/bridges.ts | 213 +++++ src/lib/seam/connect/routes/bridges/index.ts | 6 + .../seam/connect/routes/devices/devices.ts | 22 + src/lib/seam/connect/routes/index.ts | 7 + src/lib/seam/connect/routes/locks/index.ts | 1 + src/lib/seam/connect/routes/locks/locks.ts | 6 + .../connect/routes/locks/simulate/index.ts | 6 + .../connect/routes/locks/simulate/simulate.ts | 228 +++++ src/lib/seam/connect/routes/networks/index.ts | 6 + .../seam/connect/routes/networks/networks.ts | 213 +++++ .../connect/routes/seam-http-endpoints.ts | 822 ++++++++++++++++++ src/lib/seam/connect/routes/seam-http.ts | 30 + .../seam/connect/routes/seam/bridge/index.ts | 6 + .../bridge-client-sessions.ts | 320 +++++++ .../bridge/v1/bridge-client-sessions/index.ts | 6 + .../bridge-connected-systems.ts | 196 +++++ .../v1/bridge-connected-systems/index.ts | 6 + .../connect/routes/seam/bridge/v1/index.ts | 8 + .../seam/connect/routes/seam/bridge/v1/v1.ts | 179 ++++ src/lib/seam/connect/routes/seam/index.ts | 9 + .../connect/routes/seam/instant-key/index.ts | 6 + .../v1/client-sessions/client-sessions.ts | 199 +++++ .../instant-key/v1/client-sessions/index.ts | 6 + .../routes/seam/instant-key/v1/index.ts | 7 + .../connect/routes/seam/instant-key/v1/v1.ts | 171 ++++ .../connect/routes/seam/mobile-sdk/index.ts | 6 + .../routes/seam/mobile-sdk/v1/acs/acs.ts | 171 ++++ .../v1/acs/credentials/credentials.ts | 196 +++++ .../mobile-sdk/v1/acs/credentials/index.ts | 6 + .../routes/seam/mobile-sdk/v1/acs/index.ts | 7 + .../routes/seam/mobile-sdk/v1/index.ts | 8 + .../mobile-sdk/v1/phone-sessions/index.ts | 6 + .../v1/phone-sessions/phone-sessions.ts | 196 +++++ .../connect/routes/seam/mobile-sdk/v1/v1.ts | 176 ++++ .../seam/connect/routes/seam/partner/index.ts | 6 + .../v1/building-blocks/building-blocks.ts | 174 ++++ .../seam/partner/v1/building-blocks/index.ts | 7 + .../v1/building-blocks/spaces/index.ts | 6 + .../v1/building-blocks/spaces/spaces.ts | 196 +++++ .../connect/routes/seam/partner/v1/index.ts | 8 + .../routes/seam/partner/v1/resources/index.ts | 6 + .../seam/partner/v1/resources/resources.ts | 190 ++++ .../seam/connect/routes/seam/partner/v1/v1.ts | 176 ++++ .../connect/routes/thermostats/thermostats.ts | 24 + .../routes/unstable-access-grants/index.ts | 6 + .../unstable-access-grants.ts | 265 ++++++ .../routes/unstable-access-methods/index.ts | 6 + .../unstable-access-methods.ts | 240 +++++ .../routes/unstable-locations/index.ts | 6 + .../unstable-locations/unstable-locations.ts | 394 +++++++++ .../building-blocks/building-blocks.ts | 287 ++++++ .../unstable-partner/building-blocks/index.ts | 6 + .../connect/routes/unstable-partner/index.ts | 8 + .../unstable-partner/resources/index.ts | 6 + .../unstable-partner/resources/resources.ts | 193 ++++ .../unstable-partner/unstable-partner.ts | 179 ++++ 74 files changed, 6984 insertions(+) create mode 100644 src/lib/seam/connect/routes/acs/access-groups/unmanaged/index.ts create mode 100644 src/lib/seam/connect/routes/acs/access-groups/unmanaged/unmanaged.ts create mode 100644 src/lib/seam/connect/routes/acs/credential-pools/credential-pools.ts create mode 100644 src/lib/seam/connect/routes/acs/credential-pools/index.ts create mode 100644 src/lib/seam/connect/routes/acs/credential-provisioning-automations/credential-provisioning-automations.ts create mode 100644 src/lib/seam/connect/routes/acs/credential-provisioning-automations/index.ts create mode 100644 src/lib/seam/connect/routes/acs/credentials/unmanaged/index.ts create mode 100644 src/lib/seam/connect/routes/acs/credentials/unmanaged/unmanaged.ts create mode 100644 src/lib/seam/connect/routes/acs/users/unmanaged/index.ts create mode 100644 src/lib/seam/connect/routes/acs/users/unmanaged/unmanaged.ts create mode 100644 src/lib/seam/connect/routes/bridges/bridges.ts create mode 100644 src/lib/seam/connect/routes/bridges/index.ts create mode 100644 src/lib/seam/connect/routes/locks/simulate/index.ts create mode 100644 src/lib/seam/connect/routes/locks/simulate/simulate.ts create mode 100644 src/lib/seam/connect/routes/networks/index.ts create mode 100644 src/lib/seam/connect/routes/networks/networks.ts create mode 100644 src/lib/seam/connect/routes/seam/bridge/index.ts create mode 100644 src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.ts create mode 100644 src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.ts create mode 100644 src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.ts create mode 100644 src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.ts create mode 100644 src/lib/seam/connect/routes/seam/bridge/v1/index.ts create mode 100644 src/lib/seam/connect/routes/seam/bridge/v1/v1.ts create mode 100644 src/lib/seam/connect/routes/seam/index.ts create mode 100644 src/lib/seam/connect/routes/seam/instant-key/index.ts create mode 100644 src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.ts create mode 100644 src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.ts create mode 100644 src/lib/seam/connect/routes/seam/instant-key/v1/index.ts create mode 100644 src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts create mode 100644 src/lib/seam/connect/routes/seam/mobile-sdk/index.ts create mode 100644 src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts create mode 100644 src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts create mode 100644 src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.ts create mode 100644 src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.ts create mode 100644 src/lib/seam/connect/routes/seam/mobile-sdk/v1/index.ts create mode 100644 src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.ts create mode 100644 src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts create mode 100644 src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts create mode 100644 src/lib/seam/connect/routes/seam/partner/index.ts create mode 100644 src/lib/seam/connect/routes/seam/partner/v1/building-blocks/building-blocks.ts create mode 100644 src/lib/seam/connect/routes/seam/partner/v1/building-blocks/index.ts create mode 100644 src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/index.ts create mode 100644 src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/spaces.ts create mode 100644 src/lib/seam/connect/routes/seam/partner/v1/index.ts create mode 100644 src/lib/seam/connect/routes/seam/partner/v1/resources/index.ts create mode 100644 src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts create mode 100644 src/lib/seam/connect/routes/seam/partner/v1/v1.ts create mode 100644 src/lib/seam/connect/routes/unstable-access-grants/index.ts create mode 100644 src/lib/seam/connect/routes/unstable-access-grants/unstable-access-grants.ts create mode 100644 src/lib/seam/connect/routes/unstable-access-methods/index.ts create mode 100644 src/lib/seam/connect/routes/unstable-access-methods/unstable-access-methods.ts create mode 100644 src/lib/seam/connect/routes/unstable-locations/index.ts create mode 100644 src/lib/seam/connect/routes/unstable-locations/unstable-locations.ts create mode 100644 src/lib/seam/connect/routes/unstable-partner/building-blocks/building-blocks.ts create mode 100644 src/lib/seam/connect/routes/unstable-partner/building-blocks/index.ts create mode 100644 src/lib/seam/connect/routes/unstable-partner/index.ts create mode 100644 src/lib/seam/connect/routes/unstable-partner/resources/index.ts create mode 100644 src/lib/seam/connect/routes/unstable-partner/resources/resources.ts create mode 100644 src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts diff --git a/src/lib/seam/connect/routes/acs/access-groups/access-groups.ts b/src/lib/seam/connect/routes/acs/access-groups/access-groups.ts index b4404154..f4f3cde2 100644 --- a/src/lib/seam/connect/routes/acs/access-groups/access-groups.ts +++ b/src/lib/seam/connect/routes/acs/access-groups/access-groups.ts @@ -36,6 +36,8 @@ 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 './unmanaged/index.js' + export class SeamHttpAcsAccessGroups { client: Client readonly defaults: Required @@ -163,6 +165,13 @@ 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/access-groups/index.ts b/src/lib/seam/connect/routes/acs/access-groups/index.ts index bed34230..102271a5 100644 --- a/src/lib/seam/connect/routes/acs/access-groups/index.ts +++ b/src/lib/seam/connect/routes/acs/access-groups/index.ts @@ -4,3 +4,4 @@ */ export * from './access-groups.js' +export * from './unmanaged/index.js' diff --git a/src/lib/seam/connect/routes/acs/access-groups/unmanaged/index.ts b/src/lib/seam/connect/routes/acs/access-groups/unmanaged/index.ts new file mode 100644 index 00000000..bab8a37e --- /dev/null +++ b/src/lib/seam/connect/routes/acs/access-groups/unmanaged/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 './unmanaged.js' diff --git a/src/lib/seam/connect/routes/acs/access-groups/unmanaged/unmanaged.ts b/src/lib/seam/connect/routes/acs/access-groups/unmanaged/unmanaged.ts new file mode 100644 index 00000000..4ca621d1 --- /dev/null +++ b/src/lib/seam/connect/routes/acs/access-groups/unmanaged/unmanaged.ts @@ -0,0 +1,221 @@ +/* + * 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 SeamHttpAcsAccessGroupsUnmanaged { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 SeamHttpAcsAccessGroupsUnmanaged.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( + params?: AcsAccessGroupsUnmanagedGetParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/acs/access_groups/unmanaged/get', + method: 'POST', + body: params, + responseKey: 'acs_access_group', + }) + } + + list( + params?: AcsAccessGroupsUnmanagedListParams, + ): SeamHttpRequest< + AcsAccessGroupsUnmanagedListResponse, + 'acs_access_groups' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/acs/access_groups/unmanaged/list', + method: 'POST', + body: params, + 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/acs.ts b/src/lib/seam/connect/routes/acs/acs.ts index 51413396..3b244e41 100644 --- a/src/lib/seam/connect/routes/acs/acs.ts +++ b/src/lib/seam/connect/routes/acs/acs.ts @@ -34,6 +34,8 @@ import type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' import { SeamHttpAcsAccessGroups } from './access-groups/index.js' +import { SeamHttpAcsCredentialPools } from './credential-pools/index.js' +import { SeamHttpAcsCredentialProvisioningAutomations } from './credential-provisioning-automations/index.js' import { SeamHttpAcsCredentials } from './credentials/index.js' import { SeamHttpAcsEncoders } from './encoders/index.js' import { SeamHttpAcsEntrances } from './entrances/index.js' @@ -171,6 +173,17 @@ 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/acs/credential-pools/credential-pools.ts b/src/lib/seam/connect/routes/acs/credential-pools/credential-pools.ts new file mode 100644 index 00000000..b8ad5270 --- /dev/null +++ b/src/lib/seam/connect/routes/acs/credential-pools/credential-pools.ts @@ -0,0 +1,190 @@ +/* + * 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 SeamHttpAcsCredentialPools { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 SeamHttpAcsCredentialPools.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( + params?: AcsCredentialPoolsListParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/acs/credential_pools/list', + method: 'POST', + body: params, + 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-pools/index.ts b/src/lib/seam/connect/routes/acs/credential-pools/index.ts new file mode 100644 index 00000000..359efb81 --- /dev/null +++ b/src/lib/seam/connect/routes/acs/credential-pools/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 './credential-pools.js' diff --git a/src/lib/seam/connect/routes/acs/credential-provisioning-automations/credential-provisioning-automations.ts b/src/lib/seam/connect/routes/acs/credential-provisioning-automations/credential-provisioning-automations.ts new file mode 100644 index 00000000..95715a0c --- /dev/null +++ b/src/lib/seam/connect/routes/acs/credential-provisioning-automations/credential-provisioning-automations.ts @@ -0,0 +1,196 @@ +/* + * 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 SeamHttpAcsCredentialProvisioningAutomations { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 SeamHttpAcsCredentialProvisioningAutomations.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' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + 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/credential-provisioning-automations/index.ts b/src/lib/seam/connect/routes/acs/credential-provisioning-automations/index.ts new file mode 100644 index 00000000..9f5a3c67 --- /dev/null +++ b/src/lib/seam/connect/routes/acs/credential-provisioning-automations/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 './credential-provisioning-automations.js' diff --git a/src/lib/seam/connect/routes/acs/credentials/credentials.ts b/src/lib/seam/connect/routes/acs/credentials/credentials.ts index 02cc8e5c..ac0c1388 100644 --- a/src/lib/seam/connect/routes/acs/credentials/credentials.ts +++ b/src/lib/seam/connect/routes/acs/credentials/credentials.ts @@ -40,6 +40,8 @@ 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 './unmanaged/index.js' + export class SeamHttpAcsCredentials { client: Client readonly defaults: Required @@ -167,6 +169,13 @@ 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', @@ -187,6 +196,25 @@ export class SeamHttpAcsCredentials { }) } + createOfflineCode( + body?: AcsCredentialsCreateOfflineCodeBody, + ): SeamHttpRequest< + AcsCredentialsCreateOfflineCodeResponse, + 'acs_credential' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/acs/credentials/create_offline_code', + method: 'POST', + body, + responseKey: 'acs_credential', + }) + } + delete( params?: AcsCredentialsDeleteParams, ): SeamHttpRequest { @@ -273,6 +301,15 @@ 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/credentials/index.ts b/src/lib/seam/connect/routes/acs/credentials/index.ts index 2d9bacd3..62dedd6f 100644 --- a/src/lib/seam/connect/routes/acs/credentials/index.ts +++ b/src/lib/seam/connect/routes/acs/credentials/index.ts @@ -4,3 +4,4 @@ */ export * from './credentials.js' +export * from './unmanaged/index.js' diff --git a/src/lib/seam/connect/routes/acs/credentials/unmanaged/index.ts b/src/lib/seam/connect/routes/acs/credentials/unmanaged/index.ts new file mode 100644 index 00000000..bab8a37e --- /dev/null +++ b/src/lib/seam/connect/routes/acs/credentials/unmanaged/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 './unmanaged.js' diff --git a/src/lib/seam/connect/routes/acs/credentials/unmanaged/unmanaged.ts b/src/lib/seam/connect/routes/acs/credentials/unmanaged/unmanaged.ts new file mode 100644 index 00000000..3b9c94f9 --- /dev/null +++ b/src/lib/seam/connect/routes/acs/credentials/unmanaged/unmanaged.ts @@ -0,0 +1,222 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +import type { + RouteRequestBody, + RouteRequestParams, + 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 SeamHttpAcsCredentialsUnmanaged { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 SeamHttpAcsCredentialsUnmanaged.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( + params?: AcsCredentialsUnmanagedGetParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/acs/credentials/unmanaged/get', + method: 'POST', + body: params, + responseKey: 'acs_credential', + }) + } + + list( + params?: AcsCredentialsUnmanagedListParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/acs/credentials/unmanaged/list', + method: 'GET', + params, + responseKey: 'acs_credentials', + }) + } +} + +export type AcsCredentialsUnmanagedGetParams = + RouteRequestBody<'/acs/credentials/unmanaged/get'> + +export type AcsCredentialsUnmanagedGetResponse = SetNonNullable< + Required> +> + +export type AcsCredentialsUnmanagedGetOptions = never + +export type AcsCredentialsUnmanagedListParams = + RouteRequestParams<'/acs/credentials/unmanaged/list'> + +export type AcsCredentialsUnmanagedListResponse = SetNonNullable< + Required> +> + +export type AcsCredentialsUnmanagedListOptions = never diff --git a/src/lib/seam/connect/routes/acs/index.ts b/src/lib/seam/connect/routes/acs/index.ts index 26399aa6..b8b8f5bf 100644 --- a/src/lib/seam/connect/routes/acs/index.ts +++ b/src/lib/seam/connect/routes/acs/index.ts @@ -5,6 +5,8 @@ export * from './access-groups/index.js' export * from './acs.js' +export * from './credential-pools/index.js' +export * from './credential-provisioning-automations/index.js' export * from './credentials/index.js' export * from './encoders/index.js' export * from './entrances/index.js' diff --git a/src/lib/seam/connect/routes/acs/users/index.ts b/src/lib/seam/connect/routes/acs/users/index.ts index 7c31b60d..747b84d5 100644 --- a/src/lib/seam/connect/routes/acs/users/index.ts +++ b/src/lib/seam/connect/routes/acs/users/index.ts @@ -3,4 +3,5 @@ * Do not edit this file or add other files to this directory. */ +export * from './unmanaged/index.js' export * from './users.js' diff --git a/src/lib/seam/connect/routes/acs/users/unmanaged/index.ts b/src/lib/seam/connect/routes/acs/users/unmanaged/index.ts new file mode 100644 index 00000000..bab8a37e --- /dev/null +++ b/src/lib/seam/connect/routes/acs/users/unmanaged/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 './unmanaged.js' diff --git a/src/lib/seam/connect/routes/acs/users/unmanaged/unmanaged.ts b/src/lib/seam/connect/routes/acs/users/unmanaged/unmanaged.ts new file mode 100644 index 00000000..18730a1b --- /dev/null +++ b/src/lib/seam/connect/routes/acs/users/unmanaged/unmanaged.ts @@ -0,0 +1,215 @@ +/* + * 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 SeamHttpAcsUsersUnmanaged { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 SeamHttpAcsUsersUnmanaged.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( + params?: AcsUsersUnmanagedGetParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/acs/users/unmanaged/get', + method: 'POST', + body: params, + responseKey: 'acs_user', + }) + } + + list( + params?: AcsUsersUnmanagedListParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/acs/users/unmanaged/list', + method: 'POST', + body: params, + 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/users.ts b/src/lib/seam/connect/routes/acs/users/users.ts index a8cf7d9c..d0549ff3 100644 --- a/src/lib/seam/connect/routes/acs/users/users.ts +++ b/src/lib/seam/connect/routes/acs/users/users.ts @@ -36,6 +36,8 @@ 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 './unmanaged/index.js' + export class SeamHttpAcsUsers { client: Client readonly defaults: Required @@ -163,6 +165,10 @@ 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/bridges/bridges.ts b/src/lib/seam/connect/routes/bridges/bridges.ts new file mode 100644 index 00000000..3f4c786f --- /dev/null +++ b/src/lib/seam/connect/routes/bridges/bridges.ts @@ -0,0 +1,213 @@ +/* + * 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 SeamHttpBridges { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpBridges { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpBridges(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpBridges { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpBridges(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpBridges { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpBridges(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 SeamHttpBridges.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpBridges.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpBridges { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpBridges(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpBridges { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpBridges(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( + params?: BridgesGetParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/bridges/get', + method: 'POST', + body: params, + responseKey: 'bridge', + }) + } + + list( + params?: BridgesListParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/bridges/list', + method: 'POST', + body: params, + responseKey: 'bridges', + }) + } +} + +export type BridgesGetParams = RouteRequestBody<'/bridges/get'> + +export type BridgesGetResponse = SetNonNullable< + Required> +> + +export type BridgesGetOptions = never + +export type BridgesListParams = RouteRequestBody<'/bridges/list'> + +export type BridgesListResponse = SetNonNullable< + Required> +> + +export type BridgesListOptions = never diff --git a/src/lib/seam/connect/routes/bridges/index.ts b/src/lib/seam/connect/routes/bridges/index.ts new file mode 100644 index 00000000..17b80312 --- /dev/null +++ b/src/lib/seam/connect/routes/bridges/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 './bridges.js' diff --git a/src/lib/seam/connect/routes/devices/devices.ts b/src/lib/seam/connect/routes/devices/devices.ts index d8251caa..087cfc89 100644 --- a/src/lib/seam/connect/routes/devices/devices.ts +++ b/src/lib/seam/connect/routes/devices/devices.ts @@ -174,6 +174,20 @@ export class SeamHttpDevices { return SeamHttpDevicesUnmanaged.fromClient(this.client, this.defaults) } + delete(params?: DevicesDeleteParams): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/devices/delete', + method: 'POST', + body: params, + responseKey: undefined, + }) + } + get( params?: DevicesGetParams, ): SeamHttpRequest { @@ -217,6 +231,14 @@ 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 cab4d39e..7081bc6a 100644 --- a/src/lib/seam/connect/routes/index.ts +++ b/src/lib/seam/connect/routes/index.ts @@ -8,18 +8,25 @@ export * from './access-grants/index.js' export * from './access-methods/index.js' export * from './acs/index.js' export * from './action-attempts/index.js' +export * from './bridges/index.js' export * from './client-sessions/index.js' export * from './connect-webviews/index.js' export * from './connected-accounts/index.js' export * from './devices/index.js' export * from './events/index.js' export * from './locks/index.js' +export * from './networks/index.js' export * from './noise-sensors/index.js' export * from './phones/index.js' +export * from './seam/index.js' export * from './seam-http.js' export * from './seam-http-endpoints.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' export * from './webhooks/index.js' export * from './workspaces/index.js' diff --git a/src/lib/seam/connect/routes/locks/index.ts b/src/lib/seam/connect/routes/locks/index.ts index 7a3d8440..8c2242ec 100644 --- a/src/lib/seam/connect/routes/locks/index.ts +++ b/src/lib/seam/connect/routes/locks/index.ts @@ -4,3 +4,4 @@ */ export * from './locks.js' +export * from './simulate/index.js' diff --git a/src/lib/seam/connect/routes/locks/locks.ts b/src/lib/seam/connect/routes/locks/locks.ts index 515e14e8..8d24490e 100644 --- a/src/lib/seam/connect/routes/locks/locks.ts +++ b/src/lib/seam/connect/routes/locks/locks.ts @@ -36,6 +36,8 @@ 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 { SeamHttpLocksSimulate } from './simulate/index.js' + export class SeamHttpLocks { client: Client readonly defaults: Required @@ -163,6 +165,10 @@ export class SeamHttpLocks { await clientSessions.get() } + get simulate(): SeamHttpLocksSimulate { + return SeamHttpLocksSimulate.fromClient(this.client, this.defaults) + } + get(params?: LocksGetParams): SeamHttpRequest { return new SeamHttpRequest(this, { pathname: '/locks/get', diff --git a/src/lib/seam/connect/routes/locks/simulate/index.ts b/src/lib/seam/connect/routes/locks/simulate/index.ts new file mode 100644 index 00000000..dd5b7769 --- /dev/null +++ b/src/lib/seam/connect/routes/locks/simulate/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 './simulate.js' diff --git a/src/lib/seam/connect/routes/locks/simulate/simulate.ts b/src/lib/seam/connect/routes/locks/simulate/simulate.ts new file mode 100644 index 00000000..3dcb53d3 --- /dev/null +++ b/src/lib/seam/connect/routes/locks/simulate/simulate.ts @@ -0,0 +1,228 @@ +/* + * 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 SeamHttpLocksSimulate { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpLocksSimulate { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpLocksSimulate(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpLocksSimulate { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpLocksSimulate(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpLocksSimulate { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpLocksSimulate(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 SeamHttpLocksSimulate.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpLocksSimulate.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpLocksSimulate { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpLocksSimulate(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpLocksSimulate { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpLocksSimulate(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() + } + + keypadCodeEntry( + body?: LocksSimulateKeypadCodeEntryBody, + options: LocksSimulateKeypadCodeEntryOptions = {}, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/locks/simulate/keypad_code_entry', + method: 'POST', + body, + responseKey: 'action_attempt', + options, + }) + } + + manualLockViaKeypad( + body?: LocksSimulateManualLockViaKeypadBody, + options: LocksSimulateManualLockViaKeypadOptions = {}, + ): SeamHttpRequest< + LocksSimulateManualLockViaKeypadResponse, + 'action_attempt' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/locks/simulate/manual_lock_via_keypad', + method: 'POST', + body, + responseKey: 'action_attempt', + options, + }) + } +} + +export type LocksSimulateKeypadCodeEntryBody = + RouteRequestBody<'/locks/simulate/keypad_code_entry'> + +export type LocksSimulateKeypadCodeEntryResponse = SetNonNullable< + Required> +> + +export type LocksSimulateKeypadCodeEntryOptions = Pick< + SeamHttpRequestOptions, + 'waitForActionAttempt' +> + +export type LocksSimulateManualLockViaKeypadBody = + RouteRequestBody<'/locks/simulate/manual_lock_via_keypad'> + +export type LocksSimulateManualLockViaKeypadResponse = SetNonNullable< + Required> +> + +export type LocksSimulateManualLockViaKeypadOptions = Pick< + SeamHttpRequestOptions, + 'waitForActionAttempt' +> diff --git a/src/lib/seam/connect/routes/networks/index.ts b/src/lib/seam/connect/routes/networks/index.ts new file mode 100644 index 00000000..4da6d907 --- /dev/null +++ b/src/lib/seam/connect/routes/networks/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 './networks.js' diff --git a/src/lib/seam/connect/routes/networks/networks.ts b/src/lib/seam/connect/routes/networks/networks.ts new file mode 100644 index 00000000..396332a5 --- /dev/null +++ b/src/lib/seam/connect/routes/networks/networks.ts @@ -0,0 +1,213 @@ +/* + * 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 SeamHttpNetworks { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpNetworks { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpNetworks(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpNetworks { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpNetworks(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpNetworks { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpNetworks(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 SeamHttpNetworks.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpNetworks.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpNetworks { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpNetworks(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpNetworks { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpNetworks(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( + params?: NetworksGetParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/networks/get', + method: 'POST', + body: params, + responseKey: 'network', + }) + } + + list( + params?: NetworksListParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/networks/list', + method: 'POST', + body: params, + responseKey: 'networks', + }) + } +} + +export type NetworksGetParams = RouteRequestBody<'/networks/get'> + +export type NetworksGetResponse = SetNonNullable< + Required> +> + +export type NetworksGetOptions = never + +export type NetworksListParams = RouteRequestBody<'/networks/list'> + +export type NetworksListResponse = SetNonNullable< + Required> +> + +export type NetworksListOptions = never diff --git a/src/lib/seam/connect/routes/seam-http-endpoints.ts b/src/lib/seam/connect/routes/seam-http-endpoints.ts index 406b60c2..13f7db87 100644 --- a/src/lib/seam/connect/routes/seam-http-endpoints.ts +++ b/src/lib/seam/connect/routes/seam-http-endpoints.ts @@ -38,13 +38,19 @@ import { SeamHttpAccessCodesUnmanaged } from './access-codes/unmanaged/index.js' import { SeamHttpAccessGrants } from './access-grants/index.js' import { SeamHttpAccessMethods } from './access-methods/index.js' import { SeamHttpAcsAccessGroups } from './acs/access-groups/index.js' +import { SeamHttpAcsAccessGroupsUnmanaged } from './acs/access-groups/unmanaged/index.js' +import { SeamHttpAcsCredentialPools } from './acs/credential-pools/index.js' +import { SeamHttpAcsCredentialProvisioningAutomations } from './acs/credential-provisioning-automations/index.js' import { SeamHttpAcsCredentials } from './acs/credentials/index.js' +import { SeamHttpAcsCredentialsUnmanaged } from './acs/credentials/unmanaged/index.js' import { SeamHttpAcsEncoders } from './acs/encoders/index.js' import { SeamHttpAcsEncodersSimulate } from './acs/encoders/simulate/index.js' import { SeamHttpAcsEntrances } from './acs/entrances/index.js' import { SeamHttpAcsSystems } from './acs/systems/index.js' import { SeamHttpAcsUsers } from './acs/users/index.js' +import { SeamHttpAcsUsersUnmanaged } from './acs/users/unmanaged/index.js' import { SeamHttpActionAttempts } from './action-attempts/index.js' +import { SeamHttpBridges } from './bridges/index.js' import { SeamHttpClientSessions } from './client-sessions/index.js' import { SeamHttpConnectWebviews } from './connect-webviews/index.js' import { SeamHttpConnectedAccounts } from './connected-accounts/index.js' @@ -53,16 +59,30 @@ import { SeamHttpDevicesSimulate } from './devices/simulate/index.js' import { SeamHttpDevicesUnmanaged } from './devices/unmanaged/index.js' import { SeamHttpEvents } from './events/index.js' import { SeamHttpLocks } from './locks/index.js' +import { SeamHttpLocksSimulate } from './locks/simulate/index.js' +import { SeamHttpNetworks } from './networks/index.js' import { SeamHttpNoiseSensors } from './noise-sensors/index.js' import { SeamHttpNoiseSensorsNoiseThresholds } from './noise-sensors/noise-thresholds/index.js' import { SeamHttpNoiseSensorsSimulate } from './noise-sensors/simulate/index.js' import { SeamHttpPhones } from './phones/index.js' import { SeamHttpPhonesSimulate } from './phones/simulate/index.js' +import { SeamHttpSeamBridgeV1BridgeClientSessions } from './seam/bridge/v1/bridge-client-sessions/index.js' +import { SeamHttpSeamBridgeV1BridgeConnectedSystems } from './seam/bridge/v1/bridge-connected-systems/index.js' +import { SeamHttpSeamInstantKeyV1ClientSessions } from './seam/instant-key/v1/client-sessions/index.js' +import { SeamHttpSeamMobileSdkV1AcsCredentials } from './seam/mobile-sdk/v1/acs/credentials/index.js' +import { SeamHttpSeamMobileSdkV1PhoneSessions } from './seam/mobile-sdk/v1/phone-sessions/index.js' +import { SeamHttpSeamPartnerV1BuildingBlocksSpaces } from './seam/partner/v1/building-blocks/spaces/index.js' +import { SeamHttpSeamPartnerV1Resources } from './seam/partner/v1/resources/index.js' import { SeamHttpSpaces } from './spaces/index.js' import { SeamHttpThermostatsDailyPrograms } from './thermostats/daily-programs/index.js' import { SeamHttpThermostats } from './thermostats/index.js' import { SeamHttpThermostatsSchedules } from './thermostats/schedules/index.js' import { SeamHttpThermostatsSimulate } from './thermostats/simulate/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 { SeamHttpUnstablePartnerBuildingBlocks } from './unstable-partner/building-blocks/index.js' +import { SeamHttpUnstablePartnerResources } from './unstable-partner/resources/index.js' import { SeamHttpUserIdentitiesEnrollmentAutomations } from './user-identities/enrollment-automations/index.js' import { SeamHttpUserIdentities } from './user-identities/index.js' import { SeamHttpWebhooks } from './webhooks/index.js' @@ -497,6 +517,71 @@ export class SeamHttpEndpoints { } } + get ['/acs/access_groups/unmanaged/get'](): SeamHttpAcsAccessGroupsUnmanaged['get'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function acsAccessGroupsUnmanagedGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsAccessGroupsUnmanaged.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/acs/access_groups/unmanaged/list'](): SeamHttpAcsAccessGroupsUnmanaged['list'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function acsAccessGroupsUnmanagedList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsAccessGroupsUnmanaged.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/acs/credential_pools/list'](): SeamHttpAcsCredentialPools['list'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function acsCredentialPoolsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentialPools.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/acs/credential_provisioning_automations/launch'](): SeamHttpAcsCredentialProvisioningAutomations['launch'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function acsCredentialProvisioningAutomationsLaunch( + ...args: Parameters< + SeamHttpAcsCredentialProvisioningAutomations['launch'] + > + ): ReturnType { + const seam = SeamHttpAcsCredentialProvisioningAutomations.fromClient( + client, + defaults, + ) + return seam.launch(...args) + } + } + get ['/acs/credentials/assign'](): SeamHttpAcsCredentials['assign'] { const { client, defaults } = this return function acsCredentialsAssign( @@ -517,6 +602,21 @@ export class SeamHttpEndpoints { } } + get ['/acs/credentials/create_offline_code'](): SeamHttpAcsCredentials['createOfflineCode'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function acsCredentialsCreateOfflineCode( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentials.fromClient(client, defaults) + return seam.createOfflineCode(...args) + } + } + get ['/acs/credentials/delete'](): SeamHttpAcsCredentials['delete'] { const { client, defaults } = this return function acsCredentialsDelete( @@ -577,6 +677,36 @@ export class SeamHttpEndpoints { } } + get ['/acs/credentials/unmanaged/get'](): SeamHttpAcsCredentialsUnmanaged['get'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function acsCredentialsUnmanagedGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentialsUnmanaged.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/acs/credentials/unmanaged/list'](): SeamHttpAcsCredentialsUnmanaged['list'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function acsCredentialsUnmanagedList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsCredentialsUnmanaged.fromClient(client, defaults) + return seam.list(...args) + } + } + get ['/acs/encoders/encode_access_method'](): SeamHttpAcsEncoders['encodeAccessMethod'] { const { client, defaults } = this return function acsEncodersEncodeAccessMethod( @@ -863,6 +993,36 @@ export class SeamHttpEndpoints { } } + get ['/acs/users/unmanaged/get'](): SeamHttpAcsUsersUnmanaged['get'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function acsUsersUnmanagedGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsersUnmanaged.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/acs/users/unmanaged/list'](): SeamHttpAcsUsersUnmanaged['list'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function acsUsersUnmanagedList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAcsUsersUnmanaged.fromClient(client, defaults) + return seam.list(...args) + } + } + get ['/action_attempts/get'](): SeamHttpActionAttempts['get'] { const { client, defaults } = this return function actionAttemptsGet( @@ -883,6 +1043,36 @@ export class SeamHttpEndpoints { } } + get ['/bridges/get'](): SeamHttpBridges['get'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function bridgesGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpBridges.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/bridges/list'](): SeamHttpBridges['list'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function bridgesList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpBridges.fromClient(client, defaults) + return seam.list(...args) + } + } + get ['/client_sessions/create'](): SeamHttpClientSessions['create'] { const { client, defaults } = this return function clientSessionsCreate( @@ -1043,6 +1233,21 @@ export class SeamHttpEndpoints { } } + get ['/devices/delete'](): SeamHttpDevices['delete'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function devicesDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpDevices.fromClient(client, defaults) + return seam.delete(...args) + } + } + get ['/devices/get'](): SeamHttpDevices['get'] { const { client, defaults } = this return function devicesGet( @@ -1203,6 +1408,66 @@ export class SeamHttpEndpoints { } } + get ['/locks/simulate/keypad_code_entry'](): SeamHttpLocksSimulate['keypadCodeEntry'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function locksSimulateKeypadCodeEntry( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpLocksSimulate.fromClient(client, defaults) + return seam.keypadCodeEntry(...args) + } + } + + get ['/locks/simulate/manual_lock_via_keypad'](): SeamHttpLocksSimulate['manualLockViaKeypad'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function locksSimulateManualLockViaKeypad( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpLocksSimulate.fromClient(client, defaults) + return seam.manualLockViaKeypad(...args) + } + } + + get ['/networks/get'](): SeamHttpNetworks['get'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function networksGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpNetworks.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/networks/list'](): SeamHttpNetworks['list'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function networksList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpNetworks.fromClient(client, defaults) + return seam.list(...args) + } + } + get ['/noise_sensors/list'](): SeamHttpNoiseSensors['list'] { const { client, defaults } = this return function noiseSensorsList( @@ -1328,6 +1593,213 @@ export class SeamHttpEndpoints { } } + get ['/seam/bridge/v1/bridge_client_sessions/create'](): SeamHttpSeamBridgeV1BridgeClientSessions['create'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamBridgeV1BridgeClientSessionsCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamBridgeV1BridgeClientSessions.fromClient( + client, + defaults, + ) + return seam.create(...args) + } + } + + get ['/seam/bridge/v1/bridge_client_sessions/get'](): SeamHttpSeamBridgeV1BridgeClientSessions['get'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamBridgeV1BridgeClientSessionsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamBridgeV1BridgeClientSessions.fromClient( + client, + defaults, + ) + return seam.get(...args) + } + } + + get ['/seam/bridge/v1/bridge_client_sessions/refresh_telemetry_token'](): SeamHttpSeamBridgeV1BridgeClientSessions['refreshTelemetryToken'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamBridgeV1BridgeClientSessionsRefreshTelemetryToken( + ...args: Parameters< + SeamHttpSeamBridgeV1BridgeClientSessions['refreshTelemetryToken'] + > + ): ReturnType< + SeamHttpSeamBridgeV1BridgeClientSessions['refreshTelemetryToken'] + > { + const seam = SeamHttpSeamBridgeV1BridgeClientSessions.fromClient( + client, + defaults, + ) + return seam.refreshTelemetryToken(...args) + } + } + + get ['/seam/bridge/v1/bridge_client_sessions/regenerate_pairing_code'](): SeamHttpSeamBridgeV1BridgeClientSessions['regeneratePairingCode'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamBridgeV1BridgeClientSessionsRegeneratePairingCode( + ...args: Parameters< + SeamHttpSeamBridgeV1BridgeClientSessions['regeneratePairingCode'] + > + ): ReturnType< + SeamHttpSeamBridgeV1BridgeClientSessions['regeneratePairingCode'] + > { + const seam = SeamHttpSeamBridgeV1BridgeClientSessions.fromClient( + client, + defaults, + ) + return seam.regeneratePairingCode(...args) + } + } + + get ['/seam/bridge/v1/bridge_client_sessions/report_status'](): SeamHttpSeamBridgeV1BridgeClientSessions['reportStatus'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamBridgeV1BridgeClientSessionsReportStatus( + ...args: Parameters< + SeamHttpSeamBridgeV1BridgeClientSessions['reportStatus'] + > + ): ReturnType { + const seam = SeamHttpSeamBridgeV1BridgeClientSessions.fromClient( + client, + defaults, + ) + return seam.reportStatus(...args) + } + } + + get ['/seam/bridge/v1/bridge_connected_systems/list'](): SeamHttpSeamBridgeV1BridgeConnectedSystems['list'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamBridgeV1BridgeConnectedSystemsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamBridgeV1BridgeConnectedSystems.fromClient( + client, + defaults, + ) + return seam.list(...args) + } + } + + get ['/seam/instant_key/v1/client_sessions/exchange_short_code'](): SeamHttpSeamInstantKeyV1ClientSessions['exchangeShortCode'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamInstantKeyV1ClientSessionsExchangeShortCode( + ...args: Parameters< + SeamHttpSeamInstantKeyV1ClientSessions['exchangeShortCode'] + > + ): ReturnType { + const seam = SeamHttpSeamInstantKeyV1ClientSessions.fromClient( + client, + defaults, + ) + return seam.exchangeShortCode(...args) + } + } + + get ['/seam/mobile_sdk/v1/acs/credentials/list'](): SeamHttpSeamMobileSdkV1AcsCredentials['list'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamMobileSdkV1AcsCredentialsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamMobileSdkV1AcsCredentials.fromClient( + client, + defaults, + ) + return seam.list(...args) + } + } + + get ['/seam/mobile_sdk/v1/phone_sessions/get_or_create'](): SeamHttpSeamMobileSdkV1PhoneSessions['getOrCreate'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamMobileSdkV1PhoneSessionsGetOrCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamMobileSdkV1PhoneSessions.fromClient( + client, + defaults, + ) + return seam.getOrCreate(...args) + } + } + + get ['/seam/partner/v1/building_blocks/spaces/auto_map'](): SeamHttpSeamPartnerV1BuildingBlocksSpaces['autoMap'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamPartnerV1BuildingBlocksSpacesAutoMap( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamPartnerV1BuildingBlocksSpaces.fromClient( + client, + defaults, + ) + return seam.autoMap(...args) + } + } + + get ['/seam/partner/v1/resources/list'](): SeamHttpSeamPartnerV1Resources['list'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamPartnerV1ResourcesList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamPartnerV1Resources.fromClient(client, defaults) + return seam.list(...args) + } + } + get ['/spaces/add_acs_entrances'](): SeamHttpSpaces['addAcsEntrances'] { const { client, defaults } = this return function spacesAddAcsEntrances( @@ -1458,6 +1930,21 @@ export class SeamHttpEndpoints { } } + get ['/thermostats/get'](): SeamHttpThermostats['get'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function thermostatsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpThermostats.fromClient(client, defaults) + return seam.get(...args) + } + } + get ['/thermostats/heat'](): SeamHttpThermostats['heat'] { const { client, defaults } = this return function thermostatsHeat( @@ -1658,6 +2145,341 @@ export class SeamHttpEndpoints { } } + get ['/unstable_access_grants/create'](): SeamHttpUnstableAccessGrants['create'] { + 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'](): SeamHttpUnstableAccessGrants['delete'] { + 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'](): SeamHttpUnstableAccessGrants['get'] { + 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'](): SeamHttpUnstableAccessGrants['list'] { + 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'](): SeamHttpUnstableAccessMethods['delete'] { + 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'](): SeamHttpUnstableAccessMethods['get'] { + 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'](): SeamHttpUnstableAccessMethods['list'] { + 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'](): SeamHttpUnstableLocations['addAcsEntrances'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstableLocationsAddAcsEntrances( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUnstableLocations.fromClient(client, defaults) + return seam.addAcsEntrances(...args) + } + } + + get ['/unstable_locations/add_devices'](): SeamHttpUnstableLocations['addDevices'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstableLocationsAddDevices( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUnstableLocations.fromClient(client, defaults) + return seam.addDevices(...args) + } + } + + get ['/unstable_locations/create'](): SeamHttpUnstableLocations['create'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstableLocationsCreate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUnstableLocations.fromClient(client, defaults) + return seam.create(...args) + } + } + + get ['/unstable_locations/delete'](): SeamHttpUnstableLocations['delete'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstableLocationsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUnstableLocations.fromClient(client, defaults) + return seam.delete(...args) + } + } + + get ['/unstable_locations/get'](): SeamHttpUnstableLocations['get'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstableLocationsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUnstableLocations.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/unstable_locations/list'](): SeamHttpUnstableLocations['list'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstableLocationsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUnstableLocations.fromClient(client, defaults) + return seam.list(...args) + } + } + + get ['/unstable_locations/remove_acs_entrances'](): SeamHttpUnstableLocations['removeAcsEntrances'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstableLocationsRemoveAcsEntrances( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUnstableLocations.fromClient(client, defaults) + return seam.removeAcsEntrances(...args) + } + } + + get ['/unstable_locations/remove_devices'](): SeamHttpUnstableLocations['removeDevices'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstableLocationsRemoveDevices( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUnstableLocations.fromClient(client, defaults) + return seam.removeDevices(...args) + } + } + + get ['/unstable_locations/update'](): SeamHttpUnstableLocations['update'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstableLocationsUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUnstableLocations.fromClient(client, defaults) + return seam.update(...args) + } + } + + get ['/unstable_partner/building_blocks/connect_accounts'](): SeamHttpUnstablePartnerBuildingBlocks['connectAccounts'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstablePartnerBuildingBlocksConnectAccounts( + ...args: Parameters< + SeamHttpUnstablePartnerBuildingBlocks['connectAccounts'] + > + ): ReturnType { + const seam = SeamHttpUnstablePartnerBuildingBlocks.fromClient( + client, + defaults, + ) + return seam.connectAccounts(...args) + } + } + + get ['/unstable_partner/building_blocks/generate_magic_link'](): SeamHttpUnstablePartnerBuildingBlocks['generateMagicLink'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstablePartnerBuildingBlocksGenerateMagicLink( + ...args: Parameters< + SeamHttpUnstablePartnerBuildingBlocks['generateMagicLink'] + > + ): ReturnType { + const seam = SeamHttpUnstablePartnerBuildingBlocks.fromClient( + client, + defaults, + ) + return seam.generateMagicLink(...args) + } + } + + get ['/unstable_partner/building_blocks/manage_devices'](): SeamHttpUnstablePartnerBuildingBlocks['manageDevices'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstablePartnerBuildingBlocksManageDevices( + ...args: Parameters< + SeamHttpUnstablePartnerBuildingBlocks['manageDevices'] + > + ): ReturnType { + const seam = SeamHttpUnstablePartnerBuildingBlocks.fromClient( + client, + defaults, + ) + return seam.manageDevices(...args) + } + } + + get ['/unstable_partner/building_blocks/organize_spaces'](): SeamHttpUnstablePartnerBuildingBlocks['organizeSpaces'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstablePartnerBuildingBlocksOrganizeSpaces( + ...args: Parameters< + SeamHttpUnstablePartnerBuildingBlocks['organizeSpaces'] + > + ): ReturnType { + const seam = SeamHttpUnstablePartnerBuildingBlocks.fromClient( + client, + defaults, + ) + return seam.organizeSpaces(...args) + } + } + + get ['/unstable_partner/resources/push'](): SeamHttpUnstablePartnerResources['push'] { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function unstablePartnerResourcesPush( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpUnstablePartnerResources.fromClient(client, defaults) + return seam.push(...args) + } + } + get ['/user_identities/add_acs_user'](): SeamHttpUserIdentities['addAcsUser'] { const { client, defaults } = this return function userIdentitiesAddAcsUser( diff --git a/src/lib/seam/connect/routes/seam-http.ts b/src/lib/seam/connect/routes/seam-http.ts index b303ff61..899f9ab5 100644 --- a/src/lib/seam/connect/routes/seam-http.ts +++ b/src/lib/seam/connect/routes/seam-http.ts @@ -37,16 +37,22 @@ import { SeamHttpAccessGrants } from './access-grants/index.js' import { SeamHttpAccessMethods } from './access-methods/index.js' import { SeamHttpAcs } from './acs/index.js' import { SeamHttpActionAttempts } from './action-attempts/index.js' +import { SeamHttpBridges } from './bridges/index.js' import { SeamHttpClientSessions } from './client-sessions/index.js' import { SeamHttpConnectWebviews } from './connect-webviews/index.js' import { SeamHttpConnectedAccounts } from './connected-accounts/index.js' import { SeamHttpDevices } from './devices/index.js' import { SeamHttpEvents } from './events/index.js' import { SeamHttpLocks } from './locks/index.js' +import { SeamHttpNetworks } from './networks/index.js' 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' import { SeamHttpWebhooks } from './webhooks/index.js' import { SeamHttpWorkspaces } from './workspaces/index.js' @@ -198,6 +204,10 @@ export class SeamHttp { return SeamHttpActionAttempts.fromClient(this.client, this.defaults) } + get bridges(): SeamHttpBridges { + return SeamHttpBridges.fromClient(this.client, this.defaults) + } + get clientSessions(): SeamHttpClientSessions { return SeamHttpClientSessions.fromClient(this.client, this.defaults) } @@ -222,6 +232,10 @@ export class SeamHttp { return SeamHttpLocks.fromClient(this.client, this.defaults) } + get networks(): SeamHttpNetworks { + return SeamHttpNetworks.fromClient(this.client, this.defaults) + } + get noiseSensors(): SeamHttpNoiseSensors { return SeamHttpNoiseSensors.fromClient(this.client, this.defaults) } @@ -238,6 +252,22 @@ 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) + } + + get unstablePartner(): SeamHttpUnstablePartner { + return SeamHttpUnstablePartner.fromClient(this.client, this.defaults) + } + get userIdentities(): SeamHttpUserIdentities { return SeamHttpUserIdentities.fromClient(this.client, this.defaults) } diff --git a/src/lib/seam/connect/routes/seam/bridge/index.ts b/src/lib/seam/connect/routes/seam/bridge/index.ts new file mode 100644 index 00000000..2e9499e7 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/bridge/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 './v1/index.js' diff --git a/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.ts b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.ts new file mode 100644 index 00000000..07b86ff0 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.ts @@ -0,0 +1,320 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +import type { + RouteRequestBody, + RouteRequestParams, + 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 SeamHttpSeamBridgeV1BridgeClientSessions { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamBridgeV1BridgeClientSessions { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamBridgeV1BridgeClientSessions(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamBridgeV1BridgeClientSessions { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamBridgeV1BridgeClientSessions(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamBridgeV1BridgeClientSessions { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamBridgeV1BridgeClientSessions(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 SeamHttpSeamBridgeV1BridgeClientSessions.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamBridgeV1BridgeClientSessions.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamBridgeV1BridgeClientSessions { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamBridgeV1BridgeClientSessions(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamBridgeV1BridgeClientSessions { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamBridgeV1BridgeClientSessions(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( + body?: SeamBridgeV1BridgeClientSessionsCreateBody, + ): SeamHttpRequest< + SeamBridgeV1BridgeClientSessionsCreateResponse, + 'bridge_client_session' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/bridge/v1/bridge_client_sessions/create', + method: 'POST', + body, + responseKey: 'bridge_client_session', + }) + } + + get( + params?: SeamBridgeV1BridgeClientSessionsGetParams, + ): SeamHttpRequest< + SeamBridgeV1BridgeClientSessionsGetResponse, + 'bridge_client_session' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/bridge/v1/bridge_client_sessions/get', + method: 'GET', + params, + responseKey: 'bridge_client_session', + }) + } + + refreshTelemetryToken( + body?: SeamBridgeV1BridgeClientSessionsRefreshTelemetryTokenBody, + ): SeamHttpRequest< + SeamBridgeV1BridgeClientSessionsRefreshTelemetryTokenResponse, + 'bridge_client_session' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: + '/seam/bridge/v1/bridge_client_sessions/refresh_telemetry_token', + method: 'POST', + body, + responseKey: 'bridge_client_session', + }) + } + + regeneratePairingCode( + body?: SeamBridgeV1BridgeClientSessionsRegeneratePairingCodeBody, + ): SeamHttpRequest< + SeamBridgeV1BridgeClientSessionsRegeneratePairingCodeResponse, + 'bridge_client_session' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: + '/seam/bridge/v1/bridge_client_sessions/regenerate_pairing_code', + method: 'POST', + body, + responseKey: 'bridge_client_session', + }) + } + + reportStatus( + body?: SeamBridgeV1BridgeClientSessionsReportStatusBody, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/bridge/v1/bridge_client_sessions/report_status', + method: 'POST', + body, + responseKey: undefined, + }) + } +} + +export type SeamBridgeV1BridgeClientSessionsCreateBody = + RouteRequestBody<'/seam/bridge/v1/bridge_client_sessions/create'> + +export type SeamBridgeV1BridgeClientSessionsCreateResponse = SetNonNullable< + Required> +> + +export type SeamBridgeV1BridgeClientSessionsCreateOptions = never + +export type SeamBridgeV1BridgeClientSessionsGetParams = + RouteRequestParams<'/seam/bridge/v1/bridge_client_sessions/get'> + +export type SeamBridgeV1BridgeClientSessionsGetResponse = SetNonNullable< + Required> +> + +export type SeamBridgeV1BridgeClientSessionsGetOptions = never + +export type SeamBridgeV1BridgeClientSessionsRefreshTelemetryTokenBody = + RouteRequestBody<'/seam/bridge/v1/bridge_client_sessions/refresh_telemetry_token'> + +export type SeamBridgeV1BridgeClientSessionsRefreshTelemetryTokenResponse = + SetNonNullable< + Required< + RouteResponse<'/seam/bridge/v1/bridge_client_sessions/refresh_telemetry_token'> + > + > + +export type SeamBridgeV1BridgeClientSessionsRefreshTelemetryTokenOptions = never + +export type SeamBridgeV1BridgeClientSessionsRegeneratePairingCodeBody = + RouteRequestBody<'/seam/bridge/v1/bridge_client_sessions/regenerate_pairing_code'> + +export type SeamBridgeV1BridgeClientSessionsRegeneratePairingCodeResponse = + SetNonNullable< + Required< + RouteResponse<'/seam/bridge/v1/bridge_client_sessions/regenerate_pairing_code'> + > + > + +export type SeamBridgeV1BridgeClientSessionsRegeneratePairingCodeOptions = never + +export type SeamBridgeV1BridgeClientSessionsReportStatusBody = + RouteRequestBody<'/seam/bridge/v1/bridge_client_sessions/report_status'> + +export type SeamBridgeV1BridgeClientSessionsReportStatusResponse = + SetNonNullable< + Required< + RouteResponse<'/seam/bridge/v1/bridge_client_sessions/report_status'> + > + > + +export type SeamBridgeV1BridgeClientSessionsReportStatusOptions = never diff --git a/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.ts b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.ts new file mode 100644 index 00000000..b12eb3c0 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/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 './bridge-client-sessions.js' diff --git a/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.ts b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.ts new file mode 100644 index 00000000..cc7095ae --- /dev/null +++ b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.ts @@ -0,0 +1,196 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +import type { RouteRequestParams, 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 SeamHttpSeamBridgeV1BridgeConnectedSystems { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamBridgeV1BridgeConnectedSystems { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamBridgeV1BridgeConnectedSystems(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamBridgeV1BridgeConnectedSystems { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamBridgeV1BridgeConnectedSystems(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamBridgeV1BridgeConnectedSystems { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamBridgeV1BridgeConnectedSystems(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 SeamHttpSeamBridgeV1BridgeConnectedSystems.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamBridgeV1BridgeConnectedSystems.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamBridgeV1BridgeConnectedSystems { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamBridgeV1BridgeConnectedSystems(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamBridgeV1BridgeConnectedSystems { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamBridgeV1BridgeConnectedSystems(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( + params?: SeamBridgeV1BridgeConnectedSystemsListParams, + ): SeamHttpRequest< + SeamBridgeV1BridgeConnectedSystemsListResponse, + 'bridge_connected_systems' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/bridge/v1/bridge_connected_systems/list', + method: 'GET', + params, + responseKey: 'bridge_connected_systems', + }) + } +} + +export type SeamBridgeV1BridgeConnectedSystemsListParams = + RouteRequestParams<'/seam/bridge/v1/bridge_connected_systems/list'> + +export type SeamBridgeV1BridgeConnectedSystemsListResponse = SetNonNullable< + Required> +> + +export type SeamBridgeV1BridgeConnectedSystemsListOptions = never diff --git a/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.ts b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.ts new file mode 100644 index 00000000..52e1a0dc --- /dev/null +++ b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/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 './bridge-connected-systems.js' diff --git a/src/lib/seam/connect/routes/seam/bridge/v1/index.ts b/src/lib/seam/connect/routes/seam/bridge/v1/index.ts new file mode 100644 index 00000000..b4a51de3 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/bridge/v1/index.ts @@ -0,0 +1,8 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +export * from './bridge-client-sessions/index.js' +export * from './bridge-connected-systems/index.js' +export * from './v1.js' diff --git a/src/lib/seam/connect/routes/seam/bridge/v1/v1.ts b/src/lib/seam/connect/routes/seam/bridge/v1/v1.ts new file mode 100644 index 00000000..7ee3e7e1 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/bridge/v1/v1.ts @@ -0,0 +1,179 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +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 type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' +import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' + +import { SeamHttpSeamBridgeV1BridgeClientSessions } from './bridge-client-sessions/index.js' +import { SeamHttpSeamBridgeV1BridgeConnectedSystems } from './bridge-connected-systems/index.js' + +export class SeamHttpSeamBridgeV1 { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamBridgeV1 { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamBridgeV1(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamBridgeV1 { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamBridgeV1(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamBridgeV1 { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamBridgeV1(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 SeamHttpSeamBridgeV1.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamBridgeV1.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamBridgeV1 { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamBridgeV1(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamBridgeV1 { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamBridgeV1(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 bridgeClientSessions(): SeamHttpSeamBridgeV1BridgeClientSessions { + return SeamHttpSeamBridgeV1BridgeClientSessions.fromClient( + this.client, + this.defaults, + ) + } + + get bridgeConnectedSystems(): SeamHttpSeamBridgeV1BridgeConnectedSystems { + return SeamHttpSeamBridgeV1BridgeConnectedSystems.fromClient( + this.client, + this.defaults, + ) + } +} diff --git a/src/lib/seam/connect/routes/seam/index.ts b/src/lib/seam/connect/routes/seam/index.ts new file mode 100644 index 00000000..1e723249 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/index.ts @@ -0,0 +1,9 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +export * from './bridge/index.js' +export * from './instant-key/index.js' +export * from './mobile-sdk/index.js' +export * from './partner/index.js' diff --git a/src/lib/seam/connect/routes/seam/instant-key/index.ts b/src/lib/seam/connect/routes/seam/instant-key/index.ts new file mode 100644 index 00000000..2e9499e7 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/instant-key/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 './v1/index.js' diff --git a/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.ts b/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.ts new file mode 100644 index 00000000..e9d366ae --- /dev/null +++ b/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.ts @@ -0,0 +1,199 @@ +/* + * 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 SeamHttpSeamInstantKeyV1ClientSessions { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamInstantKeyV1ClientSessions { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamInstantKeyV1ClientSessions(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamInstantKeyV1ClientSessions { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamInstantKeyV1ClientSessions(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamInstantKeyV1ClientSessions { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamInstantKeyV1ClientSessions(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 SeamHttpSeamInstantKeyV1ClientSessions.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamInstantKeyV1ClientSessions.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamInstantKeyV1ClientSessions { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamInstantKeyV1ClientSessions(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamInstantKeyV1ClientSessions { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamInstantKeyV1ClientSessions(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() + } + + exchangeShortCode( + body?: SeamInstantKeyV1ClientSessionsExchangeShortCodeBody, + ): SeamHttpRequest< + SeamInstantKeyV1ClientSessionsExchangeShortCodeResponse, + 'client_session' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/instant_key/v1/client_sessions/exchange_short_code', + method: 'POST', + body, + responseKey: 'client_session', + }) + } +} + +export type SeamInstantKeyV1ClientSessionsExchangeShortCodeBody = + RouteRequestBody<'/seam/instant_key/v1/client_sessions/exchange_short_code'> + +export type SeamInstantKeyV1ClientSessionsExchangeShortCodeResponse = + SetNonNullable< + Required< + RouteResponse<'/seam/instant_key/v1/client_sessions/exchange_short_code'> + > + > + +export type SeamInstantKeyV1ClientSessionsExchangeShortCodeOptions = never diff --git a/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.ts b/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.ts new file mode 100644 index 00000000..83896398 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/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 './client-sessions.js' diff --git a/src/lib/seam/connect/routes/seam/instant-key/v1/index.ts b/src/lib/seam/connect/routes/seam/instant-key/v1/index.ts new file mode 100644 index 00000000..2d03f348 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/instant-key/v1/index.ts @@ -0,0 +1,7 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +export * from './client-sessions/index.js' +export * from './v1.js' diff --git a/src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts b/src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts new file mode 100644 index 00000000..c4549129 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts @@ -0,0 +1,171 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +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 type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' +import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' + +import { SeamHttpSeamInstantKeyV1ClientSessions } from './client-sessions/index.js' + +export class SeamHttpSeamInstantKeyV1 { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamInstantKeyV1 { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamInstantKeyV1(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamInstantKeyV1 { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamInstantKeyV1(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamInstantKeyV1 { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamInstantKeyV1(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 SeamHttpSeamInstantKeyV1.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamInstantKeyV1.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamInstantKeyV1 { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamInstantKeyV1(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamInstantKeyV1 { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamInstantKeyV1(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 clientSessions(): SeamHttpSeamInstantKeyV1ClientSessions { + return SeamHttpSeamInstantKeyV1ClientSessions.fromClient( + this.client, + this.defaults, + ) + } +} diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/index.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/index.ts new file mode 100644 index 00000000..2e9499e7 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/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 './v1/index.js' diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts new file mode 100644 index 00000000..034bbe35 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts @@ -0,0 +1,171 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +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 type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' +import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' + +import { SeamHttpSeamMobileSdkV1AcsCredentials } from './credentials/index.js' + +export class SeamHttpSeamMobileSdkV1Acs { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamMobileSdkV1Acs { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamMobileSdkV1Acs(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamMobileSdkV1Acs { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamMobileSdkV1Acs(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamMobileSdkV1Acs { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamMobileSdkV1Acs(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 SeamHttpSeamMobileSdkV1Acs.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamMobileSdkV1Acs.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamMobileSdkV1Acs { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamMobileSdkV1Acs(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamMobileSdkV1Acs { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamMobileSdkV1Acs(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 credentials(): SeamHttpSeamMobileSdkV1AcsCredentials { + return SeamHttpSeamMobileSdkV1AcsCredentials.fromClient( + this.client, + this.defaults, + ) + } +} diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts new file mode 100644 index 00000000..29d4e140 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts @@ -0,0 +1,196 @@ +/* + * 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 SeamHttpSeamMobileSdkV1AcsCredentials { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamMobileSdkV1AcsCredentials { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamMobileSdkV1AcsCredentials(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamMobileSdkV1AcsCredentials { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamMobileSdkV1AcsCredentials(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamMobileSdkV1AcsCredentials { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamMobileSdkV1AcsCredentials(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 SeamHttpSeamMobileSdkV1AcsCredentials.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamMobileSdkV1AcsCredentials.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamMobileSdkV1AcsCredentials { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamMobileSdkV1AcsCredentials(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamMobileSdkV1AcsCredentials { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamMobileSdkV1AcsCredentials(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( + params?: SeamMobileSdkV1AcsCredentialsListParams, + ): SeamHttpRequest< + SeamMobileSdkV1AcsCredentialsListResponse, + 'acs_credentials' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/mobile_sdk/v1/acs/credentials/list', + method: 'POST', + body: params, + responseKey: 'acs_credentials', + }) + } +} + +export type SeamMobileSdkV1AcsCredentialsListParams = + RouteRequestBody<'/seam/mobile_sdk/v1/acs/credentials/list'> + +export type SeamMobileSdkV1AcsCredentialsListResponse = SetNonNullable< + Required> +> + +export type SeamMobileSdkV1AcsCredentialsListOptions = never diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.ts new file mode 100644 index 00000000..2d9bacd3 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/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 './credentials.js' diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.ts new file mode 100644 index 00000000..cb58af5a --- /dev/null +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.ts @@ -0,0 +1,7 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +export * from './acs.js' +export * from './credentials/index.js' diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/index.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/index.ts new file mode 100644 index 00000000..1fdfed9e --- /dev/null +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/index.ts @@ -0,0 +1,8 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +export * from './acs/index.js' +export * from './phone-sessions/index.js' +export * from './v1.js' diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.ts new file mode 100644 index 00000000..2cf9bf2a --- /dev/null +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/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 './phone-sessions.js' diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts new file mode 100644 index 00000000..7eb019c1 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts @@ -0,0 +1,196 @@ +/* + * 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 SeamHttpSeamMobileSdkV1PhoneSessions { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamMobileSdkV1PhoneSessions { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamMobileSdkV1PhoneSessions(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamMobileSdkV1PhoneSessions { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamMobileSdkV1PhoneSessions(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamMobileSdkV1PhoneSessions { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamMobileSdkV1PhoneSessions(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 SeamHttpSeamMobileSdkV1PhoneSessions.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamMobileSdkV1PhoneSessions.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamMobileSdkV1PhoneSessions { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamMobileSdkV1PhoneSessions(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamMobileSdkV1PhoneSessions { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamMobileSdkV1PhoneSessions(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() + } + + getOrCreate( + body?: SeamMobileSdkV1PhoneSessionsGetOrCreateBody, + ): SeamHttpRequest< + SeamMobileSdkV1PhoneSessionsGetOrCreateResponse, + 'phone_session' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/mobile_sdk/v1/phone_sessions/get_or_create', + method: 'POST', + body, + responseKey: 'phone_session', + }) + } +} + +export type SeamMobileSdkV1PhoneSessionsGetOrCreateBody = + RouteRequestBody<'/seam/mobile_sdk/v1/phone_sessions/get_or_create'> + +export type SeamMobileSdkV1PhoneSessionsGetOrCreateResponse = SetNonNullable< + Required> +> + +export type SeamMobileSdkV1PhoneSessionsGetOrCreateOptions = never diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts new file mode 100644 index 00000000..b99cebed --- /dev/null +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts @@ -0,0 +1,176 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +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 type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' +import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' + +import { SeamHttpSeamMobileSdkV1Acs } from './acs/index.js' +import { SeamHttpSeamMobileSdkV1PhoneSessions } from './phone-sessions/index.js' + +export class SeamHttpSeamMobileSdkV1 { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamMobileSdkV1 { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamMobileSdkV1(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamMobileSdkV1 { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamMobileSdkV1(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamMobileSdkV1 { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamMobileSdkV1(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 SeamHttpSeamMobileSdkV1.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamMobileSdkV1.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamMobileSdkV1 { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamMobileSdkV1(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamMobileSdkV1 { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamMobileSdkV1(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 acs(): SeamHttpSeamMobileSdkV1Acs { + return SeamHttpSeamMobileSdkV1Acs.fromClient(this.client, this.defaults) + } + + get phoneSessions(): SeamHttpSeamMobileSdkV1PhoneSessions { + return SeamHttpSeamMobileSdkV1PhoneSessions.fromClient( + this.client, + this.defaults, + ) + } +} diff --git a/src/lib/seam/connect/routes/seam/partner/index.ts b/src/lib/seam/connect/routes/seam/partner/index.ts new file mode 100644 index 00000000..2e9499e7 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/partner/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 './v1/index.js' diff --git a/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/building-blocks.ts b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/building-blocks.ts new file mode 100644 index 00000000..ff9e4651 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/building-blocks.ts @@ -0,0 +1,174 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +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 type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' +import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' + +import { SeamHttpSeamPartnerV1BuildingBlocksSpaces } from './spaces/index.js' + +export class SeamHttpSeamPartnerV1BuildingBlocks { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamPartnerV1BuildingBlocks { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamPartnerV1BuildingBlocks(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamPartnerV1BuildingBlocks { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamPartnerV1BuildingBlocks(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamPartnerV1BuildingBlocks { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamPartnerV1BuildingBlocks(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 SeamHttpSeamPartnerV1BuildingBlocks.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamPartnerV1BuildingBlocks.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamPartnerV1BuildingBlocks { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamPartnerV1BuildingBlocks(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamPartnerV1BuildingBlocks { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamPartnerV1BuildingBlocks(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 spaces(): SeamHttpSeamPartnerV1BuildingBlocksSpaces { + return SeamHttpSeamPartnerV1BuildingBlocksSpaces.fromClient( + this.client, + this.defaults, + ) + } +} diff --git a/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/index.ts b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/index.ts new file mode 100644 index 00000000..234457d5 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/index.ts @@ -0,0 +1,7 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +export * from './building-blocks.js' +export * from './spaces/index.js' diff --git a/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/index.ts b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/index.ts new file mode 100644 index 00000000..af3f0bb2 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/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 './spaces.js' diff --git a/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/spaces.ts b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/spaces.ts new file mode 100644 index 00000000..acc4a45b --- /dev/null +++ b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/spaces.ts @@ -0,0 +1,196 @@ +/* + * 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 SeamHttpSeamPartnerV1BuildingBlocksSpaces { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamPartnerV1BuildingBlocksSpaces { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamPartnerV1BuildingBlocksSpaces(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamPartnerV1BuildingBlocksSpaces { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamPartnerV1BuildingBlocksSpaces(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamPartnerV1BuildingBlocksSpaces { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamPartnerV1BuildingBlocksSpaces(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 SeamHttpSeamPartnerV1BuildingBlocksSpaces.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamPartnerV1BuildingBlocksSpaces.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamPartnerV1BuildingBlocksSpaces { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamPartnerV1BuildingBlocksSpaces(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamPartnerV1BuildingBlocksSpaces { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamPartnerV1BuildingBlocksSpaces(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() + } + + autoMap( + params?: SeamPartnerV1BuildingBlocksSpacesAutoMapParams, + ): SeamHttpRequest< + SeamPartnerV1BuildingBlocksSpacesAutoMapResponse, + 'spaces' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/partner/v1/building_blocks/spaces/auto_map', + method: 'POST', + body: params, + responseKey: 'spaces', + }) + } +} + +export type SeamPartnerV1BuildingBlocksSpacesAutoMapParams = + RouteRequestBody<'/seam/partner/v1/building_blocks/spaces/auto_map'> + +export type SeamPartnerV1BuildingBlocksSpacesAutoMapResponse = SetNonNullable< + Required> +> + +export type SeamPartnerV1BuildingBlocksSpacesAutoMapOptions = never diff --git a/src/lib/seam/connect/routes/seam/partner/v1/index.ts b/src/lib/seam/connect/routes/seam/partner/v1/index.ts new file mode 100644 index 00000000..7d67e232 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/partner/v1/index.ts @@ -0,0 +1,8 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +export * from './building-blocks/index.js' +export * from './resources/index.js' +export * from './v1.js' diff --git a/src/lib/seam/connect/routes/seam/partner/v1/resources/index.ts b/src/lib/seam/connect/routes/seam/partner/v1/resources/index.ts new file mode 100644 index 00000000..60e5e587 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/partner/v1/resources/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 './resources.js' diff --git a/src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts b/src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts new file mode 100644 index 00000000..5db6887d --- /dev/null +++ b/src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts @@ -0,0 +1,190 @@ +/* + * 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 SeamHttpSeamPartnerV1Resources { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamPartnerV1Resources { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamPartnerV1Resources(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamPartnerV1Resources { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamPartnerV1Resources(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamPartnerV1Resources { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamPartnerV1Resources(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 SeamHttpSeamPartnerV1Resources.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamPartnerV1Resources.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamPartnerV1Resources { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamPartnerV1Resources(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamPartnerV1Resources { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamPartnerV1Resources(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( + params?: SeamPartnerV1ResourcesListParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/partner/v1/resources/list', + method: 'POST', + body: params, + responseKey: 'partner_resources', + }) + } +} + +export type SeamPartnerV1ResourcesListParams = + RouteRequestBody<'/seam/partner/v1/resources/list'> + +export type SeamPartnerV1ResourcesListResponse = SetNonNullable< + Required> +> + +export type SeamPartnerV1ResourcesListOptions = never diff --git a/src/lib/seam/connect/routes/seam/partner/v1/v1.ts b/src/lib/seam/connect/routes/seam/partner/v1/v1.ts new file mode 100644 index 00000000..e9088785 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/partner/v1/v1.ts @@ -0,0 +1,176 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +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 type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' +import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' + +import { SeamHttpSeamPartnerV1BuildingBlocks } from './building-blocks/index.js' +import { SeamHttpSeamPartnerV1Resources } from './resources/index.js' + +export class SeamHttpSeamPartnerV1 { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpSeamPartnerV1 { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamPartnerV1(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamPartnerV1 { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamPartnerV1(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamPartnerV1 { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamPartnerV1(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 SeamHttpSeamPartnerV1.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamPartnerV1.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamPartnerV1 { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamPartnerV1(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamPartnerV1 { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamPartnerV1(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 buildingBlocks(): SeamHttpSeamPartnerV1BuildingBlocks { + return SeamHttpSeamPartnerV1BuildingBlocks.fromClient( + this.client, + this.defaults, + ) + } + + get resources(): SeamHttpSeamPartnerV1Resources { + return SeamHttpSeamPartnerV1Resources.fromClient(this.client, this.defaults) + } +} diff --git a/src/lib/seam/connect/routes/thermostats/thermostats.ts b/src/lib/seam/connect/routes/thermostats/thermostats.ts index 06809c00..8d167a4b 100644 --- a/src/lib/seam/connect/routes/thermostats/thermostats.ts +++ b/src/lib/seam/connect/routes/thermostats/thermostats.ts @@ -233,6 +233,22 @@ export class SeamHttpThermostats { }) } + get( + params?: ThermostatsGetParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/thermostats/get', + method: 'POST', + body: params, + responseKey: 'thermostat', + }) + } + heat( body?: ThermostatsHeatBody, options: ThermostatsHeatOptions = {}, @@ -397,6 +413,14 @@ 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-access-grants/index.ts b/src/lib/seam/connect/routes/unstable-access-grants/index.ts new file mode 100644 index 00000000..a946de18 --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-access-grants/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 './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 new file mode 100644 index 00000000..069f8dbe --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-access-grants/unstable-access-grants.ts @@ -0,0 +1,265 @@ +/* + * 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) + 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( + body?: UnstableAccessGrantsCreateBody, + ): SeamHttpRequest { + 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, + responseKey: 'access_grant', + }) + } + + delete( + params?: UnstableAccessGrantsDeleteParams, + ): SeamHttpRequest { + 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: params, + responseKey: undefined, + }) + } + + get( + params?: UnstableAccessGrantsGetParams, + ): SeamHttpRequest { + 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: params, + responseKey: 'access_grant', + }) + } + + list( + params?: UnstableAccessGrantsListParams, + ): SeamHttpRequest { + 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: params, + responseKey: 'access_grants', + }) + } +} + +export type UnstableAccessGrantsCreateBody = + RouteRequestBody<'/unstable_access_grants/create'> + +export type UnstableAccessGrantsCreateResponse = SetNonNullable< + Required> +> + +export type UnstableAccessGrantsCreateOptions = never + +export type UnstableAccessGrantsDeleteParams = + RouteRequestBody<'/unstable_access_grants/delete'> + +export type UnstableAccessGrantsDeleteResponse = SetNonNullable< + Required> +> + +export type UnstableAccessGrantsDeleteOptions = never + +export type UnstableAccessGrantsGetParams = + RouteRequestBody<'/unstable_access_grants/get'> + +export type UnstableAccessGrantsGetResponse = SetNonNullable< + Required> +> + +export type UnstableAccessGrantsGetOptions = never + +export type UnstableAccessGrantsListParams = + RouteRequestBody<'/unstable_access_grants/list'> + +export type UnstableAccessGrantsListResponse = SetNonNullable< + Required> +> + +export type UnstableAccessGrantsListOptions = never diff --git a/src/lib/seam/connect/routes/unstable-access-methods/index.ts b/src/lib/seam/connect/routes/unstable-access-methods/index.ts new file mode 100644 index 00000000..39bdb594 --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-access-methods/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 './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 new file mode 100644 index 00000000..bf7cc8e8 --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-access-methods/unstable-access-methods.ts @@ -0,0 +1,240 @@ +/* + * 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) + 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( + params?: UnstableAccessMethodsDeleteParams, + ): SeamHttpRequest { + 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: params, + responseKey: undefined, + }) + } + + get( + params?: UnstableAccessMethodsGetParams, + ): SeamHttpRequest { + 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: params, + responseKey: 'access_method', + }) + } + + list( + params?: UnstableAccessMethodsListParams, + ): SeamHttpRequest { + 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: params, + responseKey: 'access_methods', + }) + } +} + +export type UnstableAccessMethodsDeleteParams = + RouteRequestBody<'/unstable_access_methods/delete'> + +export type UnstableAccessMethodsDeleteResponse = SetNonNullable< + Required> +> + +export type UnstableAccessMethodsDeleteOptions = never + +export type UnstableAccessMethodsGetParams = + RouteRequestBody<'/unstable_access_methods/get'> + +export type UnstableAccessMethodsGetResponse = SetNonNullable< + Required> +> + +export type UnstableAccessMethodsGetOptions = never + +export type UnstableAccessMethodsListParams = + RouteRequestBody<'/unstable_access_methods/list'> + +export type UnstableAccessMethodsListResponse = SetNonNullable< + Required> +> + +export type UnstableAccessMethodsListOptions = never diff --git a/src/lib/seam/connect/routes/unstable-locations/index.ts b/src/lib/seam/connect/routes/unstable-locations/index.ts new file mode 100644 index 00000000..7b6ea68c --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-locations/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 './unstable-locations.js' diff --git a/src/lib/seam/connect/routes/unstable-locations/unstable-locations.ts b/src/lib/seam/connect/routes/unstable-locations/unstable-locations.ts new file mode 100644 index 00000000..295f868f --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-locations/unstable-locations.ts @@ -0,0 +1,394 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +import type { + RouteRequestBody, + RouteRequestParams, + 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 SeamHttpUnstableLocations { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 SeamHttpUnstableLocations.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() + } + + addAcsEntrances( + body?: UnstableLocationsAddAcsEntrancesBody, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_locations/add_acs_entrances', + method: 'PUT', + body, + responseKey: undefined, + }) + } + + addDevices( + body?: UnstableLocationsAddDevicesBody, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_locations/add_devices', + method: 'PUT', + body, + responseKey: undefined, + }) + } + + create( + body?: UnstableLocationsCreateBody, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_locations/create', + method: 'POST', + body, + responseKey: 'location', + }) + } + + delete( + params?: UnstableLocationsDeleteParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_locations/delete', + method: 'POST', + body: params, + responseKey: undefined, + }) + } + + get( + params?: UnstableLocationsGetParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_locations/get', + method: 'POST', + body: params, + responseKey: 'location', + }) + } + + list( + params?: UnstableLocationsListParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_locations/list', + method: 'GET', + params, + responseKey: 'locations', + }) + } + + removeAcsEntrances( + params?: UnstableLocationsRemoveAcsEntrancesParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_locations/remove_acs_entrances', + method: 'POST', + body: params, + responseKey: undefined, + }) + } + + removeDevices( + params?: UnstableLocationsRemoveDevicesParams, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_locations/remove_devices', + method: 'POST', + body: params, + responseKey: undefined, + }) + } + + update( + body?: UnstableLocationsUpdateBody, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_locations/update', + method: 'PATCH', + body, + responseKey: 'location', + }) + } +} + +export type UnstableLocationsAddAcsEntrancesBody = + RouteRequestBody<'/unstable_locations/add_acs_entrances'> + +export type UnstableLocationsAddAcsEntrancesResponse = SetNonNullable< + Required> +> + +export type UnstableLocationsAddAcsEntrancesOptions = never + +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 = + RouteRequestParams<'/unstable_locations/list'> + +export type UnstableLocationsListResponse = SetNonNullable< + Required> +> + +export type UnstableLocationsListOptions = never + +export type UnstableLocationsRemoveAcsEntrancesParams = + RouteRequestBody<'/unstable_locations/remove_acs_entrances'> + +export type UnstableLocationsRemoveAcsEntrancesResponse = SetNonNullable< + Required> +> + +export type UnstableLocationsRemoveAcsEntrancesOptions = 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 diff --git a/src/lib/seam/connect/routes/unstable-partner/building-blocks/building-blocks.ts b/src/lib/seam/connect/routes/unstable-partner/building-blocks/building-blocks.ts new file mode 100644 index 00000000..b6865661 --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-partner/building-blocks/building-blocks.ts @@ -0,0 +1,287 @@ +/* + * 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 SeamHttpUnstablePartnerBuildingBlocks { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpUnstablePartnerBuildingBlocks { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpUnstablePartnerBuildingBlocks(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpUnstablePartnerBuildingBlocks { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpUnstablePartnerBuildingBlocks(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpUnstablePartnerBuildingBlocks { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpUnstablePartnerBuildingBlocks(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 SeamHttpUnstablePartnerBuildingBlocks.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpUnstablePartnerBuildingBlocks.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpUnstablePartnerBuildingBlocks { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpUnstablePartnerBuildingBlocks(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpUnstablePartnerBuildingBlocks { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpUnstablePartnerBuildingBlocks(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() + } + + connectAccounts( + body?: UnstablePartnerBuildingBlocksConnectAccountsBody, + ): SeamHttpRequest< + UnstablePartnerBuildingBlocksConnectAccountsResponse, + 'magic_link' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_partner/building_blocks/connect_accounts', + method: 'POST', + body, + responseKey: 'magic_link', + }) + } + + generateMagicLink( + params?: UnstablePartnerBuildingBlocksGenerateMagicLinkParams, + ): SeamHttpRequest< + UnstablePartnerBuildingBlocksGenerateMagicLinkResponse, + 'magic_link' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_partner/building_blocks/generate_magic_link', + method: 'POST', + body: params, + responseKey: 'magic_link', + }) + } + + manageDevices( + body?: UnstablePartnerBuildingBlocksManageDevicesBody, + ): SeamHttpRequest< + UnstablePartnerBuildingBlocksManageDevicesResponse, + 'magic_link' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_partner/building_blocks/manage_devices', + method: 'POST', + body, + responseKey: 'magic_link', + }) + } + + organizeSpaces( + body?: UnstablePartnerBuildingBlocksOrganizeSpacesBody, + ): SeamHttpRequest< + UnstablePartnerBuildingBlocksOrganizeSpacesResponse, + 'magic_link' + > { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_partner/building_blocks/organize_spaces', + method: 'POST', + body, + responseKey: 'magic_link', + }) + } +} + +export type UnstablePartnerBuildingBlocksConnectAccountsBody = + RouteRequestBody<'/unstable_partner/building_blocks/connect_accounts'> + +export type UnstablePartnerBuildingBlocksConnectAccountsResponse = + SetNonNullable< + Required< + RouteResponse<'/unstable_partner/building_blocks/connect_accounts'> + > + > + +export type UnstablePartnerBuildingBlocksConnectAccountsOptions = never + +export type UnstablePartnerBuildingBlocksGenerateMagicLinkParams = + RouteRequestBody<'/unstable_partner/building_blocks/generate_magic_link'> + +export type UnstablePartnerBuildingBlocksGenerateMagicLinkResponse = + SetNonNullable< + Required< + RouteResponse<'/unstable_partner/building_blocks/generate_magic_link'> + > + > + +export type UnstablePartnerBuildingBlocksGenerateMagicLinkOptions = never + +export type UnstablePartnerBuildingBlocksManageDevicesBody = + RouteRequestBody<'/unstable_partner/building_blocks/manage_devices'> + +export type UnstablePartnerBuildingBlocksManageDevicesResponse = SetNonNullable< + Required> +> + +export type UnstablePartnerBuildingBlocksManageDevicesOptions = never + +export type UnstablePartnerBuildingBlocksOrganizeSpacesBody = + RouteRequestBody<'/unstable_partner/building_blocks/organize_spaces'> + +export type UnstablePartnerBuildingBlocksOrganizeSpacesResponse = + SetNonNullable< + Required> + > + +export type UnstablePartnerBuildingBlocksOrganizeSpacesOptions = never diff --git a/src/lib/seam/connect/routes/unstable-partner/building-blocks/index.ts b/src/lib/seam/connect/routes/unstable-partner/building-blocks/index.ts new file mode 100644 index 00000000..fccad75d --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-partner/building-blocks/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 './building-blocks.js' diff --git a/src/lib/seam/connect/routes/unstable-partner/index.ts b/src/lib/seam/connect/routes/unstable-partner/index.ts new file mode 100644 index 00000000..751f59ff --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-partner/index.ts @@ -0,0 +1,8 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +export * from './building-blocks/index.js' +export * from './resources/index.js' +export * from './unstable-partner.js' diff --git a/src/lib/seam/connect/routes/unstable-partner/resources/index.ts b/src/lib/seam/connect/routes/unstable-partner/resources/index.ts new file mode 100644 index 00000000..60e5e587 --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-partner/resources/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 './resources.js' diff --git a/src/lib/seam/connect/routes/unstable-partner/resources/resources.ts b/src/lib/seam/connect/routes/unstable-partner/resources/resources.ts new file mode 100644 index 00000000..aa786116 --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-partner/resources/resources.ts @@ -0,0 +1,193 @@ +/* + * 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 SeamHttpUnstablePartnerResources { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpUnstablePartnerResources { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpUnstablePartnerResources(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpUnstablePartnerResources { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpUnstablePartnerResources(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpUnstablePartnerResources { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpUnstablePartnerResources(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 SeamHttpUnstablePartnerResources.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpUnstablePartnerResources.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpUnstablePartnerResources { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpUnstablePartnerResources(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpUnstablePartnerResources { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpUnstablePartnerResources(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() + } + + push( + body?: UnstablePartnerResourcesPushBody, + ): SeamHttpRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/unstable_partner/resources/push', + method: 'POST', + body, + responseKey: undefined, + }) + } +} + +export type UnstablePartnerResourcesPushBody = + RouteRequestBody<'/unstable_partner/resources/push'> + +export type UnstablePartnerResourcesPushResponse = SetNonNullable< + Required> +> + +export type UnstablePartnerResourcesPushOptions = never diff --git a/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts b/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts new file mode 100644 index 00000000..f93a268e --- /dev/null +++ b/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts @@ -0,0 +1,179 @@ +/* + * Automatically generated by codegen/smith.ts. + * Do not edit this file or add other files to this directory. + */ + +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 type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' +import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' + +import { SeamHttpUnstablePartnerBuildingBlocks } from './building-blocks/index.js' +import { SeamHttpUnstablePartnerResources } from './resources/index.js' + +export class SeamHttpUnstablePartner { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + 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 = {}, + ): SeamHttpUnstablePartner { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpUnstablePartner(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpUnstablePartner { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpUnstablePartner(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpUnstablePartner { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpUnstablePartner(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 SeamHttpUnstablePartner.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpUnstablePartner.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpUnstablePartner { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpUnstablePartner(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpUnstablePartner { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpUnstablePartner(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 buildingBlocks(): SeamHttpUnstablePartnerBuildingBlocks { + return SeamHttpUnstablePartnerBuildingBlocks.fromClient( + this.client, + this.defaults, + ) + } + + get resources(): SeamHttpUnstablePartnerResources { + return SeamHttpUnstablePartnerResources.fromClient( + this.client, + this.defaults, + ) + } +} From 46ae77e2293964597a09c923f66b0dfbbad32557 Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Tue, 24 Jun 2025 15:40:27 -0700 Subject: [PATCH 5/7] Add test for undocumented flag --- test/seam/connect/undocumented.test.ts | 96 ++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 test/seam/connect/undocumented.test.ts diff --git a/test/seam/connect/undocumented.test.ts b/test/seam/connect/undocumented.test.ts new file mode 100644 index 00000000..17512b2f --- /dev/null +++ b/test/seam/connect/undocumented.test.ts @@ -0,0 +1,96 @@ +import test from 'ava' +import { AxiosError } from 'axios' +import { getTestServer } from 'fixtures/seam/connect/api.js' + +import { + SeamHttp, + SeamHttpAcsAccessGroupsUnmanaged, + SeamHttpEndpoints, +} from '@seamapi/http/connect' + +test('SeamHttp: must use isUndocumentedApiEnabled to use undocumented route', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }) + t.throws(() => seam.acs.accessGroups.unmanaged, { + message: /Cannot use undocumented/, + }) + const seamUndocumented = SeamHttp.fromApiKey(seed.seam_apikey1_token, { + endpoint, + isUndocumentedApiEnabled: true, + }) + t.truthy(seamUndocumented.acs.accessGroups.unmanaged) +}) + +test('SeamHttp: must use isUndocumentedApiEnabled to use undocumented endpoint', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }) + t.truthy(seam.devices) + await t.throwsAsync( + async () => { + await seam.devices.delete() + }, + { + message: /Cannot use undocumented/, + }, + ) + const seamUndocumented = SeamHttp.fromApiKey(seed.seam_apikey1_token, { + endpoint, + isUndocumentedApiEnabled: true, + }) + t.truthy(seamUndocumented.devices) + await seamUndocumented.devices.delete({ device_id: seed.august_device_1 }) + t.pass() +}) + +test('SeamHttpAcsAccessGroupsUnmanaged: must use isUndocumentedApiEnabled', async (t) => { + const { seed, endpoint } = await getTestServer(t) + t.throws( + () => { + SeamHttpAcsAccessGroupsUnmanaged.fromApiKey(seed.seam_apikey1_token, { + endpoint, + }) + }, + { message: /Cannot use undocumented/ }, + ) + t.truthy( + SeamHttpAcsAccessGroupsUnmanaged.fromApiKey(seed.seam_apikey1_token, { + endpoint, + isUndocumentedApiEnabled: true, + }), + ) +}) + +test('SeamHttpEndpoints: cannot use undocumented endpoint', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = SeamHttpEndpoints.fromApiKey(seed.seam_apikey1_token, { + endpoint, + }) + await t.throwsAsync( + async () => { + await seam['/acs/access_groups/unmanaged/list']() + }, + { message: /Cannot use undocumented/ }, + ) + const seamUndocumented = SeamHttpEndpoints.fromApiKey( + seed.seam_apikey1_token, + { + endpoint, + isUndocumentedApiEnabled: true, + }, + ) + await t.throwsAsync( + async () => { + await seamUndocumented['/acs/access_groups/unmanaged/list']() + }, + { + instanceOf: AxiosError, + }, + ) +}) + +test.todo( + 'SeamHttpMultiWorkspace: must use isUndocumentedApiEnabled to use undocumented route', +) +test.todo( + 'SeamHttpMultiWorkspace: must use isUndocumentedApiEnabled to use undocumented endpoint', +) From e3fa94ab97b7730987601fea38374453e9092983 Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Tue, 24 Jun 2025 15:54:38 -0700 Subject: [PATCH 6/7] Fix isUndocumentedApiEnabled generation --- codegen/layouts/partials/route-class-methods.hbs | 10 +++++----- codegen/lib/layouts/route.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/codegen/layouts/partials/route-class-methods.hbs b/codegen/layouts/partials/route-class-methods.hbs index 9026a531..9a03faaa 100644 --- a/codegen/layouts/partials/route-class-methods.hbs +++ b/codegen/layouts/partials/route-class-methods.hbs @@ -5,6 +5,11 @@ static ltsVersion = seamApiLtsVersion constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { const options = parseOptions(apiKeyOrOptions) + {{#if isUndocumented}} + if (!options.isUndocumentedApiEnabled) { + throw new Error('Cannot use undocumented API without isUndocumentedApiEnabled') + } + {{/if}} this.client = 'client' in options ? options.client : createClient(options) this.defaults = limitToSeamHttpRequestOptions(options) } @@ -17,11 +22,6 @@ static fromClient( if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } - {{#if isUndocumented}} - if (!options.isUndocumentedApiEnabled) { - throw new Error('Cannot use undocumented API without isUndocumentedApiEnabled') - } - {{/if}} return new {{className}}(constructorOptions) } diff --git a/codegen/lib/layouts/route.ts b/codegen/lib/layouts/route.ts index b00c1867..92fa0360 100644 --- a/codegen/lib/layouts/route.ts +++ b/codegen/lib/layouts/route.ts @@ -4,6 +4,7 @@ import { camelCase, kebabCase, pascalCase } from 'change-case' export interface RouteLayoutContext { className: string + isUndocumented: boolean endpoints: EndpointLayoutContext[] subroutes: SubrouteLayoutContext[] skipClientSessionImport: boolean @@ -37,7 +38,6 @@ export interface SubrouteLayoutContext { methodName: string className: string fileName: string - isUndocumented: boolean } export const setRouteLayoutContext = ( @@ -46,6 +46,7 @@ export const setRouteLayoutContext = ( nodes: Array, ): void => { file.className = getClassName(node?.path ?? null) + file.isUndocumented = node?.isUndocumented ?? false file.skipClientSessionImport = node == null || node?.path === '/client_sessions' @@ -69,7 +70,6 @@ const getSubrouteLayoutContext = ( fileName: `${kebabCase(route.name)}/index.js`, methodName: camelCase(route.name), className: getClassName(route.path), - isUndocumented: route.isUndocumented, } } From ad0ccb39394c2eb5edfc14bbb816696b192f3a9d Mon Sep 17 00:00:00 2001 From: Seam Bot Date: Tue, 24 Jun 2025 22:56:25 +0000 Subject: [PATCH 7/7] ci: Generate code --- .../connect/routes/acs/access-groups/unmanaged/unmanaged.ts | 5 +++++ .../connect/routes/acs/credential-pools/credential-pools.ts | 5 +++++ .../credential-provisioning-automations.ts | 5 +++++ .../connect/routes/acs/credentials/unmanaged/unmanaged.ts | 5 +++++ src/lib/seam/connect/routes/acs/users/unmanaged/unmanaged.ts | 5 +++++ src/lib/seam/connect/routes/bridges/bridges.ts | 5 +++++ src/lib/seam/connect/routes/locks/simulate/simulate.ts | 5 +++++ src/lib/seam/connect/routes/networks/networks.ts | 5 +++++ .../v1/bridge-client-sessions/bridge-client-sessions.ts | 5 +++++ .../v1/bridge-connected-systems/bridge-connected-systems.ts | 5 +++++ src/lib/seam/connect/routes/seam/bridge/v1/v1.ts | 5 +++++ .../seam/instant-key/v1/client-sessions/client-sessions.ts | 5 +++++ src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts | 5 +++++ src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts | 5 +++++ .../routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts | 5 +++++ .../seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts | 5 +++++ src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts | 5 +++++ .../seam/partner/v1/building-blocks/building-blocks.ts | 5 +++++ .../routes/seam/partner/v1/building-blocks/spaces/spaces.ts | 5 +++++ .../connect/routes/seam/partner/v1/resources/resources.ts | 5 +++++ src/lib/seam/connect/routes/seam/partner/v1/v1.ts | 5 +++++ .../routes/unstable-access-grants/unstable-access-grants.ts | 5 +++++ .../unstable-access-methods/unstable-access-methods.ts | 5 +++++ .../connect/routes/unstable-locations/unstable-locations.ts | 5 +++++ .../unstable-partner/building-blocks/building-blocks.ts | 5 +++++ .../connect/routes/unstable-partner/resources/resources.ts | 5 +++++ .../seam/connect/routes/unstable-partner/unstable-partner.ts | 5 +++++ 27 files changed, 135 insertions(+) diff --git a/src/lib/seam/connect/routes/acs/access-groups/unmanaged/unmanaged.ts b/src/lib/seam/connect/routes/acs/access-groups/unmanaged/unmanaged.ts index 4ca621d1..32860066 100644 --- a/src/lib/seam/connect/routes/acs/access-groups/unmanaged/unmanaged.ts +++ b/src/lib/seam/connect/routes/acs/access-groups/unmanaged/unmanaged.ts @@ -44,6 +44,11 @@ export class SeamHttpAcsAccessGroupsUnmanaged { 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) } diff --git a/src/lib/seam/connect/routes/acs/credential-pools/credential-pools.ts b/src/lib/seam/connect/routes/acs/credential-pools/credential-pools.ts index b8ad5270..40f4611a 100644 --- a/src/lib/seam/connect/routes/acs/credential-pools/credential-pools.ts +++ b/src/lib/seam/connect/routes/acs/credential-pools/credential-pools.ts @@ -44,6 +44,11 @@ export class SeamHttpAcsCredentialPools { 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) } diff --git a/src/lib/seam/connect/routes/acs/credential-provisioning-automations/credential-provisioning-automations.ts b/src/lib/seam/connect/routes/acs/credential-provisioning-automations/credential-provisioning-automations.ts index 95715a0c..47572b0c 100644 --- a/src/lib/seam/connect/routes/acs/credential-provisioning-automations/credential-provisioning-automations.ts +++ b/src/lib/seam/connect/routes/acs/credential-provisioning-automations/credential-provisioning-automations.ts @@ -44,6 +44,11 @@ export class SeamHttpAcsCredentialProvisioningAutomations { 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) } diff --git a/src/lib/seam/connect/routes/acs/credentials/unmanaged/unmanaged.ts b/src/lib/seam/connect/routes/acs/credentials/unmanaged/unmanaged.ts index 3b9c94f9..8133a4ae 100644 --- a/src/lib/seam/connect/routes/acs/credentials/unmanaged/unmanaged.ts +++ b/src/lib/seam/connect/routes/acs/credentials/unmanaged/unmanaged.ts @@ -48,6 +48,11 @@ export class SeamHttpAcsCredentialsUnmanaged { 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) } diff --git a/src/lib/seam/connect/routes/acs/users/unmanaged/unmanaged.ts b/src/lib/seam/connect/routes/acs/users/unmanaged/unmanaged.ts index 18730a1b..3e73b95c 100644 --- a/src/lib/seam/connect/routes/acs/users/unmanaged/unmanaged.ts +++ b/src/lib/seam/connect/routes/acs/users/unmanaged/unmanaged.ts @@ -44,6 +44,11 @@ export class SeamHttpAcsUsersUnmanaged { 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) } diff --git a/src/lib/seam/connect/routes/bridges/bridges.ts b/src/lib/seam/connect/routes/bridges/bridges.ts index 3f4c786f..3fd31aaa 100644 --- a/src/lib/seam/connect/routes/bridges/bridges.ts +++ b/src/lib/seam/connect/routes/bridges/bridges.ts @@ -44,6 +44,11 @@ export class SeamHttpBridges { 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) } diff --git a/src/lib/seam/connect/routes/locks/simulate/simulate.ts b/src/lib/seam/connect/routes/locks/simulate/simulate.ts index 3dcb53d3..d02688fe 100644 --- a/src/lib/seam/connect/routes/locks/simulate/simulate.ts +++ b/src/lib/seam/connect/routes/locks/simulate/simulate.ts @@ -44,6 +44,11 @@ export class SeamHttpLocksSimulate { 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) } diff --git a/src/lib/seam/connect/routes/networks/networks.ts b/src/lib/seam/connect/routes/networks/networks.ts index 396332a5..8d205124 100644 --- a/src/lib/seam/connect/routes/networks/networks.ts +++ b/src/lib/seam/connect/routes/networks/networks.ts @@ -44,6 +44,11 @@ export class SeamHttpNetworks { 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) } diff --git a/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.ts b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.ts index 07b86ff0..9d4a845d 100644 --- a/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.ts +++ b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.ts @@ -48,6 +48,11 @@ export class SeamHttpSeamBridgeV1BridgeClientSessions { 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) } diff --git a/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.ts b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.ts index cc7095ae..0f135f08 100644 --- a/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.ts +++ b/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.ts @@ -44,6 +44,11 @@ export class SeamHttpSeamBridgeV1BridgeConnectedSystems { 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) } diff --git a/src/lib/seam/connect/routes/seam/bridge/v1/v1.ts b/src/lib/seam/connect/routes/seam/bridge/v1/v1.ts index 7ee3e7e1..882d6476 100644 --- a/src/lib/seam/connect/routes/seam/bridge/v1/v1.ts +++ b/src/lib/seam/connect/routes/seam/bridge/v1/v1.ts @@ -44,6 +44,11 @@ export class SeamHttpSeamBridgeV1 { 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) } diff --git a/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.ts b/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.ts index e9d366ae..60d3c092 100644 --- a/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.ts +++ b/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.ts @@ -44,6 +44,11 @@ export class SeamHttpSeamInstantKeyV1ClientSessions { 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) } diff --git a/src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts b/src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts index c4549129..edefe6d9 100644 --- a/src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts +++ b/src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts @@ -43,6 +43,11 @@ export class SeamHttpSeamInstantKeyV1 { 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) } diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts index 034bbe35..fcdc6f0a 100644 --- a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts @@ -43,6 +43,11 @@ export class SeamHttpSeamMobileSdkV1Acs { 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) } diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts index 29d4e140..c03b46df 100644 --- a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts @@ -44,6 +44,11 @@ export class SeamHttpSeamMobileSdkV1AcsCredentials { 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) } diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts index 7eb019c1..2e739cec 100644 --- a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts @@ -44,6 +44,11 @@ export class SeamHttpSeamMobileSdkV1PhoneSessions { 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) } diff --git a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts index b99cebed..d4ba06ef 100644 --- a/src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts +++ b/src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts @@ -44,6 +44,11 @@ export class SeamHttpSeamMobileSdkV1 { 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) } diff --git a/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/building-blocks.ts b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/building-blocks.ts index ff9e4651..bacf84da 100644 --- a/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/building-blocks.ts +++ b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/building-blocks.ts @@ -43,6 +43,11 @@ export class SeamHttpSeamPartnerV1BuildingBlocks { 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) } diff --git a/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/spaces.ts b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/spaces.ts index acc4a45b..38d5de68 100644 --- a/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/spaces.ts +++ b/src/lib/seam/connect/routes/seam/partner/v1/building-blocks/spaces/spaces.ts @@ -44,6 +44,11 @@ export class SeamHttpSeamPartnerV1BuildingBlocksSpaces { 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) } diff --git a/src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts b/src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts index 5db6887d..207c6aa8 100644 --- a/src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts +++ b/src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts @@ -44,6 +44,11 @@ export class SeamHttpSeamPartnerV1Resources { 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) } diff --git a/src/lib/seam/connect/routes/seam/partner/v1/v1.ts b/src/lib/seam/connect/routes/seam/partner/v1/v1.ts index e9088785..0e293c57 100644 --- a/src/lib/seam/connect/routes/seam/partner/v1/v1.ts +++ b/src/lib/seam/connect/routes/seam/partner/v1/v1.ts @@ -44,6 +44,11 @@ export class SeamHttpSeamPartnerV1 { 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) } 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 index 069f8dbe..6f1055d8 100644 --- 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 @@ -44,6 +44,11 @@ export class SeamHttpUnstableAccessGrants { 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) } 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 index bf7cc8e8..dbe7654b 100644 --- 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 @@ -44,6 +44,11 @@ export class SeamHttpUnstableAccessMethods { 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) } diff --git a/src/lib/seam/connect/routes/unstable-locations/unstable-locations.ts b/src/lib/seam/connect/routes/unstable-locations/unstable-locations.ts index 295f868f..32588748 100644 --- a/src/lib/seam/connect/routes/unstable-locations/unstable-locations.ts +++ b/src/lib/seam/connect/routes/unstable-locations/unstable-locations.ts @@ -48,6 +48,11 @@ export class SeamHttpUnstableLocations { 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) } diff --git a/src/lib/seam/connect/routes/unstable-partner/building-blocks/building-blocks.ts b/src/lib/seam/connect/routes/unstable-partner/building-blocks/building-blocks.ts index b6865661..25162d0f 100644 --- a/src/lib/seam/connect/routes/unstable-partner/building-blocks/building-blocks.ts +++ b/src/lib/seam/connect/routes/unstable-partner/building-blocks/building-blocks.ts @@ -44,6 +44,11 @@ export class SeamHttpUnstablePartnerBuildingBlocks { 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) } diff --git a/src/lib/seam/connect/routes/unstable-partner/resources/resources.ts b/src/lib/seam/connect/routes/unstable-partner/resources/resources.ts index aa786116..67506584 100644 --- a/src/lib/seam/connect/routes/unstable-partner/resources/resources.ts +++ b/src/lib/seam/connect/routes/unstable-partner/resources/resources.ts @@ -44,6 +44,11 @@ export class SeamHttpUnstablePartnerResources { 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) } diff --git a/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts b/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts index f93a268e..8f57e45f 100644 --- a/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts +++ b/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts @@ -44,6 +44,11 @@ export class SeamHttpUnstablePartner { 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) }