diff --git a/package-lock.json b/package-lock.json index 5e16fa01..65448448 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.5.2", - "@seamapi/types": "1.629.0", + "@seamapi/types": "1.632.0", "@swc/core": "^1.11.29", "@types/jsonwebtoken": "^9.0.6", "@types/node": "^22.15.21", @@ -49,7 +49,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.629.0" + "@seamapi/types": "^1.632.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -1371,9 +1371,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.629.0", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.629.0.tgz", - "integrity": "sha512-MPSWob7lnSsqqU/JIy71XwGNqumuu8OlAWKsXcDbnteE1ED17aBcmjeofXIcNgGF2ua6j8EFwWaY5yDiqol9Qg==", + "version": "1.632.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.632.0.tgz", + "integrity": "sha512-+PEOguxg1fjTwwBVy3TpNCOdP89aHDJ3ohv0PqLNrZCFpwCYuSD0iZBe/Ap1554/6iKZwgdbLBXHEUJZkb6bJA==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 0fc034f2..688fad2b 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.629.0" + "@seamapi/types": "^1.632.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -102,7 +102,7 @@ "@seamapi/blueprint": "^0.51.1", "@seamapi/fake-seam-connect": "^1.77.0", "@seamapi/smith": "^0.5.2", - "@seamapi/types": "1.629.0", + "@seamapi/types": "1.632.0", "@swc/core": "^1.11.29", "@types/jsonwebtoken": "^9.0.6", "@types/node": "^22.15.21", diff --git a/src/lib/seam/connect/routes/seam-http-endpoints.ts b/src/lib/seam/connect/routes/seam-http-endpoints.ts index 45cc26ed..8f45158e 100644 --- a/src/lib/seam/connect/routes/seam-http-endpoints.ts +++ b/src/lib/seam/connect/routes/seam-http-endpoints.ts @@ -581,6 +581,12 @@ import { type SeamConsoleV1TimelinesGetRequest, SeamHttpSeamConsoleV1Timelines, } from './seam/console/v1/timelines/index.js' +import { + type SeamCustomerV1AccessGrantsListOptions, + type SeamCustomerV1AccessGrantsListParameters, + type SeamCustomerV1AccessGrantsListRequest, + SeamHttpSeamCustomerV1AccessGrants, +} from './seam/customer/v1/access-grants/index.js' import { type SeamCustomerV1AutomationRunsListOptions, type SeamCustomerV1AutomationRunsListParameters, @@ -3040,6 +3046,27 @@ export class SeamHttpEndpoints { } } + get '/seam/customer/v1/access_grants/list'(): ( + parameters?: SeamCustomerV1AccessGrantsListParameters, + options?: SeamCustomerV1AccessGrantsListOptions, + ) => SeamCustomerV1AccessGrantsListRequest { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamCustomerV1AccessGrantsList( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1AccessGrants.fromClient( + client, + defaults, + ) + return seam.list(...args) + } + } + get '/seam/customer/v1/automation_runs/list'(): ( parameters?: SeamCustomerV1AutomationRunsListParameters, options?: SeamCustomerV1AutomationRunsListOptions, @@ -4596,6 +4623,7 @@ export type SeamHttpEndpointQueryPaths = | '/phones/list' | '/seam/console/v1/get_resource_locator' | '/seam/console/v1/timelines/get' + | '/seam/customer/v1/access_grants/list' | '/seam/customer/v1/automation_runs/list' | '/seam/customer/v1/automations/get' | '/seam/customer/v1/connectors/list' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/access-grants/access-grants.ts b/src/lib/seam/connect/routes/seam/customer/v1/access-grants/access-grants.ts new file mode 100644 index 00000000..7ab6aa80 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/access-grants/access-grants.ts @@ -0,0 +1,214 @@ +/* + * 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 SeamHttpSeamCustomerV1AccessGrants { + 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 = {}, + ): SeamHttpSeamCustomerV1AccessGrants { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpSeamCustomerV1AccessGrants(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpSeamCustomerV1AccessGrants { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpSeamCustomerV1AccessGrants(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpSeamCustomerV1AccessGrants { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpSeamCustomerV1AccessGrants(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 SeamHttpSeamCustomerV1AccessGrants.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpSeamCustomerV1AccessGrants.fromClientSessionToken( + token, + options, + ) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1AccessGrants { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1AccessGrants(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpSeamCustomerV1AccessGrants { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpSeamCustomerV1AccessGrants(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?: SeamCustomerV1AccessGrantsListParameters, + options: SeamCustomerV1AccessGrantsListOptions = {}, + ): SeamCustomerV1AccessGrantsListRequest { + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return new SeamHttpRequest(this, { + pathname: '/seam/customer/v1/access_grants/list', + method: 'POST', + body: parameters, + responseKey: 'access_grants', + options, + }) + } +} + +export type SeamCustomerV1AccessGrantsListParameters = + RouteRequestBody<'/seam/customer/v1/access_grants/list'> + +/** + * @deprecated Use SeamCustomerV1AccessGrantsListParameters instead. + */ +export type SeamCustomerV1AccessGrantsListParams = + SeamCustomerV1AccessGrantsListParameters + +/** + * @deprecated Use SeamCustomerV1AccessGrantsListRequest instead. + */ +export type SeamCustomerV1AccessGrantsListResponse = SetNonNullable< + Required> +> + +export type SeamCustomerV1AccessGrantsListRequest = SeamHttpRequest< + SeamCustomerV1AccessGrantsListResponse, + 'access_grants' +> + +export interface SeamCustomerV1AccessGrantsListOptions {} diff --git a/src/lib/seam/connect/routes/seam/customer/v1/access-grants/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/access-grants/index.ts new file mode 100644 index 00000000..afe09729 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/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 './access-grants.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 02e5dea8..7f1df971 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,7 @@ * Do not edit this file or add other files to this directory. */ +export * from './access-grants/index.js' export * from './automation-runs/index.js' export * from './automations/index.js' export * from './connectors/index.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 bf38ef4a..2b09567e 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,7 @@ 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 { SeamHttpSeamCustomerV1AccessGrants } from './access-grants/index.js' import { SeamHttpSeamCustomerV1AutomationRuns } from './automation-runs/index.js' import { SeamHttpSeamCustomerV1Automations } from './automations/index.js' import { SeamHttpSeamCustomerV1Connectors } from './connectors/index.js' @@ -175,6 +176,13 @@ export class SeamHttpSeamCustomerV1 { await clientSessions.get() } + get accessGrants(): SeamHttpSeamCustomerV1AccessGrants { + return SeamHttpSeamCustomerV1AccessGrants.fromClient( + this.client, + this.defaults, + ) + } + get automationRuns(): SeamHttpSeamCustomerV1AutomationRuns { return SeamHttpSeamCustomerV1AutomationRuns.fromClient( this.client,