Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Expose url setters in Content and lambdas client #470

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/client/ContentClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export type ContentClient = {
* Deploys an entity to the content server.
*/
deploy(deployData: DeploymentData, options?: RequestOptions): Promise<unknown>

setContentUrl(url: string): void
}

export async function downloadContent(
Expand Down Expand Up @@ -66,7 +68,7 @@ export async function downloadContent(

export function createContentClient(options: ClientOptions): ContentClient {
const { fetcher } = options
const contentUrl = sanitizeUrl(options.url)
let contentUrl = sanitizeUrl(options.url)

async function buildEntityFormDataForDeployment(
deployData: DeploymentData,
Expand Down Expand Up @@ -166,6 +168,10 @@ export function createContentClient(options: ClientOptions): ContentClient {
return new Set(alreadyUploaded)
}

function setContentUrl(url: string) {
contentUrl = sanitizeUrl(url)
}

return {
buildEntityFormDataForDeployment,
fetchEntitiesByPointers,
Expand All @@ -175,6 +181,7 @@ export function createContentClient(options: ClientOptions): ContentClient {
return downloadContent(fetcher, contentUrl + '/contents', contentHash, options)
},
deploy,
setContentUrl,
isContentAvailable
}
}
11 changes: 8 additions & 3 deletions src/client/LambdasClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sanitizeUrl } from './utils/Helper'
import * as client from './specs/lambdas-client'
import { ClientOptions } from './types'
import { CustomClient } from './utils/fetcher'
import * as client from './specs/lambdas-client'
import { sanitizeUrl } from './utils/Helper'

export type LambdasClient = ReturnType<typeof createLambdasClient>

Expand All @@ -14,6 +14,10 @@ export function createLambdasClient(options: ClientOptions) {
}
}

function setLambdasUrl(url: string) {
options.url = sanitizeUrl(url)
}

return {
getLambdaStatus: wrap(client.getLambdaStatus),
getCollections: wrap(client.getCollections),
Expand All @@ -30,6 +34,7 @@ export function createLambdasClient(options: ClientOptions) {
getRealms: wrap(client.getRealms),
getAvatarsDetailsByPost: wrap(client.getAvatarsDetailsByPost),
getAvatarDetails: wrap(client.getAvatarDetails),
getThirdPartyIntegrations: wrap(client.getThirdPartyIntegrations)
getThirdPartyIntegrations: wrap(client.getThirdPartyIntegrations),
setLambdasUrl
}
}
Loading