Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[{ displayName }, { policy }, { deliveryPolicy }]
)
const prevInstanceTopicAttributes = filter((item) => !isNil(head(values(item))))([
{ displayName: prevInstance.displayName },
{ policy: prevInstance.policy },
{ deliveryPolicy: prevInstance.deliveryPolicy }
])
// combine inputs and check if something is removed
const topicAttributesToUpdate = concatInputsAndState(topicAttributes, prevInstanceTopicAttributes)
await updateTopicAttributes(sns, { topicAttributes: topicAttributesToUpdate, topicArn })
// flatten delivery status attributes array
const flatDeliveryStatusAttributes = reduce(
(result, attribute) =>
concat(result, map((key) => ({ [key]: attribute[key] }), keys(attribute))),
[],
deliveryStatusAttributes
)
// combine inputs and check if something is removed and select only ones that differs in state and inputs
const deliveryStatusAttributesToUpdate = concatInputsAndState(
flatDeliveryStatusAttributes,
prevInstance.deliveryStatusAttributes
)
// update delivery status attributes
await updateDeliveryStatusAttributes(sns, {
deliveryStatusAttributes: deliveryStatusAttributesToUpdate,
topicArn
const serializeObject = curry((context, object) =>
reduce(
(accum, value, key) => {
value = resolve(value)
if (isSerializable(value)) {
if (isSymbol(key)) {
const symbolString = getSymbolString(context, key)
if (symbolString) {
if (isSerializableReferenceable(value)) {
return set(['symbols', symbolString], toReference(context, value), accum)
}
return set(['symbols', symbolString], serializeValue(context, value), accum)
}
// context.log(`unhandled symbol detected ${toString(key)}`)
} else {
if (isSerializableReferenceable(value)) {
return set(['props', key], toReference(context, value), accum)
}
)
// combine inputs and check if something is removed and select only ones that differs in state and inputs
const deliveryStatusAttributesToUpdate = concatInputsAndState(
flatDeliveryStatusAttributes,
prevInstance.deliveryStatusAttributes
)
// update delivery status attributes
await updateDeliveryStatusAttributes(sns, {
deliveryStatusAttributes: deliveryStatusAttributesToUpdate,
topicArn
})
return merge(
reduce(
(result, value) => merge({ [head(keys(value))]: head(values(value)) }, result),
{},
topicAttributes
),
{ deliveryStatusAttributes: flatDeliveryStatusAttributes }
)
}
const concatInputsAndState = (inputs, state = []) => {
const attributeKeys = map((item) => head(keys(item)), inputs)
return filter((item) => isNil(find(equals(item))(state)))(
concat(
inputs,
reduce(
(attributes, attribute) => {
const key = head(keys(attribute))
if (!contains(key, attributeKeys)) {
// return empty string to "unset" removed value
return concat(attributes, [{ [key]: '' }])
}
return attributes
},
[],
state
)
)
)
}
const concatSubscriptionAttributes = (inputs, state = {}) =>
concat(
// inputs subscriptionAttributes as array
map((key) => ({ [key]: inputs[key] }), keys(inputs)),
// state subscriptionAttributes as array with removed items
reduce(
(attributes, key) => {
if (!contains(key, keys(inputs))) {
// return empty object to "unset" removed value
return concat(attributes, [{ [key]: {} }])
}
return attributes
},
[],
keys(state)
)
)
async info() {
const services = await reduce(
async (accum, service) => append(await service.info(), accum),
[],
or(this.services, {})
)
const components = await reduce(
async (accum, component) => append(await component.info(), accum),
[],
or(this.components, {})
)
return {
title: this.name,
type: this.name,
data: {},
children: [...components, ...services]
}
const execNodeIds = async (iteratee, nodeIds, graph, context) =>
all(
reduce(
(accum, nodeId) => {
const node = graph.node(nodeId)
if (!node) {
throw new Error(`could not find node for nodeId:${nodeId}`)
}
graph.removeNode(nodeId)
return append(execNode(iteratee, node, context), accum)
},
[],
nodeIds
)
)
const resolveInSequence = async (functionsToExecute) =>
reduce(
(promise, functionToExecute) =>
promise.then((result) => functionToExecute().then(Array.prototype.concat.bind(result))),
Promise.resolve([]),
functionsToExecute
)