Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// clones response.items used in includes because we don't want these to be mutated
if (resolveLinks) {
response.items = resolveResponse(response, {removeUnresolved, itemEntryPoints: ['fields']})
}
// maps response items again after getters are attached
const mappedResponseItems = mapResponseItems(response.items)
if (response.nextSyncToken) {
mappedResponseItems.nextSyncToken = response.nextSyncToken
}
if (response.nextPageToken) {
mappedResponseItems.nextPageToken = response.nextPageToken
}
return freezeSys(mixinStringifySafe(toPlainObject(mappedResponseItems)))
}, (error) => {
throw error
export function wrapRole (http, data) {
const role = toPlainObject(cloneDeep(data))
enhanceWithMethods(role, createRoleApi(http))
return freezeSys(role)
}
export function wrapRoleCollection (http, data) {
const roles = toPlainObject(cloneDeep(data))
roles.items = roles.items.map((entity) => wrapRole(http, entity))
return freezeSys(roles)
}
export function wrapAssetCollection (http, data) {
const assets = toPlainObject(cloneDeep(data))
assets.items = assets.items.map((entity) => wrapAsset(http, entity))
return freezeSys(assets)
}
export function wrapEnvironmentCollection (http, data) {
const environments = toPlainObject(cloneDeep(data))
environments.items = environments.items.map((entity) => wrapEnvironment(http, entity))
return freezeSys(environments)
}
export function wrapAsset (http, data) {
const asset = toPlainObject(cloneDeep(data))
enhanceWithMethods(asset, createAssetApi(http))
return freezeSys(asset)
}
export function wrapPersonalAccessToken (http, data) {
const personalAccessToken = toPlainObject(cloneDeep(data))
enhanceWithMethods(personalAccessToken, createPersonalAccessToken(http))
return freezeSys(personalAccessToken)
}
hostUpload,
defaultHostnameUpload
} = http.httpClientParams
const environmentScopedHttpClient = http.cloneWithNewParams({
baseURL: http.defaults.baseURL + 'environments/' + environment.sys.id
})
const environmentScopedUploadClient = http.cloneWithNewParams({
space: environment.sys.space.sys.id,
host: hostUpload || defaultHostnameUpload
})
const environmentApi = createEnvironmentApi({
http: environmentScopedHttpClient,
httpUpload: environmentScopedUploadClient
})
const enhancedEnvironment = enhanceWithMethods(environment, environmentApi)
return freezeSys(enhancedEnvironment)
}
export function wrapWebhookCollection (http, data) {
const webhooks = toPlainObject(cloneDeep(data))
webhooks.items = webhooks.items.map((entity) => wrapWebhook(http, entity))
return freezeSys(webhooks)
}
hostUpload,
defaultHostnameUpload
} = http.httpClientParams
const spaceScopedHttpClient = http.cloneWithNewParams({
space: space.sys.id
})
const spaceScopedUploadClient = http.cloneWithNewParams({
space: space.sys.id,
host: hostUpload || defaultHostnameUpload
})
const spaceApi = createSpaceApi({
http: spaceScopedHttpClient,
httpUpload: spaceScopedUploadClient
})
const enhancedSpace = enhanceWithMethods(space, spaceApi)
return freezeSys(enhancedSpace)
}