diff --git a/package-lock.json b/package-lock.json index ab1de173..62d24650 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.420.2", + "@seamapi/types": "1.423.2", "@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.420.2" + "@seamapi/types": "^1.423.2" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -1216,9 +1216,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.420.2", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.420.2.tgz", - "integrity": "sha512-3W6YwDWIUsfwvEzzF6HuDNryqSqtywoGvi+zfLf9Js/wh88A3DKXYOmwamGWLus2L6vTp28F4aipcu5uNQndow==", + "version": "1.423.2", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.423.2.tgz", + "integrity": "sha512-EfMNHNE0k3Mp+AgjEDzzmnjsvOf7yrt9qG5ZZkjVqaTGsOAYTRjrRMLFz37s8My+evXn8i0Ry4wijhoXKhFviw==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index edccb9aa..7f8e476d 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "npm": ">=10.1.0" }, "peerDependencies": { - "@seamapi/types": "^1.420.2" + "@seamapi/types": "^1.423.2" }, "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.420.2", + "@seamapi/types": "1.423.2", "@swc/core": "^1.11.29", "@types/eslint": "^8.44.2", "@types/jsonwebtoken": "^9.0.6", diff --git a/src/lib/seam/connect/routes/customers/customers.ts b/src/lib/seam/connect/routes/customers/customers.ts new file mode 100644 index 00000000..a4f44723 --- /dev/null +++ b/src/lib/seam/connect/routes/customers/customers.ts @@ -0,0 +1,234 @@ +/* + * 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 SeamHttpCustomers { + 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 = {}, + ): SeamHttpCustomers { + const constructorOptions = { ...options, client } + if (!isSeamHttpOptionsWithClient(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing client') + } + return new SeamHttpCustomers(constructorOptions) + } + + static fromApiKey( + apiKey: SeamHttpOptionsWithApiKey['apiKey'], + options: Omit = {}, + ): SeamHttpCustomers { + const constructorOptions = { ...options, apiKey } + if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing apiKey') + } + return new SeamHttpCustomers(constructorOptions) + } + + static fromClientSessionToken( + clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], + options: Omit< + SeamHttpOptionsWithClientSessionToken, + 'clientSessionToken' + > = {}, + ): SeamHttpCustomers { + const constructorOptions = { ...options, clientSessionToken } + if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') + } + return new SeamHttpCustomers(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 SeamHttpCustomers.fromPublishableKey', + ) + } + const client = createClient(clientOptions) + const clientSessions = SeamHttpClientSessions.fromClient(client) + const { token } = await clientSessions.getOrCreate({ + user_identifier_key: userIdentifierKey, + }) + return SeamHttpCustomers.fromClientSessionToken(token, options) + } + + static fromConsoleSessionToken( + consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], + workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithConsoleSessionToken, + 'consoleSessionToken' | 'workspaceId' + > = {}, + ): SeamHttpCustomers { + const constructorOptions = { ...options, consoleSessionToken, workspaceId } + if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing consoleSessionToken or workspaceId', + ) + } + return new SeamHttpCustomers(constructorOptions) + } + + static fromPersonalAccessToken( + personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], + workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], + options: Omit< + SeamHttpOptionsWithPersonalAccessToken, + 'personalAccessToken' | 'workspaceId' + > = {}, + ): SeamHttpCustomers { + const constructorOptions = { ...options, personalAccessToken, workspaceId } + if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { + throw new SeamHttpInvalidOptionsError( + 'Missing personalAccessToken or workspaceId', + ) + } + return new SeamHttpCustomers(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() + } + + createPortal( + parameters?: CustomersCreatePortalParameters, + options: CustomersCreatePortalOptions = {}, + ): CustomersCreatePortalRequest { + return new SeamHttpRequest(this, { + pathname: '/customers/create_portal', + method: 'POST', + body: parameters, + responseKey: 'magic_link', + options, + }) + } + + pushData( + parameters?: CustomersPushDataParameters, + options: CustomersPushDataOptions = {}, + ): CustomersPushDataRequest { + return new SeamHttpRequest(this, { + pathname: '/customers/push_data', + method: 'POST', + body: parameters, + responseKey: undefined, + options, + }) + } +} + +export type CustomersCreatePortalParameters = + RouteRequestBody<'/customers/create_portal'> + +/** + * @deprecated Use CustomersCreatePortalParameters instead. + */ +export type CustomersCreatePortalBody = CustomersCreatePortalParameters + +/** + * @deprecated Use CustomersCreatePortalRequest instead. + */ +export type CustomersCreatePortalResponse = SetNonNullable< + Required> +> + +export type CustomersCreatePortalRequest = SeamHttpRequest< + CustomersCreatePortalResponse, + 'magic_link' +> + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface CustomersCreatePortalOptions {} + +export type CustomersPushDataParameters = + RouteRequestBody<'/customers/push_data'> + +/** + * @deprecated Use CustomersPushDataParameters instead. + */ +export type CustomersPushDataBody = CustomersPushDataParameters + +/** + * @deprecated Use CustomersPushDataRequest instead. + */ +export type CustomersPushDataResponse = SetNonNullable< + Required> +> + +export type CustomersPushDataRequest = SeamHttpRequest + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface CustomersPushDataOptions {} diff --git a/src/lib/seam/connect/routes/seam/partner/v1/resources/index.ts b/src/lib/seam/connect/routes/customers/index.ts similarity index 79% rename from src/lib/seam/connect/routes/seam/partner/v1/resources/index.ts rename to src/lib/seam/connect/routes/customers/index.ts index 60e5e587..9126f05d 100644 --- a/src/lib/seam/connect/routes/seam/partner/v1/resources/index.ts +++ b/src/lib/seam/connect/routes/customers/index.ts @@ -3,4 +3,4 @@ * Do not edit this file or add other files to this directory. */ -export * from './resources.js' +export * from './customers.js' diff --git a/src/lib/seam/connect/routes/devices/simulate/simulate.ts b/src/lib/seam/connect/routes/devices/simulate/simulate.ts index 55c8edd5..c5bbb6f3 100644 --- a/src/lib/seam/connect/routes/devices/simulate/simulate.ts +++ b/src/lib/seam/connect/routes/devices/simulate/simulate.ts @@ -249,7 +249,7 @@ export type DevicesSimulateRemoveParameters = /** * @deprecated Use DevicesSimulateRemoveParameters instead. */ -export type DevicesSimulateRemoveParams = DevicesSimulateRemoveParameters +export type DevicesSimulateRemoveBody = DevicesSimulateRemoveParameters /** * @deprecated Use DevicesSimulateRemoveRequest instead. diff --git a/src/lib/seam/connect/routes/index.ts b/src/lib/seam/connect/routes/index.ts index b7bec514..ae87c046 100644 --- a/src/lib/seam/connect/routes/index.ts +++ b/src/lib/seam/connect/routes/index.ts @@ -12,6 +12,7 @@ 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 './customers/index.js' export * from './devices/index.js' export * from './events/index.js' export * from './locks/index.js' diff --git a/src/lib/seam/connect/routes/phones/simulate/simulate.ts b/src/lib/seam/connect/routes/phones/simulate/simulate.ts index d72aff69..b588084a 100644 --- a/src/lib/seam/connect/routes/phones/simulate/simulate.ts +++ b/src/lib/seam/connect/routes/phones/simulate/simulate.ts @@ -183,7 +183,7 @@ export type PhonesSimulateCreateSandboxPhoneParameters = /** * @deprecated Use PhonesSimulateCreateSandboxPhoneParameters instead. */ -export type PhonesSimulateCreateSandboxPhoneParams = +export type PhonesSimulateCreateSandboxPhoneBody = PhonesSimulateCreateSandboxPhoneParameters /** diff --git a/src/lib/seam/connect/routes/seam-http-endpoints.ts b/src/lib/seam/connect/routes/seam-http-endpoints.ts index 08fd122b..0482b268 100644 --- a/src/lib/seam/connect/routes/seam-http-endpoints.ts +++ b/src/lib/seam/connect/routes/seam-http-endpoints.ts @@ -380,6 +380,15 @@ import { type ConnectedAccountsUpdateRequest, SeamHttpConnectedAccounts, } from './connected-accounts/index.js' +import { + type CustomersCreatePortalOptions, + type CustomersCreatePortalParameters, + type CustomersCreatePortalRequest, + type CustomersPushDataOptions, + type CustomersPushDataParameters, + type CustomersPushDataRequest, + SeamHttpCustomers, +} from './customers/index.js' import { type DevicesDeleteOptions, type DevicesDeleteParameters, @@ -512,18 +521,24 @@ import { type PhonesSimulateCreateSandboxPhoneRequest, SeamHttpPhonesSimulate, } from './phones/simulate/index.js' +import { + type SeamCustomerV1PortalsGetOptions, + type SeamCustomerV1PortalsGetParameters, + type SeamCustomerV1PortalsGetRequest, + SeamHttpSeamCustomerV1Portals, +} from './seam/customer/v1/portals/index.js' +import { + type SeamCustomerV1SettingsUpdateOptions, + type SeamCustomerV1SettingsUpdateParameters, + type SeamCustomerV1SettingsUpdateRequest, + SeamHttpSeamCustomerV1Settings, +} from './seam/customer/v1/settings/index.js' import { SeamHttpSeamPartnerV1BuildingBlocksSpaces, type SeamPartnerV1BuildingBlocksSpacesAutoMapOptions, type SeamPartnerV1BuildingBlocksSpacesAutoMapParameters, type SeamPartnerV1BuildingBlocksSpacesAutoMapRequest, } from './seam/partner/v1/building-blocks/spaces/index.js' -import { - SeamHttpSeamPartnerV1Resources, - type SeamPartnerV1ResourcesListOptions, - type SeamPartnerV1ResourcesListParameters, - type SeamPartnerV1ResourcesListRequest, -} from './seam/partner/v1/resources/index.js' import { SeamHttpSpaces, type SpacesAddAcsEntrancesOptions, @@ -713,12 +728,6 @@ import { type UnstablePartnerBuildingBlocksOrganizeSpacesParameters, type UnstablePartnerBuildingBlocksOrganizeSpacesRequest, } from './unstable-partner/building-blocks/index.js' -import { - SeamHttpUnstablePartnerResources, - type UnstablePartnerResourcesPushOptions, - type UnstablePartnerResourcesPushParameters, - type UnstablePartnerResourcesPushRequest, -} from './unstable-partner/resources/index.js' import { SeamHttpUserIdentitiesEnrollmentAutomations, type UserIdentitiesEnrollmentAutomationsDeleteOptions, @@ -2240,6 +2249,32 @@ export class SeamHttpEndpoints { } } + get ['/customers/create_portal'](): ( + parameters?: CustomersCreatePortalParameters, + options?: CustomersCreatePortalOptions, + ) => CustomersCreatePortalRequest { + const { client, defaults } = this + return function customersCreatePortal( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpCustomers.fromClient(client, defaults) + return seam.createPortal(...args) + } + } + + get ['/customers/push_data'](): ( + parameters?: CustomersPushDataParameters, + options?: CustomersPushDataOptions, + ) => CustomersPushDataRequest { + const { client, defaults } = this + return function customersPushData( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpCustomers.fromClient(client, defaults) + return seam.pushData(...args) + } + } + get ['/devices/delete'](): ( parameters?: DevicesDeleteParameters, options?: DevicesDeleteOptions, @@ -2696,6 +2731,42 @@ export class SeamHttpEndpoints { } } + get ['/seam/customer/v1/portals/get'](): ( + parameters?: SeamCustomerV1PortalsGetParameters, + options?: SeamCustomerV1PortalsGetOptions, + ) => SeamCustomerV1PortalsGetRequest { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamCustomerV1PortalsGet( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1Portals.fromClient(client, defaults) + return seam.get(...args) + } + } + + get ['/seam/customer/v1/settings/update'](): ( + parameters?: SeamCustomerV1SettingsUpdateParameters, + options?: SeamCustomerV1SettingsUpdateOptions, + ) => SeamCustomerV1SettingsUpdateRequest { + const { client, defaults } = this + if (!this.defaults.isUndocumentedApiEnabled) { + throw new Error( + 'Cannot use undocumented API without isUndocumentedApiEnabled', + ) + } + return function seamCustomerV1SettingsUpdate( + ...args: Parameters + ): ReturnType { + const seam = SeamHttpSeamCustomerV1Settings.fromClient(client, defaults) + return seam.update(...args) + } + } + get ['/seam/partner/v1/building_blocks/spaces/auto_map'](): ( parameters?: SeamPartnerV1BuildingBlocksSpacesAutoMapParameters, options?: SeamPartnerV1BuildingBlocksSpacesAutoMapOptions, @@ -2717,24 +2788,6 @@ export class SeamHttpEndpoints { } } - get ['/seam/partner/v1/resources/list'](): ( - parameters?: SeamPartnerV1ResourcesListParameters, - options?: SeamPartnerV1ResourcesListOptions, - ) => SeamPartnerV1ResourcesListRequest { - 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'](): ( parameters?: SpacesAddAcsEntrancesParameters, options?: SpacesAddAcsEntrancesOptions, @@ -3562,24 +3615,6 @@ export class SeamHttpEndpoints { } } - get ['/unstable_partner/resources/push'](): ( - parameters?: UnstablePartnerResourcesPushParameters, - options?: UnstablePartnerResourcesPushOptions, - ) => UnstablePartnerResourcesPushRequest { - 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'](): ( parameters?: UserIdentitiesAddAcsUserParameters, options?: UserIdentitiesAddAcsUserOptions, @@ -4007,9 +4042,8 @@ export type SeamHttpEndpointQueryPaths = | '/noise_sensors/noise_thresholds/list' | '/phones/get' | '/phones/list' - | '/phones/simulate/create_sandbox_phone' + | '/seam/customer/v1/portals/get' | '/seam/partner/v1/building_blocks/spaces/auto_map' - | '/seam/partner/v1/resources/list' | '/spaces/get' | '/spaces/list' | '/thermostats/get' @@ -4093,6 +4127,8 @@ export type SeamHttpEndpointMutationPaths = | '/connected_accounts/delete' | '/connected_accounts/sync' | '/connected_accounts/update' + | '/customers/create_portal' + | '/customers/push_data' | '/devices/delete' | '/devices/update' | '/devices/simulate/connect' @@ -4108,6 +4144,8 @@ export type SeamHttpEndpointMutationPaths = | '/noise_sensors/noise_thresholds/update' | '/noise_sensors/simulate/trigger_noise_threshold' | '/phones/deactivate' + | '/phones/simulate/create_sandbox_phone' + | '/seam/customer/v1/settings/update' | '/spaces/add_acs_entrances' | '/spaces/add_devices' | '/spaces/create' @@ -4147,7 +4185,6 @@ export type SeamHttpEndpointMutationPaths = | '/unstable_partner/building_blocks/connect_accounts' | '/unstable_partner/building_blocks/manage_devices' | '/unstable_partner/building_blocks/organize_spaces' - | '/unstable_partner/resources/push' | '/user_identities/add_acs_user' | '/user_identities/create' | '/user_identities/delete' diff --git a/src/lib/seam/connect/routes/seam-http.ts b/src/lib/seam/connect/routes/seam-http.ts index 899f9ab5..8ab5b00a 100644 --- a/src/lib/seam/connect/routes/seam-http.ts +++ b/src/lib/seam/connect/routes/seam-http.ts @@ -41,6 +41,7 @@ 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 { SeamHttpCustomers } from './customers/index.js' import { SeamHttpDevices } from './devices/index.js' import { SeamHttpEvents } from './events/index.js' import { SeamHttpLocks } from './locks/index.js' @@ -220,6 +221,10 @@ export class SeamHttp { return SeamHttpConnectedAccounts.fromClient(this.client, this.defaults) } + get customers(): SeamHttpCustomers { + return SeamHttpCustomers.fromClient(this.client, this.defaults) + } + get devices(): SeamHttpDevices { return SeamHttpDevices.fromClient(this.client, this.defaults) } diff --git a/src/lib/seam/connect/routes/unstable-partner/resources/index.ts b/src/lib/seam/connect/routes/seam/customer/index.ts similarity index 79% rename from src/lib/seam/connect/routes/unstable-partner/resources/index.ts rename to src/lib/seam/connect/routes/seam/customer/index.ts index 60e5e587..2e9499e7 100644 --- a/src/lib/seam/connect/routes/unstable-partner/resources/index.ts +++ b/src/lib/seam/connect/routes/seam/customer/index.ts @@ -3,4 +3,4 @@ * Do not edit this file or add other files to this directory. */ -export * from './resources.js' +export * from './v1/index.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 new file mode 100644 index 00000000..e19e87ec --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/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 './portals/index.js' +export * from './settings/index.js' +export * from './v1.js' diff --git a/src/lib/seam/connect/routes/seam/customer/v1/portals/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/portals/index.ts new file mode 100644 index 00000000..31aa3aa4 --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/portals/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 './portals.js' diff --git a/src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts b/src/lib/seam/connect/routes/seam/customer/v1/portals/portals.ts similarity index 78% rename from src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts rename to src/lib/seam/connect/routes/seam/customer/v1/portals/portals.ts index f5b21a2c..870b2131 100644 --- a/src/lib/seam/connect/routes/seam/partner/v1/resources/resources.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/portals/portals.ts @@ -36,7 +36,7 @@ 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 { +export class SeamHttpSeamCustomerV1Portals { client: Client readonly defaults: Required readonly ltsVersion = seamApiLtsVersion @@ -56,23 +56,23 @@ export class SeamHttpSeamPartnerV1Resources { static fromClient( client: SeamHttpOptionsWithClient['client'], options: Omit = {}, - ): SeamHttpSeamPartnerV1Resources { + ): SeamHttpSeamCustomerV1Portals { const constructorOptions = { ...options, client } if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } - return new SeamHttpSeamPartnerV1Resources(constructorOptions) + return new SeamHttpSeamCustomerV1Portals(constructorOptions) } static fromApiKey( apiKey: SeamHttpOptionsWithApiKey['apiKey'], options: Omit = {}, - ): SeamHttpSeamPartnerV1Resources { + ): SeamHttpSeamCustomerV1Portals { const constructorOptions = { ...options, apiKey } if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing apiKey') } - return new SeamHttpSeamPartnerV1Resources(constructorOptions) + return new SeamHttpSeamCustomerV1Portals(constructorOptions) } static fromClientSessionToken( @@ -81,24 +81,24 @@ export class SeamHttpSeamPartnerV1Resources { SeamHttpOptionsWithClientSessionToken, 'clientSessionToken' > = {}, - ): SeamHttpSeamPartnerV1Resources { + ): SeamHttpSeamCustomerV1Portals { const constructorOptions = { ...options, clientSessionToken } if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') } - return new SeamHttpSeamPartnerV1Resources(constructorOptions) + return new SeamHttpSeamCustomerV1Portals(constructorOptions) } static async fromPublishableKey( publishableKey: string, userIdentifierKey: string, options: SeamHttpFromPublishableKeyOptions = {}, - ): Promise { + ): Promise { warnOnInsecureuserIdentifierKey(userIdentifierKey) const clientOptions = parseOptions({ ...options, publishableKey }) if (isSeamHttpOptionsWithClient(clientOptions)) { throw new SeamHttpInvalidOptionsError( - 'The client option cannot be used with SeamHttpSeamPartnerV1Resources.fromPublishableKey', + 'The client option cannot be used with SeamHttpSeamCustomerV1Portals.fromPublishableKey', ) } const client = createClient(clientOptions) @@ -106,7 +106,7 @@ export class SeamHttpSeamPartnerV1Resources { const { token } = await clientSessions.getOrCreate({ user_identifier_key: userIdentifierKey, }) - return SeamHttpSeamPartnerV1Resources.fromClientSessionToken(token, options) + return SeamHttpSeamCustomerV1Portals.fromClientSessionToken(token, options) } static fromConsoleSessionToken( @@ -116,14 +116,14 @@ export class SeamHttpSeamPartnerV1Resources { SeamHttpOptionsWithConsoleSessionToken, 'consoleSessionToken' | 'workspaceId' > = {}, - ): SeamHttpSeamPartnerV1Resources { + ): SeamHttpSeamCustomerV1Portals { const constructorOptions = { ...options, consoleSessionToken, workspaceId } if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing consoleSessionToken or workspaceId', ) } - return new SeamHttpSeamPartnerV1Resources(constructorOptions) + return new SeamHttpSeamCustomerV1Portals(constructorOptions) } static fromPersonalAccessToken( @@ -133,14 +133,14 @@ export class SeamHttpSeamPartnerV1Resources { SeamHttpOptionsWithPersonalAccessToken, 'personalAccessToken' | 'workspaceId' > = {}, - ): SeamHttpSeamPartnerV1Resources { + ): SeamHttpSeamCustomerV1Portals { const constructorOptions = { ...options, personalAccessToken, workspaceId } if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing personalAccessToken or workspaceId', ) } - return new SeamHttpSeamPartnerV1Resources(constructorOptions) + return new SeamHttpSeamCustomerV1Portals(constructorOptions) } createPaginator( @@ -168,45 +168,44 @@ export class SeamHttpSeamPartnerV1Resources { await clientSessions.get() } - list( - parameters?: SeamPartnerV1ResourcesListParameters, - options: SeamPartnerV1ResourcesListOptions = {}, - ): SeamPartnerV1ResourcesListRequest { + get( + parameters?: SeamCustomerV1PortalsGetParameters, + options: SeamCustomerV1PortalsGetOptions = {}, + ): SeamCustomerV1PortalsGetRequest { if (!this.defaults.isUndocumentedApiEnabled) { throw new Error( 'Cannot use undocumented API without isUndocumentedApiEnabled', ) } return new SeamHttpRequest(this, { - pathname: '/seam/partner/v1/resources/list', + pathname: '/seam/customer/v1/portals/get', method: 'POST', body: parameters, - responseKey: 'partner_resources', + responseKey: 'customer_portal', options, }) } } -export type SeamPartnerV1ResourcesListParameters = - RouteRequestBody<'/seam/partner/v1/resources/list'> +export type SeamCustomerV1PortalsGetParameters = + RouteRequestBody<'/seam/customer/v1/portals/get'> /** - * @deprecated Use SeamPartnerV1ResourcesListParameters instead. + * @deprecated Use SeamCustomerV1PortalsGetParameters instead. */ -export type SeamPartnerV1ResourcesListParams = - SeamPartnerV1ResourcesListParameters +export type SeamCustomerV1PortalsGetParams = SeamCustomerV1PortalsGetParameters /** - * @deprecated Use SeamPartnerV1ResourcesListRequest instead. + * @deprecated Use SeamCustomerV1PortalsGetRequest instead. */ -export type SeamPartnerV1ResourcesListResponse = SetNonNullable< - Required> +export type SeamCustomerV1PortalsGetResponse = SetNonNullable< + Required> > -export type SeamPartnerV1ResourcesListRequest = SeamHttpRequest< - SeamPartnerV1ResourcesListResponse, - 'partner_resources' +export type SeamCustomerV1PortalsGetRequest = SeamHttpRequest< + SeamCustomerV1PortalsGetResponse, + 'customer_portal' > // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface SeamPartnerV1ResourcesListOptions {} +export interface SeamCustomerV1PortalsGetOptions {} diff --git a/src/lib/seam/connect/routes/seam/customer/v1/settings/index.ts b/src/lib/seam/connect/routes/seam/customer/v1/settings/index.ts new file mode 100644 index 00000000..8671c36c --- /dev/null +++ b/src/lib/seam/connect/routes/seam/customer/v1/settings/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 './settings.js' diff --git a/src/lib/seam/connect/routes/unstable-partner/resources/resources.ts b/src/lib/seam/connect/routes/seam/customer/v1/settings/settings.ts similarity index 78% rename from src/lib/seam/connect/routes/unstable-partner/resources/resources.ts rename to src/lib/seam/connect/routes/seam/customer/v1/settings/settings.ts index 092fa9f4..f407eaa1 100644 --- a/src/lib/seam/connect/routes/unstable-partner/resources/resources.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/settings/settings.ts @@ -36,7 +36,7 @@ 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 { +export class SeamHttpSeamCustomerV1Settings { client: Client readonly defaults: Required readonly ltsVersion = seamApiLtsVersion @@ -56,23 +56,23 @@ export class SeamHttpUnstablePartnerResources { static fromClient( client: SeamHttpOptionsWithClient['client'], options: Omit = {}, - ): SeamHttpUnstablePartnerResources { + ): SeamHttpSeamCustomerV1Settings { const constructorOptions = { ...options, client } if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } - return new SeamHttpUnstablePartnerResources(constructorOptions) + return new SeamHttpSeamCustomerV1Settings(constructorOptions) } static fromApiKey( apiKey: SeamHttpOptionsWithApiKey['apiKey'], options: Omit = {}, - ): SeamHttpUnstablePartnerResources { + ): SeamHttpSeamCustomerV1Settings { const constructorOptions = { ...options, apiKey } if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing apiKey') } - return new SeamHttpUnstablePartnerResources(constructorOptions) + return new SeamHttpSeamCustomerV1Settings(constructorOptions) } static fromClientSessionToken( @@ -81,24 +81,24 @@ export class SeamHttpUnstablePartnerResources { SeamHttpOptionsWithClientSessionToken, 'clientSessionToken' > = {}, - ): SeamHttpUnstablePartnerResources { + ): SeamHttpSeamCustomerV1Settings { const constructorOptions = { ...options, clientSessionToken } if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') } - return new SeamHttpUnstablePartnerResources(constructorOptions) + return new SeamHttpSeamCustomerV1Settings(constructorOptions) } static async fromPublishableKey( publishableKey: string, userIdentifierKey: string, options: SeamHttpFromPublishableKeyOptions = {}, - ): Promise { + ): Promise { warnOnInsecureuserIdentifierKey(userIdentifierKey) const clientOptions = parseOptions({ ...options, publishableKey }) if (isSeamHttpOptionsWithClient(clientOptions)) { throw new SeamHttpInvalidOptionsError( - 'The client option cannot be used with SeamHttpUnstablePartnerResources.fromPublishableKey', + 'The client option cannot be used with SeamHttpSeamCustomerV1Settings.fromPublishableKey', ) } const client = createClient(clientOptions) @@ -106,10 +106,7 @@ export class SeamHttpUnstablePartnerResources { const { token } = await clientSessions.getOrCreate({ user_identifier_key: userIdentifierKey, }) - return SeamHttpUnstablePartnerResources.fromClientSessionToken( - token, - options, - ) + return SeamHttpSeamCustomerV1Settings.fromClientSessionToken(token, options) } static fromConsoleSessionToken( @@ -119,14 +116,14 @@ export class SeamHttpUnstablePartnerResources { SeamHttpOptionsWithConsoleSessionToken, 'consoleSessionToken' | 'workspaceId' > = {}, - ): SeamHttpUnstablePartnerResources { + ): SeamHttpSeamCustomerV1Settings { const constructorOptions = { ...options, consoleSessionToken, workspaceId } if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing consoleSessionToken or workspaceId', ) } - return new SeamHttpUnstablePartnerResources(constructorOptions) + return new SeamHttpSeamCustomerV1Settings(constructorOptions) } static fromPersonalAccessToken( @@ -136,14 +133,14 @@ export class SeamHttpUnstablePartnerResources { SeamHttpOptionsWithPersonalAccessToken, 'personalAccessToken' | 'workspaceId' > = {}, - ): SeamHttpUnstablePartnerResources { + ): SeamHttpSeamCustomerV1Settings { const constructorOptions = { ...options, personalAccessToken, workspaceId } if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing personalAccessToken or workspaceId', ) } - return new SeamHttpUnstablePartnerResources(constructorOptions) + return new SeamHttpSeamCustomerV1Settings(constructorOptions) } createPaginator( @@ -171,18 +168,18 @@ export class SeamHttpUnstablePartnerResources { await clientSessions.get() } - push( - parameters?: UnstablePartnerResourcesPushParameters, - options: UnstablePartnerResourcesPushOptions = {}, - ): UnstablePartnerResourcesPushRequest { + update( + parameters?: SeamCustomerV1SettingsUpdateParameters, + options: SeamCustomerV1SettingsUpdateOptions = {}, + ): SeamCustomerV1SettingsUpdateRequest { if (!this.defaults.isUndocumentedApiEnabled) { throw new Error( 'Cannot use undocumented API without isUndocumentedApiEnabled', ) } return new SeamHttpRequest(this, { - pathname: '/unstable_partner/resources/push', - method: 'POST', + pathname: '/seam/customer/v1/settings/update', + method: 'PATCH', body: parameters, responseKey: undefined, options, @@ -190,26 +187,26 @@ export class SeamHttpUnstablePartnerResources { } } -export type UnstablePartnerResourcesPushParameters = - RouteRequestBody<'/unstable_partner/resources/push'> +export type SeamCustomerV1SettingsUpdateParameters = + RouteRequestBody<'/seam/customer/v1/settings/update'> /** - * @deprecated Use UnstablePartnerResourcesPushParameters instead. + * @deprecated Use SeamCustomerV1SettingsUpdateParameters instead. */ -export type UnstablePartnerResourcesPushBody = - UnstablePartnerResourcesPushParameters +export type SeamCustomerV1SettingsUpdateBody = + SeamCustomerV1SettingsUpdateParameters /** - * @deprecated Use UnstablePartnerResourcesPushRequest instead. + * @deprecated Use SeamCustomerV1SettingsUpdateRequest instead. */ -export type UnstablePartnerResourcesPushResponse = SetNonNullable< - Required> +export type SeamCustomerV1SettingsUpdateResponse = SetNonNullable< + Required> > -export type UnstablePartnerResourcesPushRequest = SeamHttpRequest< +export type SeamCustomerV1SettingsUpdateRequest = SeamHttpRequest< void, undefined > // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface UnstablePartnerResourcesPushOptions {} +export interface SeamCustomerV1SettingsUpdateOptions {} diff --git a/src/lib/seam/connect/routes/seam/partner/v1/v1.ts b/src/lib/seam/connect/routes/seam/customer/v1/v1.ts similarity index 83% rename from src/lib/seam/connect/routes/seam/partner/v1/v1.ts rename to src/lib/seam/connect/routes/seam/customer/v1/v1.ts index 0e293c57..7227d2c3 100644 --- a/src/lib/seam/connect/routes/seam/partner/v1/v1.ts +++ b/src/lib/seam/connect/routes/seam/customer/v1/v1.ts @@ -33,10 +33,10 @@ 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 { SeamHttpSeamPartnerV1BuildingBlocks } from './building-blocks/index.js' -import { SeamHttpSeamPartnerV1Resources } from './resources/index.js' +import { SeamHttpSeamCustomerV1Portals } from './portals/index.js' +import { SeamHttpSeamCustomerV1Settings } from './settings/index.js' -export class SeamHttpSeamPartnerV1 { +export class SeamHttpSeamCustomerV1 { client: Client readonly defaults: Required readonly ltsVersion = seamApiLtsVersion @@ -56,23 +56,23 @@ export class SeamHttpSeamPartnerV1 { static fromClient( client: SeamHttpOptionsWithClient['client'], options: Omit = {}, - ): SeamHttpSeamPartnerV1 { + ): SeamHttpSeamCustomerV1 { const constructorOptions = { ...options, client } if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } - return new SeamHttpSeamPartnerV1(constructorOptions) + return new SeamHttpSeamCustomerV1(constructorOptions) } static fromApiKey( apiKey: SeamHttpOptionsWithApiKey['apiKey'], options: Omit = {}, - ): SeamHttpSeamPartnerV1 { + ): SeamHttpSeamCustomerV1 { const constructorOptions = { ...options, apiKey } if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing apiKey') } - return new SeamHttpSeamPartnerV1(constructorOptions) + return new SeamHttpSeamCustomerV1(constructorOptions) } static fromClientSessionToken( @@ -81,24 +81,24 @@ export class SeamHttpSeamPartnerV1 { SeamHttpOptionsWithClientSessionToken, 'clientSessionToken' > = {}, - ): SeamHttpSeamPartnerV1 { + ): SeamHttpSeamCustomerV1 { const constructorOptions = { ...options, clientSessionToken } if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') } - return new SeamHttpSeamPartnerV1(constructorOptions) + return new SeamHttpSeamCustomerV1(constructorOptions) } static async fromPublishableKey( publishableKey: string, userIdentifierKey: string, options: SeamHttpFromPublishableKeyOptions = {}, - ): Promise { + ): Promise { warnOnInsecureuserIdentifierKey(userIdentifierKey) const clientOptions = parseOptions({ ...options, publishableKey }) if (isSeamHttpOptionsWithClient(clientOptions)) { throw new SeamHttpInvalidOptionsError( - 'The client option cannot be used with SeamHttpSeamPartnerV1.fromPublishableKey', + 'The client option cannot be used with SeamHttpSeamCustomerV1.fromPublishableKey', ) } const client = createClient(clientOptions) @@ -106,7 +106,7 @@ export class SeamHttpSeamPartnerV1 { const { token } = await clientSessions.getOrCreate({ user_identifier_key: userIdentifierKey, }) - return SeamHttpSeamPartnerV1.fromClientSessionToken(token, options) + return SeamHttpSeamCustomerV1.fromClientSessionToken(token, options) } static fromConsoleSessionToken( @@ -116,14 +116,14 @@ export class SeamHttpSeamPartnerV1 { SeamHttpOptionsWithConsoleSessionToken, 'consoleSessionToken' | 'workspaceId' > = {}, - ): SeamHttpSeamPartnerV1 { + ): SeamHttpSeamCustomerV1 { const constructorOptions = { ...options, consoleSessionToken, workspaceId } if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing consoleSessionToken or workspaceId', ) } - return new SeamHttpSeamPartnerV1(constructorOptions) + return new SeamHttpSeamCustomerV1(constructorOptions) } static fromPersonalAccessToken( @@ -133,14 +133,14 @@ export class SeamHttpSeamPartnerV1 { SeamHttpOptionsWithPersonalAccessToken, 'personalAccessToken' | 'workspaceId' > = {}, - ): SeamHttpSeamPartnerV1 { + ): SeamHttpSeamCustomerV1 { const constructorOptions = { ...options, personalAccessToken, workspaceId } if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing personalAccessToken or workspaceId', ) } - return new SeamHttpSeamPartnerV1(constructorOptions) + return new SeamHttpSeamCustomerV1(constructorOptions) } createPaginator( @@ -168,14 +168,11 @@ export class SeamHttpSeamPartnerV1 { await clientSessions.get() } - get buildingBlocks(): SeamHttpSeamPartnerV1BuildingBlocks { - return SeamHttpSeamPartnerV1BuildingBlocks.fromClient( - this.client, - this.defaults, - ) + get portals(): SeamHttpSeamCustomerV1Portals { + return SeamHttpSeamCustomerV1Portals.fromClient(this.client, this.defaults) } - get resources(): SeamHttpSeamPartnerV1Resources { - return SeamHttpSeamPartnerV1Resources.fromClient(this.client, this.defaults) + get settings(): SeamHttpSeamCustomerV1Settings { + return SeamHttpSeamCustomerV1Settings.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 index 6e74aa88..d8d31f24 100644 --- a/src/lib/seam/connect/routes/seam/index.ts +++ b/src/lib/seam/connect/routes/seam/index.ts @@ -3,4 +3,5 @@ * Do not edit this file or add other files to this directory. */ +export * from './customer/index.js' export * from './partner/index.js' diff --git a/src/lib/seam/connect/routes/seam/partner/v1/index.ts b/src/lib/seam/connect/routes/seam/partner/v1/index.ts index 7d67e232..ee41d3d1 100644 --- a/src/lib/seam/connect/routes/seam/partner/v1/index.ts +++ b/src/lib/seam/connect/routes/seam/partner/v1/index.ts @@ -4,5 +4,3 @@ */ export * from './building-blocks/index.js' -export * from './resources/index.js' -export * from './v1.js' diff --git a/src/lib/seam/connect/routes/unstable-partner/index.ts b/src/lib/seam/connect/routes/unstable-partner/index.ts index 751f59ff..85ca7e0f 100644 --- a/src/lib/seam/connect/routes/unstable-partner/index.ts +++ b/src/lib/seam/connect/routes/unstable-partner/index.ts @@ -4,5 +4,4 @@ */ 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/unstable-partner.ts b/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts index 8f57e45f..403ff0ba 100644 --- a/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts +++ b/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts @@ -34,7 +34,6 @@ 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 @@ -174,11 +173,4 @@ export class SeamHttpUnstablePartner { this.defaults, ) } - - get resources(): SeamHttpUnstablePartnerResources { - return SeamHttpUnstablePartnerResources.fromClient( - this.client, - this.defaults, - ) - } }