@microsurveysai/react-native 0.1.5 → 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.js CHANGED
@@ -80,6 +80,7 @@ var MAX_SCALE_POINTS = 101;
80
80
  var MAX_SCALE_ABS = 1e3;
81
81
  var MAX_STARS = 100;
82
82
  var MAX_OPTIONS = 100;
83
+ var QUESTION_TYPES = ["NPS", "CES", "CSAT_STAR", "CSAT_EMOJI", "THUMBS", "SINGLE_CHOICE", "OPEN_TEXT"];
83
84
  function boundedScale(min, max) {
84
85
  const lo = Math.min(Math.max(min, -MAX_SCALE_ABS), MAX_SCALE_ABS);
85
86
  let hi = Math.min(Math.max(max, -MAX_SCALE_ABS), MAX_SCALE_ABS);
@@ -158,8 +159,14 @@ function normalizeSurvey(raw) {
158
159
  const id = strOrUndef(raw.id);
159
160
  const name = strOrUndef(raw.name);
160
161
  if (!id || name === void 0) return null;
161
- const questions = (Array.isArray(raw.questions) ? raw.questions : []).map((q) => normalizeQuestion(asObject(q))).filter((q) => q !== null);
162
- const triggers = (Array.isArray(raw.triggers) ? raw.triggers : []).map((t) => normalizeTrigger(asObject(t))).filter((t) => t !== null);
162
+ const rawQuestions = Array.isArray(raw.questions) ? raw.questions : [];
163
+ const rawTriggers = Array.isArray(raw.triggers) ? raw.triggers : [];
164
+ if (rawQuestions.some((q) => !QUESTION_TYPES.includes(asObject(q).type)) || rawTriggers.some((t) => {
165
+ const type = asObject(t).type;
166
+ return type != null && type !== "SINGLE" && type !== "SEQUENCE";
167
+ })) return null;
168
+ const questions = rawQuestions.map((q) => normalizeQuestion(asObject(q))).filter((q) => q !== null);
169
+ const triggers = rawTriggers.map((t) => normalizeTrigger(asObject(t))).filter((t) => t !== null);
163
170
  return {
164
171
  id,
165
172
  name,
@@ -849,7 +856,7 @@ function debugProperties(properties) {
849
856
  }
850
857
 
851
858
  // src/core/version.ts
852
- var SDK_VERSION = "0.1.5";
859
+ var SDK_VERSION = "0.1.6";
853
860
 
854
861
  // src/core/client.ts
855
862
  var DEFAULT_BASE_URL = "https://console.microsurveys.ai";