Socket
Socket
Sign inDemoInstall

@oneblink/sdk-core

Package Overview
Dependencies
Maintainers
6
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oneblink/sdk-core - npm Package Compare versions

Comparing version 0.4.6-beta.1 to 0.4.6-beta.2

26

dist/formElementsService.d.ts

@@ -89,2 +89,26 @@ import { FormTypes } from '@oneblink/types';

declare function flattenFormElements(elements: FormTypes.FormElement[]): FormTypes.FormElement[];
export { forEachFormElement, forEachFormElementWithOptions, findFormElement, parseFormElementOptionsSet, flattenFormElements, };
/**
* The regex used for matching `{ELEMENT:<elementName>}` tags in OneBlink
* Calculation and Info (HTML) elements.
*/
declare const WYSIWYGRegex: RegExp;
/**
* Takes a string and calls a provided handler function for each found instance
* of `{ELEMENT:<elementName>}` in the string. Used to replace values in
* OneBlink calculation and info (HTML) elements.
*
* #### Example
*
* ```js
* formElementsService.matchElementsTagRegex(myString, (elementName) => {
* const v = submission[elementName]
* myString = myString.replace(`{ELEMENT:${elementName}}`, v)
* })
* ```
*
* @param data
* @param handler
* @returns
*/
declare const matchElementsTagRegex: (data: string, matchHandler: (elementName: string) => void) => void;
export { forEachFormElement, forEachFormElementWithOptions, findFormElement, parseFormElementOptionsSet, flattenFormElements, WYSIWYGRegex, matchElementsTagRegex, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flattenFormElements = exports.parseFormElementOptionsSet = exports.findFormElement = exports.forEachFormElementWithOptions = exports.forEachFormElement = void 0;
exports.matchElementsTagRegex = exports.WYSIWYGRegex = exports.flattenFormElements = exports.parseFormElementOptionsSet = exports.findFormElement = exports.forEachFormElementWithOptions = exports.forEachFormElement = void 0;
const _1 = require(".");

@@ -175,2 +175,36 @@ /**

exports.flattenFormElements = flattenFormElements;
/**
* The regex used for matching `{ELEMENT:<elementName>}` tags in OneBlink
* Calculation and Info (HTML) elements.
*/
const WYSIWYGRegex = /({ELEMENT:)([^}]+)(})/g;
exports.WYSIWYGRegex = WYSIWYGRegex;
/**
* Takes a string and calls a provided handler function for each found instance
* of `{ELEMENT:<elementName>}` in the string. Used to replace values in
* OneBlink calculation and info (HTML) elements.
*
* #### Example
*
* ```js
* formElementsService.matchElementsTagRegex(myString, (elementName) => {
* const v = submission[elementName]
* myString = myString.replace(`{ELEMENT:${elementName}}`, v)
* })
* ```
*
* @param data
* @param handler
* @returns
*/
const matchElementsTagRegex = (data, matchHandler) => {
let matches;
while ((matches = WYSIWYGRegex.exec(data)) !== null) {
if ((matches === null || matches === void 0 ? void 0 : matches.length) < 3)
continue;
const elementName = matches[2];
matchHandler(elementName);
}
};
exports.matchElementsTagRegex = matchElementsTagRegex;
//# sourceMappingURL=formElementsService.js.map

@@ -10,3 +10,3 @@ import { FormTypes, SubmissionTypes } from '@oneblink/types';

* ```js
* const value = formElementsService.getRootElementById(
* const value = submissionService.getRootElementById(
* formElementId,

@@ -24,1 +24,20 @@ * form.elements,

export declare function getRootElementValueById(formElementId: string, formElements: FormTypes.FormElement[], submission: SubmissionTypes.S3SubmissionData['submission']): unknown;
/**
* Takes an element name and a submission object, and returns the provided
* element's value as a string. Used for replaceable values in OneBlink
* Calculation and Info (HTML) elements.
*
* #### Example
*
* ```js
* const nameElementValue = submissionService.getSubmissionValueAsString(
* 'Name_Element',
* submission,
* )
* ```
*
* @param elementName
* @param submission
* @returns
*/
export declare function getSubmissionValueAsString(elementName: string, submission: SubmissionTypes.S3SubmissionData['submission']): string;

@@ -17,3 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getRootElementValueById = void 0;
exports.getSubmissionValueAsString = exports.getRootElementValueById = void 0;
__exportStar(require("./replaceCustomValues"), exports);

@@ -27,3 +27,3 @@ /**

* ```js
* const value = formElementsService.getRootElementById(
* const value = submissionService.getRootElementById(
* formElementId,

@@ -54,2 +54,43 @@ * form.elements,

exports.getRootElementValueById = getRootElementValueById;
/**
* Takes an element name and a submission object, and returns the provided
* element's value as a string. Used for replaceable values in OneBlink
* Calculation and Info (HTML) elements.
*
* #### Example
*
* ```js
* const nameElementValue = submissionService.getSubmissionValueAsString(
* 'Name_Element',
* submission,
* )
* ```
*
* @param elementName
* @param submission
* @returns
*/
function getSubmissionValueAsString(elementName, submission) {
const v = submission[elementName];
switch (typeof v) {
case 'function':
case 'undefined':
case 'symbol': {
return '';
}
case 'object': {
// Account for null
return (v === null || v === void 0 ? void 0 : v.toString()) || '';
}
case 'number':
case 'boolean':
case 'bigint': {
return v.toString();
}
default: {
return v;
}
}
}
exports.getSubmissionValueAsString = getSubmissionValueAsString;
//# sourceMappingURL=submissionService.js.map

2

package.json
{
"name": "@oneblink/sdk-core",
"description": "OneBlink SDK for JavaScript (works in Browsers and NodeJS)",
"version": "0.4.6-beta.1",
"version": "0.4.6-beta.2",
"author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",

@@ -6,0 +6,0 @@ "bugs": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc