export type UserSourceDynamicTenantConfig = {tenantIdFieldName: string, tenantResolverType: 'dynamic'}; export type UserSourceStaticTenantConfig = {tenantId: string, tenantResolverType: 'static'}; export type UserSourceNewTenantConfig = {tenantResolverType: 'new'}; export type ExternalCognitoUserSourceConfig = {syncOnLogin: boolean, isMigrated: boolean, region: string, clientId: string, userPoolId: string, accessKeyId: string, secretAccessKey: string, clientSecret?: string | undefined, tenantConfig: UserSourceDynamicTenantConfig | UserSourceStaticTenantConfig | UserSourceNewTenantConfig}; export type UpdateExternalCognitoUserSourceRequestDTO = {name?: string | undefined, configuration?: ExternalCognitoUserSourceConfig | undefined, index?: number | undefined, description?: string | undefined}; export type UpdateApiResourcesUserSourcesV1ExternalCognitoIdArgs = {id: string, body: UpdateExternalCognitoUserSourceRequestDTO}; export type UpdateApiResourcesUserSourcesV1ExternalCognitoIdOptions = {baseUrl?: string | undefined, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Cognito external user source * * PUT /resources/user-sources/v1/external/cognito/{id} */ export const updateApiResourcesUserSourcesV1ExternalCognitoId = async (args: UpdateApiResourcesUserSourcesV1ExternalCognitoIdArgs, options?: UpdateApiResourcesUserSourcesV1ExternalCognitoIdOptions) => { const {baseUrl = "http://localhost:8181", fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/resources/user-sources/v1/external/cognito/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };