@usertour/helpers 0.0.51 → 0.0.53
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/__tests__/content-helper.test.cjs +540 -65
- package/dist/__tests__/content-helper.test.js +542 -58
- package/dist/{chunk-YR6T3KNN.js → chunk-2TMOS3DN.js} +2 -18
- package/dist/{chunk-QWYOGIRR.js → chunk-S2HECK2C.js} +2 -1
- package/dist/content-helper.cjs +1 -19
- package/dist/content-helper.d.cts +4 -19
- package/dist/content-helper.d.ts +4 -19
- package/dist/content-helper.js +1 -5
- package/dist/error.cjs +2 -1
- package/dist/error.js +1 -1
- package/dist/index.cjs +3 -20
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -6
- package/package.json +2 -2
|
@@ -206,7 +206,7 @@ var duplicateData = (data, contentType) => {
|
|
|
206
206
|
return data;
|
|
207
207
|
};
|
|
208
208
|
var duplicateStep = (step) => {
|
|
209
|
-
const { id,
|
|
209
|
+
const { id, createdAt, updatedAt, versionId, trigger, target, data, ...rest } = step;
|
|
210
210
|
return {
|
|
211
211
|
...rest,
|
|
212
212
|
data: data ? processQuestionElements(data) : [],
|
|
@@ -214,20 +214,6 @@ var duplicateStep = (step) => {
|
|
|
214
214
|
target: duplicateTarget(target)
|
|
215
215
|
};
|
|
216
216
|
};
|
|
217
|
-
var duplicateSteps = (steps) => {
|
|
218
|
-
if (!isArray(steps)) {
|
|
219
|
-
return [];
|
|
220
|
-
}
|
|
221
|
-
return steps.map((step) => duplicateStep(step));
|
|
222
|
-
};
|
|
223
|
-
var duplicateStepWithRename = (originalStep, sequence, existingStepNames) => {
|
|
224
|
-
const duplicated = duplicateStep(originalStep);
|
|
225
|
-
return {
|
|
226
|
-
...duplicated,
|
|
227
|
-
name: generateUniqueCopyName(originalStep.name, existingStepNames),
|
|
228
|
-
sequence
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
217
|
|
|
232
218
|
export {
|
|
233
219
|
isRestrictedType,
|
|
@@ -244,7 +230,5 @@ export {
|
|
|
244
230
|
duplicateLauncherData,
|
|
245
231
|
duplicateConfig,
|
|
246
232
|
duplicateData,
|
|
247
|
-
duplicateStep
|
|
248
|
-
duplicateSteps,
|
|
249
|
-
duplicateStepWithRename
|
|
233
|
+
duplicateStep
|
|
250
234
|
};
|
|
@@ -125,7 +125,8 @@ var getContentError = (data) => {
|
|
|
125
125
|
const ret = { showError: false, errorInfo: "" };
|
|
126
126
|
if (!data.contentId) {
|
|
127
127
|
ret.showError = true;
|
|
128
|
-
|
|
128
|
+
const contentType = data.type === "checklist" ? "checklist" : "flow";
|
|
129
|
+
ret.errorInfo = `Please select a ${contentType}`;
|
|
129
130
|
}
|
|
130
131
|
return ret;
|
|
131
132
|
};
|
package/dist/content-helper.cjs
CHANGED
|
@@ -35,8 +35,6 @@ __export(content_helper_exports, {
|
|
|
35
35
|
duplicateData: () => duplicateData,
|
|
36
36
|
duplicateLauncherData: () => duplicateLauncherData,
|
|
37
37
|
duplicateStep: () => duplicateStep,
|
|
38
|
-
duplicateStepWithRename: () => duplicateStepWithRename,
|
|
39
|
-
duplicateSteps: () => duplicateSteps,
|
|
40
38
|
duplicateTarget: () => duplicateTarget,
|
|
41
39
|
duplicateTriggers: () => duplicateTriggers,
|
|
42
40
|
extractQuestionData: () => extractQuestionData,
|
|
@@ -347,7 +345,7 @@ var duplicateData = (data, contentType) => {
|
|
|
347
345
|
return data;
|
|
348
346
|
};
|
|
349
347
|
var duplicateStep = (step) => {
|
|
350
|
-
const { id,
|
|
348
|
+
const { id, createdAt, updatedAt, versionId, trigger, target, data, ...rest } = step;
|
|
351
349
|
return {
|
|
352
350
|
...rest,
|
|
353
351
|
data: data ? processQuestionElements(data) : [],
|
|
@@ -355,20 +353,6 @@ var duplicateStep = (step) => {
|
|
|
355
353
|
target: duplicateTarget(target)
|
|
356
354
|
};
|
|
357
355
|
};
|
|
358
|
-
var duplicateSteps = (steps) => {
|
|
359
|
-
if (!isArray(steps)) {
|
|
360
|
-
return [];
|
|
361
|
-
}
|
|
362
|
-
return steps.map((step) => duplicateStep(step));
|
|
363
|
-
};
|
|
364
|
-
var duplicateStepWithRename = (originalStep, sequence, existingStepNames) => {
|
|
365
|
-
const duplicated = duplicateStep(originalStep);
|
|
366
|
-
return {
|
|
367
|
-
...duplicated,
|
|
368
|
-
name: generateUniqueCopyName(originalStep.name, existingStepNames),
|
|
369
|
-
sequence
|
|
370
|
-
};
|
|
371
|
-
};
|
|
372
356
|
// Annotate the CommonJS export names for ESM import in node:
|
|
373
357
|
0 && (module.exports = {
|
|
374
358
|
duplicateChecklistData,
|
|
@@ -376,8 +360,6 @@ var duplicateStepWithRename = (originalStep, sequence, existingStepNames) => {
|
|
|
376
360
|
duplicateData,
|
|
377
361
|
duplicateLauncherData,
|
|
378
362
|
duplicateStep,
|
|
379
|
-
duplicateStepWithRename,
|
|
380
|
-
duplicateSteps,
|
|
381
363
|
duplicateTarget,
|
|
382
364
|
duplicateTriggers,
|
|
383
365
|
extractQuestionData,
|
|
@@ -79,25 +79,10 @@ type StepLike = {
|
|
|
79
79
|
/**
|
|
80
80
|
* Core function to duplicate a single step by removing database-specific fields
|
|
81
81
|
* and regenerating IDs in triggers, target actions, and question elements
|
|
82
|
+
* Preserves cvid to maintain step references in triggers/actions when duplicating entire content
|
|
82
83
|
* @param step - The step to duplicate
|
|
83
|
-
* @returns A new step object with regenerated IDs,
|
|
84
|
+
* @returns A new step object with regenerated IDs, preserving cvid
|
|
84
85
|
*/
|
|
85
|
-
declare const duplicateStep: <T extends StepLike>(step: T) => Omit<T, "id" | "
|
|
86
|
-
/**
|
|
87
|
-
* Process multiple steps for duplication
|
|
88
|
-
* Works with both Prisma Step type (server) and @usertour/types Step (client)
|
|
89
|
-
* @param steps - Array of steps to process
|
|
90
|
-
* @returns Array of steps ready for creation with regenerated IDs
|
|
91
|
-
*/
|
|
92
|
-
declare const duplicateSteps: <T extends StepLike>(steps: T[]) => Omit<T, "id" | "cvid" | "createdAt" | "updatedAt" | "versionId">[];
|
|
93
|
-
/**
|
|
94
|
-
* Duplicate a single step with a new unique name and sequence
|
|
95
|
-
* Used for UI operations when duplicating a step within the same version
|
|
96
|
-
* @param originalStep - The step to duplicate
|
|
97
|
-
* @param sequence - The new sequence number for the duplicated step
|
|
98
|
-
* @param existingStepNames - Optional array of existing step names to avoid conflicts
|
|
99
|
-
* @returns A new step object ready for creation
|
|
100
|
-
*/
|
|
101
|
-
declare const duplicateStepWithRename: (originalStep: Step, sequence: number, existingStepNames?: string[]) => Omit<Step, 'id' | 'cvid' | 'updatedAt' | 'createdAt'>;
|
|
86
|
+
declare const duplicateStep: <T extends StepLike>(step: T) => Omit<T, "id" | "createdAt" | "updatedAt" | "versionId">;
|
|
102
87
|
|
|
103
|
-
export { duplicateChecklistData, duplicateConfig, duplicateData, duplicateLauncherData, duplicateStep,
|
|
88
|
+
export { duplicateChecklistData, duplicateConfig, duplicateData, duplicateLauncherData, duplicateStep, duplicateTarget, duplicateTriggers, extractQuestionData, generateUniqueCopyName, hasMissingRequiredData, isClickableElement, isMissingRequiredData, isQuestionElement, isRestrictedType, processQuestionElements };
|
package/dist/content-helper.d.ts
CHANGED
|
@@ -79,25 +79,10 @@ type StepLike = {
|
|
|
79
79
|
/**
|
|
80
80
|
* Core function to duplicate a single step by removing database-specific fields
|
|
81
81
|
* and regenerating IDs in triggers, target actions, and question elements
|
|
82
|
+
* Preserves cvid to maintain step references in triggers/actions when duplicating entire content
|
|
82
83
|
* @param step - The step to duplicate
|
|
83
|
-
* @returns A new step object with regenerated IDs,
|
|
84
|
+
* @returns A new step object with regenerated IDs, preserving cvid
|
|
84
85
|
*/
|
|
85
|
-
declare const duplicateStep: <T extends StepLike>(step: T) => Omit<T, "id" | "
|
|
86
|
-
/**
|
|
87
|
-
* Process multiple steps for duplication
|
|
88
|
-
* Works with both Prisma Step type (server) and @usertour/types Step (client)
|
|
89
|
-
* @param steps - Array of steps to process
|
|
90
|
-
* @returns Array of steps ready for creation with regenerated IDs
|
|
91
|
-
*/
|
|
92
|
-
declare const duplicateSteps: <T extends StepLike>(steps: T[]) => Omit<T, "id" | "cvid" | "createdAt" | "updatedAt" | "versionId">[];
|
|
93
|
-
/**
|
|
94
|
-
* Duplicate a single step with a new unique name and sequence
|
|
95
|
-
* Used for UI operations when duplicating a step within the same version
|
|
96
|
-
* @param originalStep - The step to duplicate
|
|
97
|
-
* @param sequence - The new sequence number for the duplicated step
|
|
98
|
-
* @param existingStepNames - Optional array of existing step names to avoid conflicts
|
|
99
|
-
* @returns A new step object ready for creation
|
|
100
|
-
*/
|
|
101
|
-
declare const duplicateStepWithRename: (originalStep: Step, sequence: number, existingStepNames?: string[]) => Omit<Step, 'id' | 'cvid' | 'updatedAt' | 'createdAt'>;
|
|
86
|
+
declare const duplicateStep: <T extends StepLike>(step: T) => Omit<T, "id" | "createdAt" | "updatedAt" | "versionId">;
|
|
102
87
|
|
|
103
|
-
export { duplicateChecklistData, duplicateConfig, duplicateData, duplicateLauncherData, duplicateStep,
|
|
88
|
+
export { duplicateChecklistData, duplicateConfig, duplicateData, duplicateLauncherData, duplicateStep, duplicateTarget, duplicateTriggers, extractQuestionData, generateUniqueCopyName, hasMissingRequiredData, isClickableElement, isMissingRequiredData, isQuestionElement, isRestrictedType, processQuestionElements };
|
package/dist/content-helper.js
CHANGED
|
@@ -4,8 +4,6 @@ import {
|
|
|
4
4
|
duplicateData,
|
|
5
5
|
duplicateLauncherData,
|
|
6
6
|
duplicateStep,
|
|
7
|
-
duplicateStepWithRename,
|
|
8
|
-
duplicateSteps,
|
|
9
7
|
duplicateTarget,
|
|
10
8
|
duplicateTriggers,
|
|
11
9
|
extractQuestionData,
|
|
@@ -16,7 +14,7 @@ import {
|
|
|
16
14
|
isQuestionElement,
|
|
17
15
|
isRestrictedType,
|
|
18
16
|
processQuestionElements
|
|
19
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-2TMOS3DN.js";
|
|
20
18
|
import "./chunk-7ODE2AIC.js";
|
|
21
19
|
import "./chunk-SIG4WTEF.js";
|
|
22
20
|
import "./chunk-YYIGUZNZ.js";
|
|
@@ -32,8 +30,6 @@ export {
|
|
|
32
30
|
duplicateData,
|
|
33
31
|
duplicateLauncherData,
|
|
34
32
|
duplicateStep,
|
|
35
|
-
duplicateStepWithRename,
|
|
36
|
-
duplicateSteps,
|
|
37
33
|
duplicateTarget,
|
|
38
34
|
duplicateTriggers,
|
|
39
35
|
extractQuestionData,
|
package/dist/error.cjs
CHANGED
|
@@ -175,7 +175,8 @@ var getContentError = (data) => {
|
|
|
175
175
|
const ret = { showError: false, errorInfo: "" };
|
|
176
176
|
if (!data.contentId) {
|
|
177
177
|
ret.showError = true;
|
|
178
|
-
|
|
178
|
+
const contentType = data.type === "checklist" ? "checklist" : "flow";
|
|
179
|
+
ret.errorInfo = `Please select a ${contentType}`;
|
|
179
180
|
}
|
|
180
181
|
return ret;
|
|
181
182
|
};
|
package/dist/error.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -59,8 +59,6 @@ __export(src_exports, {
|
|
|
59
59
|
duplicateData: () => duplicateData,
|
|
60
60
|
duplicateLauncherData: () => duplicateLauncherData,
|
|
61
61
|
duplicateStep: () => duplicateStep,
|
|
62
|
-
duplicateStepWithRename: () => duplicateStepWithRename,
|
|
63
|
-
duplicateSteps: () => duplicateSteps,
|
|
64
62
|
duplicateTarget: () => duplicateTarget,
|
|
65
63
|
duplicateTriggers: () => duplicateTriggers,
|
|
66
64
|
evalCode: () => evalCode,
|
|
@@ -738,7 +736,8 @@ var getContentError = (data) => {
|
|
|
738
736
|
const ret = { showError: false, errorInfo: "" };
|
|
739
737
|
if (!data.contentId) {
|
|
740
738
|
ret.showError = true;
|
|
741
|
-
|
|
739
|
+
const contentType = data.type === "checklist" ? "checklist" : "flow";
|
|
740
|
+
ret.errorInfo = `Please select a ${contentType}`;
|
|
742
741
|
}
|
|
743
742
|
return ret;
|
|
744
743
|
};
|
|
@@ -1903,7 +1902,7 @@ var duplicateData = (data, contentType) => {
|
|
|
1903
1902
|
return data;
|
|
1904
1903
|
};
|
|
1905
1904
|
var duplicateStep = (step) => {
|
|
1906
|
-
const { id,
|
|
1905
|
+
const { id, createdAt, updatedAt, versionId, trigger, target, data, ...rest } = step;
|
|
1907
1906
|
return {
|
|
1908
1907
|
...rest,
|
|
1909
1908
|
data: data ? processQuestionElements(data) : [],
|
|
@@ -1911,20 +1910,6 @@ var duplicateStep = (step) => {
|
|
|
1911
1910
|
target: duplicateTarget(target)
|
|
1912
1911
|
};
|
|
1913
1912
|
};
|
|
1914
|
-
var duplicateSteps = (steps) => {
|
|
1915
|
-
if (!isArray(steps)) {
|
|
1916
|
-
return [];
|
|
1917
|
-
}
|
|
1918
|
-
return steps.map((step) => duplicateStep(step));
|
|
1919
|
-
};
|
|
1920
|
-
var duplicateStepWithRename = (originalStep, sequence, existingStepNames) => {
|
|
1921
|
-
const duplicated = duplicateStep(originalStep);
|
|
1922
|
-
return {
|
|
1923
|
-
...duplicated,
|
|
1924
|
-
name: generateUniqueCopyName(originalStep.name, existingStepNames),
|
|
1925
|
-
sequence
|
|
1926
|
-
};
|
|
1927
|
-
};
|
|
1928
1913
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1929
1914
|
0 && (module.exports = {
|
|
1930
1915
|
AbortController,
|
|
@@ -1951,8 +1936,6 @@ var duplicateStepWithRename = (originalStep, sequence, existingStepNames) => {
|
|
|
1951
1936
|
duplicateData,
|
|
1952
1937
|
duplicateLauncherData,
|
|
1953
1938
|
duplicateStep,
|
|
1954
|
-
duplicateStepWithRename,
|
|
1955
|
-
duplicateSteps,
|
|
1956
1939
|
duplicateTarget,
|
|
1957
1940
|
duplicateTriggers,
|
|
1958
1941
|
evalCode,
|
package/dist/index.d.cts
CHANGED
|
@@ -14,7 +14,7 @@ export { evaluateUrlCondition, isMatchUrlPattern } from './conditions/url.cjs';
|
|
|
14
14
|
export { convertTimeConditionLegacyToV2, evaluateTimeCondition, isTimeConditionDataLegacy, isTimeConditionDataV2, normalizeTimeConditionData } from './conditions/time.cjs';
|
|
15
15
|
export { evaluateAttributeCondition } from './conditions/attribute.cjs';
|
|
16
16
|
export { capitalizeFirstLetter, filterNullAttributes, getAttributeType, isValidISO8601 } from './attribute.cjs';
|
|
17
|
-
export { duplicateChecklistData, duplicateConfig, duplicateData, duplicateLauncherData, duplicateStep,
|
|
17
|
+
export { duplicateChecklistData, duplicateConfig, duplicateData, duplicateLauncherData, duplicateStep, duplicateTarget, duplicateTriggers, extractQuestionData, generateUniqueCopyName, hasMissingRequiredData, isClickableElement, isMissingRequiredData, isQuestionElement, isRestrictedType, processQuestionElements } from './content-helper.cjs';
|
|
18
18
|
export { default as isEqual } from 'fast-deep-equal';
|
|
19
19
|
import '@usertour/types';
|
|
20
20
|
import './storage.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { evaluateUrlCondition, isMatchUrlPattern } from './conditions/url.js';
|
|
|
14
14
|
export { convertTimeConditionLegacyToV2, evaluateTimeCondition, isTimeConditionDataLegacy, isTimeConditionDataV2, normalizeTimeConditionData } from './conditions/time.js';
|
|
15
15
|
export { evaluateAttributeCondition } from './conditions/attribute.js';
|
|
16
16
|
export { capitalizeFirstLetter, filterNullAttributes, getAttributeType, isValidISO8601 } from './attribute.js';
|
|
17
|
-
export { duplicateChecklistData, duplicateConfig, duplicateData, duplicateLauncherData, duplicateStep,
|
|
17
|
+
export { duplicateChecklistData, duplicateConfig, duplicateData, duplicateLauncherData, duplicateStep, duplicateTarget, duplicateTriggers, extractQuestionData, generateUniqueCopyName, hasMissingRequiredData, isClickableElement, isMissingRequiredData, isQuestionElement, isRestrictedType, processQuestionElements } from './content-helper.js';
|
|
18
18
|
export { default as isEqual } from 'fast-deep-equal';
|
|
19
19
|
import '@usertour/types';
|
|
20
20
|
import './storage.js';
|
package/dist/index.js
CHANGED
|
@@ -28,8 +28,6 @@ import {
|
|
|
28
28
|
duplicateData,
|
|
29
29
|
duplicateLauncherData,
|
|
30
30
|
duplicateStep,
|
|
31
|
-
duplicateStepWithRename,
|
|
32
|
-
duplicateSteps,
|
|
33
31
|
duplicateTarget,
|
|
34
32
|
duplicateTriggers,
|
|
35
33
|
extractQuestionData,
|
|
@@ -40,7 +38,7 @@ import {
|
|
|
40
38
|
isQuestionElement,
|
|
41
39
|
isRestrictedType,
|
|
42
40
|
processQuestionElements
|
|
43
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-2TMOS3DN.js";
|
|
44
42
|
import "./chunk-7ODE2AIC.js";
|
|
45
43
|
import {
|
|
46
44
|
allConditionsHaveIds,
|
|
@@ -107,7 +105,7 @@ import {
|
|
|
107
105
|
hasActionError,
|
|
108
106
|
hasError,
|
|
109
107
|
isValidSelector
|
|
110
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-S2HECK2C.js";
|
|
111
109
|
import {
|
|
112
110
|
convertTimeConditionLegacyToV2,
|
|
113
111
|
evaluateTimeCondition,
|
|
@@ -173,8 +171,6 @@ export {
|
|
|
173
171
|
duplicateData,
|
|
174
172
|
duplicateLauncherData,
|
|
175
173
|
duplicateStep,
|
|
176
|
-
duplicateStepWithRename,
|
|
177
|
-
duplicateSteps,
|
|
178
174
|
duplicateTarget,
|
|
179
175
|
duplicateTriggers,
|
|
180
176
|
evalCode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usertour/helpers",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Utility functions and helpers shared across the UserTour project",
|
|
6
6
|
"homepage": "https://www.usertour.io",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
32
|
-
"@usertour/types": "^0.0.
|
|
32
|
+
"@usertour/types": "^0.0.40",
|
|
33
33
|
"chroma-js": "^3.1.2",
|
|
34
34
|
"class-variance-authority": "^0.4.0",
|
|
35
35
|
"clsx": "^1.2.1",
|