diff --git a/package-lock.json b/package-lock.json index f5d940cc..262a5a00 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.466.0", + "@seamapi/types": "1.468.0", "@swc/core": "^1.11.29", "@types/eslint": "^8.44.2", "@types/jsonwebtoken": "^9.0.6", @@ -50,7 +50,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.466.0" + "@seamapi/types": "^1.468.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -1216,9 +1216,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.466.0", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.466.0.tgz", - "integrity": "sha512-yJ7ud18Kc3OGK9SGx4/7qvS+qP2Lqq11Ur8wc82gz1ltJCnVe0mkVpOxCxJQRT81TLs8g0XgDHVNASGww1qhvQ==", + "version": "1.468.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.468.0.tgz", + "integrity": "sha512-0GSeUx34aGgiu8FZR8GxvXpOS+nkyqiCEb2HPt/YSlDgghc1rb7ZYe8KtLgRNzbCgvgnySky0INNgCqcoGgF/Q==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 18399208..5869bcab 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.466.0" + "@seamapi/types": "^1.468.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -101,7 +101,7 @@ "@seamapi/blueprint": "^0.51.1", "@seamapi/fake-seam-connect": "^1.77.0", "@seamapi/smith": "^0.4.4", - "@seamapi/types": "1.466.0", + "@seamapi/types": "1.468.0", "@swc/core": "^1.11.29", "@types/eslint": "^8.44.2", "@types/jsonwebtoken": "^9.0.6", diff --git a/src/lib/seam/connect/routes/seam-http-endpoints.ts b/src/lib/seam/connect/routes/seam-http-endpoints.ts index e04bf16d..ef4b8b2c 100644 --- a/src/lib/seam/connect/routes/seam-http-endpoints.ts +++ b/src/lib/seam/connect/routes/seam-http-endpoints.ts @@ -560,6 +560,12 @@ import { type SeamCustomerV1AutomationsUpdateRequest, SeamHttpSeamCustomerV1Automations, } from './seam/customer/v1/automations/index.js' +import { + type SeamCustomerV1EventsListOptions, + type SeamCustomerV1EventsListParameters, + type SeamCustomerV1EventsListRequest, + SeamHttpSeamCustomerV1Events, +} from './seam/customer/v1/events/index.js' import { type SeamCustomerV1PortalsGetOptions, type SeamCustomerV1PortalsGetParameters, @@ -567,6 +573,9 @@ import { SeamHttpSeamCustomerV1Portals, } from './seam/customer/v1/portals/index.js' import { + type SeamCustomerV1SettingsGetOptions, + type SeamCustomerV1SettingsGetParameters, + type SeamCustomerV1SettingsGetRequest, type SeamCustomerV1SettingsUpdateOptions, type SeamCustomerV1SettingsUpdateParameters, type SeamCustomerV1SettingsUpdateRequest, @@ -2923,6 +2932,24 @@ export class SeamHttpEndpoints { } } + get ['/seam/customer/v1/events/list'](): ( + parameters?: SeamCustomerV1EventsListParameters, + options?: SeamCustomerV1EventsListOptions, + ) => SeamCustomerV1EventsListRequest { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamCustomerV1EventsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1Events.fromClient(client, defaults) + return seam.list(...args) + } + } + get ['/seam/customer/v1/portals/get'](): ( parameters?: SeamCustomerV1PortalsGetParameters, options?: SeamCustomerV1PortalsGetOptions, @@ -2941,6 +2968,24 @@ export class SeamHttpEndpoints { } } + get ['/seam/customer/v1/settings/get'](): ( + parameters?: SeamCustomerV1SettingsGetParameters, + options?: SeamCustomerV1SettingsGetOptions, + ) => SeamCustomerV1SettingsGetRequest { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamCustomerV1SettingsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1Settings.fromClient(client, defaults) + return seam.get(...args) + } + } + get ['/seam/customer/v1/settings/update'](): ( parameters?: SeamCustomerV1SettingsUpdateParameters, options?: SeamCustomerV1SettingsUpdateOptions, @@ -4308,7 +4353,9 @@ export type SeamHttpEndpointQueryPaths = | '/seam/console/v1/get_resource_locator' | '/seam/customer/v1/automation_runs/list' | '/seam/customer/v1/automations/get' + | '/seam/customer/v1/events/list' | '/seam/customer/v1/portals/get' + | '/seam/customer/v1/settings/get' | '/seam/partner/v1/building_blocks/spaces/auto_map' | '/spaces/get' | '/spaces/get_related' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/events/events.ts b/src/lib/seam/connect/routes/seam/customer/v1/events/events.ts new file mode 100644 index 00000000..3af31d7d --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/events/events.ts @@ -0,0 +1,211 @@ +/* + * 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 SeamHttpSeamCustomerV1Events { + 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 = {}, + ): SeamHttpSeamCustomerV1Events { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamCustomerV1Events(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamCustomerV1Events { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamCustomerV1Events(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamCustomerV1Events { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamCustomerV1Events(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 SeamHttpSeamCustomerV1Events.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamCustomerV1Events.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1Events { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1Events(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1Events { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1Events(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?: SeamCustomerV1EventsListParameters, + options: SeamCustomerV1EventsListOptions = {}, + ): SeamCustomerV1EventsListRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/customer/v1/events/list', + method: 'POST', + body: parameters, + responseKey: 'events', + options, + }) + } +} + +export type SeamCustomerV1EventsListParameters = + RouteRequestBody<'/seam/customer/v1/events/list'> + +/** + * @deprecated Use SeamCustomerV1EventsListParameters instead. + */ +export type SeamCustomerV1EventsListParams = SeamCustomerV1EventsListParameters + +/** + * @deprecated Use SeamCustomerV1EventsListRequest instead. + */ +export type SeamCustomerV1EventsListResponse = SetNonNullable< + Required> +> + +export type SeamCustomerV1EventsListRequest = SeamHttpRequest< + SeamCustomerV1EventsListResponse, + 'events' +> + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface SeamCustomerV1EventsListOptions {} diff --git a/src/lib/seam/connect/routes/seam/customer/v1/events/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/events/index.ts new file mode 100644 index 00000000..80914354 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/events/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 './events.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 c4a8018a..71ee67ad 100644 --- a/src/lib/seam/connect/routes/seam/customer/v1/index.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/index.ts @@ -5,6 +5,7 @@ export * from './automation-runs/index.js' export * from './automations/index.js' +export * from './events/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/settings/settings.ts b/src/lib/seam/connect/routes/seam/customer/v1/settings/settings.ts index f407eaa1..8c8e85f1 100644 --- a/src/lib/seam/connect/routes/seam/customer/v1/settings/settings.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/settings/settings.ts @@ -3,7 +3,11 @@ * Do not edit this file or add other files to this directory. */ -import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' +import type { + RouteRequestBody, + RouteRequestParams, + RouteResponse, +} from '@seamapi/types/connect' import { seamApiLtsVersion } from 'lib/lts-version.js' import { @@ -168,6 +172,24 @@ export class SeamHttpSeamCustomerV1Settings { await clientSessions.get() } + get( + parameters?: SeamCustomerV1SettingsGetParameters, + options: SeamCustomerV1SettingsGetOptions = {}, + ): SeamCustomerV1SettingsGetRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/customer/v1/settings/get', + method: 'GET', + params: parameters, + responseKey: 'business_vertical', + options, + }) + } + update( parameters?: SeamCustomerV1SettingsUpdateParameters, options: SeamCustomerV1SettingsUpdateOptions = {}, @@ -187,6 +209,30 @@ export class SeamHttpSeamCustomerV1Settings { } } +export type SeamCustomerV1SettingsGetParameters = + RouteRequestParams<'/seam/customer/v1/settings/get'> + +/** + * @deprecated Use SeamCustomerV1SettingsGetParameters instead. + */ +export type SeamCustomerV1SettingsGetParams = + SeamCustomerV1SettingsGetParameters + +/** + * @deprecated Use SeamCustomerV1SettingsGetRequest instead. + */ +export type SeamCustomerV1SettingsGetResponse = SetNonNullable< + Required> +> + +export type SeamCustomerV1SettingsGetRequest = SeamHttpRequest< + SeamCustomerV1SettingsGetResponse, + 'business_vertical' +> + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface SeamCustomerV1SettingsGetOptions {} + export type SeamCustomerV1SettingsUpdateParameters = RouteRequestBody<'/seam/customer/v1/settings/update'> 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 d5e4102f..ee9d6a51 100644 --- a/src/lib/seam/connect/routes/seam/customer/v1/v1.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/v1.ts @@ -35,6 +35,7 @@ import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' import { SeamHttpSeamCustomerV1AutomationRuns } from './automation-runs/index.js' import { SeamHttpSeamCustomerV1Automations } from './automations/index.js' +import { SeamHttpSeamCustomerV1Events } from './events/index.js' import { SeamHttpSeamCustomerV1Portals } from './portals/index.js' import { SeamHttpSeamCustomerV1Settings } from './settings/index.js' @@ -184,6 +185,10 @@ export class SeamHttpSeamCustomerV1 { ) } + get events(): SeamHttpSeamCustomerV1Events { + return SeamHttpSeamCustomerV1Events.fromClient(this.client, this.defaults) + } + get portals(): SeamHttpSeamCustomerV1Portals { return SeamHttpSeamCustomerV1Portals.fromClient(this.client, this.defaults) }