From 4ed648b689376009d9f63ce73b57037ca5a99b86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Jul 2025 06:52:13 +0000 Subject: [PATCH 1/2] feat(deps-dev): bump @seamapi/types in the seam group Bumps the seam group with 1 update: [@seamapi/types](https://github.com/seamapi/types). Updates `@seamapi/types` from 1.423.2 to 1.433.0 - [Release notes](https://github.com/seamapi/types/releases) - [Changelog](https://github.com/seamapi/types/blob/main/.releaserc.json) - [Commits](https://github.com/seamapi/types/compare/v1.423.2...v1.433.0) --- updated-dependencies: - dependency-name: "@seamapi/types" dependency-version: 1.433.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: seam ... Signed-off-by: dependabot[bot] --- package-lock.json | 9 ++++----- package.json | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 879bde79..779af792 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@seamapi/blueprint": "^0.51.1", "@seamapi/fake-seam-connect": "^1.77.0", "@seamapi/smith": "^0.4.4", - "@seamapi/types": "1.423.2", + "@seamapi/types": "1.433.0", "@swc/core": "^1.11.29", "@types/eslint": "^8.44.2", "@types/jsonwebtoken": "^9.0.6", @@ -1216,11 +1216,10 @@ } }, "node_modules/@seamapi/types": { - "version": "1.423.2", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.423.2.tgz", - "integrity": "sha512-EfMNHNE0k3Mp+AgjEDzzmnjsvOf7yrt9qG5ZZkjVqaTGsOAYTRjrRMLFz37s8My+evXn8i0Ry4wijhoXKhFviw==", + "version": "1.433.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.433.0.tgz", + "integrity": "sha512-Wj1SrJ3ONeRrwDnffeK8Cwd83n/zxvIGRUQ6e5n/2hP5SQ9z/fORWekpy4o1MTd7xGQawBEYLEwROq/wtn3xFw==", "dev": true, - "license": "MIT", "engines": { "node": ">=18.12.0", "npm": ">= 9.0.0" diff --git a/package.json b/package.json index ea3ff515..f5bf4284 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "@seamapi/blueprint": "^0.51.1", "@seamapi/fake-seam-connect": "^1.77.0", "@seamapi/smith": "^0.4.4", - "@seamapi/types": "1.423.2", + "@seamapi/types": "1.433.0", "@swc/core": "^1.11.29", "@types/eslint": "^8.44.2", "@types/jsonwebtoken": "^9.0.6", From ddfaa0028603753af46252930521c68d67242650 Mon Sep 17 00:00:00 2001 From: Seam Bot Date: Wed, 2 Jul 2025 06:53:14 +0000 Subject: [PATCH 2/2] ci: Generate code --- package-lock.json | 2 +- package.json | 2 +- .../routes/access-methods/access-methods.ts | 38 +++ .../connect/routes/acs/encoders/encoders.ts | 39 --- .../connect/routes/seam-http-endpoints.ts | 149 +++++++-- .../v1/automation-runs/automation-runs.ts | 215 +++++++++++++ .../seam/customer/v1/automation-runs/index.ts | 6 + .../customer/v1/automations/automations.ts | 303 ++++++++++++++++++ .../seam/customer/v1/automations/index.ts | 6 + .../connect/routes/seam/customer/v1/index.ts | 2 + .../connect/routes/seam/customer/v1/v1.ts | 16 + 11 files changed, 716 insertions(+), 62 deletions(-) create mode 100644 src/lib/seam/connect/routes/seam/customer/v1/automation-runs/automation-runs.ts create mode 100644 src/lib/seam/connect/routes/seam/customer/v1/automation-runs/index.ts create mode 100644 src/lib/seam/connect/routes/seam/customer/v1/automations/automations.ts create mode 100644 src/lib/seam/connect/routes/seam/customer/v1/automations/index.ts diff --git a/package-lock.json b/package-lock.json index 779af792..9e01e472 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.423.2" + "@seamapi/types": "^1.433.0" }, "peerDependenciesMeta": { "@seamapi/types": { diff --git a/package.json b/package.json index f5bf4284..4b9db77d 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.423.2" + "@seamapi/types": "^1.433.0" }, "peerDependenciesMeta": { "@seamapi/types": { diff --git a/src/lib/seam/connect/routes/access-methods/access-methods.ts b/src/lib/seam/connect/routes/access-methods/access-methods.ts index 83131775..5a5f09be 100644 --- a/src/lib/seam/connect/routes/access-methods/access-methods.ts +++ b/src/lib/seam/connect/routes/access-methods/access-methods.ts @@ -176,6 +176,19 @@ export class SeamHttpAccessMethods { }) } + encode( + parameters?: AccessMethodsEncodeParameters, + options: AccessMethodsEncodeOptions = {}, + ): AccessMethodsEncodeRequest { + return new SeamHttpRequest(this, { + pathname: '/access_methods/encode', + method: 'POST', + body: parameters, + responseKey: 'action_attempt', + options, + }) + } + get( parameters?: AccessMethodsGetParameters, options: AccessMethodsGetOptions = {}, @@ -223,6 +236,31 @@ export type AccessMethodsDeleteRequest = SeamHttpRequest // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface AccessMethodsDeleteOptions {} +export type AccessMethodsEncodeParameters = + RouteRequestBody<'/access_methods/encode'> + +/** + * @deprecated Use AccessMethodsEncodeParameters instead. + */ +export type AccessMethodsEncodeBody = AccessMethodsEncodeParameters + +/** + * @deprecated Use AccessMethodsEncodeRequest instead. + */ +export type AccessMethodsEncodeResponse = SetNonNullable< + Required> +> + +export type AccessMethodsEncodeRequest = SeamHttpRequest< + AccessMethodsEncodeResponse, + 'action_attempt' +> + +export type AccessMethodsEncodeOptions = Pick< + SeamHttpRequestOptions, + 'waitForActionAttempt' +> + export type AccessMethodsGetParameters = RouteRequestBody<'/access_methods/get'> /** diff --git a/src/lib/seam/connect/routes/acs/encoders/encoders.ts b/src/lib/seam/connect/routes/acs/encoders/encoders.ts index 7cfcf8a2..f90dc34f 100644 --- a/src/lib/seam/connect/routes/acs/encoders/encoders.ts +++ b/src/lib/seam/connect/routes/acs/encoders/encoders.ts @@ -173,19 +173,6 @@ export class SeamHttpAcsEncoders { return SeamHttpAcsEncodersSimulate.fromClient(this.client, this.defaults) } - encodeAccessMethod( - parameters?: AcsEncodersEncodeAccessMethodParameters, - options: AcsEncodersEncodeAccessMethodOptions = {}, - ): AcsEncodersEncodeAccessMethodRequest { - return new SeamHttpRequest(this, { - pathname: '/acs/encoders/encode_access_method', - method: 'POST', - body: parameters, - responseKey: 'action_attempt', - options, - }) - } - encodeCredential( parameters?: AcsEncodersEncodeCredentialParameters, options: AcsEncodersEncodeCredentialOptions = {}, @@ -239,32 +226,6 @@ export class SeamHttpAcsEncoders { } } -export type AcsEncodersEncodeAccessMethodParameters = - RouteRequestBody<'/acs/encoders/encode_access_method'> - -/** - * @deprecated Use AcsEncodersEncodeAccessMethodParameters instead. - */ -export type AcsEncodersEncodeAccessMethodBody = - AcsEncodersEncodeAccessMethodParameters - -/** - * @deprecated Use AcsEncodersEncodeAccessMethodRequest instead. - */ -export type AcsEncodersEncodeAccessMethodResponse = SetNonNullable< - Required> -> - -export type AcsEncodersEncodeAccessMethodRequest = SeamHttpRequest< - AcsEncodersEncodeAccessMethodResponse, - 'action_attempt' -> - -export type AcsEncodersEncodeAccessMethodOptions = Pick< - SeamHttpRequestOptions, - 'waitForActionAttempt' -> - export type AcsEncodersEncodeCredentialParameters = RouteRequestBody<'/acs/encoders/encode_credential'> diff --git a/src/lib/seam/connect/routes/seam-http-endpoints.ts b/src/lib/seam/connect/routes/seam-http-endpoints.ts index 0482b268..1db555e1 100644 --- a/src/lib/seam/connect/routes/seam-http-endpoints.ts +++ b/src/lib/seam/connect/routes/seam-http-endpoints.ts @@ -111,6 +111,9 @@ import { type AccessMethodsDeleteOptions, type AccessMethodsDeleteParameters, type AccessMethodsDeleteRequest, + type AccessMethodsEncodeOptions, + type AccessMethodsEncodeParameters, + type AccessMethodsEncodeRequest, type AccessMethodsGetOptions, type AccessMethodsGetParameters, type AccessMethodsGetRequest, @@ -201,9 +204,6 @@ import { SeamHttpAcsCredentialsUnmanaged, } from './acs/credentials/unmanaged/index.js' import { - type AcsEncodersEncodeAccessMethodOptions, - type AcsEncodersEncodeAccessMethodParameters, - type AcsEncodersEncodeAccessMethodRequest, type AcsEncodersEncodeCredentialOptions, type AcsEncodersEncodeCredentialParameters, type AcsEncodersEncodeCredentialRequest, @@ -521,6 +521,24 @@ import { type PhonesSimulateCreateSandboxPhoneRequest, SeamHttpPhonesSimulate, } from './phones/simulate/index.js' +import { + type SeamCustomerV1AutomationRunsListOptions, + type SeamCustomerV1AutomationRunsListParameters, + type SeamCustomerV1AutomationRunsListRequest, + SeamHttpSeamCustomerV1AutomationRuns, +} from './seam/customer/v1/automation-runs/index.js' +import { + type SeamCustomerV1AutomationsDeleteOptions, + type SeamCustomerV1AutomationsDeleteParameters, + type SeamCustomerV1AutomationsDeleteRequest, + type SeamCustomerV1AutomationsGetOptions, + type SeamCustomerV1AutomationsGetParameters, + type SeamCustomerV1AutomationsGetRequest, + type SeamCustomerV1AutomationsUpdateOptions, + type SeamCustomerV1AutomationsUpdateParameters, + type SeamCustomerV1AutomationsUpdateRequest, + SeamHttpSeamCustomerV1Automations, +} from './seam/customer/v1/automations/index.js' import { type SeamCustomerV1PortalsGetOptions, type SeamCustomerV1PortalsGetParameters, @@ -1237,6 +1255,19 @@ export class SeamHttpEndpoints { } } + get ['/access_methods/encode'](): ( + parameters?: AccessMethodsEncodeParameters, + options?: AccessMethodsEncodeOptions, + ) => AccessMethodsEncodeRequest { + const { client, defaults } = this + return function accessMethodsEncode( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpAccessMethods.fromClient(client, defaults) + return seam.encode(...args) + } + } + get ['/access_methods/get'](): ( parameters?: AccessMethodsGetParameters, options?: AccessMethodsGetOptions, @@ -1576,19 +1607,6 @@ export class SeamHttpEndpoints { } } - get ['/acs/encoders/encode_access_method'](): ( - parameters?: AcsEncodersEncodeAccessMethodParameters, - options?: AcsEncodersEncodeAccessMethodOptions, - ) => AcsEncodersEncodeAccessMethodRequest { - const { client, defaults } = this - return function acsEncodersEncodeAccessMethod( - ...args: Parameters - ): ReturnType { - const seam = SeamHttpAcsEncoders.fromClient(client, defaults) - return seam.encodeAccessMethod(...args) - } - } - get ['/acs/encoders/encode_credential'](): ( parameters?: AcsEncodersEncodeCredentialParameters, options?: AcsEncodersEncodeCredentialOptions, @@ -2731,6 +2749,90 @@ export class SeamHttpEndpoints { } } + get ['/seam/customer/v1/automation_runs/list'](): ( + parameters?: SeamCustomerV1AutomationRunsListParameters, + options?: SeamCustomerV1AutomationRunsListOptions, + ) => SeamCustomerV1AutomationRunsListRequest { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamCustomerV1AutomationRunsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1AutomationRuns.fromClient( + client, + defaults, + ) + return seam.list(...args) + } + } + + get ['/seam/customer/v1/automations/delete'](): ( + parameters?: SeamCustomerV1AutomationsDeleteParameters, + options?: SeamCustomerV1AutomationsDeleteOptions, + ) => SeamCustomerV1AutomationsDeleteRequest { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamCustomerV1AutomationsDelete( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1Automations.fromClient( + client, + defaults, + ) + return seam.delete(...args) + } + } + + get ['/seam/customer/v1/automations/get'](): ( + parameters?: SeamCustomerV1AutomationsGetParameters, + options?: SeamCustomerV1AutomationsGetOptions, + ) => SeamCustomerV1AutomationsGetRequest { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamCustomerV1AutomationsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1Automations.fromClient( + client, + defaults, + ) + return seam.get(...args) + } + } + + get ['/seam/customer/v1/automations/update'](): ( + parameters?: SeamCustomerV1AutomationsUpdateParameters, + options?: SeamCustomerV1AutomationsUpdateOptions, + ) => SeamCustomerV1AutomationsUpdateRequest { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamCustomerV1AutomationsUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1Automations.fromClient( + client, + defaults, + ) + return seam.update(...args) + } + } + get ['/seam/customer/v1/portals/get'](): ( parameters?: SeamCustomerV1PortalsGetParameters, options?: SeamCustomerV1PortalsGetOptions, @@ -3985,10 +4087,8 @@ export type SeamHttpEndpointQueryPaths = | '/access_codes/list' | '/access_codes/unmanaged/get' | '/access_codes/unmanaged/list' - | '/access_grants/delete' | '/access_grants/get' | '/access_grants/list' - | '/access_methods/delete' | '/access_methods/get' | '/access_methods/list' | '/acs/access_groups/get' @@ -4042,6 +4142,8 @@ export type SeamHttpEndpointQueryPaths = | '/noise_sensors/noise_thresholds/list' | '/phones/get' | '/phones/list' + | '/seam/customer/v1/automation_runs/list' + | '/seam/customer/v1/automations/get' | '/seam/customer/v1/portals/get' | '/seam/partner/v1/building_blocks/spaces/auto_map' | '/spaces/get' @@ -4050,10 +4152,8 @@ export type SeamHttpEndpointQueryPaths = | '/thermostats/list' | '/thermostats/schedules/get' | '/thermostats/schedules/list' - | '/unstable_access_grants/delete' | '/unstable_access_grants/get' | '/unstable_access_grants/list' - | '/unstable_access_methods/delete' | '/unstable_access_methods/get' | '/unstable_access_methods/list' | '/unstable_locations/get' @@ -4077,6 +4177,7 @@ export type SeamHttpEndpointPaginatedQueryPaths = | '/connect_webviews/list' | '/connected_accounts/list' | '/devices/list' + | '/seam/customer/v1/automation_runs/list' export type SeamHttpEndpointMutationPaths = | '/access_codes/create' @@ -4091,7 +4192,10 @@ export type SeamHttpEndpointMutationPaths = | '/access_codes/unmanaged/delete' | '/access_codes/unmanaged/update' | '/access_grants/create' + | '/access_grants/delete' | '/access_grants/update' + | '/access_methods/delete' + | '/access_methods/encode' | '/acs/access_groups/add_user' | '/acs/access_groups/remove_user' | '/acs/credential_provisioning_automations/launch' @@ -4101,7 +4205,6 @@ export type SeamHttpEndpointMutationPaths = | '/acs/credentials/delete' | '/acs/credentials/unassign' | '/acs/credentials/update' - | '/acs/encoders/encode_access_method' | '/acs/encoders/encode_credential' | '/acs/encoders/scan_credential' | '/acs/encoders/simulate/next_credential_encode_will_fail' @@ -4145,6 +4248,8 @@ export type SeamHttpEndpointMutationPaths = | '/noise_sensors/simulate/trigger_noise_threshold' | '/phones/deactivate' | '/phones/simulate/create_sandbox_phone' + | '/seam/customer/v1/automations/delete' + | '/seam/customer/v1/automations/update' | '/seam/customer/v1/settings/update' | '/spaces/add_acs_entrances' | '/spaces/add_devices' @@ -4175,6 +4280,8 @@ export type SeamHttpEndpointMutationPaths = | '/thermostats/simulate/hvac_mode_adjusted' | '/thermostats/simulate/temperature_reached' | '/unstable_access_grants/create' + | '/unstable_access_grants/delete' + | '/unstable_access_methods/delete' | '/unstable_locations/add_acs_entrances' | '/unstable_locations/add_devices' | '/unstable_locations/create' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/automation-runs/automation-runs.ts b/src/lib/seam/connect/routes/seam/customer/v1/automation-runs/automation-runs.ts new file mode 100644 index 00000000..7a8b135b --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/automation-runs/automation-runs.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 SeamHttpSeamCustomerV1AutomationRuns { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { + const options = parseOptions(apiKeyOrOptions) + if (!options.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + this.client = 'client' in options ? options.client : createClient(options) + this.defaults = limitToSeamHttpRequestOptions(options) + } + + static fromClient( + client: SeamHttpOptionsWithClient['client'], + options: Omit = {}, + ): SeamHttpSeamCustomerV1AutomationRuns { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamCustomerV1AutomationRuns(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamCustomerV1AutomationRuns { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamCustomerV1AutomationRuns(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamCustomerV1AutomationRuns { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamCustomerV1AutomationRuns(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 SeamHttpSeamCustomerV1AutomationRuns.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamCustomerV1AutomationRuns.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1AutomationRuns { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1AutomationRuns(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1AutomationRuns { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1AutomationRuns(constructorOptions) + } + + createPaginator( + request: SeamHttpRequest, + ): SeamPaginator { + return new SeamPaginator(this, request) + } + + async updateClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + ): Promise { + const { headers } = this.client.defaults + const authHeaders = getAuthHeadersForClientSessionToken({ + clientSessionToken, + }) + for (const key of Object.keys(authHeaders)) { + if (headers[key] == null) { + throw new Error( + 'Cannot update a clientSessionToken on a client created without a clientSessionToken', + ) + } + } + this.client.defaults.headers = { ...headers, ...authHeaders } + const clientSessions = SeamHttpClientSessions.fromClient(this.client) + await clientSessions.get() + } + + list( + parameters?: SeamCustomerV1AutomationRunsListParameters, + options: SeamCustomerV1AutomationRunsListOptions = {}, + ): SeamCustomerV1AutomationRunsListRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/customer/v1/automation_runs/list', + method: 'POST', + body: parameters, + responseKey: 'automation_runs', + options, + }) + } +} + +export type SeamCustomerV1AutomationRunsListParameters = + RouteRequestBody<'/seam/customer/v1/automation_runs/list'> + +/** + * @deprecated Use SeamCustomerV1AutomationRunsListParameters instead. + */ +export type SeamCustomerV1AutomationRunsListParams = + SeamCustomerV1AutomationRunsListParameters + +/** + * @deprecated Use SeamCustomerV1AutomationRunsListRequest instead. + */ +export type SeamCustomerV1AutomationRunsListResponse = SetNonNullable< + Required> +> + +export type SeamCustomerV1AutomationRunsListRequest = SeamHttpRequest< + SeamCustomerV1AutomationRunsListResponse, + 'automation_runs' +> + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface SeamCustomerV1AutomationRunsListOptions {} diff --git a/src/lib/seam/connect/routes/seam/customer/v1/automation-runs/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/automation-runs/index.ts new file mode 100644 index 00000000..e2ea2ec6 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/automation-runs/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 './automation-runs.js' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/automations/automations.ts b/src/lib/seam/connect/routes/seam/customer/v1/automations/automations.ts new file mode 100644 index 00000000..1f8d0bcf --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/automations/automations.ts @@ -0,0 +1,303 @@ +/* + * 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 SeamHttpSeamCustomerV1Automations { + client: Client + readonly defaults: Required + readonly ltsVersion = seamApiLtsVersion + static ltsVersion = seamApiLtsVersion + + constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { + const options = parseOptions(apiKeyOrOptions) + if (!options.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + this.client = 'client' in options ? options.client : createClient(options) + this.defaults = limitToSeamHttpRequestOptions(options) + } + + static fromClient( + client: SeamHttpOptionsWithClient['client'], + options: Omit = {}, + ): SeamHttpSeamCustomerV1Automations { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamCustomerV1Automations(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamCustomerV1Automations { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamCustomerV1Automations(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamCustomerV1Automations { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamCustomerV1Automations(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 SeamHttpSeamCustomerV1Automations.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamCustomerV1Automations.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1Automations { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1Automations(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1Automations { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1Automations(constructorOptions) + } + + createPaginator( + request: SeamHttpRequest, + ): SeamPaginator { + return new SeamPaginator(this, request) + } + + async updateClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + ): Promise { + const { headers } = this.client.defaults + const authHeaders = getAuthHeadersForClientSessionToken({ + clientSessionToken, + }) + for (const key of Object.keys(authHeaders)) { + if (headers[key] == null) { + throw new Error( + 'Cannot update a clientSessionToken on a client created without a clientSessionToken', + ) + } + } + this.client.defaults.headers = { ...headers, ...authHeaders } + const clientSessions = SeamHttpClientSessions.fromClient(this.client) + await clientSessions.get() + } + + delete( + parameters?: SeamCustomerV1AutomationsDeleteParameters, + options: SeamCustomerV1AutomationsDeleteOptions = {}, + ): SeamCustomerV1AutomationsDeleteRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/customer/v1/automations/delete', + method: 'POST', + body: parameters, + responseKey: undefined, + options, + }) + } + + get( + parameters?: SeamCustomerV1AutomationsGetParameters, + options: SeamCustomerV1AutomationsGetOptions = {}, + ): SeamCustomerV1AutomationsGetRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/customer/v1/automations/get', + method: 'GET', + params: parameters, + responseKey: undefined, + options, + }) + } + + update( + parameters?: SeamCustomerV1AutomationsUpdateParameters, + options: SeamCustomerV1AutomationsUpdateOptions = {}, + ): SeamCustomerV1AutomationsUpdateRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/customer/v1/automations/update', + method: 'PATCH', + body: parameters, + responseKey: undefined, + options, + }) + } +} + +export type SeamCustomerV1AutomationsDeleteParameters = + RouteRequestBody<'/seam/customer/v1/automations/delete'> + +/** + * @deprecated Use SeamCustomerV1AutomationsDeleteParameters instead. + */ +export type SeamCustomerV1AutomationsDeleteParams = + SeamCustomerV1AutomationsDeleteParameters + +/** + * @deprecated Use SeamCustomerV1AutomationsDeleteRequest instead. + */ +export type SeamCustomerV1AutomationsDeleteResponse = SetNonNullable< + Required> +> + +export type SeamCustomerV1AutomationsDeleteRequest = SeamHttpRequest< + void, + undefined +> + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface SeamCustomerV1AutomationsDeleteOptions {} + +export type SeamCustomerV1AutomationsGetParameters = + RouteRequestParams<'/seam/customer/v1/automations/get'> + +/** + * @deprecated Use SeamCustomerV1AutomationsGetParameters instead. + */ +export type SeamCustomerV1AutomationsGetParams = + SeamCustomerV1AutomationsGetParameters + +/** + * @deprecated Use SeamCustomerV1AutomationsGetRequest instead. + */ +export type SeamCustomerV1AutomationsGetResponse = SetNonNullable< + Required> +> + +export type SeamCustomerV1AutomationsGetRequest = SeamHttpRequest< + void, + undefined +> + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface SeamCustomerV1AutomationsGetOptions {} + +export type SeamCustomerV1AutomationsUpdateParameters = + RouteRequestBody<'/seam/customer/v1/automations/update'> + +/** + * @deprecated Use SeamCustomerV1AutomationsUpdateParameters instead. + */ +export type SeamCustomerV1AutomationsUpdateBody = + SeamCustomerV1AutomationsUpdateParameters + +/** + * @deprecated Use SeamCustomerV1AutomationsUpdateRequest instead. + */ +export type SeamCustomerV1AutomationsUpdateResponse = SetNonNullable< + Required> +> + +export type SeamCustomerV1AutomationsUpdateRequest = SeamHttpRequest< + void, + undefined +> + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface SeamCustomerV1AutomationsUpdateOptions {} diff --git a/src/lib/seam/connect/routes/seam/customer/v1/automations/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/automations/index.ts new file mode 100644 index 00000000..49fd0137 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/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 './automations.js' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/index.ts index e19e87ec..c4a8018a 100644 --- a/src/lib/seam/connect/routes/seam/customer/v1/index.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/index.ts @@ -3,6 +3,8 @@ * Do not edit this file or add other files to this directory. */ +export * from './automation-runs/index.js' +export * from './automations/index.js' export * from './portals/index.js' export * from './settings/index.js' export * from './v1.js' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/v1.ts b/src/lib/seam/connect/routes/seam/customer/v1/v1.ts index 7227d2c3..d5e4102f 100644 --- a/src/lib/seam/connect/routes/seam/customer/v1/v1.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/v1.ts @@ -33,6 +33,8 @@ import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/ import type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' +import { SeamHttpSeamCustomerV1AutomationRuns } from './automation-runs/index.js' +import { SeamHttpSeamCustomerV1Automations } from './automations/index.js' import { SeamHttpSeamCustomerV1Portals } from './portals/index.js' import { SeamHttpSeamCustomerV1Settings } from './settings/index.js' @@ -168,6 +170,20 @@ export class SeamHttpSeamCustomerV1 { await clientSessions.get() } + get automationRuns(): SeamHttpSeamCustomerV1AutomationRuns { + return SeamHttpSeamCustomerV1AutomationRuns.fromClient( + this.client, + this.defaults, + ) + } + + get automations(): SeamHttpSeamCustomerV1Automations { + return SeamHttpSeamCustomerV1Automations.fromClient( + this.client, + this.defaults, + ) + } + get portals(): SeamHttpSeamCustomerV1Portals { return SeamHttpSeamCustomerV1Portals.fromClient(this.client, this.defaults) }