@oneblink/sdk
Advanced tools
Comparing version 0.3.2 to 0.3.3-beta.0
@@ -5,2 +5,6 @@ # Changelog | ||
### Added | ||
- Added `SEARCH` options type and `searchUrl` property for autocomplete element | ||
# 0.3.2 (2019-06-20) | ||
@@ -7,0 +11,0 @@ |
@@ -86,3 +86,3 @@ // @flow | ||
toDate?: string, | ||
optionsType? : 'custom' | 'dynamic', | ||
optionsType? : 'custom' | 'dynamic' | 'search', | ||
dynamicOptionSetId?: number, | ||
@@ -100,3 +100,4 @@ options?: Array<{ | ||
isElementLookup?: boolean, | ||
formId?: number | ||
formId?: number, | ||
searchUrl?: string | ||
} | ||
@@ -103,0 +104,0 @@ |
@@ -38,2 +38,4 @@ // @flow | ||
const DYNAMIC_OPTION_TYPE = 'DYNAMIC' | ||
const SEARCH_OPTION_TYPE = 'SEARCH' | ||
const optionTypes = [ | ||
@@ -64,5 +66,5 @@ CUSTOM_OPTION_TYPE, | ||
then: Joi.array().label('Form Element - Conditionally Show Predicates').unique('elementId').min(1).items(Joi.object().keys({ | ||
'elementId': Joi.string().guid().required().label('Form Element - Conditionally Show Predicate - Element Id'), | ||
'type': Joi.string().default('OPTIONS').label('Form Element - Conditionally Show Predicate - Type').valid(['OPTIONS', 'NUMERIC']), | ||
'optionIds': Joi.label('Form Element - Conditionally Show Predicate - Option Ids') | ||
elementId: Joi.string().guid().required().label('Form Element - Conditionally Show Predicate - Element Id'), | ||
type: Joi.string().default('OPTIONS').label('Form Element - Conditionally Show Predicate - Type').valid(['OPTIONS', 'NUMERIC']), | ||
optionIds: Joi.label('Form Element - Conditionally Show Predicate - Option Ids') | ||
.when('type', { | ||
@@ -73,3 +75,3 @@ is: Joi.only('OPTIONS'), | ||
}), | ||
'operator': Joi.label('Form Element - Conditionally Show Predicate - Operator') | ||
operator: Joi.label('Form Element - Conditionally Show Predicate - Operator') | ||
.when('type', { | ||
@@ -80,3 +82,3 @@ is: Joi.only('NUMERIC'), | ||
}), | ||
'value': Joi.label('Form Element - Conditionally Show Predicate - Value') | ||
value: Joi.label('Form Element - Conditionally Show Predicate - Value') | ||
.when('type', { | ||
@@ -122,6 +124,6 @@ is: Joi.only('NUMERIC'), | ||
// Generic | ||
'id': Joi.string().guid().required().label('Form Element - Id'), | ||
'type': Joi.string().required().label('Form Element - Type').valid(elementTypes), | ||
'name': Joi.string().label('Form Element - Name').required(), | ||
'label': Joi.when('type', { | ||
id: Joi.string().guid().required().label('Form Element - Id'), | ||
type: Joi.string().required().label('Form Element - Type').valid(elementTypes), | ||
name: Joi.string().label('Form Element - Name').required(), | ||
label: Joi.when('type', { | ||
is: Joi.only(['form', 'infoPage']), | ||
@@ -131,3 +133,3 @@ then: Joi.any().strip(), | ||
}), | ||
'required': Joi.when('type', { | ||
required: Joi.when('type', { | ||
is: Joi.only(['form', 'infoPage']), | ||
@@ -137,3 +139,3 @@ then: Joi.any().strip(), | ||
}), | ||
'readOnly': Joi.when('type', { | ||
readOnly: Joi.when('type', { | ||
is: Joi.only(['form', 'infoPage']), | ||
@@ -143,4 +145,4 @@ then: Joi.any().strip(), | ||
}), | ||
'conditionallyShow': Joi.bool().default(false).label('Form Element - Conditionally Show'), | ||
'requiresAllConditionallyShowPredicates': Joi.when('conditionallyShow', { | ||
conditionallyShow: Joi.bool().default(false).label('Form Element - Conditionally Show'), | ||
requiresAllConditionallyShowPredicates: Joi.when('conditionallyShow', { | ||
is: true, | ||
@@ -150,4 +152,4 @@ then: Joi.bool().default(false).label('Form Element - Requires All Conditionally Show Predicates are Met'), | ||
}), | ||
'conditionallyShowPredicates': ConditionallyShowPredicatesSchema, | ||
'defaultValue': Joi.allow(null).label('Form Element - Default Value') | ||
conditionallyShowPredicates: ConditionallyShowPredicatesSchema, | ||
defaultValue: Joi.allow(null).label('Form Element - Default Value') | ||
.when('type', { | ||
@@ -246,3 +248,3 @@ is: Joi.only([ | ||
// Radio buttons | ||
'buttons': Joi.when('type', { | ||
buttons: Joi.when('type', { | ||
is: Joi.only(['radio', 'checkboxes']), | ||
@@ -253,3 +255,3 @@ then: Joi.boolean().label('Form Element - Radio Buttons as Buttons').default(false), | ||
// Select | ||
'multi': Joi.when('type', { | ||
multi: Joi.when('type', { | ||
is: 'select', | ||
@@ -261,3 +263,3 @@ then: Joi.boolean().label('Form Element - Multi Select').default(false), | ||
// Number | ||
'isSlider': Joi.when('type', { | ||
isSlider: Joi.when('type', { | ||
is: 'number', | ||
@@ -267,3 +269,3 @@ then: Joi.boolean().label('Form Element - Display Number as Slider').default(false), | ||
}), | ||
'sliderIncrement': Joi.when('isSlider', { | ||
sliderIncrement: Joi.when('isSlider', { | ||
is: true, | ||
@@ -273,3 +275,3 @@ then: JoiRange.range().within({ min: Joi.ref('minNumber'), max: Joi.ref('maxNumber') }).label('Form Element - Slider Increment'), | ||
}), | ||
'minNumber': Joi.number().allow(null).label('Form Element - Minimum Number') | ||
minNumber: Joi.number().allow(null).label('Form Element - Minimum Number') | ||
.when('type', { | ||
@@ -283,3 +285,3 @@ is: Joi.not('number'), | ||
}), | ||
'maxNumber': Joi.number().label('Form Element - Maximum Number') | ||
maxNumber: Joi.number().label('Form Element - Maximum Number') | ||
.when('type', { | ||
@@ -299,3 +301,3 @@ is: Joi.not('number'), | ||
// Heading | ||
'headingType': Joi.when('type', { | ||
headingType: Joi.when('type', { | ||
is: Joi.only('heading'), | ||
@@ -313,3 +315,3 @@ then: Joi.number().required().label('Form Element - Heading Size').valid([ | ||
// Date and Date+Time | ||
'fromDate': Joi.when('type', { | ||
fromDate: Joi.when('type', { | ||
is: Joi.only(['date', 'datetime']), | ||
@@ -319,3 +321,3 @@ then: Joi.date().iso().label('Form Element - From Date').allow(null), | ||
}), | ||
'toDate': Joi.when('type', { | ||
toDate: Joi.when('type', { | ||
is: Joi.only(['date', 'datetime']), | ||
@@ -329,8 +331,13 @@ then: Joi.when('fromDate', { | ||
// Checkboxes, selects, radio and autocomplete | ||
'optionsType': Joi.when('type', { | ||
optionsType: Joi.when('type', { | ||
is: Joi.only(['checkboxes', 'radio', 'select', 'autocomplete']), | ||
then: Joi.string().label('Form Element - Options type').default(CUSTOM_OPTION_TYPE).valid(optionTypes), | ||
then: Joi.string().label('Form Element - Options type').default(CUSTOM_OPTION_TYPE) | ||
.when('type', { | ||
is: 'autocomplete', | ||
then: Joi.valid([...optionTypes, SEARCH_OPTION_TYPE]), | ||
otherwise: Joi.valid(optionTypes) | ||
}), | ||
otherwise: Joi.any().strip() | ||
}), | ||
'dynamicOptionSetId': Joi.when('optionsType', { | ||
dynamicOptionSetId: Joi.when('optionsType', { | ||
is: DYNAMIC_OPTION_TYPE, | ||
@@ -340,12 +347,12 @@ then: Joi.number().label('Form Element - Dynamic Option Set Id').required(), | ||
}), | ||
'options': Joi.when('optionsType', { | ||
options: Joi.when('optionsType', { | ||
is: CUSTOM_OPTION_TYPE, | ||
then: Joi.array().label('Form Element - Options').unique('id').items(Joi.object().keys({ | ||
'id': Joi.string().guid().required().label('Form Element - Option Id'), | ||
'value': Joi.string().required().label('Form Element - Option Value'), | ||
'label': Joi.string().required().label('Form Element - Option Label'), | ||
'colour': Joi.string().allow([null, '']).regex(/^#[A-Fa-f0-9]{3}([A-Fa-f0-9]{3})?$/).label('Form Element - Option Colour'), | ||
'attributes': Joi.array().items(Joi.object().keys({ | ||
'optionIds': Joi.array().required().items(Joi.string()).label('Form Element - Attributes Mapping - Element Id'), | ||
'elementId': Joi.string().guid().required().label('Form Element - Option Value - Attribute Option Id') | ||
id: Joi.string().guid().required().label('Form Element - Option Id'), | ||
value: Joi.string().required().label('Form Element - Option Value'), | ||
label: Joi.string().required().label('Form Element - Option Label'), | ||
colour: Joi.string().allow([null, '']).regex(/^#[A-Fa-f0-9]{3}([A-Fa-f0-9]{3})?$/).label('Form Element - Option Colour'), | ||
attributes: Joi.array().items(Joi.object().keys({ | ||
optionIds: Joi.array().required().items(Joi.string()).label('Form Element - Attributes Mapping - Element Id'), | ||
elementId: Joi.string().guid().required().label('Form Element - Option Value - Attribute Option Id') | ||
})) | ||
@@ -355,11 +362,11 @@ })).required(), | ||
}), | ||
'attributesMapping': Joi.when('optionsType', { | ||
attributesMapping: Joi.when('optionsType', { | ||
is: DYNAMIC_OPTION_TYPE, | ||
then: Joi.array().items(Joi.object().keys({ | ||
'elementId': Joi.string().guid().required().label('Form Element - Option Value - Attribute Element Id'), | ||
'attribute': Joi.string().required().label('Form Element - Attributes Mapping - Attribute') | ||
elementId: Joi.string().guid().required().label('Form Element - Option Value - Attribute Element Id'), | ||
attribute: Joi.string().required().label('Form Element - Attributes Mapping - Attribute') | ||
})), | ||
otherwise: Joi.any().strip() | ||
}), | ||
'conditionallyShowOptions': Joi.when('type', { | ||
conditionallyShowOptions: Joi.when('type', { | ||
is: Joi.only(['checkboxes', 'radio', 'select', 'autocomplete']), | ||
@@ -369,3 +376,3 @@ then: Joi.boolean().label('Form Element - conditionallyShowOptionsElementIds').default(false), | ||
}), | ||
'conditionallyShowOptionsElementIds': Joi.when('optionsType', { | ||
conditionallyShowOptionsElementIds: Joi.when('optionsType', { | ||
is: CUSTOM_OPTION_TYPE, | ||
@@ -377,3 +384,3 @@ then: Joi.array().items(Joi.string().guid().required().label('Form Element - Attributes Mapping - Element Id')), | ||
// repeatableSet | ||
'minSetEntries': Joi.when('type', { | ||
minSetEntries: Joi.when('type', { | ||
is: Joi.only('repeatableSet'), | ||
@@ -385,3 +392,3 @@ then: Joi.number() | ||
}), | ||
'maxSetEntries': Joi.when('type', { | ||
maxSetEntries: Joi.when('type', { | ||
is: Joi.only('repeatableSet'), | ||
@@ -397,3 +404,3 @@ then: Joi.number() | ||
}), | ||
'addSetEntryLabel': Joi.string() | ||
addSetEntryLabel: Joi.string() | ||
.when('type', { | ||
@@ -404,3 +411,3 @@ is: Joi.only('repeatableSet'), | ||
}), | ||
'removeSetEntryLabel': Joi | ||
removeSetEntryLabel: Joi | ||
.when('type', { | ||
@@ -411,3 +418,3 @@ is: Joi.only('repeatableSet'), | ||
}), | ||
'elements': Joi | ||
elements: Joi | ||
.when('type', { | ||
@@ -420,3 +427,3 @@ is: Joi.only('repeatableSet'), | ||
// Barcode Scanner | ||
'restrictBarcodeTypes': Joi | ||
restrictBarcodeTypes: Joi | ||
.when('type', { | ||
@@ -427,3 +434,3 @@ is: Joi.only('barcodeScanner'), | ||
}), | ||
'restrictedBarcodeTypes': Joi | ||
restrictedBarcodeTypes: Joi | ||
.when('type', { | ||
@@ -440,3 +447,3 @@ is: Joi.only('barcodeScanner'), | ||
// calculation | ||
'calculation': Joi | ||
calculation: Joi | ||
.when('type', { | ||
@@ -447,3 +454,3 @@ is: Joi.only('calculation'), | ||
}), | ||
'preCalculationDisplay': Joi | ||
preCalculationDisplay: Joi | ||
.when('type', { | ||
@@ -462,3 +469,3 @@ is: Joi.only('calculation'), | ||
// Data lookup configuration | ||
'isDataLookup': Joi.when('type', { | ||
isDataLookup: Joi.when('type', { | ||
is: Joi.only(userInputTypes), | ||
@@ -468,3 +475,3 @@ then: Joi.boolean().default(false).label('Data Lookup enabled'), | ||
}), | ||
'dataLookupUrl': Joi | ||
dataLookupUrl: Joi | ||
.when('type', { | ||
@@ -479,3 +486,3 @@ is: Joi.only(userInputTypes), | ||
}), | ||
'dataLookupApiId': Joi | ||
dataLookupApiId: Joi | ||
.when('type', { | ||
@@ -492,3 +499,3 @@ is: Joi.only(userInputTypes), | ||
// Element lookup configuration | ||
'isElementLookup': Joi | ||
isElementLookup: Joi | ||
.when('type', { | ||
@@ -499,3 +506,3 @@ is: Joi.only(userInputTypes), | ||
}), | ||
'elementLookupUrl': Joi | ||
elementLookupUrl: Joi | ||
.when('type', { | ||
@@ -510,3 +517,3 @@ is: Joi.only(userInputTypes), | ||
}), | ||
'elementLookupApiId': Joi | ||
elementLookupApiId: Joi | ||
.when('type', { | ||
@@ -523,6 +530,17 @@ is: Joi.only(userInputTypes), | ||
// form and infoPage | ||
'formId': Joi.when('type', { | ||
formId: Joi.when('type', { | ||
is: ['form', 'infoPage'], | ||
then: Joi.number().label('Form Id').required(), | ||
otherwise: Joi.any().strip() | ||
}), | ||
// autocomplete with SEARCH option type | ||
searchUrl: Joi.when('type', { | ||
is: 'autocomplete', | ||
then: Joi.when('optionsType', { | ||
is: SEARCH_OPTION_TYPE, | ||
then: Joi.string().required().label('Search URL'), | ||
otherwise: Joi.any().strip() | ||
}), | ||
otherwise: Joi.any().strip() | ||
}) | ||
@@ -533,3 +551,3 @@ }) | ||
isDraft: Joi.boolean().default(false), | ||
'type': Joi.string().required().label('Form Submission Event - Type').valid([ | ||
type: Joi.string().required().label('Form Submission Event - Type').valid([ | ||
'CALLBACK', | ||
@@ -540,8 +558,8 @@ 'PDF', | ||
]), | ||
'configuration': Joi.allow(null).label('Form Submission Event - Configuration') | ||
configuration: Joi.allow(null).label('Form Submission Event - Configuration') | ||
.when('type', { | ||
is: 'CALLBACK', | ||
then: Joi.object().keys({ | ||
'url': Joi.string().uri().required().label('Form Submission Event - Callback Url'), | ||
'secret': Joi.string().required().label('Form Submission Event - Callback Secret') | ||
url: Joi.string().uri().required().label('Form Submission Event - Callback Url'), | ||
secret: Joi.string().required().label('Form Submission Event - Callback Secret') | ||
}) | ||
@@ -552,8 +570,8 @@ }) | ||
then: Joi.object().keys({ | ||
'email': Joi.alternatives([ | ||
email: Joi.alternatives([ | ||
Joi.string().email().required().label('Form Submission Event - Email Address'), | ||
Joi.string().regex(/^{ELEMENT:\S+}$/).required().label('Form Submission Event - Email Address') | ||
]), | ||
'pdfFileName': Joi.string().allow([null, '']).label('Form Submission Event - PDF File Name'), | ||
'emailSubjectLine': Joi.string().allow([null, '']).label('Form Submission Event - Email Subject Line') | ||
pdfFileName: Joi.string().allow([null, '']).label('Form Submission Event - PDF File Name'), | ||
emailSubjectLine: Joi.string().allow([null, '']).label('Form Submission Event - Email Subject Line') | ||
}) | ||
@@ -564,6 +582,6 @@ }) | ||
then: Joi.object().keys({ | ||
'apiId': Joi.string().required().regex(/^[a-z\d-]+\.api\.(?:oneblink|blinkm)\.io$/).label('Form Submission Event - API Instance'), | ||
'apiEnvironment': Joi.string().required().label('Form Submission Event - API Environment'), | ||
'apiEnvironmentRoute': Joi.string().required().label('Form Submission Event - API Environment Route'), | ||
'secret': Joi.string().required().label('Form Submission Event - Callback Secret') | ||
apiId: Joi.string().required().regex(/^[a-z\d-]+\.api\.(?:oneblink|blinkm)\.io$/).label('Form Submission Event - API Instance'), | ||
apiEnvironment: Joi.string().required().label('Form Submission Event - API Environment'), | ||
apiEnvironmentRoute: Joi.string().required().label('Form Submission Event - API Environment Route'), | ||
secret: Joi.string().required().label('Form Submission Event - Callback Secret') | ||
}) | ||
@@ -575,25 +593,25 @@ }) | ||
formSchema: Joi.object().keys({ | ||
'id': Joi.number(), | ||
'name': Joi.string().label('Name').required(), | ||
'description': Joi.string().label('Description').allow('').allow(null), | ||
'organisationId': Joi.string().label('Organisation').required(), | ||
'elements': Joi.array().label('Form Elements').when('isMultiPage', { | ||
id: Joi.number(), | ||
name: Joi.string().label('Name').required(), | ||
description: Joi.string().label('Description').allow('').allow(null), | ||
organisationId: Joi.string().label('Organisation').required(), | ||
elements: Joi.array().label('Form Elements').when('isMultiPage', { | ||
is: false, | ||
then: Joi.array().required().items(BaseSchema).unique('name', { ignoreUndefined: true }).unique('id'), | ||
otherwise: Joi.array().items(Joi.object().keys({ | ||
'id': Joi.string().guid().required().label('Form Element - Id'), | ||
'label': Joi.string().required().label('Form Element - Label'), | ||
'type': Joi.only('page'), | ||
'conditionallyShow': Joi.bool().default(false).label('Form Element - Conditionally Show'), | ||
'conditionallyShowPredicates': ConditionallyShowPredicatesSchema, | ||
'requiresAllConditionallyShowPredicates': Joi.bool().default(false).label('Form Element - Requires All Conditionally Show Predicates are Met'), | ||
'elements': Joi.array().label('Form Element - Page - Elements').required().items(BaseSchema).min(1).unique('name', { ignoreUndefined: true }).unique('id') | ||
id: Joi.string().guid().required().label('Form Element - Id'), | ||
label: Joi.string().required().label('Form Element - Label'), | ||
type: Joi.only('page'), | ||
conditionallyShow: Joi.bool().default(false).label('Form Element - Conditionally Show'), | ||
conditionallyShowPredicates: ConditionallyShowPredicatesSchema, | ||
requiresAllConditionallyShowPredicates: Joi.bool().default(false).label('Form Element - Requires All Conditionally Show Predicates are Met'), | ||
elements: Joi.array().label('Form Element - Page - Elements').required().items(BaseSchema).min(1).unique('name', { ignoreUndefined: true }).unique('id') | ||
})) | ||
}), | ||
'isMultiPage': Joi.bool().default(false).label('Form Is Multi Page'), | ||
'isAuthenticated': Joi.bool().default(false).label('Form Authentication'), | ||
'isPublished': Joi.bool().default(false).label('Form Publication'), | ||
'submissionEvents': Joi.array().allow(null).label('Submission Events').items(SubmissionEventsSchema), | ||
'postSubmissionAction': Joi.string().label('Post Submission Action').required().valid(['URL', 'CLOSE', 'FORMS_LIBRARY']), | ||
'redirectUrl': Joi.when('postSubmissionAction', { | ||
isMultiPage: Joi.bool().default(false).label('Form Is Multi Page'), | ||
isAuthenticated: Joi.bool().default(false).label('Form Authentication'), | ||
isPublished: Joi.bool().default(false).label('Form Publication'), | ||
submissionEvents: Joi.array().allow(null).label('Submission Events').items(SubmissionEventsSchema), | ||
postSubmissionAction: Joi.string().label('Post Submission Action').required().valid(['URL', 'CLOSE', 'FORMS_LIBRARY']), | ||
redirectUrl: Joi.when('postSubmissionAction', { | ||
is: 'URL', | ||
@@ -603,8 +621,8 @@ then: Joi.string().required().label('Post Submission Redirect URL'), | ||
}), | ||
'isInfoPage': Joi.bool().default(false).label('Form Information Page'), | ||
'formsAppIds': Joi.array().items(Joi.number()).required().label('Associated Forms Apps'), | ||
'createdAt': Joi.string().label('Date Created').allow('').allow(null), | ||
'updatedAt': Joi.string().label('Date Updated').allow('').allow(null) | ||
isInfoPage: Joi.bool().default(false).label('Form Information Page'), | ||
formsAppIds: Joi.array().items(Joi.number()).required().label('Associated Forms Apps'), | ||
createdAt: Joi.string().label('Date Created').allow('').allow(null), | ||
updatedAt: Joi.string().label('Date Updated').allow('').allow(null) | ||
}), | ||
elementSchema: BaseSchema | ||
} |
{ | ||
"name": "@oneblink/sdk", | ||
"description": "OneBlink SDK to serve as an entry point for all OneBlink Services in NodeJS", | ||
"version": "0.3.2", | ||
"version": "0.3.3-beta.0", | ||
"bugs": { | ||
@@ -6,0 +6,0 @@ "url": "https://github.com/blinkmobile/oneblink-sdk-js/issues" |
93135
2737