1.0.16 • Published 1 year ago

oss-alphabroder v1.0.16

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Utility Functions for Alphabroder Web

npm i oss-alphabroder
import { checkWarehouses ,isProduction, isBrowser, eReports} from 'oss-alphabroder';

Purpose

This code contains a set of utility functions for the Alphabroder web application. These functions provide various services such as checking the production environment, checking warehouse codes, and converting decoration codes to decoration method names.

Functionality

  • isBrowser: A constant that checks if the code is running in a browser environment.
  • isProduction: A function that returns a boolean indicating whether the code is running in a production environment.
  • checkWarehouses: A function that takes in a warehouse code and a method, and returns the corresponding warehouse code.
  • getDecoMethodNameFromDecoCode: A function that takes in a decoration code and returns the corresponding decoration method name.
  • ossAurycData(): A function retrieves session metadata from the Auryc browser API and logs it to the console as a table. It also returns the metadata as an object. If an error occurs, it returns null.
  • ossAurycEvent(): A function that send an object to Auryc event meta-data.
  • asyncFnWithRetries(): A async function that executes the specified function with retries, catching any errors that occur.
  • matchInkSoftSequence() : A function that takes in a decoLocation object and tries to match the colors in the coordination_colors array with the colors in the artObjects array. If it fails to find a match, it will return a transparent color.

Code Implementation

The code is implemented using JavaScript and exports these functions as CommonJS modules to be used in other parts of the application.

Example Usage

Here is an example of how the checkWarehouses function could be used in the application:

import { checkWarehouses } from 'oss-alphabroder';

const warehouse = 'all';
const method = 'Embroidery';

const updatedWarehouse = checkWarehouses(warehouse, method);
console.log(updatedWarehouse); // Output: 'kd'
import { getDecoMethodNameFromDecoCode } from 'oss-alphabroder';

const decoCode = 'SCREEN';

const decoMethodName = getDecoMethodNameFromDecoCode(decoCode);
console.log(decoMethodName); // Output: 'Screen Print'

ossAurycData()

This function retrieves session metadata from the Auryc browser API and logs it to the console as a table. It also returns the metadata as an object. If an error occurs, it returns null.

Parameters

This function takes no parameters.

ossAurycEvent(properties)

This function adds event properties to the Auryc browser API. The properties are passed as an object to the function.

Parameters

properties (object): Object containing event properties to add. This function does not return a value.

import { ossAurycEvent } from 'oss-alphabroder';

ossAurycEvent({ pageName: 'Home', userLoggedIn: true , 'myCustomProperty': 'myCustomValue' });

asyncFnWithRetries(fn, maxRetries, retryDelay)

import { asyncFnWithRetries } from 'oss-alphabroder';
asyncFnWithRetries(fn, maxRetries, retryDelay)
/**
 * Executes the specified function with retries, catching any errors that occur.
 * @param fn The function to execute.
 * @param maxRetries The maximum number of retries.
 * @param retryDelay The delay between retries, in milliseconds.
 * @returns The result of the function, or null if an error occurs after all retries.
 */
1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago