UNPKG

diffusion

Version:

Diffusion JavaScript client

53 lines (43 loc) 1.42 kB
var DEFAULT_ATTRIBUTES = { // Type-specific - only serialised for associated subtype serialiser slaveMasterTopic : "", emptyFieldValue : "", handler : "", // General properties tidyOnUnsubscribe : false, properties : {}, reference : "", }; function createDetails(type, schema, properties) { var attributes = {}; // Have to copy so as to avoid subsequent modification from properties for (var k in DEFAULT_ATTRIBUTES) { attributes[k] = DEFAULT_ATTRIBUTES[k]; } // Handle properties from TopicSpecifications if (properties) { var props = {}; for (var p in properties) { switch (p) { case "TIDY_ON_UNSUBSCRIBE" : attributes.tidyOnUnsubscribe = properties.TIDY_ON_UNSUBSCRIBE === "true"; break; case "SLAVE_MASTER_TOPIC" : attributes.slaveMasterTopic = properties.SLAVE_MASTER_TOPIC; break; default : props[p] = properties[p]; break; } } attributes.properties = props; } return { type : type, schema : schema, attributes : attributes }; } module.exports.detailsFromSpecification = function(specification) { return createDetails(specification.type, {}, specification.properties); };