oro-sdk 3.10.0 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/helpers/workflow.d.ts +47 -1
- package/dist/oro-sdk.cjs.development.js +568 -932
- package/dist/oro-sdk.cjs.development.js.map +1 -1
- package/dist/oro-sdk.cjs.production.min.js +1 -1
- package/dist/oro-sdk.cjs.production.min.js.map +1 -1
- package/dist/oro-sdk.esm.js +568 -932
- package/dist/oro-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/workflow.ts +63 -5
- package/LICENSE +0 -21
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "3.
|
2
|
+
"version": "3.13.0",
|
3
3
|
"main": "dist/index.js",
|
4
4
|
"typings": "dist/index.d.ts",
|
5
5
|
"files": [
|
@@ -54,7 +54,7 @@
|
|
54
54
|
"form-data": "^4.0.0",
|
55
55
|
"formdata-node": "^4.3.1",
|
56
56
|
"idb-keyval": "^5.0.6",
|
57
|
-
"oro-sdk-apis": "1.
|
57
|
+
"oro-sdk-apis": "1.48.0",
|
58
58
|
"oro-toolbox": "0.0.6",
|
59
59
|
"uuid": "^8.3.2"
|
60
60
|
}
|
package/src/helpers/workflow.ts
CHANGED
@@ -179,13 +179,71 @@ async function populateWorkflowField(
|
|
179
179
|
})
|
180
180
|
}
|
181
181
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
182
|
+
/**
|
183
|
+
* Determine if a question is triggered by some answers
|
184
|
+
*
|
185
|
+
* We use the following logical combinations of rules:
|
186
|
+
*
|
187
|
+
* #### Single string
|
188
|
+
*
|
189
|
+
* ```
|
190
|
+
* // Required: rule1
|
191
|
+
* rules: rule1
|
192
|
+
* ```
|
193
|
+
*
|
194
|
+
* #### Array of strings (AND is applied between statements):
|
195
|
+
*
|
196
|
+
* ```
|
197
|
+
* // Required: rule1 AND rule2
|
198
|
+
* rules: [ rule1, rule2 ]
|
199
|
+
* ```
|
200
|
+
*
|
201
|
+
* #### Array of arrays of strings (OR is applied between inner arrays. AND is applied between inner arrays statements)
|
202
|
+
*
|
203
|
+
* ```
|
204
|
+
* // Required: rule1 OR rule2
|
205
|
+
* rules: [
|
206
|
+
* [ rule1 ],
|
207
|
+
* [ rule2 ]
|
208
|
+
* ]
|
209
|
+
*
|
210
|
+
* // Required: rule1 OR (rule2 AND rule3)
|
211
|
+
* rules: [
|
212
|
+
* [ rule1 ],
|
213
|
+
* [ rule2, rule3 ]
|
214
|
+
* ]
|
215
|
+
*
|
216
|
+
* // THIS IS FORBIDDEN
|
217
|
+
* rules: [
|
218
|
+
* rule1, // <-- THIS IS FORBIDDEN. Instead use [ rule1 ]
|
219
|
+
* [ rule2, rule3 ]
|
220
|
+
* ]
|
221
|
+
* ```
|
222
|
+
*
|
223
|
+
* @param triggers the triggering rules
|
224
|
+
* @param answers the answers to check againts triggering rules
|
225
|
+
* @returns `true` if triggers are verified against ansers. Otherwise, returns `false`.
|
226
|
+
* @throws an Error if triggers typing is wrong
|
227
|
+
*/
|
228
|
+
export function isTriggered(triggers: string[][] | string[] | string, answers: string[]): boolean {
|
229
|
+
// is triggers contained in answers
|
230
|
+
if (typeof triggers === 'string') {
|
231
|
+
return answers.includes(triggers)
|
232
|
+
}
|
233
|
+
|
234
|
+
if (Array.isArray(triggers)) {
|
235
|
+
// rule combination kind: rule1 OR (rule2 AND rule3)
|
236
|
+
if (Array.isArray(triggers[0])) {
|
237
|
+
return (triggers as string[][]).some((subSetTriggers) =>
|
238
|
+
subSetTriggers.every((trigger) => answers.includes(trigger))
|
239
|
+
)
|
240
|
+
} else {
|
241
|
+
// rule combination kind: rule1 AND rule2
|
242
|
+
return (triggers as string[]).every((trigger) => answers.includes(trigger))
|
186
243
|
}
|
187
244
|
}
|
188
|
-
|
245
|
+
|
246
|
+
throw Error('[isTriggered] triggers is not typed well')
|
189
247
|
}
|
190
248
|
|
191
249
|
export function flattenSelectedAnswers(answers: SelectedAnswersData) {
|
package/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2021 ORO Health Inc.
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|