/*=============================================================================

Define ServiceName Service Provider

=============================================================================
961276
function ServiceName(keys){
  if (!keys) return
  this.name = 'service_name'
  this.keys = keys

  this.initialize = function() {
    // Require npm package and pass any api keys or login credentials here
    //this.client = require('npm package here');
  }

  this.send = function(data, callback) {
    var context = this;

    /*
    Define data to be sent here

    var sendingData = {
      // Data parameters go here
      // Setup incoming data to match the format for this specific service
    };
    */

    /*
    Send the formatted data via the service-specific sending function

    this.client.sendingFunction(sendingData, function (err, result) {
      // Handle errors and results here by wrapping them in our status handlers

      var serviceStat;
      if (err) {
        // Handle error with our wrapper (defined below)
        serviceStat = new ServiceNameErrorStatus(err);
        return callback(serviceStat);
      } else {
        // Handle result with our wrapper (defined below)
        // Make sure to attach the wrapped result as the status property of the original result object
        serviceStat = new ServiceNameSuccessStatus(result);
        result.status = serviceStat;
        return callback(null, result);
      }
    })
    */
  }

  this.initialize()
}
1313226
function createServer(serverName) {
        console.log("creating server", serverName)
        var server = servers[serverName] = net.createServer(handleConnection)
        ports.service(serverName, listen)

        function handleConnection(connection) {
            console.log("got incoming connection", connection)
            var stream = proxy.connect(serverName)
                , buffer = PauseStream().pause()
                , intermediate = through(stringer)

            connection.pipe(buffer)

            process.nextTick(pipe)

            function pipe() {
                buffer.pipe(intermediate)
                    .pipe(stream).pipe(connection)

                buffer.resume()
            }
        }

        function listen(port, ready) {
            server.listen(port, ready)
        }
    }
265741
@Override
	protected String getServiceName(final String methodName) {
		if (methodName != null) {
			int ndx = methodName.indexOf(this.separator);
			if (ndx > 0) {
				return methodName.substring(0, ndx);
			}
		}
		return methodName;
	}
170006
function addPluginName(data) {
	var loader = data.loader;
	var bundles = data.bundles;

	var promises = bundles.map(function(bundle) {
		if (!isJavaScriptBundle(bundle)) {
			return loader.normalize(bundle.name).then(function(name) {
				bundle.pluginName = name.substring(name.indexOf("!") + 1);
			});
		}
	});

	return Promise.all(promises).then(function() {
		return data;
	});
}
704473
function buildEndpointServices(services = [], numZones = 0) {
  if (!Array.isArray(services) || services.length < 1) {
    return {};
  }
  if (numZones < 1) {
    return {};
  }

  const subnetIds = [];
  const routeTableIds = [];
  for (let i = 1; i <= numZones; i += 1) {
    subnetIds.push({ Ref: `${APP_SUBNET}Subnet${i}` });
    routeTableIds.push({ Ref: `${APP_SUBNET}RouteTable${i}` });
  }

  const resources = {};
  services.forEach(service => {
    Object.assign(resources, buildVPCEndpoint(service, { routeTableIds, subnetIds }));
  });

  return resources;
}
138658
function MODULENAME_DivHTML( divId, resourceURL, paramObj ) {
	log( "MODULENAME",  "divId="+divId+" resourceURL="+resourceURL );
	if ( moduleConfig[ divId ] != null ) {
		MODULENAME_RenderHTML( divId, resourceURL, paramObj, moduleConfig[ divId ]  );
	} else {

		//TODO: move that to portal-ng.js
		var metaURL =  resourceURL+"/MODULENAME";
    if ( paramObj != null ) {
      if ( paramObj.def != null ) {
        metaURL = resourceURL+"/"+paramObj.def;
      }
		}
		// pass get params of page to module config loader call, to enable dynamic table columns
		if ( paramObj.get != null ) {
			var first = true;
			for (var key in paramObj.get) {
				metaURL += (first ? "?" :"&");
				metaURL += key + "=" + paramObj.get[ key ];
				first = false;
			}
		}

		$.getJSON( 
			resourceURL+"/MODULENAME", 
			function( pmd ) {
				MODULENAME_RenderHTML( divId, resourceURL, paramObj, pmd );
			}
		);					
	}	
}
681738
function Injector(obj){
  var services = {};
  var get = name => {
    if(!(name in services)){
      const err = new Error(`[injector] service "${name}" not found`);
      return Promise.reject(err);
    }
    return services[name];
  };
  if(typeof obj === 'object')
    services = obj;
  if(typeof obj === 'function')
    get = obj;
  function resolve(name) {
    let service = get(name);
    if(typeof service === 'function')
      service = invoke(service);
    return service;
  };
  function invoke(fn, that){
    return Promise
    .all(getParameterNames(fn).map(resolve))
    .then(params => fn.apply(that, params));
  }
  return invoke;
}
916981
function getServiceInfo(serviceName, adapterMap) {
        var serviceInfo = { serviceName: serviceName };
        var serviceParts = utils.splitCamelCase(serviceName);  // turn oneTwoThree into ['one', 'two', 'three']
        var nbrParts = serviceParts.length;

        // first check to see if the second to last part is an adapter
        serviceInfo.adapterName = serviceParts[nbrParts - 2];  // NOTE: last item in array is 'Service'
        if (adapterMap[serviceInfo.adapterName]) {
            serviceInfo.resourceName = serviceParts.slice(0, nbrParts - 2).join('.');
        }
        // if not, it means we are dealing with a straight service (ex. postService)
        else {
            serviceInfo.adapterName = 'service';
            serviceInfo.resourceName = serviceParts.slice(0, nbrParts - 1).join('.');
        }

        serviceInfo.adapterImpl = adapterMap[serviceInfo.adapterName];

        return serviceInfo;
    }
219590
function parentName (options) {
  function instantiate (input) {
    if (/^[A-Z]{3}/.test(input)) {
      return input.replace(/^([A-Z]+)([A-Z])/, function (str, p1, p2) {
        return p1.toLowerCase() + p2
      })
    } else {
      return input.charAt(0).toLowerCase() + input.slice(1)
    }
  }

  /* don't bother with a parentName for exported identifiers */
  if (this.isExported) return ''

  if (this.memberof && this.kind !== 'constructor') {
    var parent = arrayify(options.data.root).find(where({ id: this.memberof }))
    if (parent) {
      if (this.scope === 'instance') {
        var name = parent.typicalname || parent.name
        return instantiate(name)
      } else if (this.scope === 'static' && !(parent.kind === 'class' || parent.kind === 'constructor')) {
        return parent.typicalname || parent.name
      } else {
        return parent.name
      }
    } else {
      return this.memberof
    }
  }
}
517489
ServiceName serviceName(final String name) {
        RuntimeCapability<?> dynamicCapability = runtimeCapability.fromBaseCapability(name);
        return dynamicCapability.getCapabilityServiceName(clazz);
    }
88473
function (methodName) {
            var parameters = this.smd.parameters || [];

            parameters = parameters.concat(this.smd.services[methodName].parameters || []);

            return parameters;
        }
146085
function(definition, client) {

  this.client = client;

  this.schema = null;

  this.ddlHelper = {
    tableName: null,
    pkAttrName: null,
    pkAutoIncrement: false,
    attrNamesToColNames: {},
    attrTypes: {},
    colNamesToAttrNames: {},
    colTypes: {},
    defaultValues: {},
    cqlCreateTable: null,
    indexes: {}
  };

  this._parseDefinition(definition);
}
141395
function configure(name, service) {
	if (!name) {
		throw new Error('Please specify a name for the client');
	}
	if (name === 'configure' || name === 'client') {
		throw new Error('Cannot register service with reserved name: ' + name);
	}
	module.exports[name] = new Client(service);
}
1198780
function Service(name) {
	if (typeof name === "function") {
		var _constructor = name;name = null;
		return register(_constructor);
	}
	return register;

	function register(constructor) {
		registerLock(constructor);
		var meta = (0, _utils.funcMeta)(constructor);

		name = name || meta.name;
		meta.service.name = name;

		_app.app.service(name, constructor);
	}
}
93598
function DiffProvider(serviceRegistry, filter) {
		var allReferences = serviceRegistry.getServiceReferences("orion.core.diff"); //$NON-NLS-0$
		var i, _references = allReferences;
		if (filter) {
			_references = [];
			for(i = 0; i < allReferences.length; ++i) {
				if (filter(allReferences[i])) {
					_references.push(allReferences[i]);
				}
			}
		}
		var _patterns = [];
		var _services = [];
		
		for(i = 0; i < _references.length; ++i) {
			_patterns[i] = new RegExp(_references[i].getProperty("pattern") || ".*");//$NON-NLS-1$ //$NON-NLS-0$
			_services[i] = serviceRegistry.getService(_references[i]);
		}

		this._getService = function(location) {
			location = _normalizeURL(location);
			for(var i = 0; i < _patterns.length; ++i) {
				if (_patterns[i].test(location)) {
					return _services[i];
				}
			}
			throw messages["NoDiffServiceLocationMatched"] + location;
		};
	}
401717
function serverDecorator (server, id, params = {}) {
  params = joi.attempt(params, internals.scheme.params)

  const route = Object.assign({}, lookupRoute(server, id))
  const routeSections = route.path.match(internals.regexp.params) || []

  routeSections.forEach((routeSection) => {
    const stripped = routeSection.replace(internals.regexp.braces, '')
    let parsed

    if (stripped.includes('?')) {
      parsed = parseOptional(params.params, routeSection, stripped)
    } else if (stripped.includes('*') && stripped.slice(-1) !== '*') {
      parsed = parseMulti(params.params, routeSection, stripped)
    } else {
      parsed = parsePlain(params.params, routeSection, stripped)
    }

    route.path = route.path.replace(parsed.dst, parsed.src)
  })

  if (params.query) {
    route.path += `?${qs.stringify(params.query)}`
    route.path = route.path.replace(/\?$/, '')
  }

  return route.path
}
857476
function validateConfig(config) {
    // appId and versionId are not validated here since
    // not all operations require these to be present.
    // Validation of specific params are done in the
    // ServiceBase.js
    const {subscriptionKey} = config;
    const messageTail = `is missing from the configuration.\n\nDid you run ${chalk.cyan.bold('qnamaker init')} yet?`;
    assert(typeof subscriptionKey === 'string', `The subscriptionKey ${messageTail}`);
}