npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@leisurelink/lla-sync

v1.0.2

Published

This module is meant to provide much of the groundwork for synchronization of ARI data between a third party supplier and the LeisureLink Public API. Simply put, once the module is initialized and configured, the user can provide the module with an array

Downloads

5

Readme

lla-sync

This module is meant to provide much of the groundwork for synchronization of ARI data between a third party supplier and the LeisureLink Public API. Simply put, once the module is initialized and configured, the user can provide the module with an array of user-defined 'unit' objects along with the sync operations to perform and the module will return the user-defined 'unit' data with details regarding the operations that were performed and whether they were successful.

Implementation Details

Implementing the lla-sync module into a project can be broken into two pieces: configuration and synchronization.

Configuration

The configuration portion of using the lla-sync module is the most complicated part of using the module.

lla_sync( { mapper, apiClient, [options] } )

This function will instantiate the module.

Arguments
  • mapper - The instantiated mapper object (assumes the lla-mapper function contract)
  • apiClient - The instantiated LeisureLink client object (assumes the dreamcatcher-client function contract)
  • options - Optional configuration for fine-tuning
    • apiRetries - Number of attempts to retry a LeisureLink API call upon "recoverable" failures
    • apiRetryDelay - Seconds to wait after a "recoverable" failure
    • concurrencyLimit - Max number of concurrent operations to perform for a single call to sync
    • debugMode - Not implemented

configureDefaultMappingSettings( { mappingType, mappingKeyFnc } )

This function will define how to lookup a mapping incase specific mapping details aren't provided for an operation.

Arguments
  • mappingType - Name of the mapping used by mapper
  • mappingKeyFnc - Fcn that takes a user-defined 'unit' object and outputs the external key for lla-mapper

configuredSyncOperation( { syncOperation, transformFnc, [mappingType], [mappingKeyFnc] } )

This function will configure a single sync operation that can be triggered later.

Arguments
  • syncOperation - Name of the sync operation
  • transformFnc - Fnc that takes an object and outputs the body of the API call
  • mappingType - Optional name of the non-default mapping used by lla-mapper
  • mappingKeyFnc - Optional non-default fnc that takes an object and outputs an external key

Comprehensive Code Example

var lla_sync = require('lla-sync');

// initialize the module
var syncModule = lla_sync({
    mapper: lla_mapper,
    apiClient: dreamcatcherClient,
    options: {
      apiRetries: 5,
      apiRetryDelay: 10,
      concurrencyLimit: 50,
      debugMode: false
    }
});

// configure a default mapping settings to be used if specific settings aren't defined for an operation
syncModule.configureDefaultMappingSettings({
    mappingType: 'rentalUnit',
    mappingKeyFnc: getExternalKeyFnc
});

// configure an operation that can be run later
syncModule.configureSyncOperation({
    syncOperation: 'specialAvailability',
    transformFnc: transformSpecialFnc,
    mappingType: 'special',
    mappingKeyFnc: getSpecialExternalKeyFnc
});

// configure an operation that uses the default mapping settings
// requires running configureDefaultMappingSettings first
syncModule.configureSyncOperation({
    syncOperation: 'availability',
    transformFnc: transformAvailabilityFnc
});

Synchronization

Once the module has been appropriately configured, the operations to run and the user-defined 'unit' data can be provided to the sync function.

sync( { syncOperations, syncData, callback } )

Arguments
  • syncOperations - Array of sync operation names to perform
  • syncData
    • startDate - Date string representing the first day to sync
    • endDate - Date string representing the last day to sync
    • data - Array of user-defined 'unit' objects
  • callback - Fnc to handle the error/results
Results

If no critical error occurs during synchronization, the callback will receive an array of units with information regarding the result of its sync operations. Each unit will contain the following data:

  • supplierUnit - The user-defined object that was provided to the sync function
  • syncOperations - Dictionary of the sync operations that were run for the unit

Each sync operation object will contain the following data:

  • mapping - The mapping that was retrieved for the unit
  • successful - Boolean representing whether the operation completed successfully
  • error - Standard error object if synchronization failed
  • timestamp - Timestamp when successful was set

Comprehensive Code Example

// prepare the data
var syncData = {
    startDate: '2015-10-16',
    endDate: '2016-10-16',
    data: [ {}, {} ] // should contain real data
};

// synchronize!
syncModule.sync(
    ['availability','specialAvailability'],
    syncData,
    function(error, results) {
    // handle error/result data
});