@usertour/helpers 0.0.46 → 0.0.48
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__/condition.test.cjs +2 -2
- package/dist/__tests__/condition.test.js +1 -1
- package/dist/__tests__/content-helper.test.cjs +1009 -0
- package/dist/__tests__/content-helper.test.d.cts +2 -0
- package/dist/__tests__/content-helper.test.d.ts +2 -0
- package/dist/__tests__/content-helper.test.js +716 -0
- package/dist/chunk-7GJAPR7Y.js +218 -0
- package/dist/{chunk-SLM6E7HG.js → chunk-SIG4WTEF.js} +2 -2
- package/dist/conditions/condition.cjs +2 -2
- package/dist/conditions/condition.js +1 -1
- package/dist/conditions/index.cjs +2 -2
- package/dist/conditions/index.js +1 -1
- package/dist/content-helper.cjs +67 -23
- package/dist/content-helper.d.cts +34 -9
- package/dist/content-helper.d.ts +34 -9
- package/dist/content-helper.js +25 -169
- package/dist/index.cjs +219 -2
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +31 -1
- package/package.json +1 -1
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import {
|
|
2
|
+
regenerateConditionIds
|
|
3
|
+
} from "./chunk-SIG4WTEF.js";
|
|
4
|
+
import {
|
|
5
|
+
cuid,
|
|
6
|
+
uuidV4
|
|
7
|
+
} from "./chunk-3KG2HTZ3.js";
|
|
8
|
+
import {
|
|
9
|
+
isArray,
|
|
10
|
+
isEmptyString,
|
|
11
|
+
isObject
|
|
12
|
+
} from "./chunk-GFH3VWOC.js";
|
|
13
|
+
|
|
14
|
+
// src/content-helper.ts
|
|
15
|
+
import { ContentDataType, ContentEditorElementType } from "@usertour/types";
|
|
16
|
+
var isRestrictedType = (type) => {
|
|
17
|
+
const restrictedTypes = [
|
|
18
|
+
ContentEditorElementType.NPS,
|
|
19
|
+
ContentEditorElementType.STAR_RATING,
|
|
20
|
+
ContentEditorElementType.SCALE,
|
|
21
|
+
ContentEditorElementType.SINGLE_LINE_TEXT,
|
|
22
|
+
ContentEditorElementType.MULTI_LINE_TEXT,
|
|
23
|
+
ContentEditorElementType.MULTIPLE_CHOICE
|
|
24
|
+
];
|
|
25
|
+
return restrictedTypes.includes(type);
|
|
26
|
+
};
|
|
27
|
+
var isMissingRequiredData = (element) => {
|
|
28
|
+
var _a, _b, _c, _d;
|
|
29
|
+
if (isRestrictedType(element.type)) {
|
|
30
|
+
return isEmptyString((_a = element.data) == null ? void 0 : _a.name);
|
|
31
|
+
}
|
|
32
|
+
if (element.type === ContentEditorElementType.BUTTON) {
|
|
33
|
+
if (isEmptyString((_b = element.data) == null ? void 0 : _b.text)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (!((_c = element == null ? void 0 : element.data) == null ? void 0 : _c.actions) || ((_d = element == null ? void 0 : element.data) == null ? void 0 : _d.actions.length) === 0) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
42
|
+
var hasMissingRequiredData = (contents) => {
|
|
43
|
+
return contents.some(
|
|
44
|
+
(group) => group.children.some(
|
|
45
|
+
(column) => column.children.some((item) => isMissingRequiredData(item.element))
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
var isQuestionElement = (element) => {
|
|
50
|
+
return element.type === ContentEditorElementType.SINGLE_LINE_TEXT || element.type === ContentEditorElementType.MULTI_LINE_TEXT || element.type === ContentEditorElementType.NPS || element.type === ContentEditorElementType.STAR_RATING || element.type === ContentEditorElementType.SCALE || element.type === ContentEditorElementType.MULTIPLE_CHOICE;
|
|
51
|
+
};
|
|
52
|
+
var isClickableElement = (element) => {
|
|
53
|
+
return element.type === ContentEditorElementType.BUTTON || isQuestionElement(element);
|
|
54
|
+
};
|
|
55
|
+
var extractQuestionData = (data) => {
|
|
56
|
+
const result = [];
|
|
57
|
+
function isQuestionRootElement(item) {
|
|
58
|
+
return "element" in item && isQuestionElement(item.element);
|
|
59
|
+
}
|
|
60
|
+
function traverse(item) {
|
|
61
|
+
if (isQuestionRootElement(item)) {
|
|
62
|
+
result.push(item.element);
|
|
63
|
+
}
|
|
64
|
+
if ("children" in item && item.children) {
|
|
65
|
+
for (const child of item.children) {
|
|
66
|
+
traverse(child);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const item of data) {
|
|
71
|
+
traverse(item);
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
};
|
|
75
|
+
var processQuestionElements = (contents) => {
|
|
76
|
+
if (!contents || !isArray(contents) || contents.length === 0) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
return contents.map((group) => ({
|
|
80
|
+
...group,
|
|
81
|
+
children: group.children.map((column) => ({
|
|
82
|
+
...column,
|
|
83
|
+
children: column.children.map((item) => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
const element = item.element;
|
|
86
|
+
if (isQuestionElement(element)) {
|
|
87
|
+
const questionElement = element;
|
|
88
|
+
const updatedElement = {
|
|
89
|
+
...questionElement,
|
|
90
|
+
data: {
|
|
91
|
+
...questionElement.data,
|
|
92
|
+
cvid: cuid(),
|
|
93
|
+
...((_a = questionElement.data) == null ? void 0 : _a.actions) && isArray(questionElement.data.actions) ? { actions: regenerateConditionIds(questionElement.data.actions) } : {}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
...item,
|
|
98
|
+
element: updatedElement
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (element.type === ContentEditorElementType.BUTTON) {
|
|
102
|
+
const buttonElement = element;
|
|
103
|
+
if (((_b = buttonElement.data) == null ? void 0 : _b.actions) && isArray(buttonElement.data.actions)) {
|
|
104
|
+
return {
|
|
105
|
+
...item,
|
|
106
|
+
element: {
|
|
107
|
+
...buttonElement,
|
|
108
|
+
data: {
|
|
109
|
+
...buttonElement.data,
|
|
110
|
+
actions: regenerateConditionIds(buttonElement.data.actions)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return item;
|
|
117
|
+
})
|
|
118
|
+
}))
|
|
119
|
+
}));
|
|
120
|
+
};
|
|
121
|
+
var generateUniqueCopyName = (originalName, existingNames) => {
|
|
122
|
+
let name = `${originalName} (copy)`;
|
|
123
|
+
if (existingNames == null ? void 0 : existingNames.includes(name)) {
|
|
124
|
+
let number = 2;
|
|
125
|
+
while (existingNames.includes(`${originalName} (copy ${number})`)) {
|
|
126
|
+
number++;
|
|
127
|
+
}
|
|
128
|
+
name = `${originalName} (copy ${number})`;
|
|
129
|
+
}
|
|
130
|
+
return name;
|
|
131
|
+
};
|
|
132
|
+
var duplicateTriggers = (triggers) => {
|
|
133
|
+
if (!isArray(triggers)) {
|
|
134
|
+
return triggers;
|
|
135
|
+
}
|
|
136
|
+
return triggers.map((trigger) => ({
|
|
137
|
+
...trigger,
|
|
138
|
+
id: cuid(),
|
|
139
|
+
actions: isArray(trigger.actions) ? regenerateConditionIds(trigger.actions) : trigger.actions,
|
|
140
|
+
conditions: isArray(trigger.conditions) ? regenerateConditionIds(trigger.conditions) : trigger.conditions
|
|
141
|
+
}));
|
|
142
|
+
};
|
|
143
|
+
var duplicateTarget = (target) => {
|
|
144
|
+
if (!target) {
|
|
145
|
+
return void 0;
|
|
146
|
+
}
|
|
147
|
+
if (target.actions && isArray(target.actions)) {
|
|
148
|
+
return {
|
|
149
|
+
...target,
|
|
150
|
+
actions: regenerateConditionIds(target.actions)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return target;
|
|
154
|
+
};
|
|
155
|
+
var duplicateChecklistData = (data) => {
|
|
156
|
+
if (!data || !isObject(data) || !isArray(data.items)) {
|
|
157
|
+
return data;
|
|
158
|
+
}
|
|
159
|
+
const checklistData = data;
|
|
160
|
+
return {
|
|
161
|
+
...checklistData,
|
|
162
|
+
items: checklistData.items.map((item) => ({
|
|
163
|
+
...item,
|
|
164
|
+
id: uuidV4(),
|
|
165
|
+
clickedActions: isArray(item.clickedActions) ? regenerateConditionIds(item.clickedActions) : item.clickedActions,
|
|
166
|
+
completeConditions: isArray(item.completeConditions) ? regenerateConditionIds(item.completeConditions) : item.completeConditions,
|
|
167
|
+
onlyShowTaskConditions: isArray(item.onlyShowTaskConditions) ? regenerateConditionIds(item.onlyShowTaskConditions) : item.onlyShowTaskConditions
|
|
168
|
+
}))
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
var duplicateConfig = (config) => {
|
|
172
|
+
if (!config) {
|
|
173
|
+
return config;
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
...config,
|
|
177
|
+
autoStartRules: config.autoStartRules ? regenerateConditionIds(config.autoStartRules) : config.autoStartRules,
|
|
178
|
+
hideRules: config.hideRules ? regenerateConditionIds(config.hideRules) : config.hideRules
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
var duplicateData = (data, contentType) => {
|
|
182
|
+
if (contentType === ContentDataType.CHECKLIST) {
|
|
183
|
+
return duplicateChecklistData(data);
|
|
184
|
+
}
|
|
185
|
+
return data;
|
|
186
|
+
};
|
|
187
|
+
var createStepCopy = (originalStep, sequence, existingStepNames) => {
|
|
188
|
+
const { id, cvid, updatedAt, createdAt, ...rest } = originalStep;
|
|
189
|
+
const name = generateUniqueCopyName(originalStep == null ? void 0 : originalStep.name, existingStepNames);
|
|
190
|
+
const trigger = (originalStep == null ? void 0 : originalStep.trigger) ? duplicateTriggers(originalStep == null ? void 0 : originalStep.trigger) : [];
|
|
191
|
+
const data = (originalStep == null ? void 0 : originalStep.data) ? processQuestionElements(originalStep == null ? void 0 : originalStep.data) : [];
|
|
192
|
+
const target = duplicateTarget(originalStep == null ? void 0 : originalStep.target);
|
|
193
|
+
return {
|
|
194
|
+
...rest,
|
|
195
|
+
data,
|
|
196
|
+
trigger,
|
|
197
|
+
target,
|
|
198
|
+
name,
|
|
199
|
+
sequence
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export {
|
|
204
|
+
isRestrictedType,
|
|
205
|
+
isMissingRequiredData,
|
|
206
|
+
hasMissingRequiredData,
|
|
207
|
+
isQuestionElement,
|
|
208
|
+
isClickableElement,
|
|
209
|
+
extractQuestionData,
|
|
210
|
+
processQuestionElements,
|
|
211
|
+
generateUniqueCopyName,
|
|
212
|
+
duplicateTriggers,
|
|
213
|
+
duplicateTarget,
|
|
214
|
+
duplicateChecklistData,
|
|
215
|
+
duplicateConfig,
|
|
216
|
+
duplicateData,
|
|
217
|
+
createStepCopy
|
|
218
|
+
};
|
|
@@ -51,9 +51,9 @@ var evaluateRule = async (condition, options) => {
|
|
|
51
51
|
var _a, _b;
|
|
52
52
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
53
53
|
const conditionId = condition.id;
|
|
54
|
-
if (activatedIds == null ? void 0 : activatedIds.includes(conditionId))
|
|
54
|
+
if (conditionId && (activatedIds == null ? void 0 : activatedIds.includes(conditionId)))
|
|
55
55
|
return true;
|
|
56
|
-
if (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId))
|
|
56
|
+
if (conditionId && (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId)))
|
|
57
57
|
return false;
|
|
58
58
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[condition.type];
|
|
59
59
|
if (customEvaluator) {
|
|
@@ -539,9 +539,9 @@ var evaluateRule = async (condition, options) => {
|
|
|
539
539
|
var _a, _b;
|
|
540
540
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
541
541
|
const conditionId = condition.id;
|
|
542
|
-
if (activatedIds == null ? void 0 : activatedIds.includes(conditionId))
|
|
542
|
+
if (conditionId && (activatedIds == null ? void 0 : activatedIds.includes(conditionId)))
|
|
543
543
|
return true;
|
|
544
|
-
if (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId))
|
|
544
|
+
if (conditionId && (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId)))
|
|
545
545
|
return false;
|
|
546
546
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[condition.type];
|
|
547
547
|
if (customEvaluator) {
|
|
@@ -584,9 +584,9 @@ var evaluateRule = async (condition, options) => {
|
|
|
584
584
|
var _a, _b;
|
|
585
585
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
586
586
|
const conditionId = condition.id;
|
|
587
|
-
if (activatedIds == null ? void 0 : activatedIds.includes(conditionId))
|
|
587
|
+
if (conditionId && (activatedIds == null ? void 0 : activatedIds.includes(conditionId)))
|
|
588
588
|
return true;
|
|
589
|
-
if (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId))
|
|
589
|
+
if (conditionId && (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId)))
|
|
590
590
|
return false;
|
|
591
591
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[condition.type];
|
|
592
592
|
if (customEvaluator) {
|
package/dist/conditions/index.js
CHANGED
package/dist/content-helper.cjs
CHANGED
|
@@ -31,6 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var content_helper_exports = {};
|
|
32
32
|
__export(content_helper_exports, {
|
|
33
33
|
createStepCopy: () => createStepCopy,
|
|
34
|
+
duplicateChecklistData: () => duplicateChecklistData,
|
|
35
|
+
duplicateConfig: () => duplicateConfig,
|
|
36
|
+
duplicateData: () => duplicateData,
|
|
37
|
+
duplicateTarget: () => duplicateTarget,
|
|
38
|
+
duplicateTriggers: () => duplicateTriggers,
|
|
34
39
|
extractQuestionData: () => extractQuestionData,
|
|
35
40
|
generateUniqueCopyName: () => generateUniqueCopyName,
|
|
36
41
|
hasMissingRequiredData: () => hasMissingRequiredData,
|
|
@@ -38,9 +43,7 @@ __export(content_helper_exports, {
|
|
|
38
43
|
isMissingRequiredData: () => isMissingRequiredData,
|
|
39
44
|
isQuestionElement: () => isQuestionElement,
|
|
40
45
|
isRestrictedType: () => isRestrictedType,
|
|
41
|
-
processQuestionElements: () => processQuestionElements
|
|
42
|
-
regenerateTarget: () => regenerateTarget,
|
|
43
|
-
regenerateTrigger: () => regenerateTrigger
|
|
46
|
+
processQuestionElements: () => processQuestionElements
|
|
44
47
|
});
|
|
45
48
|
module.exports = __toCommonJS(content_helper_exports);
|
|
46
49
|
var import_types3 = require("@usertour/types");
|
|
@@ -126,6 +129,9 @@ var ObjProto = Object.prototype;
|
|
|
126
129
|
var objToString = ObjProto.toString;
|
|
127
130
|
var objHasOwn = ObjProto.hasOwnProperty;
|
|
128
131
|
var isArray = nativeIsArray || ((obj) => objToString.call(obj) === "[object Array]");
|
|
132
|
+
var isObject = (x) => {
|
|
133
|
+
return x === Object(x) && !isArray(x);
|
|
134
|
+
};
|
|
129
135
|
var isString = (x) => {
|
|
130
136
|
return objToString.call(x) === "[object String]";
|
|
131
137
|
};
|
|
@@ -250,15 +256,29 @@ var processQuestionElements = (contents) => {
|
|
|
250
256
|
}))
|
|
251
257
|
}));
|
|
252
258
|
};
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
259
|
+
var generateUniqueCopyName = (originalName, existingNames) => {
|
|
260
|
+
let name = `${originalName} (copy)`;
|
|
261
|
+
if (existingNames == null ? void 0 : existingNames.includes(name)) {
|
|
262
|
+
let number = 2;
|
|
263
|
+
while (existingNames.includes(`${originalName} (copy ${number})`)) {
|
|
264
|
+
number++;
|
|
265
|
+
}
|
|
266
|
+
name = `${originalName} (copy ${number})`;
|
|
267
|
+
}
|
|
268
|
+
return name;
|
|
269
|
+
};
|
|
270
|
+
var duplicateTriggers = (triggers) => {
|
|
271
|
+
if (!isArray(triggers)) {
|
|
272
|
+
return triggers;
|
|
273
|
+
}
|
|
274
|
+
return triggers.map((trigger) => ({
|
|
275
|
+
...trigger,
|
|
256
276
|
id: cuid(),
|
|
257
|
-
|
|
258
|
-
|
|
277
|
+
actions: isArray(trigger.actions) ? regenerateConditionIds(trigger.actions) : trigger.actions,
|
|
278
|
+
conditions: isArray(trigger.conditions) ? regenerateConditionIds(trigger.conditions) : trigger.conditions
|
|
259
279
|
}));
|
|
260
280
|
};
|
|
261
|
-
var
|
|
281
|
+
var duplicateTarget = (target) => {
|
|
262
282
|
if (!target) {
|
|
263
283
|
return void 0;
|
|
264
284
|
}
|
|
@@ -270,23 +290,44 @@ var regenerateTarget = (target) => {
|
|
|
270
290
|
}
|
|
271
291
|
return target;
|
|
272
292
|
};
|
|
273
|
-
var
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
let number = 2;
|
|
277
|
-
while (existingNames.includes(`${originalName} (copy ${number})`)) {
|
|
278
|
-
number++;
|
|
279
|
-
}
|
|
280
|
-
name = `${originalName} (copy ${number})`;
|
|
293
|
+
var duplicateChecklistData = (data) => {
|
|
294
|
+
if (!data || !isObject(data) || !isArray(data.items)) {
|
|
295
|
+
return data;
|
|
281
296
|
}
|
|
282
|
-
|
|
297
|
+
const checklistData = data;
|
|
298
|
+
return {
|
|
299
|
+
...checklistData,
|
|
300
|
+
items: checklistData.items.map((item) => ({
|
|
301
|
+
...item,
|
|
302
|
+
id: uuidV4(),
|
|
303
|
+
clickedActions: isArray(item.clickedActions) ? regenerateConditionIds(item.clickedActions) : item.clickedActions,
|
|
304
|
+
completeConditions: isArray(item.completeConditions) ? regenerateConditionIds(item.completeConditions) : item.completeConditions,
|
|
305
|
+
onlyShowTaskConditions: isArray(item.onlyShowTaskConditions) ? regenerateConditionIds(item.onlyShowTaskConditions) : item.onlyShowTaskConditions
|
|
306
|
+
}))
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
var duplicateConfig = (config) => {
|
|
310
|
+
if (!config) {
|
|
311
|
+
return config;
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
...config,
|
|
315
|
+
autoStartRules: config.autoStartRules ? regenerateConditionIds(config.autoStartRules) : config.autoStartRules,
|
|
316
|
+
hideRules: config.hideRules ? regenerateConditionIds(config.hideRules) : config.hideRules
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
var duplicateData = (data, contentType) => {
|
|
320
|
+
if (contentType === import_types3.ContentDataType.CHECKLIST) {
|
|
321
|
+
return duplicateChecklistData(data);
|
|
322
|
+
}
|
|
323
|
+
return data;
|
|
283
324
|
};
|
|
284
325
|
var createStepCopy = (originalStep, sequence, existingStepNames) => {
|
|
285
326
|
const { id, cvid, updatedAt, createdAt, ...rest } = originalStep;
|
|
286
327
|
const name = generateUniqueCopyName(originalStep == null ? void 0 : originalStep.name, existingStepNames);
|
|
287
|
-
const trigger = (originalStep == null ? void 0 : originalStep.trigger) ?
|
|
328
|
+
const trigger = (originalStep == null ? void 0 : originalStep.trigger) ? duplicateTriggers(originalStep == null ? void 0 : originalStep.trigger) : [];
|
|
288
329
|
const data = (originalStep == null ? void 0 : originalStep.data) ? processQuestionElements(originalStep == null ? void 0 : originalStep.data) : [];
|
|
289
|
-
const target =
|
|
330
|
+
const target = duplicateTarget(originalStep == null ? void 0 : originalStep.target);
|
|
290
331
|
return {
|
|
291
332
|
...rest,
|
|
292
333
|
data,
|
|
@@ -299,6 +340,11 @@ var createStepCopy = (originalStep, sequence, existingStepNames) => {
|
|
|
299
340
|
// Annotate the CommonJS export names for ESM import in node:
|
|
300
341
|
0 && (module.exports = {
|
|
301
342
|
createStepCopy,
|
|
343
|
+
duplicateChecklistData,
|
|
344
|
+
duplicateConfig,
|
|
345
|
+
duplicateData,
|
|
346
|
+
duplicateTarget,
|
|
347
|
+
duplicateTriggers,
|
|
302
348
|
extractQuestionData,
|
|
303
349
|
generateUniqueCopyName,
|
|
304
350
|
hasMissingRequiredData,
|
|
@@ -306,7 +352,5 @@ var createStepCopy = (originalStep, sequence, existingStepNames) => {
|
|
|
306
352
|
isMissingRequiredData,
|
|
307
353
|
isQuestionElement,
|
|
308
354
|
isRestrictedType,
|
|
309
|
-
processQuestionElements
|
|
310
|
-
regenerateTarget,
|
|
311
|
-
regenerateTrigger
|
|
355
|
+
processQuestionElements
|
|
312
356
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContentEditorElementType, ContentEditorElement, ContentEditorRoot, ContentEditorClickableElement, ContentEditorQuestionElement, StepTrigger, Step } from '@usertour/types';
|
|
1
|
+
import { ContentEditorElementType, ContentEditorElement, ContentEditorRoot, ContentEditorClickableElement, ContentEditorQuestionElement, StepTrigger, Step, ContentConfigObject } from '@usertour/types';
|
|
2
2
|
|
|
3
3
|
declare const isRestrictedType: (type: ContentEditorElementType) => boolean;
|
|
4
4
|
declare const isMissingRequiredData: (element: ContentEditorElement) => boolean;
|
|
@@ -13,13 +13,6 @@ declare const extractQuestionData: (data: ContentEditorRoot[]) => ContentEditorQ
|
|
|
13
13
|
* @returns A new array with question element cvids replaced by new cuids and actions regenerated
|
|
14
14
|
*/
|
|
15
15
|
declare const processQuestionElements: (contents: ContentEditorRoot[] | undefined) => ContentEditorRoot[];
|
|
16
|
-
declare const regenerateTrigger: (trigger: StepTrigger[]) => StepTrigger[];
|
|
17
|
-
/**
|
|
18
|
-
* Process target to regenerate condition IDs in actions field
|
|
19
|
-
* @param target - The target object to process
|
|
20
|
-
* @returns A new target object with regenerated action condition IDs, or undefined if target is undefined
|
|
21
|
-
*/
|
|
22
|
-
declare const regenerateTarget: (target: Step['target']) => Step['target'];
|
|
23
16
|
/**
|
|
24
17
|
* Generate a unique copy name based on the original name and existing names
|
|
25
18
|
* @param originalName - The original name to base the copy name on
|
|
@@ -27,6 +20,38 @@ declare const regenerateTarget: (target: Step['target']) => Step['target'];
|
|
|
27
20
|
* @returns A unique name in the format "Name (copy)", "Name (copy 2)", etc.
|
|
28
21
|
*/
|
|
29
22
|
declare const generateUniqueCopyName: (originalName: string, existingNames?: string[]) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Regenerate IDs for step triggers and their nested actions/conditions
|
|
25
|
+
* @param triggers - Array of step triggers to process
|
|
26
|
+
* @returns New array with regenerated IDs for triggers, actions, and conditions
|
|
27
|
+
*/
|
|
28
|
+
declare const duplicateTriggers: (triggers: StepTrigger[]) => StepTrigger[];
|
|
29
|
+
/**
|
|
30
|
+
* Process target to regenerate condition IDs in actions field
|
|
31
|
+
* @param target - The target object to process
|
|
32
|
+
* @returns A new target object with regenerated action condition IDs, or undefined if target is undefined
|
|
33
|
+
*/
|
|
34
|
+
declare const duplicateTarget: (target: Step['target']) => Step['target'];
|
|
35
|
+
/**
|
|
36
|
+
* Process ChecklistData to regenerate condition IDs in RulesCondition[] fields
|
|
37
|
+
* Handles clickedActions, completeConditions, and onlyShowTaskConditions for each item
|
|
38
|
+
* @param data - The checklist data to process
|
|
39
|
+
* @returns Processed checklist data with regenerated condition IDs
|
|
40
|
+
*/
|
|
41
|
+
declare const duplicateChecklistData: (data: unknown) => unknown;
|
|
42
|
+
/**
|
|
43
|
+
* Process version config to regenerate condition IDs in autoStartRules and hideRules
|
|
44
|
+
* @param config - The content config object to process
|
|
45
|
+
* @returns New config object with regenerated condition IDs
|
|
46
|
+
*/
|
|
47
|
+
declare const duplicateConfig: (config: ContentConfigObject) => ContentConfigObject;
|
|
48
|
+
/**
|
|
49
|
+
* Process version data based on content type to regenerate condition IDs
|
|
50
|
+
* @param data - The version data to process
|
|
51
|
+
* @param contentType - The type of content (checklist, flow, etc.)
|
|
52
|
+
* @returns Processed data with regenerated condition IDs
|
|
53
|
+
*/
|
|
54
|
+
declare const duplicateData: (data: unknown, contentType: string) => unknown;
|
|
30
55
|
declare const createStepCopy: (originalStep: Step, sequence: number, existingStepNames?: string[]) => Step;
|
|
31
56
|
|
|
32
|
-
export { createStepCopy, extractQuestionData, generateUniqueCopyName, hasMissingRequiredData, isClickableElement, isMissingRequiredData, isQuestionElement, isRestrictedType, processQuestionElements
|
|
57
|
+
export { createStepCopy, duplicateChecklistData, duplicateConfig, duplicateData, duplicateTarget, duplicateTriggers, extractQuestionData, generateUniqueCopyName, hasMissingRequiredData, isClickableElement, isMissingRequiredData, isQuestionElement, isRestrictedType, processQuestionElements };
|
package/dist/content-helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContentEditorElementType, ContentEditorElement, ContentEditorRoot, ContentEditorClickableElement, ContentEditorQuestionElement, StepTrigger, Step } from '@usertour/types';
|
|
1
|
+
import { ContentEditorElementType, ContentEditorElement, ContentEditorRoot, ContentEditorClickableElement, ContentEditorQuestionElement, StepTrigger, Step, ContentConfigObject } from '@usertour/types';
|
|
2
2
|
|
|
3
3
|
declare const isRestrictedType: (type: ContentEditorElementType) => boolean;
|
|
4
4
|
declare const isMissingRequiredData: (element: ContentEditorElement) => boolean;
|
|
@@ -13,13 +13,6 @@ declare const extractQuestionData: (data: ContentEditorRoot[]) => ContentEditorQ
|
|
|
13
13
|
* @returns A new array with question element cvids replaced by new cuids and actions regenerated
|
|
14
14
|
*/
|
|
15
15
|
declare const processQuestionElements: (contents: ContentEditorRoot[] | undefined) => ContentEditorRoot[];
|
|
16
|
-
declare const regenerateTrigger: (trigger: StepTrigger[]) => StepTrigger[];
|
|
17
|
-
/**
|
|
18
|
-
* Process target to regenerate condition IDs in actions field
|
|
19
|
-
* @param target - The target object to process
|
|
20
|
-
* @returns A new target object with regenerated action condition IDs, or undefined if target is undefined
|
|
21
|
-
*/
|
|
22
|
-
declare const regenerateTarget: (target: Step['target']) => Step['target'];
|
|
23
16
|
/**
|
|
24
17
|
* Generate a unique copy name based on the original name and existing names
|
|
25
18
|
* @param originalName - The original name to base the copy name on
|
|
@@ -27,6 +20,38 @@ declare const regenerateTarget: (target: Step['target']) => Step['target'];
|
|
|
27
20
|
* @returns A unique name in the format "Name (copy)", "Name (copy 2)", etc.
|
|
28
21
|
*/
|
|
29
22
|
declare const generateUniqueCopyName: (originalName: string, existingNames?: string[]) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Regenerate IDs for step triggers and their nested actions/conditions
|
|
25
|
+
* @param triggers - Array of step triggers to process
|
|
26
|
+
* @returns New array with regenerated IDs for triggers, actions, and conditions
|
|
27
|
+
*/
|
|
28
|
+
declare const duplicateTriggers: (triggers: StepTrigger[]) => StepTrigger[];
|
|
29
|
+
/**
|
|
30
|
+
* Process target to regenerate condition IDs in actions field
|
|
31
|
+
* @param target - The target object to process
|
|
32
|
+
* @returns A new target object with regenerated action condition IDs, or undefined if target is undefined
|
|
33
|
+
*/
|
|
34
|
+
declare const duplicateTarget: (target: Step['target']) => Step['target'];
|
|
35
|
+
/**
|
|
36
|
+
* Process ChecklistData to regenerate condition IDs in RulesCondition[] fields
|
|
37
|
+
* Handles clickedActions, completeConditions, and onlyShowTaskConditions for each item
|
|
38
|
+
* @param data - The checklist data to process
|
|
39
|
+
* @returns Processed checklist data with regenerated condition IDs
|
|
40
|
+
*/
|
|
41
|
+
declare const duplicateChecklistData: (data: unknown) => unknown;
|
|
42
|
+
/**
|
|
43
|
+
* Process version config to regenerate condition IDs in autoStartRules and hideRules
|
|
44
|
+
* @param config - The content config object to process
|
|
45
|
+
* @returns New config object with regenerated condition IDs
|
|
46
|
+
*/
|
|
47
|
+
declare const duplicateConfig: (config: ContentConfigObject) => ContentConfigObject;
|
|
48
|
+
/**
|
|
49
|
+
* Process version data based on content type to regenerate condition IDs
|
|
50
|
+
* @param data - The version data to process
|
|
51
|
+
* @param contentType - The type of content (checklist, flow, etc.)
|
|
52
|
+
* @returns Processed data with regenerated condition IDs
|
|
53
|
+
*/
|
|
54
|
+
declare const duplicateData: (data: unknown, contentType: string) => unknown;
|
|
30
55
|
declare const createStepCopy: (originalStep: Step, sequence: number, existingStepNames?: string[]) => Step;
|
|
31
56
|
|
|
32
|
-
export { createStepCopy, extractQuestionData, generateUniqueCopyName, hasMissingRequiredData, isClickableElement, isMissingRequiredData, isQuestionElement, isRestrictedType, processQuestionElements
|
|
57
|
+
export { createStepCopy, duplicateChecklistData, duplicateConfig, duplicateData, duplicateTarget, duplicateTriggers, extractQuestionData, generateUniqueCopyName, hasMissingRequiredData, isClickableElement, isMissingRequiredData, isQuestionElement, isRestrictedType, processQuestionElements };
|