@jfdevelops/multi-step-form-core 1.0.0-alpha.22 → 1.0.0-alpha.24
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 +0 -4
- package/dist/_internals.d.cts +2 -3
- package/dist/_internals.d.mts +2 -3
- package/dist/_internals.mjs +1 -2
- package/dist/index.cjs +17 -17
- package/dist/index.d.cts +12 -11
- package/dist/index.d.mts +12 -11
- package/dist/index.mjs +8 -10
- package/dist/internals/step-schema.cjs +120 -71
- package/dist/internals/step-schema.cjs.map +1 -1
- package/dist/internals/step-schema.d.cts +47 -29
- package/dist/internals/step-schema.d.cts.map +1 -1
- package/dist/internals/step-schema.d.mts +47 -29
- package/dist/internals/step-schema.d.mts.map +1 -1
- package/dist/internals/step-schema.mjs +120 -71
- package/dist/internals/step-schema.mjs.map +1 -1
- package/dist/schema.cjs +14 -10
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.cts +11 -13
- package/dist/schema.d.cts.map +1 -1
- package/dist/schema.d.mts +11 -13
- package/dist/schema.d.mts.map +1 -1
- package/dist/schema.mjs +14 -10
- package/dist/schema.mjs.map +1 -1
- package/dist/steps/fields.cjs +80 -0
- package/dist/steps/fields.cjs.map +1 -1
- package/dist/steps/fields.d.cts +117 -9
- package/dist/steps/fields.d.cts.map +1 -1
- package/dist/steps/fields.d.mts +117 -9
- package/dist/steps/fields.d.mts.map +1 -1
- package/dist/steps/fields.mjs +80 -0
- package/dist/steps/fields.mjs.map +1 -1
- package/dist/steps/fn-utils/helper-fn/index.cjs +81 -0
- package/dist/steps/fn-utils/helper-fn/index.cjs.map +1 -0
- package/dist/steps/fn-utils/helper-fn/index.d.cts +146 -0
- package/dist/steps/fn-utils/helper-fn/index.d.cts.map +1 -0
- package/dist/steps/fn-utils/helper-fn/index.d.mts +146 -0
- package/dist/steps/fn-utils/helper-fn/index.d.mts.map +1 -0
- package/dist/steps/fn-utils/helper-fn/index.mjs +75 -0
- package/dist/steps/fn-utils/helper-fn/index.mjs.map +1 -0
- package/dist/steps/fn-utils/helper-fn/utils.d.cts +81 -0
- package/dist/steps/fn-utils/helper-fn/utils.d.cts.map +1 -0
- package/dist/steps/fn-utils/helper-fn/utils.d.mts +81 -0
- package/dist/steps/fn-utils/helper-fn/utils.d.mts.map +1 -0
- package/dist/steps/fn-utils/index.cjs +1 -0
- package/dist/steps/fn-utils/index.mjs +3 -0
- package/dist/steps/fn-utils/reset-fn.d.cts +30 -0
- package/dist/steps/fn-utils/reset-fn.d.cts.map +1 -0
- package/dist/steps/fn-utils/reset-fn.d.mts +30 -0
- package/dist/steps/fn-utils/reset-fn.d.mts.map +1 -0
- package/dist/steps/fn-utils/update-fn.d.cts +121 -0
- package/dist/steps/fn-utils/update-fn.d.cts.map +1 -0
- package/dist/steps/fn-utils/update-fn.d.mts +121 -0
- package/dist/steps/fn-utils/update-fn.d.mts.map +1 -0
- package/dist/steps/index.cjs +4 -2
- package/dist/steps/index.mjs +5 -3
- package/dist/steps/schema.cjs +61 -84
- package/dist/steps/schema.cjs.map +1 -1
- package/dist/steps/schema.d.cts +66 -67
- package/dist/steps/schema.d.cts.map +1 -1
- package/dist/steps/schema.d.mts +66 -67
- package/dist/steps/schema.d.mts.map +1 -1
- package/dist/steps/schema.mjs +62 -86
- package/dist/steps/schema.mjs.map +1 -1
- package/dist/steps/steps.cjs +83 -0
- package/dist/steps/steps.cjs.map +1 -0
- package/dist/steps/steps.d.cts +81 -0
- package/dist/steps/steps.d.cts.map +1 -0
- package/dist/steps/steps.d.mts +81 -0
- package/dist/steps/steps.d.mts.map +1 -0
- package/dist/steps/steps.mjs +76 -0
- package/dist/steps/steps.mjs.map +1 -0
- package/dist/steps/utils.cjs +40 -30
- package/dist/steps/utils.cjs.map +1 -1
- package/dist/steps/utils.d.cts +8 -5
- package/dist/steps/utils.d.cts.map +1 -1
- package/dist/steps/utils.d.mts +8 -5
- package/dist/steps/utils.d.mts.map +1 -1
- package/dist/steps/utils.mjs +40 -31
- package/dist/steps/utils.mjs.map +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.cjs.map +1 -1
- package/dist/storage.d.cts +9 -7
- package/dist/storage.d.cts.map +1 -1
- package/dist/storage.d.mts +9 -7
- package/dist/storage.d.mts.map +1 -1
- package/dist/storage.mjs +1 -1
- package/dist/storage.mjs.map +1 -1
- package/dist/utils/casing.cjs +1 -1
- package/dist/utils/casing.cjs.map +1 -1
- package/dist/utils/casing.d.cts +27 -11
- package/dist/utils/casing.d.cts.map +1 -1
- package/dist/utils/casing.d.mts +27 -11
- package/dist/utils/casing.d.mts.map +1 -1
- package/dist/utils/casing.mjs +1 -1
- package/dist/utils/casing.mjs.map +1 -1
- package/dist/utils/helpers.cjs +8 -0
- package/dist/utils/helpers.cjs.map +1 -1
- package/dist/utils/helpers.mjs +7 -1
- package/dist/utils/helpers.mjs.map +1 -1
- package/dist/utils/index.cjs +3 -0
- package/dist/utils/index.mjs +5 -0
- package/dist/utils/invariant.cjs +28 -8
- package/dist/utils/invariant.cjs.map +1 -1
- package/dist/utils/invariant.d.cts +12 -2
- package/dist/utils/invariant.d.cts.map +1 -1
- package/dist/utils/invariant.d.mts +12 -2
- package/dist/utils/invariant.d.mts.map +1 -1
- package/dist/utils/invariant.mjs +28 -9
- package/dist/utils/invariant.mjs.map +1 -1
- package/dist/utils/types.d.cts +15 -3
- package/dist/utils/types.d.cts.map +1 -1
- package/dist/utils/types.d.mts +15 -3
- package/dist/utils/types.d.mts.map +1 -1
- package/dist/utils/validator.d.cts.map +1 -1
- package/dist/utils/validator.d.mts.map +1 -1
- package/package.json +1 -1
- package/dist/internals/utils.cjs +0 -94
- package/dist/internals/utils.cjs.map +0 -1
- package/dist/internals/utils.d.cts +0 -33
- package/dist/internals/utils.d.cts.map +0 -1
- package/dist/internals/utils.d.mts +0 -33
- package/dist/internals/utils.d.mts.map +0 -1
- package/dist/internals/utils.mjs +0 -91
- package/dist/internals/utils.mjs.map +0 -1
- package/dist/observable.cjs +0 -44
- package/dist/observable.cjs.map +0 -1
- package/dist/observable.d.cts +0 -26
- package/dist/observable.d.cts.map +0 -1
- package/dist/observable.d.mts +0 -26
- package/dist/observable.d.mts.map +0 -1
- package/dist/observable.mjs +0 -44
- package/dist/observable.mjs.map +0 -1
- package/dist/steps/types.cjs +0 -33
- package/dist/steps/types.cjs.map +0 -1
- package/dist/steps/types.d.cts +0 -354
- package/dist/steps/types.d.cts.map +0 -1
- package/dist/steps/types.d.mts +0 -354
- package/dist/steps/types.d.mts.map +0 -1
- package/dist/steps/types.mjs +0 -27
- package/dist/steps/types.mjs.map +0 -1
- package/dist/utils/field-types.cjs +0 -23
- package/dist/utils/field-types.cjs.map +0 -1
- package/dist/utils/field-types.d.cts +0 -39
- package/dist/utils/field-types.d.cts.map +0 -1
- package/dist/utils/field-types.d.mts +0 -39
- package/dist/utils/field-types.d.mts.map +0 -1
- package/dist/utils/field-types.mjs +0 -20
- package/dist/utils/field-types.mjs.map +0 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { invariant } from "../utils/invariant.mjs";
|
|
3
|
-
import { createCtx, functionalUpdate } from "../steps/utils.mjs";
|
|
1
|
+
import { HelperFnChosenSteps } from "../steps/fn-utils/helper-fn/index.mjs";
|
|
4
2
|
import { MultiStepFormLogger } from "../utils/logger.mjs";
|
|
3
|
+
import { createInvariant, invariant } from "../utils/invariant.mjs";
|
|
4
|
+
import "../utils/index.mjs";
|
|
5
5
|
import { path } from "../utils/path.mjs";
|
|
6
6
|
import { runStandardValidation } from "../utils/validator.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { steps } from "../steps/steps.mjs";
|
|
8
|
+
import { comparePartialArray, printErrors, typedObjectKeys } from "../utils/helpers.mjs";
|
|
9
|
+
import { createCtx, functionalUpdate, omit } from "../steps/utils.mjs";
|
|
9
10
|
import "../steps/index.mjs";
|
|
10
11
|
|
|
11
12
|
//#region src/internals/step-schema.ts
|
|
@@ -62,7 +63,7 @@ var MultiStepFormStepSchemaInternal = class {
|
|
|
62
63
|
prefix: (value) => `${value}:update${targetStep}`
|
|
63
64
|
});
|
|
64
65
|
logger.info(`${targetStep} will be updated`);
|
|
65
|
-
invariant(
|
|
66
|
+
invariant(targetStep in this.value, `[update]: The target step ${targetStep} isn't a valid step. Please select a valid step`);
|
|
66
67
|
const { [targetStep]: currentStep, ...values } = this.value;
|
|
67
68
|
invariant("updater" in options, "[update]: No \"updater\" was found. Please provide a value to the \"updater\" property");
|
|
68
69
|
const updater = options.updater;
|
|
@@ -241,8 +242,7 @@ var MultiStepFormStepSchemaInternal = class {
|
|
|
241
242
|
debug,
|
|
242
243
|
prefix: (value) => `${value}:reset${targetStep}`
|
|
243
244
|
});
|
|
244
|
-
|
|
245
|
-
const originalValues = createStep(this.#originalValue);
|
|
245
|
+
const originalValues = steps.instantiate({ steps: this.#originalValue });
|
|
246
246
|
const enrichedOriginalValues = this.enrichValues(originalValues, this.#additionalEnrichedProps);
|
|
247
247
|
if (fields === "all") {
|
|
248
248
|
logger.info(`Resetting all fields for ${targetStep}`);
|
|
@@ -256,7 +256,7 @@ var MultiStepFormStepSchemaInternal = class {
|
|
|
256
256
|
updatedValues,
|
|
257
257
|
values: enrichedOriginalValues
|
|
258
258
|
});
|
|
259
|
-
if (
|
|
259
|
+
if (HelperFnChosenSteps.isTuple(fields)) reset(fields);
|
|
260
260
|
if (typeof fields === "object" && Object.keys(fields).length > 0) reset(path.createDeep(fields));
|
|
261
261
|
}
|
|
262
262
|
createStepResetterFn(targetStep) {
|
|
@@ -272,54 +272,64 @@ var MultiStepFormStepSchemaInternal = class {
|
|
|
272
272
|
this.createStepResetterFnImpl(options);
|
|
273
273
|
}
|
|
274
274
|
createHelperFnInputUpdate(chosenSteps) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
275
|
+
return HelperFnChosenSteps.match({
|
|
276
|
+
meta: { value: this.value },
|
|
277
|
+
validValues: ({ meta }) => Object.keys(meta.value),
|
|
278
|
+
all: ({ meta }) => {
|
|
279
|
+
const stepSpecificUpdateFn = typedObjectKeys(meta.value).reduce((acc, key) => {
|
|
280
|
+
acc[key] = this.createStepUpdaterFn(key);
|
|
281
|
+
return acc;
|
|
282
|
+
}, {});
|
|
283
|
+
return Object.assign(this.update, stepSpecificUpdateFn);
|
|
284
|
+
},
|
|
285
|
+
object: ({ chosenSteps: chosenSteps$1 }) => {
|
|
286
|
+
const stepSpecificUpdateFn = Object.keys(chosenSteps$1).reduce((acc, key) => {
|
|
287
|
+
acc[key] = this.createStepUpdaterFn(key);
|
|
288
|
+
return acc;
|
|
289
|
+
}, {});
|
|
290
|
+
return Object.assign(this.update, stepSpecificUpdateFn);
|
|
291
|
+
},
|
|
292
|
+
tuple: () => {
|
|
293
|
+
const stepSpecificUpdateFn = chosenSteps.reduce((acc, step) => {
|
|
294
|
+
acc[step] = this.createStepUpdaterFn(step);
|
|
295
|
+
return acc;
|
|
296
|
+
}, {});
|
|
297
|
+
return Object.assign(this.update, stepSpecificUpdateFn);
|
|
298
|
+
},
|
|
299
|
+
default: ({ errorMessage }) => {
|
|
300
|
+
throw new TypeError(`[update]: ${errorMessage}`);
|
|
301
|
+
}
|
|
302
|
+
})(chosenSteps);
|
|
298
303
|
}
|
|
299
304
|
createHelperFnInputReset(chosenSteps) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
305
|
+
return HelperFnChosenSteps.match({
|
|
306
|
+
meta: { value: this.value },
|
|
307
|
+
validValues: ({ meta }) => Object.keys(meta.value),
|
|
308
|
+
all: () => {
|
|
309
|
+
const stepSpecificUpdateFn = typedObjectKeys(this.value).reduce((acc, key) => {
|
|
310
|
+
acc[key] = this.createStepResetterFn(key);
|
|
311
|
+
return acc;
|
|
312
|
+
}, {});
|
|
313
|
+
return Object.assign(this.reset, stepSpecificUpdateFn);
|
|
314
|
+
},
|
|
315
|
+
tuple: () => {
|
|
316
|
+
const stepSpecificUpdateFn = chosenSteps.reduce((acc, step) => {
|
|
317
|
+
acc[step] = this.createStepResetterFn(step);
|
|
318
|
+
return acc;
|
|
319
|
+
}, {});
|
|
320
|
+
return Object.assign(this.reset, stepSpecificUpdateFn);
|
|
321
|
+
},
|
|
322
|
+
object: ({ chosenSteps: chosenSteps$1 }) => {
|
|
323
|
+
const stepSpecificUpdateFn = Object.keys(chosenSteps$1).reduce((acc, key) => {
|
|
324
|
+
acc[key] = this.createStepResetterFn(key);
|
|
325
|
+
return acc;
|
|
326
|
+
}, {});
|
|
327
|
+
return Object.assign(this.reset, stepSpecificUpdateFn);
|
|
328
|
+
},
|
|
329
|
+
default: ({ errorMessage }) => {
|
|
330
|
+
throw new TypeError(`[reset]: ${errorMessage}`);
|
|
331
|
+
}
|
|
332
|
+
})(chosenSteps);
|
|
323
333
|
}
|
|
324
334
|
createStepHelperFn(stepData) {
|
|
325
335
|
return (optionsOrFunction, fn) => {
|
|
@@ -334,21 +344,62 @@ var MultiStepFormStepSchemaInternal = class {
|
|
|
334
344
|
});
|
|
335
345
|
};
|
|
336
346
|
if (typeof optionsOrFunction === "object") return (input) => {
|
|
337
|
-
|
|
347
|
+
let ctx = createCtx(this.value, stepData);
|
|
338
348
|
if ("validator" in optionsOrFunction) {
|
|
339
349
|
invariant(typeof input === "object", "An input is expected since you provided a validator");
|
|
340
350
|
runStandardValidation(optionsOrFunction.validator, input.data);
|
|
341
|
-
let resolvedCtx = ctx;
|
|
342
351
|
if (optionsOrFunction.ctxData) {
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
352
|
+
const ctxData = optionsOrFunction.ctxData;
|
|
353
|
+
invariant(typeof ctxData === "function", "Option \"ctxData\" must be a function");
|
|
354
|
+
const logger = new MultiStepFormLogger({
|
|
355
|
+
debug: false,
|
|
356
|
+
prefix: (value) => `${value}:ctxData`
|
|
357
|
+
});
|
|
358
|
+
const additionalCtx = HelperFnChosenSteps.match({
|
|
359
|
+
meta: {
|
|
360
|
+
value: this.value,
|
|
361
|
+
stepData,
|
|
362
|
+
ctxData,
|
|
363
|
+
logger
|
|
364
|
+
},
|
|
365
|
+
validValues: ({ meta }) => Object.keys(meta.value),
|
|
366
|
+
all: ({ meta }) => {
|
|
367
|
+
const { value, ctxData: ctxData$1, logger: logger$1 } = meta;
|
|
368
|
+
return this.buildCtxData({
|
|
369
|
+
ctxData: ctxData$1,
|
|
370
|
+
values: value,
|
|
371
|
+
logger: logger$1
|
|
372
|
+
});
|
|
373
|
+
},
|
|
374
|
+
tuple: ({ meta }) => {
|
|
375
|
+
const { value, stepData: stepData$1, ctxData: ctxData$1, logger: logger$1 } = meta;
|
|
376
|
+
const values = omit(value, HelperFnChosenSteps.createTupleNotation(...stepData$1));
|
|
377
|
+
return this.buildCtxData({
|
|
378
|
+
ctxData: ctxData$1,
|
|
379
|
+
values,
|
|
380
|
+
logger: logger$1
|
|
381
|
+
});
|
|
382
|
+
},
|
|
383
|
+
object: ({ meta }) => {
|
|
384
|
+
const { value, stepData: stepData$1, ctxData: ctxData$1, logger: logger$1 } = meta;
|
|
385
|
+
const values = omit(value, Object.keys(stepData$1));
|
|
386
|
+
return this.buildCtxData({
|
|
387
|
+
ctxData: ctxData$1,
|
|
388
|
+
values,
|
|
389
|
+
logger: logger$1
|
|
390
|
+
});
|
|
391
|
+
},
|
|
392
|
+
default: ({ errorMessage }) => {
|
|
393
|
+
throw new TypeError(`[ctxData]: ${errorMessage}`);
|
|
394
|
+
}
|
|
395
|
+
})(stepData);
|
|
396
|
+
ctx = {
|
|
397
|
+
...ctx,
|
|
398
|
+
...additionalCtx
|
|
348
399
|
};
|
|
349
400
|
}
|
|
350
401
|
return fn({
|
|
351
|
-
ctx
|
|
402
|
+
ctx,
|
|
352
403
|
...functions,
|
|
353
404
|
...input
|
|
354
405
|
});
|
|
@@ -361,17 +412,15 @@ var MultiStepFormStepSchemaInternal = class {
|
|
|
361
412
|
throw new Error(`The first argument must be a function or an object, (was ${typeof optionsOrFunction})`);
|
|
362
413
|
};
|
|
363
414
|
}
|
|
364
|
-
extractStepFromKey(key) {
|
|
365
|
-
const [targetStep] = [key];
|
|
366
|
-
return {
|
|
367
|
-
targetStep,
|
|
368
|
-
step: Number.parseInt(targetStep.replace("step", ""))
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
415
|
enrichValues(values, additionalProps) {
|
|
416
|
+
const invariant$1 = createInvariant("[enrichValues]");
|
|
417
|
+
invariant$1(typeof values === "object" && values !== null, "The values must be an object");
|
|
418
|
+
if (additionalProps) invariant$1(typeof additionalProps === "function", "The additional props must be a function");
|
|
372
419
|
let enriched = { ...values };
|
|
373
420
|
for (const [key, stepValue] of Object.entries(enriched)) {
|
|
374
|
-
const
|
|
421
|
+
const targetStep = key;
|
|
422
|
+
const step = Number.parseInt(targetStep.replace("step", ""));
|
|
423
|
+
invariant$1(typeof stepValue === "object" && stepValue !== null, `The value for ${key} must be an object`);
|
|
375
424
|
enriched[targetStep] = {
|
|
376
425
|
...stepValue,
|
|
377
426
|
update: this.createStepUpdaterFn(targetStep),
|
|
@@ -1 +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 CtxDataSelector,\n type HelperFnCtx,\n type helperFnResetFn,\n type HelperFnResetFn,\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\nfunction verifyUpdate<def, paths extends DeepKeys<def>>(options: {\n strict: boolean;\n partial: boolean;\n silenceErrors: boolean;\n obj: def;\n paths: paths[];\n actual: path.pickBy<def, paths>;\n}) {\n const { strict, partial, actual, obj, paths, silenceErrors } = options;\n\n // Define the logic for when the update is considered valid\n const { mismatches, ok } = path.equalsAtPaths(obj, paths, actual);\n\n let isValid = true;\n\n if (strict) {\n isValid = ok && mismatches.length === 0;\n }\n\n if (partial) {\n const mismatchesWithoutMissingKey = mismatches.filter(\n ({ reason }) => reason !== 'missing-key'\n );\n\n if (strict) {\n isValid = mismatchesWithoutMissingKey.length === 0;\n } else {\n const withoutExtraKey = mismatchesWithoutMissingKey.filter(\n ({ reason }) => reason !== 'extra-key'\n );\n\n isValid = withoutExtraKey.length === 0;\n }\n }\n\n if (!silenceErrors) {\n invariant(\n isValid,\n `[update]: found value mismatches in ${path.printMismatches({\n ok,\n mismatches,\n })}`\n );\n }\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 buildCtxData<\n targetStep extends ValidStepKey<stepNumbers>,\n additionalCtx extends Record<string, unknown>\n >(\n options: Required<\n CtxDataSelector<resolvedStep, stepNumbers, [targetStep], additionalCtx>\n > & {\n values: Omit<resolvedStep, targetStep>;\n logger: MultiStepFormLogger;\n }\n ) {\n const { logger, values, ctxData } = options;\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 return additionalCtx;\n }\n\n private createStepUpdaterFnImpl<\n targetStep extends ValidStepKey<stepNumbers>,\n fields extends UpdateFn.chosenFields<\n UpdateFn.resolvedStep<resolvedStep, stepNumbers, targetStep>\n >,\n strict extends boolean,\n partial extends boolean,\n additionalCtx extends Record<string, unknown>,\n additionalUpdaterData extends UpdateFn.additionalUpdaterData\n >(\n options: UpdateFn.options<\n resolvedStep,\n stepNumbers,\n targetStep,\n fields,\n strict,\n partial,\n additionalCtx,\n additionalUpdaterData\n >\n ) {\n const {\n targetStep,\n ctxData,\n fields = 'all',\n debug,\n partial = false,\n strict = true,\n silentErrors,\n } = options;\n const silenceErrors = silentErrors ?? (partial || !strict);\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 const additionalCtx = this.buildCtxData({\n values,\n ctxData,\n logger,\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 reset: this.createHelperFnInputReset([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 verifyUpdate({\n strict,\n partial,\n silenceErrors,\n obj,\n paths,\n actual: actual as never,\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 obj: currentUpdatedValue,\n paths,\n value: actual as never,\n partial,\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 verifyUpdate({\n strict,\n partial,\n silenceErrors,\n obj: currentStep,\n paths: fields,\n actual: updated as never,\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({\n obj: currentStep,\n paths: fields,\n value: updated as never,\n partial,\n }),\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 verifyUpdate({\n strict,\n partial,\n silenceErrors,\n obj: currentStep,\n paths: keys as never,\n actual: updated as never,\n });\n\n updatedValue = {\n ...updatedValue,\n [targetStep]: path.updateAt({\n obj: currentStep,\n paths: keys as never,\n value: updated as never,\n partial,\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 strict extends boolean = true,\n partial extends boolean = false,\n additionalCtx extends Record<string, unknown> = {},\n additionalUpdaterData extends UpdateFn.additionalUpdaterData = never\n >(\n options: UpdateFn.options<\n resolvedStep,\n stepNumbers,\n targetStep,\n field,\n strict,\n partial,\n additionalCtx,\n additionalUpdaterData\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({\n obj: values,\n paths: resolvedFields,\n value: picked,\n }),\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(this.value).reduce((acc, key) => {\n (acc as any)[key] = this.createStepUpdaterFn(key as never);\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 as any)[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 as any)[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 createHelperFnInputReset<\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 as any)[key] = this.createStepResetterFn(key);\n\n return acc;\n }, {} as helperFnResetFn<resolvedStep, stepNumbers, ValidStepKey<stepNumbers>>);\n const reset = Object.assign(\n this.reset,\n stepSpecificUpdateFn\n ) as HelperFnResetFn<resolvedStep, stepNumbers, chosenSteps>;\n\n return reset;\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 as any)[step] = this.createStepResetterFn(step);\n\n return acc;\n }, {} as helperFnResetFn<resolvedStep, stepNumbers, ValidStepKey<stepNumbers>>);\n const reset = Object.assign(\n this.reset,\n stepSpecificUpdateFn\n ) as HelperFnResetFn<resolvedStep, stepNumbers, chosenSteps>;\n\n return reset;\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 as any)[key] = this.createStepResetterFn(key);\n\n return acc;\n }, {} as helperFnResetFn<resolvedStep, stepNumbers, ValidStepKey<stepNumbers>>);\n const reset = Object.assign(\n this.reset,\n stepSpecificUpdateFn\n ) as HelperFnResetFn<resolvedStep, stepNumbers, chosenSteps>;\n\n return reset;\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 functions = {\n update: this.createHelperFnInputUpdate(stepData),\n reset: this.createHelperFnInputReset(stepData),\n };\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 ...functions,\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 ...functions,\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 ...functions,\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":";;;;;;;;;;;AA8DA,SAAS,aAA+C,SAOrD;CACD,MAAM,EAAE,QAAQ,SAAS,QAAQ,KAAK,OAAO,kBAAkB;CAG/D,MAAM,EAAE,YAAY,OAAO,KAAK,cAAc,KAAK,OAAO,OAAO;CAEjE,IAAI,UAAU;AAEd,KAAI,OACF,WAAU,MAAM,WAAW,WAAW;AAGxC,KAAI,SAAS;EACX,MAAM,8BAA8B,WAAW,QAC5C,EAAE,aAAa,WAAW,cAC5B;AAED,MAAI,OACF,WAAU,4BAA4B,WAAW;MAMjD,WAJwB,4BAA4B,QACjD,EAAE,aAAa,WAAW,YAC5B,CAEyB,WAAW;;AAIzC,KAAI,CAAC,cACH,WACE,SACA,uCAAuC,KAAK,gBAAgB;EAC1D;EACA;EACD,CAAC,GACH;;AAIL,IAAa,kCAAb,MAME;CACA,CAASA;CACT,CAASC;CACT,CAASC;CACT,CAASC;CAET,IAAY,QAAQ;AAClB,SAAO,MAAKD,UAAW;;CAGzB,YACE,SAMA;EACA,MAAM,EAAE,UAAU,UAAU,eAAe,4BACzC;AAEF,QAAKF,gBAAiB;AACtB,QAAKE,WAAY;AACjB,QAAKC,WAAY;AACjB,QAAKF,0BAA2B;;CAGlC,AAAQ,iBAAiB,OAAqB;AAC5C,QAAKE,SAAU,KAAK,aAAa,MAAM,CAAC;;CAG1C,AAAQ,aAIN,SAMA;EACA,MAAM,EAAE,QAAQ,QAAQ,YAAY;AACpC,YACE,OAAO,YAAY,YACnB,2CACD;AACD,SAAO,KAAK,8BAA4B;EAExC,MAAM,gBAAgB,QAAQ,EAAE,KAAK,QAAiB,CAAC;AAEvD,YACE,OAAO,kBAAkB,YACvB,OAAO,KAAK,cAAc,CAAC,SAAS,GACtC,wDACD;AAED,SAAO,KACL,gDAAgD,IAAI,KAAK,WACvD,MACA;GAC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,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"}
|
|
1
|
+
{"version":3,"file":"step-schema.mjs","names":["#originalValue","#additionalEnrichedProps","#getValue","#setValue","currentStep","actual: Record<string, unknown>","chosenSteps","stepData","invariant: Invariant"],"sources":["../../src/internals/step-schema.ts"],"sourcesContent":["import { createCtx, type fields } from '@/steps';\nimport { HelperFn, HelperFnChosenSteps } from '@/steps/fn-utils/helper-fn';\nimport type {\n HelperFnInput,\n HelperFnOptions,\n HelperFnOutput,\n} from '@/steps/fn-utils/helper-fn/utils';\nimport type { ResetFn } from '@/steps/fn-utils/reset-fn';\nimport type { UpdateFn } from '@/steps/fn-utils/update-fn';\nimport { steps } from '@/steps/steps';\nimport { functionalUpdate, omit } from '@/steps/utils';\nimport type { BaseStorageConfig, DefaultStorageKey } from '@/storage';\nimport {\n invariant,\n MultiStepFormLogger,\n type CasingType,\n type DeepKeys,\n type DefaultCasing,\n} from '@/utils';\nimport {\n comparePartialArray,\n printErrors,\n typedObjectKeys,\n} from '@/utils/helpers';\nimport { createInvariant, type Invariant } from '@/utils/invariant';\nimport { path } from '@/utils/path';\nimport {\n runStandardValidation,\n type StandardSchemaValidator,\n} from '@/utils/validator';\n\nfunction verifyUpdate<def, paths extends DeepKeys<def>>(options: {\n strict: boolean;\n partial: boolean;\n silenceErrors: boolean;\n obj: def;\n paths: paths[];\n actual: path.pickBy<def, paths>;\n}) {\n const { strict, partial, actual, obj, paths, silenceErrors } = options;\n\n // Define the logic for when the update is considered valid\n const { mismatches, ok } = path.equalsAtPaths(obj, paths, actual);\n\n let isValid = true;\n\n if (strict) {\n isValid = ok && mismatches.length === 0;\n }\n\n if (partial) {\n const mismatchesWithoutMissingKey = mismatches.filter(\n ({ reason }) => reason !== 'missing-key'\n );\n\n if (strict) {\n isValid = mismatchesWithoutMissingKey.length === 0;\n } else {\n const withoutExtraKey = mismatchesWithoutMissingKey.filter(\n ({ reason }) => reason !== 'extra-key'\n );\n\n isValid = withoutExtraKey.length === 0;\n }\n }\n\n if (!silenceErrors) {\n invariant(\n isValid,\n `[update]: found value mismatches in ${path.printMismatches({\n ok,\n mismatches,\n })}`\n );\n }\n}\n\nexport namespace MultiStepFormStepSchemaInternal {\n export interface Options<\n def extends StepSchema.Config,\n value extends steps.instantiateSteps<def> = steps.instantiateSteps<def>,\n additionalEnrichedProps extends Record<string, unknown> = {}\n > {\n originalValue: def['steps'];\n additionalEnrichedProps?: (step: number) => additionalEnrichedProps;\n /**\n * The resolved multi step form values.\n */\n getValue: () => value;\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: value) => void;\n }\n}\n\nexport namespace StepSchema {\n export interface Config<\n TCasing extends CasingType = DefaultCasing,\n TStorageKey extends string = string\n > extends steps.instantiateConfig,\n fields.NameTransformCasingOptions<TCasing> {\n /**\n * The options for the storage module.\n */\n storage?: BaseStorageConfig<TStorageKey>;\n }\n\n export type inferStorageKey<T> = T extends Config\n ? undefined extends T['storage']\n ? DefaultStorageKey\n : T['storage'] extends { key: infer key extends string }\n ? key\n : DefaultStorageKey\n : DefaultStorageKey;\n}\n\nexport class MultiStepFormStepSchemaInternal<\n const def extends StepSchema.Config,\n value extends steps.instantiateSteps<def> = steps.instantiateSteps<def>,\n additionalEnrichedProps extends Record<string, unknown> = {}\n> {\n readonly #originalValue: def['steps'];\n readonly #additionalEnrichedProps?: (step: number) => additionalEnrichedProps;\n readonly #getValue: () => value;\n readonly #setValue: (value: value) => void;\n\n private get value() {\n return this.#getValue();\n }\n\n constructor(\n options: MultiStepFormStepSchemaInternal.Options<\n def,\n value,\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: value) {\n this.#setValue(this.enrichValues(value));\n }\n\n private buildCtxData<\n chosenSteps extends HelperFnChosenSteps.main<\n value,\n steps.StepNumbers<value>\n >,\n values,\n additionalCtx extends Record<string, unknown>\n >(\n options: Required<\n HelperFn.CtxDataSelector<value, chosenSteps, additionalCtx>\n > & {\n values: values;\n logger: MultiStepFormLogger;\n }\n ) {\n const { logger, values, ctxData } = options;\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 return additionalCtx;\n }\n\n private createStepUpdaterFnImpl<\n targetStep extends steps.StepNumbers<value>,\n fields extends UpdateFn.chosenFields<\n UpdateFn.resolvedStep<value, targetStep>\n >,\n strict extends boolean,\n partial extends boolean,\n additionalCtx extends Record<string, unknown>,\n additionalUpdaterData extends UpdateFn.additionalUpdaterData\n >(\n options: UpdateFn.options<\n value,\n targetStep,\n fields,\n strict,\n partial,\n additionalCtx,\n additionalUpdaterData\n >\n ) {\n const {\n targetStep,\n ctxData,\n fields = 'all',\n debug,\n partial = false,\n strict = true,\n silentErrors,\n } = options;\n const silenceErrors = silentErrors ?? (partial || !strict);\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 targetStep in this.value,\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\n let updatedValue = { ...this.value };\n let ctx = createCtx(updatedValue, [targetStep]);\n\n // Build the `ctx` first\n if (ctxData) {\n const additionalCtx = this.buildCtxData({\n values,\n ctxData,\n logger,\n });\n\n ctx = {\n ...ctx,\n ...additionalCtx,\n } as never;\n }\n\n const updated = functionalUpdate(updater, {\n ctx: ctx as never,\n update: this.createHelperFnInputUpdate([targetStep]),\n reset: this.createHelperFnInputReset([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 // @ts-expect-error - we know the keys are present\n const { update, reset, createHelperFn, ...currentStep } =\n this.value[stepKey as keyof value];\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 verifyUpdate({\n strict,\n partial,\n silenceErrors,\n obj,\n paths,\n actual: actual as never,\n });\n\n logger.info('The entire step will be updated');\n\n const currentUpdatedValue = updatedValue[\n stepKey as keyof value\n ] as Record<string, unknown>;\n const updatedAtPath = path.updateAt({\n obj: currentUpdatedValue,\n paths,\n value: actual as never,\n partial,\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 verifyUpdate({\n strict,\n partial,\n silenceErrors,\n obj: currentStep,\n paths: fields,\n actual: updated as never,\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({\n obj: currentStep as Record<string, unknown>,\n paths: fields,\n value: updated as never,\n partial,\n }),\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 verifyUpdate({\n strict,\n partial,\n silenceErrors,\n obj: currentStep,\n paths: keys as never,\n actual: updated as never,\n });\n\n updatedValue = {\n ...updatedValue,\n [targetStep]: path.updateAt({\n obj: currentStep as Record<string, unknown>,\n paths: keys as never,\n value: updated as never,\n partial,\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 steps.StepNumbers<value>>(\n targetStep: targetStep\n ): UpdateFn.stepSpecific<value, targetStep> {\n return (options) => {\n this.createStepUpdaterFnImpl({ targetStep, ...options });\n };\n }\n\n update<\n targetStep extends steps.StepNumbers<value>,\n field extends UpdateFn.chosenFields<\n UpdateFn.resolvedStep<value, targetStep>\n > = 'all',\n strict extends boolean = true,\n partial extends boolean = false,\n additionalCtx extends Record<string, unknown> = {},\n additionalUpdaterData extends UpdateFn.additionalUpdaterData = never\n >(\n options: UpdateFn.options<\n value,\n targetStep,\n field,\n strict,\n partial,\n additionalCtx,\n additionalUpdaterData\n >\n ) {\n return this.createStepUpdaterFnImpl(options);\n }\n\n private resetFields<\n targetStep extends steps.StepNumbers<value>,\n currentStep extends UpdateFn.resolvedStep<value, targetStep>\n >(config: {\n targetStep: targetStep;\n values: value;\n updatedValues: value;\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<value, DeepKeys<value>>(\n values,\n ...(resolvedFields as any)\n );\n\n config.updatedValues = {\n ...config.updatedValues,\n ...path.updateAt({\n obj: values,\n paths: resolvedFields as DeepKeys<value>[],\n value: picked,\n }),\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 steps.StepNumbers<value>,\n fields extends UpdateFn.chosenFields<currentStep>,\n currentStep extends UpdateFn.resolvedStep<value, targetStep>\n >(options: ResetFn.Options<value, targetStep, fields, currentStep>) {\n const { fields = 'all', targetStep, debug } = options;\n const logger = new MultiStepFormLogger({\n debug,\n prefix: (value) => `${value}:reset${targetStep}`,\n });\n const originalValues = steps.instantiate({\n steps: this.#originalValue,\n });\n const enrichedOriginalValues = this.enrichValues(\n originalValues,\n this.#additionalEnrichedProps\n ) as value;\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 (HelperFnChosenSteps.isTuple<DeepKeys<currentStep>>(fields)) {\n reset(fields as never);\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 steps.StepNumbers<value>>(\n targetStep: targetStep\n ): ResetFn.stepSpecific<value, 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 steps.StepNumbers<value>,\n fields extends UpdateFn.chosenFields<currentStep>,\n currentStep extends UpdateFn.resolvedStep<value, targetStep>\n >(options: ResetFn.Options<value, targetStep, fields, currentStep>) {\n this.createStepResetterFnImpl(options);\n }\n\n createHelperFnInputUpdate<\n chosenSteps extends HelperFnChosenSteps.main<\n value,\n steps.StepNumbers<value>\n >\n >(chosenSteps: chosenSteps) {\n const match = HelperFnChosenSteps.match({\n meta: {\n value: this.value,\n },\n validValues: ({ meta }) => Object.keys(meta.value),\n all: ({ meta }) => {\n const stepSpecificUpdateFn = typedObjectKeys(meta.value).reduce(\n (acc, key) => {\n (acc as any)[key] = this.createStepUpdaterFn(key as never);\n\n return acc;\n },\n {} as UpdateFn.createHelperFnForAllSteps<value, chosenSteps>\n );\n const update = Object.assign(\n this.update,\n stepSpecificUpdateFn\n ) as UpdateFn.HelperFn<value, chosenSteps>;\n\n return update;\n },\n object: ({ chosenSteps }) => {\n const stepSpecificUpdateFn = Object.keys(chosenSteps).reduce(\n (acc, key) => {\n (acc as any)[key] = this.createStepUpdaterFn(key as never);\n\n return acc;\n },\n {} as UpdateFn.createHelperFnForObjectSteps<value, chosenSteps>\n );\n const update = Object.assign(\n this.update,\n stepSpecificUpdateFn\n ) as UpdateFn.HelperFn<value, chosenSteps>;\n\n return update;\n },\n tuple: () => {\n const stepSpecificUpdateFn = (\n chosenSteps as HelperFnChosenSteps.tupleNotation<\n steps.StepNumbers<value>\n >\n ).reduce((acc, step) => {\n (acc as any)[step] = this.createStepUpdaterFn(step);\n\n return acc;\n }, {} as UpdateFn.createHelperFnForTupleSteps<value, chosenSteps>);\n const update = Object.assign(\n this.update,\n stepSpecificUpdateFn\n ) as UpdateFn.HelperFn<value, chosenSteps>;\n\n return update;\n },\n default: ({ errorMessage }) => {\n throw new TypeError(`[update]: ${errorMessage}`);\n },\n });\n\n return match<value, chosenSteps>(chosenSteps);\n }\n\n createHelperFnInputReset<\n chosenSteps extends HelperFnChosenSteps.main<\n value,\n steps.StepNumbers<value>\n >\n >(chosenSteps: chosenSteps) {\n const match = HelperFnChosenSteps.match({\n meta: {\n value: this.value,\n },\n validValues: ({ meta }) => Object.keys(meta.value),\n all: () => {\n const stepSpecificUpdateFn = typedObjectKeys(this.value).reduce(\n (acc, key) => {\n (acc as any)[key] = this.createStepResetterFn(key as never);\n\n return acc;\n },\n {} as ResetFn.createHelperFnForAllSteps<value, chosenSteps>\n );\n const reset = Object.assign(\n this.reset,\n stepSpecificUpdateFn\n ) as ResetFn.HelperFn<value, chosenSteps>;\n\n return reset;\n },\n tuple: () => {\n const stepSpecificUpdateFn = (\n chosenSteps as HelperFnChosenSteps.tupleNotation<\n steps.StepNumbers<value>\n >\n ).reduce((acc, step) => {\n (acc as any)[step] = this.createStepResetterFn(step as never);\n\n return acc;\n }, {} as ResetFn.createHelperFnForTupleSteps<value, chosenSteps>);\n const reset = Object.assign(\n this.reset,\n stepSpecificUpdateFn\n ) as ResetFn.HelperFn<value, chosenSteps>;\n\n return reset;\n },\n object: ({ chosenSteps }) => {\n const stepSpecificUpdateFn = Object.keys(chosenSteps).reduce(\n (acc, key) => {\n (acc as any)[key] = this.createStepResetterFn(key as never);\n\n return acc;\n },\n {} as ResetFn.createHelperFnForObjectSteps<value, chosenSteps>\n );\n const reset = Object.assign(\n this.reset,\n stepSpecificUpdateFn\n ) as ResetFn.HelperFn<value, chosenSteps>;\n\n return reset;\n },\n default: ({ errorMessage }) => {\n throw new TypeError(`[reset]: ${errorMessage}`);\n },\n });\n\n return match<value, chosenSteps>(chosenSteps);\n }\n\n createStepHelperFn<\n chosenSteps extends HelperFnChosenSteps.main<\n value,\n steps.StepNumbers<value>\n >\n >(stepData: chosenSteps) {\n return <validator, additionalCtx extends Record<string, unknown>, response>(\n optionsOrFunction:\n | Omit<\n HelperFnOptions.WithValidator<\n value,\n chosenSteps,\n validator,\n additionalCtx\n >,\n 'stepData'\n >\n | Omit<\n HelperFnOptions.WithoutValidator<value, chosenSteps, additionalCtx>,\n 'stepData'\n >\n | HelperFnInput.WithoutValidator<\n value,\n chosenSteps,\n additionalCtx,\n response\n >,\n fn:\n | HelperFnInput.WithValidator<\n value,\n chosenSteps,\n validator,\n additionalCtx,\n response\n >\n | HelperFnInput.WithoutValidator<\n value,\n chosenSteps,\n additionalCtx,\n response\n >\n ) => {\n const functions = {\n update: this.createHelperFnInputUpdate(stepData),\n reset: this.createHelperFnInputReset(stepData),\n };\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(this.value, stepData) as never;\n return optionsOrFunction({\n ctx,\n ...functions,\n });\n };\n }\n\n if (typeof optionsOrFunction === 'object') {\n return (input?: HelperFnOutput.Input<validator>) => {\n // Create ctx fresh each time the function is called to ensure it has the latest this.value\n let ctx = createCtx(this.value, stepData);\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 if (optionsOrFunction.ctxData) {\n const ctxData = optionsOrFunction.ctxData;\n\n invariant(\n typeof ctxData === 'function',\n 'Option \"ctxData\" must be a function'\n );\n\n const logger = new MultiStepFormLogger({\n debug: false,\n prefix: (value) => `${value}:ctxData`,\n });\n const match = HelperFnChosenSteps.match({\n meta: {\n value: this.value,\n stepData,\n ctxData,\n logger,\n },\n validValues: ({ meta }) => Object.keys(meta.value),\n all: ({ meta }) => {\n // Allow all steps to be selected\n const { value, ctxData, logger } = meta;\n\n return this.buildCtxData({\n ctxData,\n values: value,\n logger,\n });\n },\n tuple: ({ meta }) => {\n // Allow the non-selected steps to be selected\n const { value, stepData, ctxData, logger } = meta;\n const targetSteps = HelperFnChosenSteps.createTupleNotation(\n ...(stepData as HelperFnChosenSteps.tupleNotation<\n steps.StepNumbers<value>\n >)\n );\n const values = omit(value, targetSteps);\n\n return this.buildCtxData({\n ctxData,\n values,\n logger,\n });\n },\n object: ({ meta }) => {\n // Allow the non-selected steps to be selected\n const { value, stepData, ctxData, logger } = meta;\n const targetSteps = Object.keys(\n stepData\n ) as steps.StepNumbers<value>[];\n const values = omit(value, targetSteps);\n\n return this.buildCtxData({\n ctxData,\n values,\n logger,\n });\n },\n default: ({ errorMessage }) => {\n throw new TypeError(`[ctxData]: ${errorMessage}`);\n },\n });\n const additionalCtx = match<value, chosenSteps>(stepData);\n\n ctx = {\n ...ctx,\n ...additionalCtx,\n } as never;\n }\n\n return fn({\n ctx: ctx as never,\n ...functions,\n ...input,\n } as never);\n }\n\n return (\n fn as HelperFnInput.WithoutValidator<\n value,\n chosenSteps,\n additionalCtx,\n response\n >\n )({\n ctx: ctx as never,\n ...functions,\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 enrichValues<\n values extends Record<string, unknown>,\n additionalProps extends Record<string, unknown>\n >(values: values, additionalProps?: (step: number) => additionalProps) {\n const invariant: Invariant = createInvariant('[enrichValues]');\n\n invariant(\n typeof values === 'object' && values !== null,\n 'The values must be an object'\n );\n\n if (additionalProps) {\n invariant(\n typeof additionalProps === 'function',\n 'The additional props must be a function'\n );\n }\n\n let enriched = { ...values };\n\n for (const [key, stepValue] of Object.entries(enriched)) {\n const targetStep = key as steps.StepNumbers<value>;\n const step = Number.parseInt(targetStep.replace('step', ''));\n\n invariant(\n typeof stepValue === 'object' && stepValue !== null,\n `The value for ${key} must be an object`\n );\n\n enriched[targetStep as keyof values] = {\n ...stepValue,\n update: this.createStepUpdaterFn(targetStep),\n reset: this.createStepResetterFn(targetStep),\n createHelperFn: this.createStepHelperFn([targetStep]),\n ...additionalProps?.(step),\n } as never;\n }\n\n return enriched;\n }\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAS,aAA+C,SAOrD;CACD,MAAM,EAAE,QAAQ,SAAS,QAAQ,KAAK,OAAO,kBAAkB;CAG/D,MAAM,EAAE,YAAY,OAAO,KAAK,cAAc,KAAK,OAAO,OAAO;CAEjE,IAAI,UAAU;AAEd,KAAI,OACF,WAAU,MAAM,WAAW,WAAW;AAGxC,KAAI,SAAS;EACX,MAAM,8BAA8B,WAAW,QAC5C,EAAE,aAAa,WAAW,cAC5B;AAED,MAAI,OACF,WAAU,4BAA4B,WAAW;MAMjD,WAJwB,4BAA4B,QACjD,EAAE,aAAa,WAAW,YAC5B,CAEyB,WAAW;;AAIzC,KAAI,CAAC,cACH,WACE,SACA,uCAAuC,KAAK,gBAAgB;EAC1D;EACA;EACD,CAAC,GACH;;AA+CL,IAAa,kCAAb,MAIE;CACA,CAASA;CACT,CAASC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0CACD;EAGH,IAAI,WAAW,EAAE,GAAG,QAAQ;AAE5B,OAAK,MAAM,CAAC,KAAK,cAAc,OAAO,QAAQ,SAAS,EAAE;GACvD,MAAM,aAAa;GACnB,MAAM,OAAO,OAAO,SAAS,WAAW,QAAQ,QAAQ,GAAG,CAAC;AAE5D,eACE,OAAO,cAAc,YAAY,cAAc,MAC/C,iBAAiB,IAAI,oBACtB;AAED,YAAS,cAA8B;IACrC,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"}
|
package/dist/schema.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_casing = require('./utils/casing.cjs');
|
|
2
|
+
require('./utils/index.cjs');
|
|
2
3
|
const require_storage = require('./storage.cjs');
|
|
3
4
|
const require_subscribable = require('./subscribable.cjs');
|
|
4
5
|
const require_schema = require('./steps/schema.cjs');
|
|
@@ -9,6 +10,7 @@ var MultiStepFormSchema = class extends require_subscribable.Subscribable {
|
|
|
9
10
|
defaultNameTransformationCasing;
|
|
10
11
|
stepSchema;
|
|
11
12
|
storage;
|
|
13
|
+
storageConfig;
|
|
12
14
|
mountCount = 0;
|
|
13
15
|
constructor(options) {
|
|
14
16
|
super();
|
|
@@ -16,13 +18,17 @@ var MultiStepFormSchema = class extends require_subscribable.Subscribable {
|
|
|
16
18
|
this.defaultNameTransformationCasing = require_casing.setCasingType(nameTransformCasing);
|
|
17
19
|
this.stepSchema = new require_schema.MultiStepFormStepSchema({
|
|
18
20
|
steps,
|
|
19
|
-
nameTransformCasing: this.defaultNameTransformationCasing
|
|
21
|
+
nameTransformCasing: this.defaultNameTransformationCasing,
|
|
22
|
+
storage
|
|
20
23
|
});
|
|
21
|
-
this.
|
|
24
|
+
this.storageConfig = {
|
|
22
25
|
key: storage?.key ?? require_storage.DEFAULT_STORAGE_KEY,
|
|
23
|
-
data: this.stepSchema.value,
|
|
24
26
|
store: storage?.store,
|
|
25
|
-
throwWhenUndefined: storage?.throwWhenUndefined
|
|
27
|
+
throwWhenUndefined: storage?.throwWhenUndefined
|
|
28
|
+
};
|
|
29
|
+
this.storage = new require_storage.MultiStepFormStorage({
|
|
30
|
+
data: this.stepSchema.value,
|
|
31
|
+
...this.storageConfig
|
|
26
32
|
});
|
|
27
33
|
this.stepSchema.subscribe(() => {
|
|
28
34
|
this.notify();
|
|
@@ -49,12 +55,10 @@ var MultiStepFormSchema = class extends require_subscribable.Subscribable {
|
|
|
49
55
|
onUnmount() {}
|
|
50
56
|
notify() {
|
|
51
57
|
for (const listener of this.listeners) listener({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
steps: this.stepSchema.original
|
|
58
|
+
defaultNameTransformationCasing: this.defaultNameTransformationCasing,
|
|
59
|
+
original: this.stepSchema.original,
|
|
60
|
+
steps: this.stepSchema.steps,
|
|
61
|
+
value: this.stepSchema.value
|
|
58
62
|
});
|
|
59
63
|
}
|
|
60
64
|
};
|
package/dist/schema.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.cjs","names":["Subscribable","setCasingType","MultiStepFormStepSchema","
|
|
1
|
+
{"version":3,"file":"schema.cjs","names":["Subscribable","setCasingType","MultiStepFormStepSchema","DEFAULT_STORAGE_KEY","MultiStepFormStorage"],"sources":["../src/schema.ts"],"sourcesContent":["import { MultiStepFormStepSchema } from '@/steps';\nimport { setCasingType } from '@/utils';\nimport type { StepSchema } from './internals/index.js';\nimport type { steps } from './steps/steps.js';\nimport {\n DEFAULT_STORAGE_KEY,\n MultiStepFormStorage,\n type BaseStorageConfig,\n} from './storage.js';\nimport { Subscribable } from './subscribable.js';\n\nexport class MultiStepFormSchema<\n const def extends StepSchema.Config,\n value extends steps.instantiateSteps<def>,\n> extends Subscribable<MultiStepFormStepSchema.Listener<def, value>> {\n readonly defaultNameTransformationCasing: def['nameTransformCasing'];\n readonly stepSchema: MultiStepFormStepSchema<def, value>;\n storage: MultiStepFormStorage<value, StepSchema.inferStorageKey<def>>;\n protected readonly storageConfig: BaseStorageConfig<\n StepSchema.inferStorageKey<def>\n >;\n private mountCount = 0;\n\n constructor(options: def) {\n super();\n\n const { steps, nameTransformCasing, storage } = options;\n\n this.defaultNameTransformationCasing = setCasingType(\n nameTransformCasing\n ) as def['nameTransformCasing'];\n this.stepSchema = new MultiStepFormStepSchema<def, value>({\n steps,\n nameTransformCasing: this.defaultNameTransformationCasing,\n storage,\n } as never);\n this.storageConfig = {\n key: (storage?.key ??\n DEFAULT_STORAGE_KEY) as StepSchema.inferStorageKey<def>,\n store: storage?.store,\n throwWhenUndefined: storage?.throwWhenUndefined,\n };\n this.storage = new MultiStepFormStorage({\n data: this.stepSchema.value,\n ...this.storageConfig,\n });\n\n this.stepSchema.subscribe(() => {\n this.notify();\n });\n }\n\n getSnapshot() {\n return this;\n }\n\n mount() {\n this.mountCount++;\n\n if (this.mountCount === 1) {\n this.onMount();\n }\n\n return () => {\n this.unmount();\n };\n }\n\n unmount() {\n this.mountCount = Math.max(0, this.mountCount - 1);\n\n if (this.mountCount === 0) {\n this.onUnmount();\n }\n }\n\n isMounted() {\n return this.mountCount > 0;\n }\n\n protected onMount() {}\n protected onUnmount() {}\n\n protected notify() {\n for (const listener of this.listeners) {\n listener({\n defaultNameTransformationCasing: this.defaultNameTransformationCasing,\n original: this.stepSchema.original,\n steps: this.stepSchema.steps,\n value: this.stepSchema.value,\n });\n }\n }\n}\n\nexport function createMultiStepFormSchema<\n const def extends StepSchema.Config,\n value extends steps.instantiateSteps<def>,\n>(options: def) {\n return new MultiStepFormSchema<def, value>(options);\n}\n"],"mappings":";;;;;;;;AAWA,IAAa,sBAAb,cAGUA,kCAA2D;CACnE,AAAS;CACT,AAAS;CACT;CACA,AAAmB;CAGnB,AAAQ,aAAa;CAErB,YAAY,SAAc;AACxB,SAAO;EAEP,MAAM,EAAE,OAAO,qBAAqB,YAAY;AAEhD,OAAK,kCAAkCC,6BACrC,oBACD;AACD,OAAK,aAAa,IAAIC,uCAAoC;GACxD;GACA,qBAAqB,KAAK;GAC1B;GACD,CAAU;AACX,OAAK,gBAAgB;GACnB,KAAM,SAAS,OACbC;GACF,OAAO,SAAS;GAChB,oBAAoB,SAAS;GAC9B;AACD,OAAK,UAAU,IAAIC,qCAAqB;GACtC,MAAM,KAAK,WAAW;GACtB,GAAG,KAAK;GACT,CAAC;AAEF,OAAK,WAAW,gBAAgB;AAC9B,QAAK,QAAQ;IACb;;CAGJ,cAAc;AACZ,SAAO;;CAGT,QAAQ;AACN,OAAK;AAEL,MAAI,KAAK,eAAe,EACtB,MAAK,SAAS;AAGhB,eAAa;AACX,QAAK,SAAS;;;CAIlB,UAAU;AACR,OAAK,aAAa,KAAK,IAAI,GAAG,KAAK,aAAa,EAAE;AAElD,MAAI,KAAK,eAAe,EACtB,MAAK,WAAW;;CAIpB,YAAY;AACV,SAAO,KAAK,aAAa;;CAG3B,AAAU,UAAU;CACpB,AAAU,YAAY;CAEtB,AAAU,SAAS;AACjB,OAAK,MAAM,YAAY,KAAK,UAC1B,UAAS;GACP,iCAAiC,KAAK;GACtC,UAAU,KAAK,WAAW;GAC1B,OAAO,KAAK,WAAW;GACvB,OAAO,KAAK,WAAW;GACxB,CAAC;;;AAKR,SAAgB,0BAGd,SAAc;AACd,QAAO,IAAI,oBAAgC,QAAQ"}
|
package/dist/schema.d.cts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { DefaultStorageKey, MultiStepFormStorage } from "./storage.cjs";
|
|
1
|
+
import { steps } from "./steps/steps.cjs";
|
|
2
|
+
import { BaseStorageConfig, MultiStepFormStorage } from "./storage.cjs";
|
|
3
|
+
import { StepSchema } from "./internals/step-schema.cjs";
|
|
5
4
|
import { Subscribable } from "./subscribable.cjs";
|
|
6
5
|
import { MultiStepFormStepSchema } from "./steps/schema.cjs";
|
|
7
6
|
|
|
8
7
|
//#region src/schema.d.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly
|
|
14
|
-
storage: MultiStepFormStorage<resolvedStep, storageKey>;
|
|
8
|
+
declare class MultiStepFormSchema<const def extends StepSchema.Config, value extends steps.instantiateSteps<def>> extends Subscribable<MultiStepFormStepSchema.Listener<def, value>> {
|
|
9
|
+
readonly defaultNameTransformationCasing: def['nameTransformCasing'];
|
|
10
|
+
readonly stepSchema: MultiStepFormStepSchema<def, value>;
|
|
11
|
+
storage: MultiStepFormStorage<value, StepSchema.inferStorageKey<def>>;
|
|
12
|
+
protected readonly storageConfig: BaseStorageConfig<StepSchema.inferStorageKey<def>>;
|
|
15
13
|
private mountCount;
|
|
16
|
-
constructor(options:
|
|
14
|
+
constructor(options: def);
|
|
17
15
|
getSnapshot(): this;
|
|
18
16
|
mount(): () => void;
|
|
19
17
|
unmount(): void;
|
|
@@ -22,7 +20,7 @@ declare class MultiStepFormSchema<step extends Step<casing>, casing extends Casi
|
|
|
22
20
|
protected onUnmount(): void;
|
|
23
21
|
protected notify(): void;
|
|
24
22
|
}
|
|
25
|
-
declare function createMultiStepFormSchema<
|
|
23
|
+
declare function createMultiStepFormSchema<const def extends StepSchema.Config, value extends steps.instantiateSteps<def>>(options: def): MultiStepFormSchema<def, value>;
|
|
26
24
|
//#endregion
|
|
27
|
-
export { MultiStepFormSchema,
|
|
25
|
+
export { MultiStepFormSchema, createMultiStepFormSchema };
|
|
28
26
|
//# sourceMappingURL=schema.d.cts.map
|
package/dist/schema.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.cts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.cts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;cAWa,sCACO,UAAA,CAAW,sBACf,KAAA,CAAM,iBAAiB,cAC7B,aAAa,uBAAA,CAAwB,SAAS,KAAK;4CACjB;EAJ/B,SAAA,UAAA,EAKU,uBALS,CAKe,GALf,EAKoB,KALpB,CAAA;EACZ,OAAA,EAKT,oBALoB,CAKC,KALD,EAKQ,UAAA,CAAW,eALnB,CAKmC,GALnC,CAAA,CAAA;EACQ,mBAAA,aAAA,EAKH,iBALG,CAMnC,UAAA,CAAW,eANwB,CAMR,GANQ,CAAA,CAAA;EAAvB,QAAM,UAAA;EACkC,WAAA,CAAA,OAAA,EASjC,GATiC;EAAK,WAAA,CAAA,CAAA,EAAA,IAAA;EAAtC,KAAA,CAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EACqB,OAAA,CAAA,CAAA,EAAA,IAAA;EACG,SAAA,CAAA,CAAA,EAAA,OAAA;EAAK,UAAA,OAAA,CAAA,CAAA,EAAA,IAAA;EAA7B,UAAA,SAAA,CAAA,CAAA,EAAA,IAAA;EACS,UAAA,MAAA,CAAA,CAAA,EAAA,IAAA;;AAAO,iBA8EvB,yBA9EkC,CAAA,kBA+E9B,UAAA,CAAW,MA/EmB,EAAA,cAgFlC,KAAA,CAAM,gBAhF4B,CAgFX,GAhFW,CAAA,CAAA,CAAA,OAAA,EAiFvC,GAjFuC,CAAA,EAiFpC,mBAjFoC,CAiFpC,GAjFoC,EAiFpC,KAjFoC,CAAA"}
|
package/dist/schema.d.mts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { DefaultStorageKey, MultiStepFormStorage } from "./storage.mjs";
|
|
1
|
+
import { steps } from "./steps/steps.mjs";
|
|
2
|
+
import { BaseStorageConfig, MultiStepFormStorage } from "./storage.mjs";
|
|
3
|
+
import { StepSchema } from "./internals/step-schema.mjs";
|
|
5
4
|
import { Subscribable } from "./subscribable.mjs";
|
|
6
5
|
import { MultiStepFormStepSchema } from "./steps/schema.mjs";
|
|
7
6
|
|
|
8
7
|
//#region src/schema.d.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly
|
|
14
|
-
storage: MultiStepFormStorage<resolvedStep, storageKey>;
|
|
8
|
+
declare class MultiStepFormSchema<const def extends StepSchema.Config, value extends steps.instantiateSteps<def>> extends Subscribable<MultiStepFormStepSchema.Listener<def, value>> {
|
|
9
|
+
readonly defaultNameTransformationCasing: def['nameTransformCasing'];
|
|
10
|
+
readonly stepSchema: MultiStepFormStepSchema<def, value>;
|
|
11
|
+
storage: MultiStepFormStorage<value, StepSchema.inferStorageKey<def>>;
|
|
12
|
+
protected readonly storageConfig: BaseStorageConfig<StepSchema.inferStorageKey<def>>;
|
|
15
13
|
private mountCount;
|
|
16
|
-
constructor(options:
|
|
14
|
+
constructor(options: def);
|
|
17
15
|
getSnapshot(): this;
|
|
18
16
|
mount(): () => void;
|
|
19
17
|
unmount(): void;
|
|
@@ -22,7 +20,7 @@ declare class MultiStepFormSchema<step extends Step<casing>, casing extends Casi
|
|
|
22
20
|
protected onUnmount(): void;
|
|
23
21
|
protected notify(): void;
|
|
24
22
|
}
|
|
25
|
-
declare function createMultiStepFormSchema<
|
|
23
|
+
declare function createMultiStepFormSchema<const def extends StepSchema.Config, value extends steps.instantiateSteps<def>>(options: def): MultiStepFormSchema<def, value>;
|
|
26
24
|
//#endregion
|
|
27
|
-
export { MultiStepFormSchema,
|
|
25
|
+
export { MultiStepFormSchema, createMultiStepFormSchema };
|
|
28
26
|
//# sourceMappingURL=schema.d.mts.map
|
package/dist/schema.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.mts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.mts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;;cAWa,sCACO,UAAA,CAAW,sBACf,KAAA,CAAM,iBAAiB,cAC7B,aAAa,uBAAA,CAAwB,SAAS,KAAK;4CACjB;EAJ/B,SAAA,UAAA,EAKU,uBALS,CAKe,GALf,EAKoB,KALpB,CAAA;EACZ,OAAA,EAKT,oBALoB,CAKC,KALD,EAKQ,UAAA,CAAW,eALnB,CAKmC,GALnC,CAAA,CAAA;EACQ,mBAAA,aAAA,EAKH,iBALG,CAMnC,UAAA,CAAW,eANwB,CAMR,GANQ,CAAA,CAAA;EAAvB,QAAM,UAAA;EACkC,WAAA,CAAA,OAAA,EASjC,GATiC;EAAK,WAAA,CAAA,CAAA,EAAA,IAAA;EAAtC,KAAA,CAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EACqB,OAAA,CAAA,CAAA,EAAA,IAAA;EACG,SAAA,CAAA,CAAA,EAAA,OAAA;EAAK,UAAA,OAAA,CAAA,CAAA,EAAA,IAAA;EAA7B,UAAA,SAAA,CAAA,CAAA,EAAA,IAAA;EACS,UAAA,MAAA,CAAA,CAAA,EAAA,IAAA;;AAAO,iBA8EvB,yBA9EkC,CAAA,kBA+E9B,UAAA,CAAW,MA/EmB,EAAA,cAgFlC,KAAA,CAAM,gBAhF4B,CAgFX,GAhFW,CAAA,CAAA,CAAA,OAAA,EAiFvC,GAjFuC,CAAA,EAiFpC,mBAjFoC,CAiFpC,GAjFoC,EAiFpC,KAjFoC,CAAA"}
|