diff --git a/package-lock.json b/package-lock.json index 22371bcc..aa6774af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@seamapi/blueprint": "^0.52.2", "@seamapi/fake-seam-connect": "^1.77.0", "@seamapi/smith": "^0.5.2", - "@seamapi/types": "1.738.0", + "@seamapi/types": "1.739.0", "@swc/core": "^1.11.29", "@types/jsonwebtoken": "^9.0.6", "@types/node": "^24.10.9", @@ -49,7 +49,7 @@ "npm": ">=10.9.4" }, "peerDependencies": { - "@seamapi/types": "^1.738.0" + "@seamapi/types": "^1.739.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -1405,9 +1405,9 @@ "license": "MIT" }, "node_modules/@seamapi/types": { - "version": "1.738.0", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.738.0.tgz", - "integrity": "sha512-s4uWEZ2wQp5HcThHxSav70ngrQPtygRO3QvV/Ru1tbFjvVGHoyIgEG8eKjlgXM9l/J1xor1MkW1nZyOGu0JWwg==", + "version": "1.739.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.739.0.tgz", + "integrity": "sha512-ipwXvs6qeUhbrf7H60N0He9tn0XCSiXMWmDgbNxxDY42gw7I/jCM94AG5ERM1vp+ZtKCyDBEb5Ax1pOzwWx0zQ==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 67410793..67d17c3e 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "npm": ">=10.9.4" }, "peerDependencies": { - "@seamapi/types": "^1.738.0" + "@seamapi/types": "^1.739.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -102,7 +102,7 @@ "@seamapi/blueprint": "^0.52.2", "@seamapi/fake-seam-connect": "^1.77.0", "@seamapi/smith": "^0.5.2", - "@seamapi/types": "1.738.0", + "@seamapi/types": "1.739.0", "@swc/core": "^1.11.29", "@types/jsonwebtoken": "^9.0.6", "@types/node": "^24.10.9", diff --git a/src/lib/seam/connect/routes/seam-http-endpoints.ts b/src/lib/seam/connect/routes/seam-http-endpoints.ts index b25c8f09..f4fc569b 100644 --- a/src/lib/seam/connect/routes/seam-http-endpoints.ts +++ b/src/lib/seam/connect/routes/seam-http-endpoints.ts @@ -665,6 +665,15 @@ import { type SeamCustomerV1ConnectorsUpdateRequest, SeamHttpSeamCustomerV1Connectors, } from './seam/customer/v1/connectors/index.js' +import { + type SeamCustomerV1CustomersAutomationsGetOptions, + type SeamCustomerV1CustomersAutomationsGetParameters, + type SeamCustomerV1CustomersAutomationsGetRequest, + type SeamCustomerV1CustomersAutomationsUpdateOptions, + type SeamCustomerV1CustomersAutomationsUpdateParameters, + type SeamCustomerV1CustomersAutomationsUpdateRequest, + SeamHttpSeamCustomerV1CustomersAutomations, +} from './seam/customer/v1/customers/automations/index.js' import { type SeamCustomerV1CustomersListOptions, type SeamCustomerV1CustomersListParameters, @@ -3480,6 +3489,38 @@ export class SeamHttpEndpoints { } } + get '/seam/customer/v1/customers/automations/get'(): ( + parameters?: SeamCustomerV1CustomersAutomationsGetParameters, + options?: SeamCustomerV1CustomersAutomationsGetOptions, + ) => SeamCustomerV1CustomersAutomationsGetRequest { + const { client, defaults } = this + return function seamCustomerV1CustomersAutomationsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1CustomersAutomations.fromClient( + client, + defaults, + ) + return seam.get(...args) + } + } + + get '/seam/customer/v1/customers/automations/update'(): ( + parameters?: SeamCustomerV1CustomersAutomationsUpdateParameters, + options?: SeamCustomerV1CustomersAutomationsUpdateOptions, + ) => SeamCustomerV1CustomersAutomationsUpdateRequest { + const { client, defaults } = this + return function seamCustomerV1CustomersAutomationsUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1CustomersAutomations.fromClient( + client, + defaults, + ) + return seam.update(...args) + } + } + get '/seam/customer/v1/customers/list'(): ( parameters?: SeamCustomerV1CustomersListParameters, options?: SeamCustomerV1CustomersListOptions, @@ -4994,6 +5035,7 @@ export type SeamHttpEndpointQueryPaths = | '/seam/customer/v1/connectors/authorize' | '/seam/customer/v1/connectors/connector_types' | '/seam/customer/v1/connectors/list' + | '/seam/customer/v1/customers/automations/get' | '/seam/customer/v1/customers/list' | '/seam/customer/v1/customers/me' | '/seam/customer/v1/encoders/list' @@ -5142,6 +5184,7 @@ export type SeamHttpEndpointMutationPaths = | '/seam/customer/v1/connectors/delete' | '/seam/customer/v1/connectors/sync' | '/seam/customer/v1/connectors/update' + | '/seam/customer/v1/customers/automations/update' | '/seam/customer/v1/customers/open_portal' | '/seam/customer/v1/settings/update' | '/seam/customer/v1/spaces/create' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/customers/automations/automations.ts b/src/lib/seam/connect/routes/seam/customer/v1/customers/automations/automations.ts new file mode 100644 index 00000000..6afbee48 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/customers/automations/automations.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 SeamHttpSeamCustomerV1CustomersAutomations { + 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 = {}, + ): SeamHttpSeamCustomerV1CustomersAutomations { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamCustomerV1CustomersAutomations(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamCustomerV1CustomersAutomations { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamCustomerV1CustomersAutomations(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamCustomerV1CustomersAutomations { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamCustomerV1CustomersAutomations(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 SeamHttpSeamCustomerV1CustomersAutomations.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamCustomerV1CustomersAutomations.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1CustomersAutomations { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1CustomersAutomations(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1CustomersAutomations { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1CustomersAutomations(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( + parameters?: SeamCustomerV1CustomersAutomationsGetParameters, + options: SeamCustomerV1CustomersAutomationsGetOptions = {}, + ): SeamCustomerV1CustomersAutomationsGetRequest { + return new SeamHttpRequest(this, { + pathname: '/seam/customer/v1/customers/automations/get', + method: 'POST', + body: parameters, + responseKey: 'automation', + options, + }) + } + + update( + parameters?: SeamCustomerV1CustomersAutomationsUpdateParameters, + options: SeamCustomerV1CustomersAutomationsUpdateOptions = {}, + ): SeamCustomerV1CustomersAutomationsUpdateRequest { + return new SeamHttpRequest(this, { + pathname: '/seam/customer/v1/customers/automations/update', + method: 'PATCH', + body: parameters, + responseKey: undefined, + options, + }) + } +} + +export type SeamCustomerV1CustomersAutomationsGetParameters = + RouteRequestBody<'/seam/customer/v1/customers/automations/get'> + +/** + * @deprecated Use SeamCustomerV1CustomersAutomationsGetParameters instead. + */ +export type SeamCustomerV1CustomersAutomationsGetParams = + SeamCustomerV1CustomersAutomationsGetParameters + +/** + * @deprecated Use SeamCustomerV1CustomersAutomationsGetRequest instead. + */ +export type SeamCustomerV1CustomersAutomationsGetResponse = SetNonNullable< + Required> +> + +export type SeamCustomerV1CustomersAutomationsGetRequest = SeamHttpRequest< + SeamCustomerV1CustomersAutomationsGetResponse, + 'automation' +> + +export interface SeamCustomerV1CustomersAutomationsGetOptions {} + +export type SeamCustomerV1CustomersAutomationsUpdateParameters = + RouteRequestBody<'/seam/customer/v1/customers/automations/update'> + +/** + * @deprecated Use SeamCustomerV1CustomersAutomationsUpdateParameters instead. + */ +export type SeamCustomerV1CustomersAutomationsUpdateBody = + SeamCustomerV1CustomersAutomationsUpdateParameters + +/** + * @deprecated Use SeamCustomerV1CustomersAutomationsUpdateRequest instead. + */ +export type SeamCustomerV1CustomersAutomationsUpdateResponse = SetNonNullable< + Required> +> + +export type SeamCustomerV1CustomersAutomationsUpdateRequest = SeamHttpRequest< + void, + undefined +> + +export interface SeamCustomerV1CustomersAutomationsUpdateOptions {} diff --git a/src/lib/seam/connect/routes/seam/customer/v1/customers/automations/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/customers/automations/index.ts new file mode 100644 index 00000000..49fd0137 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/customers/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/customers/customers.ts b/src/lib/seam/connect/routes/seam/customer/v1/customers/customers.ts index 52c1fcd6..1134be7e 100644 --- a/src/lib/seam/connect/routes/seam/customer/v1/customers/customers.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/customers/customers.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 { SeamHttpSeamCustomerV1CustomersAutomations } from './automations/index.js' + export class SeamHttpSeamCustomerV1Customers { client: Client readonly defaults: Required @@ -170,6 +172,13 @@ export class SeamHttpSeamCustomerV1Customers { await clientSessions.get() } + get automations(): SeamHttpSeamCustomerV1CustomersAutomations { + return SeamHttpSeamCustomerV1CustomersAutomations.fromClient( + this.client, + this.defaults, + ) + } + list( parameters?: SeamCustomerV1CustomersListParameters, options: SeamCustomerV1CustomersListOptions = {}, diff --git a/src/lib/seam/connect/routes/seam/customer/v1/customers/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/customers/index.ts index 9126f05d..78de25f4 100644 --- a/src/lib/seam/connect/routes/seam/customer/v1/customers/index.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/customers/index.ts @@ -3,4 +3,5 @@ * Do not edit this file or add other files to this directory. */ +export * from './automations/index.js' export * from './customers.js'