@jfdevelops/multi-step-form-core 1.0.0-alpha.12 → 1.0.0-alpha.13
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/_internals.cjs +13 -9
- package/dist/_internals.d.cts +4 -0
- package/dist/_internals.d.mts +4 -0
- package/dist/_internals.mjs +5 -7
- package/dist/index.cjs +45 -669
- package/dist/index.d.cts +14 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.mjs +16 -668
- package/dist/internals/step-schema.cjs +309 -0
- package/dist/internals/step-schema.cjs.map +1 -0
- package/dist/internals/step-schema.d.cts +39 -0
- package/dist/internals/step-schema.d.cts.map +1 -0
- package/dist/internals/step-schema.d.mts +39 -0
- package/dist/internals/step-schema.d.mts.map +1 -0
- package/dist/internals/step-schema.mjs +309 -0
- package/dist/internals/step-schema.mjs.map +1 -0
- package/dist/internals/utils.cjs +94 -0
- package/dist/internals/utils.cjs.map +1 -0
- package/dist/internals/utils.d.cts +27 -0
- package/dist/internals/utils.d.cts.map +1 -0
- package/dist/internals/utils.d.mts +27 -0
- package/dist/internals/utils.d.mts.map +1 -0
- package/dist/internals/utils.mjs +91 -0
- package/dist/internals/utils.mjs.map +1 -0
- package/dist/observable.cjs +44 -0
- package/dist/observable.cjs.map +1 -0
- package/dist/observable.d.cts +26 -0
- package/dist/observable.d.cts.map +1 -0
- package/dist/observable.d.mts +26 -0
- package/dist/observable.d.mts.map +1 -0
- package/dist/observable.mjs +44 -0
- package/dist/observable.mjs.map +1 -0
- package/dist/schema.cjs +68 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +28 -0
- package/dist/schema.d.cts.map +1 -0
- package/dist/schema.d.mts +28 -0
- package/dist/schema.d.mts.map +1 -0
- package/dist/schema.mjs +67 -0
- package/dist/schema.mjs.map +1 -0
- package/dist/steps/fields.cjs +23 -0
- package/dist/steps/fields.cjs.map +1 -0
- package/dist/steps/fields.d.cts +18 -0
- package/dist/steps/fields.d.cts.map +1 -0
- package/dist/steps/fields.d.mts +18 -0
- package/dist/steps/fields.d.mts.map +1 -0
- package/dist/steps/fields.mjs +18 -0
- package/dist/steps/fields.mjs.map +1 -0
- package/dist/steps/index.cjs +4 -0
- package/dist/steps/index.mjs +6 -0
- package/dist/steps/schema.cjs +194 -0
- package/dist/steps/schema.cjs.map +1 -0
- package/dist/steps/schema.d.cts +124 -0
- package/dist/steps/schema.d.cts.map +1 -0
- package/dist/steps/schema.d.mts +124 -0
- package/dist/steps/schema.d.mts.map +1 -0
- package/dist/steps/schema.mjs +194 -0
- package/dist/steps/schema.mjs.map +1 -0
- package/dist/steps/types.cjs +33 -0
- package/dist/steps/types.cjs.map +1 -0
- package/dist/steps/types.d.cts +268 -0
- package/dist/steps/types.d.cts.map +1 -0
- package/dist/steps/types.d.mts +268 -0
- package/dist/steps/types.d.mts.map +1 -0
- package/dist/steps/types.mjs +27 -0
- package/dist/steps/types.mjs.map +1 -0
- package/dist/steps/utils.cjs +96 -0
- package/dist/steps/utils.cjs.map +1 -0
- package/dist/steps/utils.d.cts +10 -0
- package/dist/steps/utils.d.cts.map +1 -0
- package/dist/steps/utils.d.mts +10 -0
- package/dist/steps/utils.d.mts.map +1 -0
- package/dist/steps/utils.mjs +94 -0
- package/dist/steps/utils.mjs.map +1 -0
- package/dist/storage.cjs +72 -0
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.d.cts +33 -0
- package/dist/storage.d.cts.map +1 -0
- package/dist/storage.d.mts +33 -0
- package/dist/storage.d.mts.map +1 -0
- package/dist/storage.mjs +71 -0
- package/dist/storage.mjs.map +1 -0
- package/dist/subscribable.cjs +25 -0
- package/dist/subscribable.cjs.map +1 -0
- package/dist/subscribable.d.cts +14 -0
- package/dist/subscribable.d.cts.map +1 -0
- package/dist/subscribable.d.mts +14 -0
- package/dist/subscribable.d.mts.map +1 -0
- package/dist/subscribable.mjs +24 -0
- package/dist/subscribable.mjs.map +1 -0
- package/dist/utils/casing.cjs +63 -0
- package/dist/utils/casing.cjs.map +1 -0
- package/dist/utils/casing.d.cts +40 -0
- package/dist/utils/casing.d.cts.map +1 -0
- package/dist/utils/casing.d.mts +40 -0
- package/dist/utils/casing.d.mts.map +1 -0
- package/dist/utils/casing.mjs +57 -0
- package/dist/utils/casing.mjs.map +1 -0
- package/dist/utils/field-types.cjs +23 -0
- package/dist/utils/field-types.cjs.map +1 -0
- package/dist/utils/field-types.d.cts +11 -0
- package/dist/utils/field-types.d.cts.map +1 -0
- package/dist/utils/field-types.d.mts +11 -0
- package/dist/utils/field-types.d.mts.map +1 -0
- package/dist/utils/field-types.mjs +20 -0
- package/dist/utils/field-types.mjs.map +1 -0
- package/dist/utils/helpers.cjs +30 -0
- package/dist/utils/helpers.cjs.map +1 -0
- package/dist/utils/helpers.mjs +27 -0
- package/dist/utils/helpers.mjs.map +1 -0
- package/dist/utils/invariant.cjs +18 -0
- package/dist/utils/invariant.cjs.map +1 -0
- package/dist/utils/invariant.d.cts +5 -0
- package/dist/utils/invariant.d.cts.map +1 -0
- package/dist/utils/invariant.d.mts +5 -0
- package/dist/utils/invariant.d.mts.map +1 -0
- package/dist/utils/invariant.mjs +17 -0
- package/dist/utils/invariant.mjs.map +1 -0
- package/dist/utils/logger.cjs +58 -0
- package/dist/utils/logger.cjs.map +1 -0
- package/dist/utils/logger.d.cts +53 -0
- package/dist/utils/logger.d.cts.map +1 -0
- package/dist/utils/logger.d.mts +53 -0
- package/dist/utils/logger.d.mts.map +1 -0
- package/dist/utils/logger.mjs +56 -0
- package/dist/utils/logger.mjs.map +1 -0
- package/dist/utils/path.cjs +272 -0
- package/dist/utils/path.cjs.map +1 -0
- package/dist/utils/path.d.cts +131 -0
- package/dist/utils/path.d.cts.map +1 -0
- package/dist/utils/path.d.mts +131 -0
- package/dist/utils/path.d.mts.map +1 -0
- package/dist/utils/path.mjs +266 -0
- package/dist/utils/path.mjs.map +1 -0
- package/dist/utils/types.d.cts +23 -0
- package/dist/utils/types.d.cts.map +1 -0
- package/dist/utils/types.d.mts +23 -0
- package/dist/utils/types.d.mts.map +1 -0
- package/dist/utils/validator.cjs +12 -0
- package/dist/utils/validator.cjs.map +1 -0
- package/dist/utils/validator.d.cts +77 -0
- package/dist/utils/validator.d.cts.map +1 -0
- package/dist/utils/validator.d.mts +77 -0
- package/dist/utils/validator.d.mts.map +1 -0
- package/dist/utils/validator.mjs +11 -0
- package/dist/utils/validator.mjs.map +1 -0
- package/package.json +12 -12
- package/dist/_internals.cjs.map +0 -1
- package/dist/_internals.mjs.map +0 -1
- package/dist/errors/invalid-key.d.ts +0 -18
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.mjs.map +0 -1
- package/dist/internals/index.d.ts +0 -2
- package/dist/internals/step-schema.d.ts +0 -28
- package/dist/observable.d.ts +0 -21
- package/dist/schema.d.ts +0 -22
- package/dist/steps/fields.d.ts +0 -20
- package/dist/steps/index.d.ts +0 -4
- package/dist/steps/schema.d.ts +0 -138
- package/dist/steps/types.d.ts +0 -295
- package/dist/steps/utils.d.ts +0 -21
- package/dist/storage.d.ts +0 -28
- package/dist/subscribable.d.ts +0 -10
- package/dist/types-C4Mgnku6.cjs +0 -949
- package/dist/types-C4Mgnku6.cjs.map +0 -1
- package/dist/types-CYf1_lBe.js +0 -953
- package/dist/types-CYf1_lBe.js.map +0 -1
- package/dist/utils/casing.d.ts +0 -38
- package/dist/utils/field-types.d.ts +0 -6
- package/dist/utils/helper-fns.d.ts +0 -8
- package/dist/utils/helpers.d.ts +0 -8
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/invariant.d.ts +0 -1
- package/dist/utils/logger.d.ts +0 -50
- package/dist/utils/path.d.ts +0 -141
- package/dist/utils/types.d.ts +0 -34
- package/dist/utils/validator.d.ts +0 -74
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { comparePartialArray, printErrors, typedObjectKeys } from "../utils/helpers.mjs";
|
|
2
|
+
import { invariant } from "../utils/invariant.mjs";
|
|
3
|
+
import { createCtx, functionalUpdate } from "../steps/utils.mjs";
|
|
4
|
+
import { MultiStepFormLogger } from "../utils/logger.mjs";
|
|
5
|
+
import { path } from "../utils/path.mjs";
|
|
6
|
+
import { runStandardValidation } from "../utils/validator.mjs";
|
|
7
|
+
import { createStep, isTupleNotation, isValidStepKey } from "./utils.mjs";
|
|
8
|
+
import { HelperFnChosenSteps } from "../steps/types.mjs";
|
|
9
|
+
import "../steps/index.mjs";
|
|
10
|
+
|
|
11
|
+
//#region src/internals/step-schema.ts
|
|
12
|
+
var MultiStepFormStepSchemaInternal = class {
|
|
13
|
+
#originalValue;
|
|
14
|
+
#additionalEnrichedProps;
|
|
15
|
+
#getValue;
|
|
16
|
+
#setValue;
|
|
17
|
+
get value() {
|
|
18
|
+
return this.#getValue();
|
|
19
|
+
}
|
|
20
|
+
constructor(options) {
|
|
21
|
+
const { getValue, setValue, originalValue, additionalEnrichedProps } = options;
|
|
22
|
+
this.#originalValue = originalValue;
|
|
23
|
+
this.#getValue = getValue;
|
|
24
|
+
this.#setValue = setValue;
|
|
25
|
+
this.#additionalEnrichedProps = additionalEnrichedProps;
|
|
26
|
+
}
|
|
27
|
+
handlePostUpdate(value) {
|
|
28
|
+
this.#setValue(this.enrichValues(value));
|
|
29
|
+
}
|
|
30
|
+
createStepUpdaterFnImpl(options) {
|
|
31
|
+
const { targetStep, ctxData, fields = "all", debug } = options;
|
|
32
|
+
const logger = new MultiStepFormLogger({
|
|
33
|
+
debug,
|
|
34
|
+
prefix: (value) => `${value}:update${targetStep}`
|
|
35
|
+
});
|
|
36
|
+
logger.info(`${targetStep} will be updated`);
|
|
37
|
+
invariant(isValidStepKey(this.value, targetStep), `[update]: The target step ${targetStep} isn't a valid step. Please select a valid step`);
|
|
38
|
+
const { [targetStep]: currentStep, ...values } = this.value;
|
|
39
|
+
invariant("updater" in options, "[update]: No \"updater\" was found. Please provide a value to the \"updater\" property");
|
|
40
|
+
const updater = options.updater;
|
|
41
|
+
let updatedValue = { ...this.value };
|
|
42
|
+
let ctx = createCtx(updatedValue, [targetStep]);
|
|
43
|
+
if (ctxData) {
|
|
44
|
+
invariant(typeof ctxData === "function", "[update]: \"ctxData\" must be a function");
|
|
45
|
+
logger.info("Custom \"ctx\" will be used");
|
|
46
|
+
const additionalCtx = ctxData({ ctx: values });
|
|
47
|
+
invariant(typeof additionalCtx === "object" && Object.keys(additionalCtx).length > 0, "[update]: \"ctxData\" must return an object with keys");
|
|
48
|
+
logger.info(`Custom "ctx" consists of the following keys: ${new Intl.ListFormat("en", {
|
|
49
|
+
style: "long",
|
|
50
|
+
type: "conjunction"
|
|
51
|
+
}).format(Object.keys(additionalCtx))}`);
|
|
52
|
+
ctx = {
|
|
53
|
+
...ctx,
|
|
54
|
+
...additionalCtx
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const updated = functionalUpdate(updater, {
|
|
58
|
+
ctx,
|
|
59
|
+
update: this.createHelperFnInputUpdate([targetStep])
|
|
60
|
+
});
|
|
61
|
+
logger.info(`The updated data is ${JSON.stringify(updated, null, 2)}`);
|
|
62
|
+
if (fields === "all") {
|
|
63
|
+
invariant(typeof updated === "object", "[update]: \"updater\" must be an object or a function that returns an object");
|
|
64
|
+
const functionKeys = new Set([
|
|
65
|
+
"update",
|
|
66
|
+
"reset",
|
|
67
|
+
"createHelperFn"
|
|
68
|
+
]);
|
|
69
|
+
const stepKeys = Object.keys(this.value);
|
|
70
|
+
const updaterResultKeys = Object.keys(updated).filter((value) => !functionKeys.has(value));
|
|
71
|
+
const missingKeys = stepKeys.filter((key) => !updaterResultKeys.includes(key));
|
|
72
|
+
for (const stepKey of stepKeys) {
|
|
73
|
+
const { update, reset, createHelperFn, ...currentStep$1 } = this.value[stepKey];
|
|
74
|
+
invariant(updaterResultKeys.length === Object.keys(currentStep$1).length, (formatter) => {
|
|
75
|
+
return `[update]: "updater" is missing keys ${formatter.format(missingKeys)}`;
|
|
76
|
+
});
|
|
77
|
+
const functions = {
|
|
78
|
+
update,
|
|
79
|
+
reset,
|
|
80
|
+
createHelperFn
|
|
81
|
+
};
|
|
82
|
+
const obj = {
|
|
83
|
+
...currentStep$1,
|
|
84
|
+
update,
|
|
85
|
+
reset,
|
|
86
|
+
createHelperFn
|
|
87
|
+
};
|
|
88
|
+
const paths = path.createDeep(obj);
|
|
89
|
+
const actual = {
|
|
90
|
+
...updated,
|
|
91
|
+
...functions
|
|
92
|
+
};
|
|
93
|
+
const { mismatches, ok } = path.equalsAtPaths(obj, paths, actual);
|
|
94
|
+
invariant(ok && mismatches.length === 0, () => {
|
|
95
|
+
return `[update]: found value mismatches in ${path.formatMismatches({
|
|
96
|
+
mismatches,
|
|
97
|
+
ok
|
|
98
|
+
})}`;
|
|
99
|
+
});
|
|
100
|
+
logger.info("The entire step will be updated");
|
|
101
|
+
const currentUpdatedValue = updatedValue[stepKey];
|
|
102
|
+
const updatedAtPath = path.updateAt(currentUpdatedValue, paths, actual);
|
|
103
|
+
updatedValue = {
|
|
104
|
+
...updatedValue,
|
|
105
|
+
[targetStep]: updatedAtPath
|
|
106
|
+
};
|
|
107
|
+
this.handlePostUpdate(updatedValue);
|
|
108
|
+
logger.info(`The new value is: ${JSON.stringify(updatedValue, null, 2)}`);
|
|
109
|
+
}
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const currentStepDeepKeys = path.createDeep(currentStep);
|
|
113
|
+
if (Array.isArray(fields)) {
|
|
114
|
+
const compareResult = comparePartialArray(currentStepDeepKeys, fields);
|
|
115
|
+
invariant(compareResult.status === "success", `[update]: Found errors with the provided fields\n${compareResult.status === "error" ? printErrors(compareResult.errors) : ""}`);
|
|
116
|
+
const { mismatches, ok } = path.equalsAtPaths(currentStep, fields, updated);
|
|
117
|
+
invariant(ok && mismatches.length === 0, `[update]: found value mismatches in ${path.printMismatches({
|
|
118
|
+
ok,
|
|
119
|
+
mismatches
|
|
120
|
+
})}`);
|
|
121
|
+
logger.info(`The following fields will be updated: ${new Intl.ListFormat("en", {
|
|
122
|
+
type: "conjunction",
|
|
123
|
+
style: "long"
|
|
124
|
+
}).format(fields)}`);
|
|
125
|
+
updatedValue = {
|
|
126
|
+
...updatedValue,
|
|
127
|
+
[targetStep]: path.updateAt(currentStep, fields, updated)
|
|
128
|
+
};
|
|
129
|
+
this.handlePostUpdate(updatedValue);
|
|
130
|
+
logger.info(`The new value is: ${JSON.stringify(updatedValue, null, 2)}`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (typeof fields === "object" && Object.keys(fields).length > 0) {
|
|
134
|
+
const keys = path.createDeep(fields);
|
|
135
|
+
const compareResult = comparePartialArray(currentStepDeepKeys, keys);
|
|
136
|
+
invariant(compareResult.status === "success", `[update]: Found errors with the provided fields\n${compareResult.status === "error" ? printErrors(compareResult.errors) : ""}`);
|
|
137
|
+
const { mismatches, ok } = path.equalsAtPaths(currentStep, keys, updated);
|
|
138
|
+
invariant(ok && mismatches.length === 0, `[update]: found value mismatches in ${path.printMismatches({
|
|
139
|
+
ok,
|
|
140
|
+
mismatches
|
|
141
|
+
})}`);
|
|
142
|
+
updatedValue = {
|
|
143
|
+
...updatedValue,
|
|
144
|
+
[targetStep]: path.updateAt(currentStep, keys, updated)
|
|
145
|
+
};
|
|
146
|
+
logger.info(`The following fields will be updated: ${new Intl.ListFormat("en", {
|
|
147
|
+
type: "conjunction",
|
|
148
|
+
style: "long"
|
|
149
|
+
}).format(Object.keys(fields))}`);
|
|
150
|
+
this.handlePostUpdate(updatedValue);
|
|
151
|
+
logger.info(`The new value is: ${JSON.stringify(updatedValue, null, 2)}`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
logger.error("Unsupported value for the \"fields\" option");
|
|
155
|
+
throw new TypeError(`[update]: property "fields" must be set to one of the following: "all", an array of deep paths to update, or an object of paths. Was ${typeof updater}`, { cause: updater });
|
|
156
|
+
}
|
|
157
|
+
createStepUpdaterFn(targetStep) {
|
|
158
|
+
return (options) => {
|
|
159
|
+
this.createStepUpdaterFnImpl({
|
|
160
|
+
targetStep,
|
|
161
|
+
...options
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
update(options) {
|
|
166
|
+
return this.createStepUpdaterFnImpl(options);
|
|
167
|
+
}
|
|
168
|
+
resetFields(config) {
|
|
169
|
+
return (fields) => {
|
|
170
|
+
const { targetStep, logger, values } = config;
|
|
171
|
+
const resolvedFields = fields.map((value) => `${targetStep}.${value}`);
|
|
172
|
+
const picked = path.pickBy(values, ...resolvedFields);
|
|
173
|
+
config.updatedValues = {
|
|
174
|
+
...config.updatedValues,
|
|
175
|
+
...path.updateAt(values, fields, picked)
|
|
176
|
+
};
|
|
177
|
+
const message = `${new Intl.ListFormat("en", {
|
|
178
|
+
style: "long",
|
|
179
|
+
type: "conjunction"
|
|
180
|
+
}).format(fields)} for ${targetStep}`;
|
|
181
|
+
logger.info(`Resetting ${message}`);
|
|
182
|
+
this.handlePostUpdate(config.updatedValues);
|
|
183
|
+
logger.info(`Reset ${message}`);
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
createStepResetterFnImpl(options) {
|
|
187
|
+
const { fields = "all", targetStep, debug } = options;
|
|
188
|
+
const logger = new MultiStepFormLogger({
|
|
189
|
+
debug,
|
|
190
|
+
prefix: (value) => `${value}:reset${targetStep}`
|
|
191
|
+
});
|
|
192
|
+
invariant(fields, "[update]: \"fields\" must have a value when \"type\" is \"reset\"");
|
|
193
|
+
const originalValues = createStep(this.#originalValue);
|
|
194
|
+
const enrichedOriginalValues = this.enrichValues(originalValues, this.#additionalEnrichedProps);
|
|
195
|
+
if (fields === "all") {
|
|
196
|
+
logger.info(`Resetting all fields for ${targetStep}`);
|
|
197
|
+
this.handlePostUpdate(enrichedOriginalValues);
|
|
198
|
+
logger.info(`Reset all fields for ${targetStep}`);
|
|
199
|
+
}
|
|
200
|
+
let updatedValues = { ...enrichedOriginalValues };
|
|
201
|
+
const reset = this.resetFields({
|
|
202
|
+
logger,
|
|
203
|
+
targetStep,
|
|
204
|
+
updatedValues,
|
|
205
|
+
values: enrichedOriginalValues
|
|
206
|
+
});
|
|
207
|
+
if (isTupleNotation(fields)) reset(fields);
|
|
208
|
+
if (typeof fields === "object" && Object.keys(fields).length > 0) reset(path.createDeep(fields));
|
|
209
|
+
}
|
|
210
|
+
createStepResetterFn(targetStep) {
|
|
211
|
+
return (options) => {
|
|
212
|
+
return this.createStepResetterFnImpl({
|
|
213
|
+
targetStep,
|
|
214
|
+
fields: options?.fields ?? "all",
|
|
215
|
+
debug: options?.debug ?? false
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
reset(options) {
|
|
220
|
+
this.createStepResetterFnImpl(options);
|
|
221
|
+
}
|
|
222
|
+
createHelperFnInputUpdate(chosenSteps) {
|
|
223
|
+
if (HelperFnChosenSteps.isAll(chosenSteps)) {
|
|
224
|
+
const stepSpecificUpdateFn = typedObjectKeys(this.value).reduce((acc, key) => {
|
|
225
|
+
acc[key] = this.createStepUpdaterFn(key);
|
|
226
|
+
return acc;
|
|
227
|
+
}, {});
|
|
228
|
+
return Object.assign(this.update, stepSpecificUpdateFn);
|
|
229
|
+
}
|
|
230
|
+
const validKeys = Object.keys(this.value);
|
|
231
|
+
if (HelperFnChosenSteps.isTuple(chosenSteps, validKeys)) {
|
|
232
|
+
const stepSpecificUpdateFn = chosenSteps.reduce((acc, step) => {
|
|
233
|
+
acc[step] = this.createStepUpdaterFn(step);
|
|
234
|
+
return acc;
|
|
235
|
+
}, {});
|
|
236
|
+
return Object.assign(this.update, stepSpecificUpdateFn);
|
|
237
|
+
}
|
|
238
|
+
if (HelperFnChosenSteps.isObject(chosenSteps, validKeys)) {
|
|
239
|
+
const stepSpecificUpdateFn = typedObjectKeys(chosenSteps).reduce((acc, key) => {
|
|
240
|
+
acc[key] = this.createStepUpdaterFn(key);
|
|
241
|
+
return acc;
|
|
242
|
+
}, {});
|
|
243
|
+
return Object.assign(this.update, stepSpecificUpdateFn);
|
|
244
|
+
}
|
|
245
|
+
throw new TypeError(`[update]: ${HelperFnChosenSteps.CATCH_ALL_MESSAGE}`);
|
|
246
|
+
}
|
|
247
|
+
createStepHelperFn(stepData) {
|
|
248
|
+
return (optionsOrFunction, fn) => {
|
|
249
|
+
const createInputUpdateFn = this.createHelperFnInputUpdate(stepData);
|
|
250
|
+
if (typeof optionsOrFunction === "function") return () => {
|
|
251
|
+
return optionsOrFunction({
|
|
252
|
+
ctx: createCtx(this.value, stepData),
|
|
253
|
+
update: createInputUpdateFn
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
if (typeof optionsOrFunction === "object") return (input) => {
|
|
257
|
+
const ctx = createCtx(this.value, stepData);
|
|
258
|
+
if ("validator" in optionsOrFunction) {
|
|
259
|
+
invariant(typeof input === "object", "An input is expected since you provided a validator");
|
|
260
|
+
runStandardValidation(optionsOrFunction.validator, input.data);
|
|
261
|
+
let resolvedCtx = ctx;
|
|
262
|
+
if (optionsOrFunction.ctxData) {
|
|
263
|
+
const currentStepKey = stepData[0];
|
|
264
|
+
const { [currentStepKey]: _, ...values } = this.value;
|
|
265
|
+
resolvedCtx = {
|
|
266
|
+
...resolvedCtx,
|
|
267
|
+
...optionsOrFunction.ctxData({ ctx: values })
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
return fn({
|
|
271
|
+
ctx: resolvedCtx,
|
|
272
|
+
update: createInputUpdateFn,
|
|
273
|
+
...input
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return fn({
|
|
277
|
+
ctx,
|
|
278
|
+
update: createInputUpdateFn
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
throw new Error(`The first argument must be a function or an object, (was ${typeof optionsOrFunction})`);
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
extractStepFromKey(key) {
|
|
285
|
+
const [targetStep] = [key];
|
|
286
|
+
return {
|
|
287
|
+
targetStep,
|
|
288
|
+
step: Number.parseInt(targetStep.replace("step", ""))
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
enrichValues(values, additionalProps) {
|
|
292
|
+
let enriched = { ...values };
|
|
293
|
+
for (const [key, stepValue] of Object.entries(enriched)) {
|
|
294
|
+
const { step, targetStep } = this.extractStepFromKey(key);
|
|
295
|
+
enriched[targetStep] = {
|
|
296
|
+
...stepValue,
|
|
297
|
+
update: this.createStepUpdaterFn(targetStep),
|
|
298
|
+
reset: this.createStepResetterFn(targetStep),
|
|
299
|
+
createHelperFn: this.createStepHelperFn([targetStep]),
|
|
300
|
+
...additionalProps?.(step)
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
return enriched;
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
//#endregion
|
|
308
|
+
export { MultiStepFormStepSchemaInternal };
|
|
309
|
+
//# sourceMappingURL=step-schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-schema.mjs","names":["#originalValue","#additionalEnrichedProps","#getValue","#setValue","currentStep","actual: Record<string, unknown>"],"sources":["../../src/internals/step-schema.ts"],"sourcesContent":["import {\n createCtx,\n HelperFnChosenSteps,\n type AnyResolvedStep,\n type CreatedHelperFnInput,\n type CreateHelperFunctionOptionsWithoutValidator,\n type CreateHelperFunctionOptionsWithValidator,\n type HelperFnCtx,\n type helperFnUpdateFn,\n type HelperFnUpdateFn,\n type HelperFnWithoutValidator,\n type HelperFnWithValidator,\n type InferStepOptions,\n type ResetFn,\n type Step,\n type StepNumbers,\n type UpdateFn,\n type ValidStepKey,\n} from '@/steps';\nimport { functionalUpdate } from '@/steps/utils';\nimport {\n invariant,\n MultiStepFormLogger,\n type CasingType,\n type DeepKeys,\n} from '@/utils';\nimport {\n comparePartialArray,\n printErrors,\n typedObjectKeys,\n} from '@/utils/helpers';\nimport { path } from '@/utils/path';\nimport {\n runStandardValidation,\n type StandardSchemaValidator,\n} from '@/utils/validator';\nimport { createStep, isTupleNotation, isValidStepKey } from './utils';\n\nexport type InternalOptions<\n TStep extends Step<TCasing>,\n TCasing extends CasingType,\n TResolvedStep extends AnyResolvedStep,\n additionalEnrichedProps extends Record<string, unknown>\n> = {\n originalValue: InferStepOptions<TStep>;\n additionalEnrichedProps?: (step: number) => additionalEnrichedProps;\n /**\n * The resolved multi step form values.\n */\n getValue: () => TResolvedStep;\n /**\n * A function used for setting the `value`. It is called after the\n * `value` is updated successfully.\n * @param value The updated and enriched multi step form values.\n * @returns\n */\n setValue: (value: TResolvedStep) => void;\n};\n\nexport class MultiStepFormStepSchemaInternal<\n step extends Step<casing>,\n casing extends CasingType,\n resolvedStep extends AnyResolvedStep,\n stepNumbers extends StepNumbers<resolvedStep>,\n additionalEnrichedProps extends Record<string, unknown> = {}\n> {\n readonly #originalValue: InferStepOptions<step>;\n readonly #additionalEnrichedProps?: (step: number) => additionalEnrichedProps;\n readonly #getValue: () => resolvedStep;\n readonly #setValue: (value: resolvedStep) => void;\n\n private get value() {\n return this.#getValue();\n }\n\n constructor(\n options: InternalOptions<\n step,\n casing,\n resolvedStep,\n additionalEnrichedProps\n >\n ) {\n const { getValue, setValue, originalValue, additionalEnrichedProps } =\n options;\n\n this.#originalValue = originalValue;\n this.#getValue = getValue;\n this.#setValue = setValue;\n this.#additionalEnrichedProps = additionalEnrichedProps;\n }\n\n private handlePostUpdate(value: resolvedStep) {\n this.#setValue(this.enrichValues(value));\n }\n\n private createStepUpdaterFnImpl<\n targetStep extends ValidStepKey<stepNumbers>,\n fields extends UpdateFn.chosenFields<currentStep>,\n additionalCtx extends Record<string, unknown>,\n currentStep extends UpdateFn.resolvedStep<\n resolvedStep,\n stepNumbers,\n targetStep\n >\n >(\n options: UpdateFn.options<\n resolvedStep,\n stepNumbers,\n targetStep,\n fields,\n additionalCtx,\n currentStep\n >\n ) {\n const { targetStep, ctxData, fields = 'all', debug } = options;\n const logger = new MultiStepFormLogger({\n debug,\n prefix: (value) => `${value}:update${targetStep}`,\n });\n\n logger.info(`${targetStep} will be updated`);\n invariant(\n isValidStepKey(this.value, targetStep),\n `[update]: The target step ${targetStep} isn't a valid step. Please select a valid step`\n );\n\n const { [targetStep]: currentStep, ...values } = this.value;\n\n invariant(\n 'updater' in options,\n '[update]: No \"updater\" was found. Please provide a value to the \"updater\" property'\n );\n\n const updater = options.updater;\n let updatedValue = { ...this.value };\n\n let ctx = createCtx(updatedValue, [targetStep]);\n\n // Build the `ctx` first\n if (ctxData) {\n invariant(\n typeof ctxData === 'function',\n '[update]: \"ctxData\" must be a function'\n );\n logger.info('Custom \"ctx\" will be used');\n\n const additionalCtx = ctxData({ ctx: values as never });\n\n invariant(\n typeof additionalCtx === 'object' &&\n Object.keys(additionalCtx).length > 0,\n '[update]: \"ctxData\" must return an object with keys'\n );\n\n logger.info(\n `Custom \"ctx\" consists of the following keys: ${new Intl.ListFormat(\n 'en',\n {\n style: 'long',\n type: 'conjunction',\n }\n ).format(Object.keys(additionalCtx))}`\n );\n\n ctx = {\n ...ctx,\n ...additionalCtx,\n };\n }\n\n const updated = functionalUpdate(updater, {\n ctx: ctx as never,\n update: this.createHelperFnInputUpdate([targetStep]),\n });\n logger.info(`The updated data is ${JSON.stringify(updated, null, 2)}`);\n\n // TODO validate `updater` - will have to be done in each case (I think)\n\n // default case: updating all fields for the current step\n if (fields === 'all') {\n invariant(\n typeof updated === 'object',\n '[update]: \"updater\" must be an object or a function that returns an object'\n );\n\n const functionKeys = new Set(['update', 'reset', 'createHelperFn']);\n const stepKeys = Object.keys(this.value);\n const updaterResultKeys = Object.keys(\n updated as Record<string, unknown>\n ).filter((value) => !functionKeys.has(value));\n const missingKeys = stepKeys.filter(\n (key) => !updaterResultKeys.includes(key)\n );\n\n for (const stepKey of stepKeys) {\n const { update, reset, createHelperFn, ...currentStep } = this.value[\n stepKey\n ] as resolvedStep[keyof resolvedStep];\n\n invariant(\n updaterResultKeys.length === Object.keys(currentStep).length,\n (formatter) => {\n return `[update]: \"updater\" is missing keys ${formatter.format(\n missingKeys\n )}`;\n }\n );\n const functions = { update, reset, createHelperFn };\n const obj = { ...currentStep, update, reset, createHelperFn };\n const paths = path.createDeep(obj);\n const actual: Record<string, unknown> = {\n ...updated,\n ...functions,\n };\n\n const { mismatches, ok } = path.equalsAtPaths(\n obj,\n paths,\n actual as never\n );\n\n invariant(ok && mismatches.length === 0, () => {\n const formatted = path.formatMismatches({ mismatches, ok });\n\n return `[update]: found value mismatches in ${formatted}`;\n });\n\n logger.info('The entire step will be updated');\n\n const currentUpdatedValue = updatedValue[stepKey] as Record<\n string,\n unknown\n >;\n const updatedAtPath = path.updateAt(\n currentUpdatedValue,\n paths,\n actual as never\n );\n\n updatedValue = {\n ...updatedValue,\n [targetStep]: updatedAtPath,\n };\n\n this.handlePostUpdate(updatedValue);\n logger.info(\n `The new value is: ${JSON.stringify(updatedValue, null, 2)}`\n );\n }\n\n return;\n }\n\n const currentStepDeepKeys = path.createDeep(currentStep);\n\n if (Array.isArray(fields)) {\n const compareResult = comparePartialArray(currentStepDeepKeys, fields);\n\n invariant(\n compareResult.status === 'success',\n `[update]: Found errors with the provided fields\\n${\n compareResult.status === 'error'\n ? printErrors(compareResult.errors)\n : ''\n }`\n );\n\n const { mismatches, ok } = path.equalsAtPaths(\n currentStep,\n fields,\n updated as never\n );\n\n invariant(\n ok && mismatches.length === 0,\n `[update]: found value mismatches in ${path.printMismatches({\n ok,\n mismatches,\n })}`\n );\n\n logger.info(\n `The following fields will be updated: ${new Intl.ListFormat('en', {\n type: 'conjunction',\n style: 'long',\n }).format(fields)}`\n );\n\n updatedValue = {\n ...updatedValue,\n [targetStep]: path.updateAt(currentStep, fields, updated as never),\n };\n\n this.handlePostUpdate(updatedValue);\n logger.info(`The new value is: ${JSON.stringify(updatedValue, null, 2)}`);\n\n return;\n }\n\n if (typeof fields === 'object' && Object.keys(fields).length > 0) {\n const keys = path.createDeep(fields);\n const compareResult = comparePartialArray(\n currentStepDeepKeys,\n keys as never\n );\n\n invariant(\n compareResult.status === 'success',\n `[update]: Found errors with the provided fields\\n${\n compareResult.status === 'error'\n ? printErrors(compareResult.errors)\n : ''\n }`\n );\n\n // TODO validate all values (deepest) are `true`\n const { mismatches, ok } = path.equalsAtPaths(\n currentStep,\n keys as never,\n updated as never\n );\n\n invariant(\n ok && mismatches.length === 0,\n `[update]: found value mismatches in ${path.printMismatches({\n ok,\n mismatches,\n })}`\n );\n\n updatedValue = {\n ...updatedValue,\n [targetStep]: path.updateAt(\n currentStep,\n keys as never,\n updated as never\n ),\n };\n\n logger.info(\n `The following fields will be updated: ${new Intl.ListFormat('en', {\n type: 'conjunction',\n style: 'long',\n }).format(Object.keys(fields))}`\n );\n this.handlePostUpdate(updatedValue);\n logger.info(`The new value is: ${JSON.stringify(updatedValue, null, 2)}`);\n\n return;\n }\n\n logger.error('Unsupported value for the \"fields\" option');\n throw new TypeError(\n `[update]: property \"fields\" must be set to one of the following: \"all\", an array of deep paths to update, or an object of paths. Was ${typeof updater}`,\n { cause: updater }\n );\n }\n\n createStepUpdaterFn<targetStep extends ValidStepKey<stepNumbers>>(\n targetStep: targetStep\n ): UpdateFn.stepSpecific<resolvedStep, stepNumbers, targetStep> {\n return (options) => {\n this.createStepUpdaterFnImpl({ targetStep, ...options });\n };\n }\n\n update<\n targetStep extends ValidStepKey<stepNumbers>,\n field extends UpdateFn.chosenFields<\n UpdateFn.resolvedStep<resolvedStep, stepNumbers, targetStep>\n > = 'all',\n additionalCtx extends Record<string, unknown> = {}\n >(\n options: UpdateFn.options<\n resolvedStep,\n stepNumbers,\n targetStep,\n field,\n additionalCtx\n >\n ) {\n return this.createStepUpdaterFnImpl(options);\n }\n\n private resetFields<\n targetStep extends ValidStepKey<stepNumbers>,\n currentStep extends UpdateFn.resolvedStep<\n resolvedStep,\n stepNumbers,\n targetStep\n >\n >(config: {\n targetStep: targetStep;\n values: AnyResolvedStep;\n updatedValues: AnyResolvedStep;\n logger: MultiStepFormLogger;\n }) {\n return <\n fields extends HelperFnChosenSteps.tupleNotation<DeepKeys<currentStep>>\n >(\n fields: fields\n ) => {\n const { targetStep, logger, values } = config;\n const resolvedFields = fields.map((value) => `${targetStep}.${value}`);\n const picked = path.pickBy<resolvedStep, DeepKeys<resolvedStep>>(\n values,\n ...(resolvedFields as any)\n );\n\n config.updatedValues = {\n ...config.updatedValues,\n ...path.updateAt(values, fields, picked),\n };\n\n const formatter = new Intl.ListFormat('en', {\n style: 'long',\n type: 'conjunction',\n });\n const message = `${formatter.format(fields)} for ${targetStep}`;\n\n logger.info(`Resetting ${message}`);\n this.handlePostUpdate(config.updatedValues);\n logger.info(`Reset ${message}`);\n };\n }\n\n private createStepResetterFnImpl<\n targetStep extends ValidStepKey<stepNumbers>,\n fields extends UpdateFn.chosenFields<currentStep>,\n currentStep extends UpdateFn.resolvedStep<\n resolvedStep,\n stepNumbers,\n targetStep\n >\n >(\n options: ResetFn.Options<\n resolvedStep,\n stepNumbers,\n targetStep,\n fields,\n currentStep\n >\n ) {\n const { fields = 'all', targetStep, debug } = options;\n const logger = new MultiStepFormLogger({\n debug,\n prefix: (value) => `${value}:reset${targetStep}`,\n });\n invariant(\n fields,\n '[update]: \"fields\" must have a value when \"type\" is \"reset\"'\n );\n\n const originalValues = createStep(this.#originalValue);\n const enrichedOriginalValues = this.enrichValues<\n resolvedStep,\n additionalEnrichedProps\n >(originalValues as never, this.#additionalEnrichedProps);\n\n if (fields === 'all') {\n logger.info(`Resetting all fields for ${targetStep}`);\n this.handlePostUpdate(enrichedOriginalValues);\n logger.info(`Reset all fields for ${targetStep}`);\n }\n\n let updatedValues = { ...enrichedOriginalValues };\n const reset = this.resetFields<targetStep, currentStep>({\n logger,\n targetStep,\n updatedValues,\n values: enrichedOriginalValues,\n });\n\n if (isTupleNotation<DeepKeys<currentStep>>(fields)) {\n reset(fields);\n }\n\n if (typeof fields === 'object' && Object.keys(fields).length > 0) {\n const keys = path.createDeep(fields);\n\n reset(keys as never);\n }\n }\n\n createStepResetterFn<targetStep extends ValidStepKey<stepNumbers>>(\n targetStep: targetStep\n ): ResetFn.stepSpecific<resolvedStep, stepNumbers, targetStep> {\n return (options) => {\n return this.createStepResetterFnImpl({\n targetStep,\n fields: options?.fields ?? 'all',\n debug: options?.debug ?? false,\n });\n };\n }\n\n reset<\n targetStep extends ValidStepKey<stepNumbers>,\n fields extends UpdateFn.chosenFields<currentStep>,\n currentStep extends UpdateFn.resolvedStep<\n resolvedStep,\n stepNumbers,\n targetStep\n >\n >(\n options: ResetFn.Options<\n resolvedStep,\n stepNumbers,\n targetStep,\n fields,\n currentStep\n >\n ) {\n this.createStepResetterFnImpl(options);\n }\n\n createHelperFnInputUpdate<\n chosenSteps extends HelperFnChosenSteps<resolvedStep, stepNumbers>\n >(chosenSteps: chosenSteps) {\n if (HelperFnChosenSteps.isAll(chosenSteps)) {\n const stepSpecificUpdateFn = typedObjectKeys<\n resolvedStep,\n ValidStepKey<stepNumbers>\n >(this.value).reduce((acc, key) => {\n acc[key] = this.createStepUpdaterFn(key);\n\n return acc;\n }, {} as helperFnUpdateFn<resolvedStep, stepNumbers, ValidStepKey<stepNumbers>>);\n const update = Object.assign(\n this.update,\n stepSpecificUpdateFn\n ) as HelperFnUpdateFn<resolvedStep, stepNumbers, chosenSteps>;\n\n return update;\n }\n\n const validKeys = Object.keys(this.value);\n\n if (HelperFnChosenSteps.isTuple<stepNumbers>(chosenSteps, validKeys)) {\n const stepSpecificUpdateFn = chosenSteps.reduce((acc, step) => {\n acc[step] = this.createStepUpdaterFn(step);\n\n return acc;\n }, {} as helperFnUpdateFn<resolvedStep, stepNumbers, ValidStepKey<stepNumbers>>);\n const update = Object.assign(\n this.update,\n stepSpecificUpdateFn\n ) as HelperFnUpdateFn<resolvedStep, stepNumbers, chosenSteps>;\n\n return update;\n }\n\n if (HelperFnChosenSteps.isObject<stepNumbers>(chosenSteps, validKeys)) {\n const stepSpecificUpdateFn = typedObjectKeys<\n HelperFnChosenSteps.objectNotation<`step${stepNumbers}`>,\n ValidStepKey<stepNumbers>\n >(chosenSteps).reduce((acc, key) => {\n acc[key] = this.createStepUpdaterFn(key);\n\n return acc;\n }, {} as helperFnUpdateFn<resolvedStep, stepNumbers, ValidStepKey<stepNumbers>>);\n const update = Object.assign(\n this.update,\n stepSpecificUpdateFn\n ) as HelperFnUpdateFn<resolvedStep, stepNumbers, chosenSteps>;\n\n return update;\n }\n\n throw new TypeError(`[update]: ${HelperFnChosenSteps.CATCH_ALL_MESSAGE}`);\n }\n\n createStepHelperFn<\n chosenSteps extends HelperFnChosenSteps<resolvedStep, stepNumbers>\n >(stepData: chosenSteps) {\n return <validator, additionalCtx extends Record<string, unknown>, response>(\n optionsOrFunction:\n | Omit<\n CreateHelperFunctionOptionsWithValidator<\n resolvedStep,\n stepNumbers,\n chosenSteps,\n validator,\n additionalCtx\n >,\n 'stepData'\n >\n | Omit<\n CreateHelperFunctionOptionsWithoutValidator<\n resolvedStep,\n stepNumbers,\n chosenSteps\n >,\n 'stepData'\n >\n | HelperFnWithoutValidator<\n resolvedStep,\n stepNumbers,\n chosenSteps,\n additionalCtx,\n response\n >,\n fn:\n | HelperFnWithValidator<\n resolvedStep,\n stepNumbers,\n chosenSteps,\n validator,\n additionalCtx,\n response\n >\n | HelperFnWithoutValidator<\n resolvedStep,\n stepNumbers,\n chosenSteps,\n additionalCtx,\n response\n >\n ) => {\n const createInputUpdateFn = this.createHelperFnInputUpdate(\n stepData\n ) as HelperFnUpdateFn<resolvedStep, stepNumbers, chosenSteps>;\n\n if (typeof optionsOrFunction === 'function') {\n return () => {\n // Create ctx fresh each time the function is called to ensure it has the latest this.value\n const ctx = createCtx<resolvedStep, stepNumbers, chosenSteps>(\n this.value,\n stepData\n ) as never;\n return optionsOrFunction({\n ctx,\n update: createInputUpdateFn,\n });\n };\n }\n\n if (typeof optionsOrFunction === 'object') {\n return (input?: CreatedHelperFnInput<validator>) => {\n // Create ctx fresh each time the function is called to ensure it has the latest this.value\n const ctx = createCtx<resolvedStep, stepNumbers, chosenSteps>(\n this.value,\n stepData\n ) as never;\n\n if ('validator' in optionsOrFunction) {\n invariant(\n typeof input === 'object',\n 'An input is expected since you provided a validator'\n );\n\n runStandardValidation(\n optionsOrFunction.validator as StandardSchemaValidator,\n input.data\n );\n\n let resolvedCtx = ctx as HelperFnCtx<\n resolvedStep,\n stepNumbers,\n chosenSteps\n >;\n\n if (optionsOrFunction.ctxData) {\n const currentStepKey = (\n stepData as HelperFnChosenSteps.tupleNotation<\n ValidStepKey<stepNumbers>\n >\n )[0] as keyof resolvedStep;\n const { [currentStepKey]: _, ...values } = this.value;\n\n resolvedCtx = {\n ...resolvedCtx,\n ...optionsOrFunction.ctxData({ ctx: values as never }),\n };\n }\n\n return fn({\n ctx: resolvedCtx as never,\n update: createInputUpdateFn,\n ...input,\n });\n }\n\n return (\n fn as HelperFnWithoutValidator<\n resolvedStep,\n stepNumbers,\n chosenSteps,\n additionalCtx,\n response\n >\n )({\n ctx,\n update: createInputUpdateFn,\n });\n };\n }\n\n throw new Error(\n `The first argument must be a function or an object, (was ${typeof optionsOrFunction})`\n );\n };\n }\n\n private extractStepFromKey(key: string) {\n const [targetStep] = [key] as HelperFnChosenSteps.tupleNotation<\n ValidStepKey<stepNumbers>\n >;\n const step = Number.parseInt(targetStep.replace('step', '')) as stepNumbers;\n\n return { targetStep, step };\n }\n\n enrichValues<\n values extends AnyResolvedStep,\n additionalProps extends Record<string, unknown>\n >(values: values, additionalProps?: (step: number) => additionalProps) {\n let enriched = { ...values };\n\n for (const [key, stepValue] of Object.entries(enriched)) {\n const { step, targetStep } = this.extractStepFromKey(key);\n\n enriched[targetStep] = {\n ...stepValue,\n update: this.createStepUpdaterFn(targetStep),\n reset: this.createStepResetterFn(targetStep),\n createHelperFn: this.createStepHelperFn([targetStep]),\n ...additionalProps?.(step),\n };\n }\n\n return enriched;\n }\n}\n"],"mappings":";;;;;;;;;;;AA2DA,IAAa,kCAAb,MAME;CACA,CAASA;CACT,CAASC;CACT,CAASC;CACT,CAASC;CAET,IAAY,QAAQ;AAClB,SAAO,MAAKD,UAAW;;CAGzB,YACE,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K,OACL,SACD;AAED,QAAI,eAAe,mBAAmB;AACpC,eACE,OAAO,UAAU,UACjB,sDACD;AAED,2BACE,kBAAkB,WAClB,MAAM,KACP;KAED,IAAI,cAAc;AAMlB,SAAI,kBAAkB,SAAS;MAC7B,MAAM,iBACJ,SAGA;MACF,MAAM,GAAG,iBAAiB,GAAG,GAAG,WAAW,KAAK;AAEhD,oBAAc;OACZ,GAAG;OACH,GAAG,kBAAkB,QAAQ,EAAE,KAAK,QAAiB,CAAC;OACvD;;AAGH,YAAO,GAAG;MACR,KAAK;MACL,QAAQ;MACR,GAAG;MACJ,CAAC;;AAGJ,WACE,GAOA;KACA;KACA,QAAQ;KACT,CAAC;;AAIN,SAAM,IAAI,MACR,4DAA4D,OAAO,kBAAkB,GACtF;;;CAIL,AAAQ,mBAAmB,KAAa;EACtC,MAAM,CAAC,cAAc,CAAC,IAAI;AAK1B,SAAO;GAAE;GAAY,MAFR,OAAO,SAAS,WAAW,QAAQ,QAAQ,GAAG,CAAC;GAEjC;;CAG7B,aAGE,QAAgB,iBAAqD;EACrE,IAAI,WAAW,EAAE,GAAG,QAAQ;AAE5B,OAAK,MAAM,CAAC,KAAK,cAAc,OAAO,QAAQ,SAAS,EAAE;GACvD,MAAM,EAAE,MAAM,eAAe,KAAK,mBAAmB,IAAI;AAEzD,YAAS,cAAc;IACrB,GAAG;IACH,QAAQ,KAAK,oBAAoB,WAAW;IAC5C,OAAO,KAAK,qBAAqB,WAAW;IAC5C,gBAAgB,KAAK,mBAAmB,CAAC,WAAW,CAAC;IACrD,GAAG,kBAAkB,KAAK;IAC3B;;AAGH,SAAO"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const require_invariant = require('../utils/invariant.cjs');
|
|
2
|
+
const require_casing = require('../utils/casing.cjs');
|
|
3
|
+
const require_field_types = require('../utils/field-types.cjs');
|
|
4
|
+
const require_validator = require('../utils/validator.cjs');
|
|
5
|
+
|
|
6
|
+
//#region src/internals/utils.ts
|
|
7
|
+
const VALIDATED_STEP_REGEX = /^step\d+$/i;
|
|
8
|
+
function isValidStepKey(steps, stepKey) {
|
|
9
|
+
return Object.keys(steps).includes(stepKey);
|
|
10
|
+
}
|
|
11
|
+
function createFieldLabel(label, fieldName, casingType) {
|
|
12
|
+
return label ?? require_casing.changeCasing(fieldName, casingType);
|
|
13
|
+
}
|
|
14
|
+
function createStepFields(options) {
|
|
15
|
+
const resolvedFields = {};
|
|
16
|
+
const { fields, defaultCasing, validateFields } = options;
|
|
17
|
+
for (const [name, values] of Object.entries(fields)) {
|
|
18
|
+
require_invariant.invariant(typeof name === "string", `Each key for the "fields" option must be a string. Key ${name} was a ${typeof name}`);
|
|
19
|
+
require_invariant.invariant(typeof values === "object", `The value for key ${name} must be an object. Was ${typeof values}`);
|
|
20
|
+
const { defaultValue, label, nameTransformCasing, type = require_field_types.DEFAULT_FIELD_TYPE } = values;
|
|
21
|
+
if (validateFields) resolvedFields[name] = defaultValue;
|
|
22
|
+
else {
|
|
23
|
+
const casing = nameTransformCasing ?? defaultCasing;
|
|
24
|
+
resolvedFields[name] = {
|
|
25
|
+
...resolvedFields[name],
|
|
26
|
+
nameTransformCasing: casing,
|
|
27
|
+
type,
|
|
28
|
+
defaultValue,
|
|
29
|
+
label: createFieldLabel(label, name, casing)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (validateFields) {
|
|
34
|
+
const validatedFields = require_validator.runStandardValidation(validateFields, resolvedFields);
|
|
35
|
+
require_invariant.invariant(typeof validatedFields === "object", `The result of the validated fields must be an object, was (${typeof validatedFields}). This is probably an internal error, so open up an issue about it`);
|
|
36
|
+
require_invariant.invariant(!!validatedFields, "The result of the validated fields must be defined. This is probably an internal error, so open up an issue about it");
|
|
37
|
+
for (const [name, defaultValue] of Object.entries(validatedFields)) {
|
|
38
|
+
const currentField = fields[name];
|
|
39
|
+
require_invariant.invariant(currentField, `No field found in the fields config for "${name}"`);
|
|
40
|
+
const { label, type = require_field_types.DEFAULT_FIELD_TYPE, nameTransformCasing } = currentField;
|
|
41
|
+
const casing = nameTransformCasing ?? defaultCasing;
|
|
42
|
+
resolvedFields[name] = {
|
|
43
|
+
...resolvedFields[name],
|
|
44
|
+
nameTransformCasing: casing,
|
|
45
|
+
type,
|
|
46
|
+
defaultValue,
|
|
47
|
+
label: createFieldLabel(label, name, casing)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return resolvedFields;
|
|
52
|
+
}
|
|
53
|
+
function createStep(stepsConfig) {
|
|
54
|
+
const resolvedSteps = {};
|
|
55
|
+
require_invariant.invariant(!!stepsConfig, "The steps config must be defined", TypeError);
|
|
56
|
+
require_invariant.invariant(typeof stepsConfig === "object", `The steps config must be an object, was (${typeof stepsConfig})`, TypeError);
|
|
57
|
+
for (const [stepKey, stepValue] of Object.entries(stepsConfig)) {
|
|
58
|
+
require_invariant.invariant(typeof stepKey === "string", `Each key for the step config must be a string. Key "${stepKey}" was ${typeof stepKey} `, TypeError);
|
|
59
|
+
require_invariant.invariant(VALIDATED_STEP_REGEX.test(stepKey), `The key "${stepKey}" isn't formatted properly. Each key in the step config must be the following format: "step{number}"`);
|
|
60
|
+
const validStepKey = stepKey;
|
|
61
|
+
const { fields, title, nameTransformCasing: defaultCasing = require_casing.DEFAULT_CASING, description, validateFields } = stepValue;
|
|
62
|
+
const currentStep = validStepKey.toString().replace("step", "");
|
|
63
|
+
require_invariant.invariant(fields, `Missing fields for step ${currentStep} (${String(validStepKey)})`, TypeError);
|
|
64
|
+
require_invariant.invariant(typeof fields === "object", "Fields must be an object", TypeError);
|
|
65
|
+
require_invariant.invariant(Object.keys(fields).length > 0, `The fields config for step ${currentStep} (${String(validStepKey)}) is empty. Please add a field`);
|
|
66
|
+
require_invariant.invariant(typeof fields === "object", `The "fields" property must be an object. Was ${typeof fields}`);
|
|
67
|
+
const resolvedFields = createStepFields({
|
|
68
|
+
defaultCasing,
|
|
69
|
+
fields,
|
|
70
|
+
validateFields
|
|
71
|
+
});
|
|
72
|
+
resolvedSteps[validStepKey] = {
|
|
73
|
+
...resolvedSteps[validStepKey],
|
|
74
|
+
title,
|
|
75
|
+
nameTransformCasing: defaultCasing,
|
|
76
|
+
...typeof description === "string" ? { description } : {},
|
|
77
|
+
fields: resolvedFields
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return resolvedSteps;
|
|
81
|
+
}
|
|
82
|
+
function isTupleNotation(value) {
|
|
83
|
+
if (!Array.isArray(value)) return false;
|
|
84
|
+
if (value.length === 0) return false;
|
|
85
|
+
if (!value.every((v) => typeof v === "string")) return false;
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
exports.VALIDATED_STEP_REGEX = VALIDATED_STEP_REGEX;
|
|
91
|
+
exports.createStep = createStep;
|
|
92
|
+
exports.isTupleNotation = isTupleNotation;
|
|
93
|
+
exports.isValidStepKey = isValidStepKey;
|
|
94
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["changeCasing","resolvedFields: Record<string, unknown>","DEFAULT_FIELD_TYPE","runStandardValidation","DEFAULT_CASING"],"sources":["../../src/internals/utils.ts"],"sourcesContent":["import type {\n AnyResolvedStep,\n AnyStepField,\n Step,\n InferStepOptions,\n ResolvedStep,\n HelperFnChosenSteps,\n} from '@/steps';\nimport {\n type Constrain,\n type CasingType,\n changeCasing,\n DEFAULT_FIELD_TYPE,\n invariant,\n type DefaultCasing,\n DEFAULT_CASING,\n} from '@/utils';\nimport {\n type AnyValidator,\n type DefaultValidator,\n runStandardValidation,\n type StandardSchemaValidator,\n} from '@/utils/validator';\n\nexport const VALIDATED_STEP_REGEX = /^step\\d+$/i;\nexport function isValidStepKey<T extends AnyResolvedStep>(\n steps: T,\n stepKey: string\n): stepKey is Constrain<keyof T, string> {\n return Object.keys(steps).includes(stepKey);\n}\n\nexport function createFieldLabel(\n label: string | false | undefined,\n fieldName: string,\n casingType: CasingType\n) {\n return label ?? changeCasing(fieldName, casingType);\n}\n\nexport function createStepFields(options: {\n fields: AnyStepField;\n validateFields:\n | Constrain<unknown, AnyValidator, DefaultValidator>\n | undefined;\n defaultCasing: CasingType;\n}) {\n const resolvedFields: Record<string, unknown> = {};\n const { fields, defaultCasing, validateFields } = options;\n\n for (const [name, values] of Object.entries(fields)) {\n invariant(\n typeof name === 'string',\n `Each key for the \"fields\" option must be a string. Key ${name} was a ${typeof name}`\n );\n invariant(\n typeof values === 'object',\n `The value for key ${name} must be an object. Was ${typeof values}`\n );\n\n const {\n defaultValue,\n label,\n nameTransformCasing,\n type = DEFAULT_FIELD_TYPE,\n } = values;\n\n if (validateFields) {\n resolvedFields[name] = defaultValue;\n } else {\n const casing = nameTransformCasing ?? defaultCasing;\n\n resolvedFields[name] = {\n ...(resolvedFields[name] as Record<string, unknown>),\n nameTransformCasing: casing,\n type,\n defaultValue,\n label: createFieldLabel(label, name, casing),\n\n // TODO add more fields here\n };\n }\n }\n\n if (validateFields) {\n const validatedFields = runStandardValidation(\n validateFields as StandardSchemaValidator,\n resolvedFields\n );\n\n invariant(\n typeof validatedFields === 'object',\n `The result of the validated fields must be an object, was (${typeof validatedFields}). This is probably an internal error, so open up an issue about it`\n );\n invariant(\n !!validatedFields,\n 'The result of the validated fields must be defined. This is probably an internal error, so open up an issue about it'\n );\n\n for (const [name, defaultValue] of Object.entries(validatedFields)) {\n const currentField = fields[name];\n\n invariant(\n currentField,\n `No field found in the fields config for \"${name}\"`\n );\n\n const {\n label,\n type = DEFAULT_FIELD_TYPE,\n nameTransformCasing,\n } = currentField;\n const casing = nameTransformCasing ?? defaultCasing;\n\n resolvedFields[name] = {\n ...(resolvedFields[name] as Record<string, unknown>),\n nameTransformCasing: casing,\n type,\n defaultValue,\n label: createFieldLabel(label, name, casing),\n };\n }\n }\n\n return resolvedFields;\n}\nexport function createStep<\n step extends Step<casing>,\n casing extends CasingType = DefaultCasing\n>(stepsConfig: InferStepOptions<step>) {\n const resolvedSteps = {} as ResolvedStep<step, casing>;\n\n invariant(!!stepsConfig, 'The steps config must be defined', TypeError);\n invariant(\n typeof stepsConfig === 'object',\n `The steps config must be an object, was (${typeof stepsConfig})`,\n TypeError\n );\n\n for (const [stepKey, stepValue] of Object.entries(stepsConfig)) {\n invariant(\n typeof stepKey === 'string',\n `Each key for the step config must be a string. Key \"${stepKey}\" was ${typeof stepKey} `,\n TypeError\n );\n invariant(\n VALIDATED_STEP_REGEX.test(stepKey),\n `The key \"${stepKey}\" isn't formatted properly. Each key in the step config must be the following format: \"step{number}\"`\n );\n\n const validStepKey = stepKey as keyof typeof resolvedSteps;\n const {\n fields,\n title,\n nameTransformCasing: defaultCasing = DEFAULT_CASING,\n description,\n validateFields,\n } = stepValue;\n\n const currentStep = validStepKey.toString().replace('step', '');\n\n invariant(\n fields,\n `Missing fields for step ${currentStep} (${String(validStepKey)})`,\n TypeError\n );\n invariant(\n typeof fields === 'object',\n 'Fields must be an object',\n TypeError\n );\n invariant(\n Object.keys(fields).length > 0,\n `The fields config for step ${currentStep} (${String(\n validStepKey\n )}) is empty. Please add a field`\n );\n invariant(\n typeof fields === 'object',\n `The \"fields\" property must be an object. Was ${typeof fields}`\n );\n\n const resolvedFields = createStepFields({\n defaultCasing,\n fields,\n validateFields,\n });\n\n resolvedSteps[validStepKey] = {\n ...resolvedSteps[validStepKey],\n title,\n nameTransformCasing: defaultCasing,\n // Only add the description if it's defined\n ...(typeof description === 'string' ? { description } : {}),\n fields: resolvedFields,\n };\n }\n\n return resolvedSteps;\n}\n\nexport function isTupleNotation<T extends string>(\n value: unknown\n): value is HelperFnChosenSteps.tupleNotation<T> {\n if (!Array.isArray(value)) {\n return false;\n }\n\n if (value.length === 0) {\n return false;\n }\n\n if (!value.every((v) => typeof v === 'string')) {\n return false;\n }\n\n return true;\n}\n"],"mappings":";;;;;;AAwBA,MAAa,uBAAuB;AACpC,SAAgB,eACd,OACA,SACuC;A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vB,4CAA4C,OAAO,YAAY,IAC/D,UACD;AAED,MAAK,MAAM,CAAC,SAAS,cAAc,OAAO,QAAQ,YAAY,EAAE;AAC9D,8BACE,OAAO,YAAY,UACnB,uDAAuD,QAAQ,QAAQ,OAAO,QAAQ,IACtF,UACD;AACD,8BACE,qBAAqB,KAAK,QAAQ,EAClC,YAAY,QAAQ,sGACrB;EAED,MAAM,eAAe;EACrB,MAAM,EACJ,QACA,OACA,qBAAqB,gBAAgBE,+BACrC,aACA,mBACE;EAEJ,MAAM,cAAc,aAAa,UAAU,CAAC,QAAQ,QAAQ,GAAG;AAE/D,8BACE,QACA,2BAA2B,YAAY,IAAI,OAAO,aAAa,CAAC,IAChE,UACD;AACD,8BACE,OAAO,WAAW,UAClB,4BACA,UACD;AACD,8BACE,OAAO,KAAK,OAAO,CAAC,SAAS,GAC7B,8BAA8B,YAAY,IAAI,OAC5C,aACD,CAAC,gCACH;AACD,8BACE,OAAO,WAAW,UAClB,gDAAgD,OAAO,SACxD;EAED,MAAM,iBAAiB,iBAAiB;GACtC;GACA;GACA;GACD,CAAC;AAEF,gBAAc,gBAAgB;GAC5B,GAAG,cAAc;GACjB;GACA,qBAAqB;GAErB,GAAI,OAAO,gBAAgB,WAAW,EAAE,aAAa,GAAG,EAAE;GAC1D,QAAQ;GACT;;AAGH,QAAO;;AAGT,SAAgB,gBACd,OAC+C;AAC/C,KAAI,CAAC,MAAM,QAAQ,MAAM,CACvB,QAAO;AAGT,KAAI,MAAM,WAAW,EACnB,QAAO;AAGT,KAAI,CAAC,MAAM,OAAO,MAAM,OAAO,MAAM,SAAS,CAC5C,QAAO;AAGT,QAAO"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Constrain, Expand } from "../utils/types.cjs";
|
|
2
|
+
import { CasingType, DefaultCasing } from "../utils/casing.cjs";
|
|
3
|
+
import { DefaultFieldType } from "../utils/field-types.cjs";
|
|
4
|
+
import { AnyResolvedStep, ExtractStepFromKey, GetDefaultCasingTransformation, GetFieldsForStep, InferStepOptions, ResetFn, ResolvedFields, Step, StepSpecificHelperFn, UpdateFn } from "../steps/types.cjs";
|
|
5
|
+
|
|
6
|
+
//#region src/internals/utils.d.ts
|
|
7
|
+
declare const VALIDATED_STEP_REGEX: RegExp;
|
|
8
|
+
declare function isValidStepKey<T$1 extends AnyResolvedStep>(steps: T$1, stepKey: string): stepKey is Constrain<keyof T$1, string>;
|
|
9
|
+
declare function createStep<step extends Step<casing>, casing extends CasingType = DefaultCasing>(stepsConfig: InferStepOptions<step>): Expand<InferStepOptions<step> extends infer T_1 extends InferStepOptions<TStep> ? { [stepKey_1 in keyof T_1]: Expand<(Omit<T_1[stepKey_1], "validateFields" | "fields"> extends infer T_2 ? { [K in keyof T_2]-?: K extends keyof Defaults ? undefined extends T_2[K] ? Exclude<T_2[K], T_2[K] & undefined> | Defaults[K] : T_2[K] : T_2[K] } : never) & { [K_1 in Exclude<"type", Exclude<keyof T_1[stepKey_1], "validateFields" | "fields">> | Exclude<"nameTransformCasing", Exclude<keyof T_1[stepKey_1], "validateFields" | "fields">>]-?: {
|
|
10
|
+
type: DefaultFieldType;
|
|
11
|
+
nameTransformCasing: GetDefaultCasingTransformation<T_1, stepKey_1, TDefaultCasing>;
|
|
12
|
+
}[K_1] } & {
|
|
13
|
+
fields: Expand<ResolvedFields<T_1, stepKey_1, GetFieldsForStep<T_1, stepKey_1>>>;
|
|
14
|
+
}> } : never> extends infer T extends Expand<InferStepOptions<TStep_1> extends infer T_2 extends InferStepOptions<TStep> ? { [stepKey_2 in keyof T_2]: Expand<(Omit<T_2[stepKey_2], "validateFields" | "fields"> extends infer T_3 ? { [K in keyof T_3]-?: K extends keyof Defaults ? undefined extends T_3[K] ? Exclude<T_3[K], T_3[K] & undefined> | Defaults[K] : T_3[K] : T_3[K] } : never) & { [K_1 in Exclude<"type", Exclude<keyof T_2[stepKey_2], "validateFields" | "fields">> | Exclude<"nameTransformCasing", Exclude<keyof T_2[stepKey_2], "validateFields" | "fields">>]-?: {
|
|
15
|
+
type: DefaultFieldType;
|
|
16
|
+
nameTransformCasing: GetDefaultCasingTransformation<T_2, stepKey_2, TDefaultCasing>;
|
|
17
|
+
}[K_1] } & {
|
|
18
|
+
fields: Expand<ResolvedFields<T_2, stepKey_2, GetFieldsForStep<T_2, stepKey_2>>>;
|
|
19
|
+
}> } : never> ? { [stepKey in keyof T]: T[stepKey] & {
|
|
20
|
+
createHelperFn: StepSpecificHelperFn<T, ExtractStepFromKey<keyof T extends infer T_1 ? T_1 extends keyof T ? T_1 extends string ? T_1 : never : never : never>, ExtractStepFromKey<stepKey extends string ? stepKey : never>>;
|
|
21
|
+
} & (stepKey extends `step${ExtractStepFromKey<keyof T extends infer T_2 ? T_2 extends keyof T ? T_2 extends string ? T_2 : never : never : never>}` ? {
|
|
22
|
+
update: UpdateFn.stepSpecific<T, ExtractStepFromKey<keyof T extends infer T_3 ? T_3 extends keyof T ? T_3 extends string ? T_3 : never : never : never>, stepKey>;
|
|
23
|
+
reset: ResetFn.stepSpecific<T, ExtractStepFromKey<keyof T extends infer T_4 ? T_4 extends keyof T ? T_4 extends string ? T_4 : never : never : never>, stepKey>;
|
|
24
|
+
} : {}) } : never;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { VALIDATED_STEP_REGEX, createStep, isValidStepKey };
|
|
27
|
+
//# sourceMappingURL=utils.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.cts","names":[],"sources":["../../src/internals/utils.ts"],"sourcesContent":[],"mappings":";;;;;;cAwBa,sBAAoB;iBACjB,2BAAyB,wBAChC,kCAEK,gBAAgB;AAAhB,iBAkGE,UAlGF,CAAA,aAmGC,IAnGD,CAmGM,MAnGN,CAAA,EAAA,eAoGG,UApGH,GAoGgB,aApGhB,CAAA,CAAA,WAAA,EAqGC,gBArGD,CAqGkB,IArGlB,CAAA,CAAA,EAqGuB,MArGvB,CAqGuB,gBArGvB,CAqGuB,IArGvB,CAAA,SAAA,K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GAAA,GAAA,SAAA,OAAA,GAAA,GAAA,SAAA,MAAA,GAAA,GAAA,GAAA,KAAA,GAAA,KAAA,GAAA,KAAA,CAAA,SAAA,CAAA;CAAA,GAAA,CAAA,CAAA,CAAA,EAAA,GAAA,KAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Constrain, Expand } from "../utils/types.mjs";
|
|
2
|
+
import { CasingType, DefaultCasing } from "../utils/casing.mjs";
|
|
3
|
+
import { DefaultFieldType } from "../utils/field-types.mjs";
|
|
4
|
+
import { AnyResolvedStep, ExtractStepFromKey, GetDefaultCasingTransformation, GetFieldsForStep, InferStepOptions, ResetFn, ResolvedFields, Step, StepSpecificHelperFn, UpdateFn } from "../steps/types.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/internals/utils.d.ts
|
|
7
|
+
declare const VALIDATED_STEP_REGEX: RegExp;
|
|
8
|
+
declare function isValidStepKey<T$1 extends AnyResolvedStep>(steps: T$1, stepKey: string): stepKey is Constrain<keyof T$1, string>;
|
|
9
|
+
declare function createStep<step extends Step<casing>, casing extends CasingType = DefaultCasing>(stepsConfig: InferStepOptions<step>): Expand<InferStepOptions<step> extends infer T_1 extends InferStepOptions<TStep> ? { [stepKey_1 in keyof T_1]: Expand<(Omit<T_1[stepKey_1], "validateFields" | "fields"> extends infer T_2 ? { [K in keyof T_2]-?: K extends keyof Defaults ? undefined extends T_2[K] ? Exclude<T_2[K], T_2[K] & undefined> | Defaults[K] : T_2[K] : T_2[K] } : never) & { [K_1 in Exclude<"type", Exclude<keyof T_1[stepKey_1], "validateFields" | "fields">> | Exclude<"nameTransformCasing", Exclude<keyof T_1[stepKey_1], "validateFields" | "fields">>]-?: {
|
|
10
|
+
type: DefaultFieldType;
|
|
11
|
+
nameTransformCasing: GetDefaultCasingTransformation<T_1, stepKey_1, TDefaultCasing>;
|
|
12
|
+
}[K_1] } & {
|
|
13
|
+
fields: Expand<ResolvedFields<T_1, stepKey_1, GetFieldsForStep<T_1, stepKey_1>>>;
|
|
14
|
+
}> } : never> extends infer T extends Expand<InferStepOptions<TStep_1> extends infer T_2 extends InferStepOptions<TStep> ? { [stepKey_2 in keyof T_2]: Expand<(Omit<T_2[stepKey_2], "validateFields" | "fields"> extends infer T_3 ? { [K in keyof T_3]-?: K extends keyof Defaults ? undefined extends T_3[K] ? Exclude<T_3[K], T_3[K] & undefined> | Defaults[K] : T_3[K] : T_3[K] } : never) & { [K_1 in Exclude<"type", Exclude<keyof T_2[stepKey_2], "validateFields" | "fields">> | Exclude<"nameTransformCasing", Exclude<keyof T_2[stepKey_2], "validateFields" | "fields">>]-?: {
|
|
15
|
+
type: DefaultFieldType;
|
|
16
|
+
nameTransformCasing: GetDefaultCasingTransformation<T_2, stepKey_2, TDefaultCasing>;
|
|
17
|
+
}[K_1] } & {
|
|
18
|
+
fields: Expand<ResolvedFields<T_2, stepKey_2, GetFieldsForStep<T_2, stepKey_2>>>;
|
|
19
|
+
}> } : never> ? { [stepKey in keyof T]: T[stepKey] & {
|
|
20
|
+
createHelperFn: StepSpecificHelperFn<T, ExtractStepFromKey<keyof T extends infer T_1 ? T_1 extends keyof T ? T_1 extends string ? T_1 : never : never : never>, ExtractStepFromKey<stepKey extends string ? stepKey : never>>;
|
|
21
|
+
} & (stepKey extends `step${ExtractStepFromKey<keyof T extends infer T_2 ? T_2 extends keyof T ? T_2 extends string ? T_2 : never : never : never>}` ? {
|
|
22
|
+
update: UpdateFn.stepSpecific<T, ExtractStepFromKey<keyof T extends infer T_3 ? T_3 extends keyof T ? T_3 extends string ? T_3 : never : never : never>, stepKey>;
|
|
23
|
+
reset: ResetFn.stepSpecific<T, ExtractStepFromKey<keyof T extends infer T_4 ? T_4 extends keyof T ? T_4 extends string ? T_4 : never : never : never>, stepKey>;
|
|
24
|
+
} : {}) } : never;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { VALIDATED_STEP_REGEX, createStep, isValidStepKey };
|
|
27
|
+
//# sourceMappingURL=utils.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.mts","names":[],"sources":["../../src/internals/utils.ts"],"sourcesContent":[],"mappings":";;;;;;cAwBa,sBAAoB;iBACjB,2BAAyB,wBAChC,kCAEK,gBAAgB;AAAhB,iBAkGE,UAlGF,CAAA,aAmGC,IAnGD,CAmGM,MAnGN,CAAA,EAAA,eAoGG,UApGH,GAoGgB,aApGhB,CAAA,CAAA,WAAA,EAqGC,gBArGD,CAqGkB,IArGlB,CAAA,CAAA,EAqGuB,MArGvB,CAqGuB,gBArGvB,CAqGuB,IArGvB,CAAA,SAAA,KAAA,aAqGuB,gBArGvB,CAqGuB,KArGvB,CAAA,GAAA,gBAAA,MAqGuB,GArGvB,SAAA,CAAA,CAqGuB,IArGvB,CAqGuB,GArGvB,CAqGuB,SArGvB,CAAA,EAAA,gBAAA,GAAA,QAAA,CAAA,SAAA,KAAA,IAAA,GAAA,QAAA,MAqGuB,GArGvB,KAqGuB,CArGvB,SAAA,MAqGuB,QArGvB,GAAA,SAAA,SAqGuB,GArGvB,CAqGuB,CArGvB,CAAA,GAqGuB,OArGvB,CAqGuB,GArGvB,CAqGuB,CArGvB,CAAA,EAqGuB,GArGvB,CAqGuB,CArGvB,CAAA,GAAA,SAAA,CAAA,GAqGuB,QArGvB,CAqGuB,CArGvB,CAAA,GAqGuB,GArGvB,CAqGuB,CArGvB,CAAA,GAqGuB,GArGvB,CAqGuB,CArGvB,CAAA,EAAA,GAAA,KAAA,CAAA,GAAA,UAqGuB,OArGvB,CAAA,MAAA,EAqGuB,OArGvB,CAAA,MAqGuB,GArGvB,CAqGuB,SArGvB,CAAA,EAAA,gBAAA,GAAA,QAAA,CAAA,CAAA,GAqGuB,OArGvB,CAAA,qBAAA,EAqGuB,OArGvB,CAAA,MAqGuB,GArGvB,CAqGuB,SArGvB,CAAA,EAAA,gBAAA,GAAA,QAAA,CAAA,CAAA,KAAA;EAAS,IAAA,EAqGc,gBArGd;EAkGP,mBAAU,gCAAA,I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