@microsurveysai/react-native 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/dist/index.cjs
CHANGED
|
@@ -121,6 +121,7 @@ var MAX_SCALE_POINTS = 101;
|
|
|
121
121
|
var MAX_SCALE_ABS = 1e3;
|
|
122
122
|
var MAX_STARS = 100;
|
|
123
123
|
var MAX_OPTIONS = 100;
|
|
124
|
+
var QUESTION_TYPES = ["NPS", "CES", "CSAT_STAR", "CSAT_EMOJI", "THUMBS", "SINGLE_CHOICE", "OPEN_TEXT"];
|
|
124
125
|
function boundedScale(min, max) {
|
|
125
126
|
const lo = Math.min(Math.max(min, -MAX_SCALE_ABS), MAX_SCALE_ABS);
|
|
126
127
|
let hi = Math.min(Math.max(max, -MAX_SCALE_ABS), MAX_SCALE_ABS);
|
|
@@ -199,8 +200,14 @@ function normalizeSurvey(raw) {
|
|
|
199
200
|
const id = strOrUndef(raw.id);
|
|
200
201
|
const name = strOrUndef(raw.name);
|
|
201
202
|
if (!id || name === void 0) return null;
|
|
202
|
-
const
|
|
203
|
-
const
|
|
203
|
+
const rawQuestions = Array.isArray(raw.questions) ? raw.questions : [];
|
|
204
|
+
const rawTriggers = Array.isArray(raw.triggers) ? raw.triggers : [];
|
|
205
|
+
if (rawQuestions.some((q) => !QUESTION_TYPES.includes(asObject(q).type)) || rawTriggers.some((t) => {
|
|
206
|
+
const type = asObject(t).type;
|
|
207
|
+
return type != null && type !== "SINGLE" && type !== "SEQUENCE";
|
|
208
|
+
})) return null;
|
|
209
|
+
const questions = rawQuestions.map((q) => normalizeQuestion(asObject(q))).filter((q) => q !== null);
|
|
210
|
+
const triggers = rawTriggers.map((t) => normalizeTrigger(asObject(t))).filter((t) => t !== null);
|
|
204
211
|
return {
|
|
205
212
|
id,
|
|
206
213
|
name,
|
|
@@ -890,7 +897,7 @@ function debugProperties(properties) {
|
|
|
890
897
|
}
|
|
891
898
|
|
|
892
899
|
// src/core/version.ts
|
|
893
|
-
var SDK_VERSION = "0.1.
|
|
900
|
+
var SDK_VERSION = "0.1.6";
|
|
894
901
|
|
|
895
902
|
// src/core/client.ts
|
|
896
903
|
var DEFAULT_BASE_URL = "https://console.microsurveys.ai";
|