@adriansteffan/reactive 0.1.33 → 0.1.36
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/{mod-BI0gtRcG.js → mod-urua6TFn.js} +833 -820
- package/dist/mod.d.ts +2 -0
- package/dist/reactive.es.js +22 -21
- package/dist/reactive.umd.js +28 -28
- package/dist/{web-C3D6toM6.js → web-BtWqed4E.js} +1 -1
- package/dist/{web-D5dD50rU.js → web-D9yqAhIx.js} +1 -1
- package/package.json +1 -1
- package/src/utils/common.ts +8 -0
- package/src/utils/upload.ts +11 -4
package/package.json
CHANGED
package/src/utils/common.ts
CHANGED
|
@@ -54,6 +54,14 @@ export interface BaseComponentProps {
|
|
|
54
54
|
updateStore: (mergeIn: Store) => void;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
export function selectPrevTrialData(data: any[], type?: string): any | undefined {
|
|
58
|
+
if (!type) return data.at(-1);
|
|
59
|
+
for (let i = data.length - 1; i >= 0; i--) {
|
|
60
|
+
if (data[i].type === type) return data[i];
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
57
65
|
type ParamType = 'string' | 'number' | 'boolean' | 'array' | 'json';
|
|
58
66
|
|
|
59
67
|
type ParamValue<T extends ParamType> = T extends 'number'
|
package/src/utils/upload.ts
CHANGED
|
@@ -130,12 +130,12 @@ function autoBuildCSVs(sessionID: string, data: any[], sessionData?: Record<stri
|
|
|
130
130
|
const prefix = item.name || item.type;
|
|
131
131
|
// Add user-provided metadata (non-builtin top-level keys), namespaced by trial name
|
|
132
132
|
for (const [key, value] of Object.entries(item)) {
|
|
133
|
-
if (!trialBuiltinKeys.has(key)) row[`${prefix}_${key}`] = value;
|
|
133
|
+
if (!trialBuiltinKeys.has(key)) row[`${prefix}_${key}`] = typeof value === 'object' && value !== null && !Array.isArray(value) ? JSON.stringify(value) : value;
|
|
134
134
|
}
|
|
135
135
|
// Add responseData fields, namespaced by trial name
|
|
136
136
|
if (item.responseData && typeof item.responseData === 'object' && !Array.isArray(item.responseData)) {
|
|
137
137
|
for (const [key, value] of Object.entries(item.responseData)) {
|
|
138
|
-
row[`${prefix}_${key}`] = value;
|
|
138
|
+
row[`${prefix}_${key}`] = typeof value === 'object' && value !== null && !Array.isArray(value) ? JSON.stringify(value) : value;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
@@ -159,14 +159,21 @@ function autoBuildCSVs(sessionID: string, data: any[], sessionData?: Record<stri
|
|
|
159
159
|
if (trialBuiltinKeys.has(key)) {
|
|
160
160
|
if (trialInfoKeys.has(key)) base[`trial_${key}`] = value;
|
|
161
161
|
} else {
|
|
162
|
-
base[key] = value;
|
|
162
|
+
base[key] = typeof value === 'object' && value !== null && !Array.isArray(value) ? JSON.stringify(value) : value;
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
// When no flatten function is registered, spread responseData directly.
|
|
166
166
|
const flatRows = flatten
|
|
167
167
|
? flatten(item)
|
|
168
168
|
: [item.responseData && typeof item.responseData === 'object' ? { ...item.responseData } : {}];
|
|
169
|
-
return flatRows.map((row: any) =>
|
|
169
|
+
return flatRows.map((row: any) => {
|
|
170
|
+
const merged = { ...base, ...row };
|
|
171
|
+
for (const k of Object.keys(merged)) {
|
|
172
|
+
const v = merged[k];
|
|
173
|
+
if (typeof v === 'object' && v !== null && !Array.isArray(v)) merged[k] = JSON.stringify(v);
|
|
174
|
+
}
|
|
175
|
+
return merged;
|
|
176
|
+
});
|
|
170
177
|
});
|
|
171
178
|
if (rows.length > 0) {
|
|
172
179
|
files.push({
|