@jfdevelops/multi-step-form-core 1.0.0-alpha.23 → 1.0.0-alpha.25

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.
Files changed (147) hide show
  1. package/dist/_internals.cjs +0 -4
  2. package/dist/_internals.d.cts +2 -3
  3. package/dist/_internals.d.mts +2 -3
  4. package/dist/_internals.mjs +1 -2
  5. package/dist/index.cjs +17 -18
  6. package/dist/index.d.cts +12 -11
  7. package/dist/index.d.mts +12 -11
  8. package/dist/index.mjs +8 -10
  9. package/dist/internals/step-schema.cjs +120 -71
  10. package/dist/internals/step-schema.cjs.map +1 -1
  11. package/dist/internals/step-schema.d.cts +47 -29
  12. package/dist/internals/step-schema.d.cts.map +1 -1
  13. package/dist/internals/step-schema.d.mts +47 -29
  14. package/dist/internals/step-schema.d.mts.map +1 -1
  15. package/dist/internals/step-schema.mjs +120 -71
  16. package/dist/internals/step-schema.mjs.map +1 -1
  17. package/dist/schema.cjs +14 -10
  18. package/dist/schema.cjs.map +1 -1
  19. package/dist/schema.d.cts +11 -13
  20. package/dist/schema.d.cts.map +1 -1
  21. package/dist/schema.d.mts +11 -13
  22. package/dist/schema.d.mts.map +1 -1
  23. package/dist/schema.mjs +14 -10
  24. package/dist/schema.mjs.map +1 -1
  25. package/dist/steps/fields.cjs +95 -0
  26. package/dist/steps/fields.cjs.map +1 -1
  27. package/dist/steps/fields.d.cts +119 -9
  28. package/dist/steps/fields.d.cts.map +1 -1
  29. package/dist/steps/fields.d.mts +119 -9
  30. package/dist/steps/fields.d.mts.map +1 -1
  31. package/dist/steps/fields.mjs +95 -0
  32. package/dist/steps/fields.mjs.map +1 -1
  33. package/dist/steps/fn-utils/helper-fn/index.cjs +81 -0
  34. package/dist/steps/fn-utils/helper-fn/index.cjs.map +1 -0
  35. package/dist/steps/fn-utils/helper-fn/index.d.cts +146 -0
  36. package/dist/steps/fn-utils/helper-fn/index.d.cts.map +1 -0
  37. package/dist/steps/fn-utils/helper-fn/index.d.mts +146 -0
  38. package/dist/steps/fn-utils/helper-fn/index.d.mts.map +1 -0
  39. package/dist/steps/fn-utils/helper-fn/index.mjs +75 -0
  40. package/dist/steps/fn-utils/helper-fn/index.mjs.map +1 -0
  41. package/dist/steps/fn-utils/helper-fn/utils.d.cts +81 -0
  42. package/dist/steps/fn-utils/helper-fn/utils.d.cts.map +1 -0
  43. package/dist/steps/fn-utils/helper-fn/utils.d.mts +81 -0
  44. package/dist/steps/fn-utils/helper-fn/utils.d.mts.map +1 -0
  45. package/dist/steps/fn-utils/index.cjs +1 -0
  46. package/dist/steps/fn-utils/index.mjs +3 -0
  47. package/dist/steps/fn-utils/reset-fn.d.cts +30 -0
  48. package/dist/steps/fn-utils/reset-fn.d.cts.map +1 -0
  49. package/dist/steps/fn-utils/reset-fn.d.mts +30 -0
  50. package/dist/steps/fn-utils/reset-fn.d.mts.map +1 -0
  51. package/dist/steps/fn-utils/update-fn.d.cts +121 -0
  52. package/dist/steps/fn-utils/update-fn.d.cts.map +1 -0
  53. package/dist/steps/fn-utils/update-fn.d.mts +121 -0
  54. package/dist/steps/fn-utils/update-fn.d.mts.map +1 -0
  55. package/dist/steps/index.cjs +4 -2
  56. package/dist/steps/index.mjs +5 -3
  57. package/dist/steps/schema.cjs +61 -84
  58. package/dist/steps/schema.cjs.map +1 -1
  59. package/dist/steps/schema.d.cts +66 -67
  60. package/dist/steps/schema.d.cts.map +1 -1
  61. package/dist/steps/schema.d.mts +66 -67
  62. package/dist/steps/schema.d.mts.map +1 -1
  63. package/dist/steps/schema.mjs +62 -86
  64. package/dist/steps/schema.mjs.map +1 -1
  65. package/dist/steps/steps.cjs +83 -0
  66. package/dist/steps/steps.cjs.map +1 -0
  67. package/dist/steps/steps.d.cts +81 -0
  68. package/dist/steps/steps.d.cts.map +1 -0
  69. package/dist/steps/steps.d.mts +81 -0
  70. package/dist/steps/steps.d.mts.map +1 -0
  71. package/dist/steps/steps.mjs +76 -0
  72. package/dist/steps/steps.mjs.map +1 -0
  73. package/dist/steps/utils.cjs +40 -30
  74. package/dist/steps/utils.cjs.map +1 -1
  75. package/dist/steps/utils.d.cts +8 -5
  76. package/dist/steps/utils.d.cts.map +1 -1
  77. package/dist/steps/utils.d.mts +8 -5
  78. package/dist/steps/utils.d.mts.map +1 -1
  79. package/dist/steps/utils.mjs +40 -31
  80. package/dist/steps/utils.mjs.map +1 -1
  81. package/dist/storage.cjs +1 -1
  82. package/dist/storage.cjs.map +1 -1
  83. package/dist/storage.d.cts +9 -7
  84. package/dist/storage.d.cts.map +1 -1
  85. package/dist/storage.d.mts +9 -7
  86. package/dist/storage.d.mts.map +1 -1
  87. package/dist/storage.mjs +1 -1
  88. package/dist/storage.mjs.map +1 -1
  89. package/dist/utils/casing.cjs +1 -1
  90. package/dist/utils/casing.cjs.map +1 -1
  91. package/dist/utils/casing.d.cts +27 -11
  92. package/dist/utils/casing.d.cts.map +1 -1
  93. package/dist/utils/casing.d.mts +27 -11
  94. package/dist/utils/casing.d.mts.map +1 -1
  95. package/dist/utils/casing.mjs +1 -1
  96. package/dist/utils/casing.mjs.map +1 -1
  97. package/dist/utils/helpers.cjs +8 -0
  98. package/dist/utils/helpers.cjs.map +1 -1
  99. package/dist/utils/helpers.mjs +7 -1
  100. package/dist/utils/helpers.mjs.map +1 -1
  101. package/dist/utils/index.cjs +3 -0
  102. package/dist/utils/index.mjs +5 -0
  103. package/dist/utils/invariant.cjs +28 -8
  104. package/dist/utils/invariant.cjs.map +1 -1
  105. package/dist/utils/invariant.d.cts +12 -2
  106. package/dist/utils/invariant.d.cts.map +1 -1
  107. package/dist/utils/invariant.d.mts +12 -2
  108. package/dist/utils/invariant.d.mts.map +1 -1
  109. package/dist/utils/invariant.mjs +28 -9
  110. package/dist/utils/invariant.mjs.map +1 -1
  111. package/dist/utils/types.d.cts +15 -3
  112. package/dist/utils/types.d.cts.map +1 -1
  113. package/dist/utils/types.d.mts +15 -3
  114. package/dist/utils/types.d.mts.map +1 -1
  115. package/package.json +1 -1
  116. package/dist/internals/utils.cjs +0 -102
  117. package/dist/internals/utils.cjs.map +0 -1
  118. package/dist/internals/utils.d.cts +0 -11
  119. package/dist/internals/utils.d.cts.map +0 -1
  120. package/dist/internals/utils.d.mts +0 -11
  121. package/dist/internals/utils.d.mts.map +0 -1
  122. package/dist/internals/utils.mjs +0 -99
  123. package/dist/internals/utils.mjs.map +0 -1
  124. package/dist/observable.cjs +0 -44
  125. package/dist/observable.cjs.map +0 -1
  126. package/dist/observable.d.cts +0 -26
  127. package/dist/observable.d.cts.map +0 -1
  128. package/dist/observable.d.mts +0 -26
  129. package/dist/observable.d.mts.map +0 -1
  130. package/dist/observable.mjs +0 -44
  131. package/dist/observable.mjs.map +0 -1
  132. package/dist/steps/types.cjs +0 -33
  133. package/dist/steps/types.cjs.map +0 -1
  134. package/dist/steps/types.d.cts +0 -354
  135. package/dist/steps/types.d.cts.map +0 -1
  136. package/dist/steps/types.d.mts +0 -354
  137. package/dist/steps/types.d.mts.map +0 -1
  138. package/dist/steps/types.mjs +0 -27
  139. package/dist/steps/types.mjs.map +0 -1
  140. package/dist/utils/field-types.cjs +0 -97
  141. package/dist/utils/field-types.cjs.map +0 -1
  142. package/dist/utils/field-types.d.cts +0 -52
  143. package/dist/utils/field-types.d.cts.map +0 -1
  144. package/dist/utils/field-types.d.mts +0 -52
  145. package/dist/utils/field-types.d.mts.map +0 -1
  146. package/dist/utils/field-types.mjs +0 -93
  147. package/dist/utils/field-types.mjs.map +0 -1
@@ -0,0 +1,121 @@
1
+ import { DeepKeys, DeepPartial, Expand, Relaxed, Updater, objectHelpers, stripFunctions } from "../../utils/types.cjs";
2
+ import { path } from "../../utils/path.cjs";
3
+ import { steps } from "../steps.cjs";
4
+ import { HelperFn, HelperFnChosenSteps } from "./helper-fn/index.cjs";
5
+
6
+ //#region src/steps/fn-utils/update-fn.d.ts
7
+ declare namespace UpdateFn {
8
+ export type chosenFields<TCurrentStep extends steps.Any> = HelperFnChosenSteps.defaultStringOption | HelperFnChosenSteps.tupleNotation<DeepKeys<TCurrentStep>> | path.generateObjectConfig<TCurrentStep>;
9
+ type resolveAllPropertyPath<TCurrentStep extends steps.Any, TField extends chosenFields<TCurrentStep>> = TField extends HelperFnChosenSteps.defaultStringOption ? Relaxed<TCurrentStep> : never;
10
+ type resolveTuplePropertyPath<TCurrentStep extends steps.Any, TField extends chosenFields<TCurrentStep>, TDeepKeys extends DeepKeys<TCurrentStep> = DeepKeys<TCurrentStep>> = TField extends HelperFnChosenSteps.tupleNotation<TDeepKeys> ? TField[number] extends DeepKeys<Relaxed<TCurrentStep>> ? path.pickBy<Relaxed<TCurrentStep>, TField[number]> : never : never;
11
+ type resolveObjectPropertyPath<TCurrentStep extends steps.Any, TField extends chosenFields<TCurrentStep>, TDeepKeys extends DeepKeys<TCurrentStep> = DeepKeys<TCurrentStep>> = TField extends path.generateObjectConfig<TField> ? path.objectToPath<TField> extends TDeepKeys ? path.objectToPath<TField> extends DeepKeys<Relaxed<TCurrentStep>> ? path.pickBy<Relaxed<TCurrentStep>, path.objectToPath<TField>> : never : never : never;
12
+ type resolvePathType<TCurrentStep extends steps.Any, TField extends chosenFields<TCurrentStep>> = TField extends HelperFnChosenSteps.defaultStringOption ? 'all' : TField extends Array<infer _> ? 'tuple' : objectHelpers.isObject<TField> extends true ? 'object' : never;
13
+ type resolvePathMap<TCurrentStep extends steps.Any, TField extends chosenFields<TCurrentStep>> = {
14
+ all: resolveAllPropertyPath<TCurrentStep, TField>;
15
+ tuple: resolveTuplePropertyPath<TCurrentStep, TField>;
16
+ object: resolveObjectPropertyPath<TCurrentStep, TField>;
17
+ };
18
+ export type resolvedStep<value extends steps.instantiateSteps, targetStep extends steps.StepNumbers<value>> = stripFunctions<value[targetStep]>;
19
+ export type resolvedFieldValue<value extends steps.instantiateSteps, targetStep extends steps.StepNumbers<value>, field extends chosenFields<currentStep>, currentStep extends resolvedStep<value, targetStep> = resolvedStep<value, targetStep>, pathType extends resolvePathType<currentStep, field> = resolvePathType<currentStep, field>> = resolvePathMap<currentStep, field>[pathType];
20
+ export type mode = {
21
+ /**
22
+ * Enables strict mode for the update operation.
23
+ *
24
+ * When enabled, you won't be able to add new keys to an object. If
25
+ * you need to add new keys, set to `false`.
26
+ * @default true
27
+ */
28
+ strict: boolean;
29
+ /**
30
+ * Enables partial mode for the update operation.
31
+ *
32
+ * When enabled, you will be required to return the whole object. If
33
+ * you need to return a partial object, set to `false`.
34
+ * @default false
35
+ */
36
+ partial: boolean;
37
+ };
38
+ export type additionalUpdaterData = Record<string, unknown> | (() => Record<string, unknown>);
39
+ export type inferAdditionalUpdaterData<T extends additionalUpdaterData> = T extends (() => infer _) ? _ : T;
40
+ export type resolvedUpdaterReturnType<T, TMode extends mode, TAdditionalCtx extends additionalUpdaterData> = TMode['strict'] extends true ? TMode['partial'] extends true ? DeepPartial<T> : T : TMode['partial'] extends true ? DeepPartial<T> & TAdditionalCtx : T & TAdditionalCtx;
41
+ export interface DebugOptions {
42
+ /**
43
+ * Enables verbose debug logging for this update operation.
44
+ * Set to `true` to output helpful information for troubleshooting.
45
+ */
46
+ debug?: boolean;
47
+ /**
48
+ * Controls whether console errors should be silenced.
49
+ *
50
+ * By default, errors will be silenced when `partial: true` OR `strict: false`.
51
+ *
52
+ */
53
+ silentErrors?: boolean;
54
+ }
55
+ export interface BaseOptions<value extends steps.instantiateSteps, targetStep extends steps.StepNumbers<value>, fields extends chosenFields<currentStep>, currentStep extends resolvedStep<value, targetStep> = resolvedStep<value, targetStep>> extends DebugOptions {
56
+ /**
57
+ * The step to update.
58
+ */
59
+ targetStep: targetStep;
60
+ /**
61
+ * The specific fields to update.
62
+ *
63
+ * Optionally provide a value to narrow the results of the `ctx` in the
64
+ * updater `fn`.
65
+ */
66
+ fields?: fields;
67
+ }
68
+ export interface ModeOptions<TMode extends mode> {
69
+ /**
70
+ * Enables verbose debug logging for this update operation.
71
+ * Set to `true` to output helpful information for troubleshooting.
72
+ */
73
+ debug?: boolean;
74
+ /**
75
+ * Controls whether console errors should be silenced.
76
+ *
77
+ * By default, errors will be silenced when `partial: true` OR `strict: false`.
78
+ *
79
+ */
80
+ silentErrors?: boolean;
81
+ /**
82
+ * Enables strict mode for the update operation.
83
+ *
84
+ * When enabled, you won't be able to add new keys to an object. If
85
+ * you need to add new keys, set to `false`.
86
+ * @default true
87
+ */
88
+ strict?: TMode['strict'];
89
+ /**
90
+ * Enables partial mode for the update operation.
91
+ *
92
+ * When enabled, you will be required to return the whole object. If
93
+ * you need to return a partial object, set to `false`.
94
+ * @default false
95
+ */
96
+ partial?: TMode['partial'];
97
+ }
98
+ export interface SharedOptions<value extends steps.instantiateSteps, targetStep extends steps.StepNumbers<value>, fields extends chosenFields<currentStep>, updateMode extends mode, currentStep extends resolvedStep<value, targetStep> = resolvedStep<value, targetStep>> extends BaseOptions<value, targetStep, fields, currentStep>, ModeOptions<updateMode> {}
99
+ export type options<value extends steps.instantiateSteps, targetStep extends steps.StepNumbers<value>, field extends chosenFields<TCurrentStep>, strict extends boolean, partial extends boolean, additionalCtx extends Record<string, unknown>, updaterData extends additionalUpdaterData, TCurrentStep extends resolvedStep<value, targetStep> = resolvedStep<value, targetStep>, TMode extends mode = {
100
+ strict: strict;
101
+ partial: partial;
102
+ }> = SharedOptions<value, targetStep, field, TMode, TCurrentStep> & HelperFn.CtxDataSelector<value, [targetStep], additionalCtx> & {
103
+ updater: Updater<Expand<HelperFn.BaseInput<value, [targetStep], never, additionalCtx>>, resolvedUpdaterReturnType<resolvedFieldValue<value, targetStep, field, TCurrentStep>, TMode, updaterData>>;
104
+ };
105
+ export type general<value extends steps.instantiateSteps> = <targetStep extends steps.StepNumbers<value>, field extends chosenFields<resolvedStep<value, targetStep>> = 'all', strict extends boolean = true, partial extends boolean = false, additionalCtx extends Record<string, unknown> = {}, additionalUpdaterData extends Record<string, unknown> = {}>(options: options<value, targetStep, field, strict, partial, additionalCtx, additionalUpdaterData>) => void;
106
+ export type stepSpecific<value extends steps.instantiateSteps, targetStep extends stepNumbers, stepNumbers extends steps.StepNumbers<value> = steps.StepNumbers<value>> = <field extends chosenFields<resolvedStep<value, targetStep>> = 'all', strict extends boolean = true, partial extends boolean = false, additionalCtx extends Record<string, unknown> = {}, additionalUpdaterData extends Record<string, unknown> = {}>(options: Omit<options<value, targetStep, field, strict, partial, additionalCtx, additionalUpdaterData>, 'targetStep'>) => void;
107
+ export type StepSpecificHelperFn<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = { [key in HelperFnChosenSteps.resolve<value, chosenSteps>]: stepSpecific<value, key> };
108
+ export type createHelperFnForAllSteps<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = chosenSteps extends HelperFnChosenSteps.defaultStringOption ? StepSpecificHelperFn<value, chosenSteps> : never;
109
+ export type createHelperFnForTupleSteps<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = chosenSteps extends HelperFnChosenSteps.tupleNotation<steps.StepNumbers<value>> ? StepSpecificHelperFn<value, chosenSteps> : never;
110
+ export type createHelperFnForObjectSteps<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = chosenSteps extends HelperFnChosenSteps.objectNotation<steps.StepNumbers<value>> ? { [key in keyof chosenSteps]: key extends HelperFnChosenSteps.resolve<value, chosenSteps> ? StepSpecificHelperFn<value, chosenSteps>[key] : never } : never;
111
+ type HelperFnMap<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = {
112
+ all: createHelperFnForAllSteps<value, chosenSteps>;
113
+ tuple: createHelperFnForTupleSteps<value, chosenSteps>;
114
+ object: createHelperFnForObjectSteps<value, chosenSteps>;
115
+ };
116
+ export type HelperFn<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = general<value> & HelperFnMap<value, chosenSteps>[HelperFnChosenSteps.resolveType<value, chosenSteps>];
117
+ export {};
118
+ }
119
+ //#endregion
120
+ export { UpdateFn };
121
+ //# sourceMappingURL=update-fn.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-fn.d.cts","names":[],"sources":["../../../src/steps/fn-utils/update-fn.ts"],"sourcesContent":[],"mappings":";;;;;;kBAaiB,QAAA;gDAC+B,KAAA,CAAM,OAChD,mBAAA,CAAoB,sBACpB,mBAAA,CAAoB,cAAc,SAAS,iBAC3C,IAAA,CAAK,qBAAqB;EAJf,KAAA,sBAAQ,CAAA,qBAOA,KAAA,CAAM,GAPN,EAAA,eAQN,YARM,CAQO,YARP,CAAA,CAAA,GASnB,MATmB,SASJ,mBAAA,CAAoB,mBAThB,GAUnB,OAVmB,CAUX,YAVW,CAAA,GAAA,KAAA;EACuB,KAAM,wBAAA,CAAA,qBAY7B,KAAA,CAAM,GAZuB,EAAA,eAanC,YAbmC,CAatB,YAbsB,CAAA,EAAA,kBAchC,QAdgC,CAcvB,YAduB,CAAA,GAcP,QAdO,CAcE,YAdF,CAAA,CAAA,GAehD,MAfgD,SAejC,mBAAA,CAAoB,aAfa,CAeC,SAfD,CAAA,GAgBhD,MAhBgD,CAAA,MAAA,CAAA,SAgBzB,QAhByB,CAgBhB,OAhBgB,CAgBR,YAhBQ,CAAA,CAAA,GAiB9C,IAAA,CAAK,MAjByC,CAiBlC,OAjBkC,CAiB1B,YAjB0B,CAAA,EAiBX,MAjBW,CAAA,MAAA,CAAA,CAAA,GAAA,KAAA,GAAA,KAAA;EAChD,KAAA,yBAAoB,CAAA,qBAoBD,KAAA,CAAM,GApBL,EAAA,eAqBP,YArBO,CAqBM,YArBN,CAAA,EAAA,kBAsBJ,QAtBI,CAsBK,YAtBL,CAAA,GAsBqB,QAtBrB,CAsB8B,YAtB9B,CAAA,CAAA,GAuBpB,MAvBoB,SAuBL,IAAA,CAAK,oBAvBA,CAuBqB,MAvBrB,CAAA,GAwBpB,IAAA,CAAK,YAxBe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xC,CAsNE,KAtNF,EAuNE,KAAA,CAAM,WAvNR,CAuNoB,KAvNpB,CAAA,CAAA,CAAA,GAAA;IAA8B,GAAA,EA0NzB,yBA1NyB,CA0NC,KA1ND,EA0NQ,WA1NR,CAAA;IAGhB,KAAA,EAwNP,2BAxNO,CAwNqB,KAxNrB,EAwN4B,WAxN5B,CAAA;IACS,MAAA,EAwNf,4BAxNe,CAwNc,KAxNd,EAwNqB,WAxNrB,CAAA;EACrB,CAAA;EACA,OAAA,KAAA,QAAA,CAAA,cAyNY,KAAA,CAAM,gBAzNlB,EAAA,oBA0NkB,mBAAA,CAAoB,IA1NtC,CA2NA,KA3NA,EA4NA,KAAA,CAAM,WA5NN,CA4NkB,KA5NlB,CAAA,CAAA,CAAA,GA8NA,OA9NA,CA8NQ,KA9NR,CAAA,GA+NF,WA/NE,CA+NU,KA/NV,EA+NiB,WA/NjB,CAAA,CA+N8B,mBAAA,CAAoB,WA/NlD,CAgOA,KAhOA,EAiOA,WAjOA,CAAA,CAAA;EACc"}
@@ -0,0 +1,121 @@
1
+ import { DeepKeys, DeepPartial, Expand, Relaxed, Updater, objectHelpers, stripFunctions } from "../../utils/types.mjs";
2
+ import { path } from "../../utils/path.mjs";
3
+ import { steps } from "../steps.mjs";
4
+ import { HelperFn, HelperFnChosenSteps } from "./helper-fn/index.mjs";
5
+
6
+ //#region src/steps/fn-utils/update-fn.d.ts
7
+ declare namespace UpdateFn {
8
+ export type chosenFields<TCurrentStep extends steps.Any> = HelperFnChosenSteps.defaultStringOption | HelperFnChosenSteps.tupleNotation<DeepKeys<TCurrentStep>> | path.generateObjectConfig<TCurrentStep>;
9
+ type resolveAllPropertyPath<TCurrentStep extends steps.Any, TField extends chosenFields<TCurrentStep>> = TField extends HelperFnChosenSteps.defaultStringOption ? Relaxed<TCurrentStep> : never;
10
+ type resolveTuplePropertyPath<TCurrentStep extends steps.Any, TField extends chosenFields<TCurrentStep>, TDeepKeys extends DeepKeys<TCurrentStep> = DeepKeys<TCurrentStep>> = TField extends HelperFnChosenSteps.tupleNotation<TDeepKeys> ? TField[number] extends DeepKeys<Relaxed<TCurrentStep>> ? path.pickBy<Relaxed<TCurrentStep>, TField[number]> : never : never;
11
+ type resolveObjectPropertyPath<TCurrentStep extends steps.Any, TField extends chosenFields<TCurrentStep>, TDeepKeys extends DeepKeys<TCurrentStep> = DeepKeys<TCurrentStep>> = TField extends path.generateObjectConfig<TField> ? path.objectToPath<TField> extends TDeepKeys ? path.objectToPath<TField> extends DeepKeys<Relaxed<TCurrentStep>> ? path.pickBy<Relaxed<TCurrentStep>, path.objectToPath<TField>> : never : never : never;
12
+ type resolvePathType<TCurrentStep extends steps.Any, TField extends chosenFields<TCurrentStep>> = TField extends HelperFnChosenSteps.defaultStringOption ? 'all' : TField extends Array<infer _> ? 'tuple' : objectHelpers.isObject<TField> extends true ? 'object' : never;
13
+ type resolvePathMap<TCurrentStep extends steps.Any, TField extends chosenFields<TCurrentStep>> = {
14
+ all: resolveAllPropertyPath<TCurrentStep, TField>;
15
+ tuple: resolveTuplePropertyPath<TCurrentStep, TField>;
16
+ object: resolveObjectPropertyPath<TCurrentStep, TField>;
17
+ };
18
+ export type resolvedStep<value extends steps.instantiateSteps, targetStep extends steps.StepNumbers<value>> = stripFunctions<value[targetStep]>;
19
+ export type resolvedFieldValue<value extends steps.instantiateSteps, targetStep extends steps.StepNumbers<value>, field extends chosenFields<currentStep>, currentStep extends resolvedStep<value, targetStep> = resolvedStep<value, targetStep>, pathType extends resolvePathType<currentStep, field> = resolvePathType<currentStep, field>> = resolvePathMap<currentStep, field>[pathType];
20
+ export type mode = {
21
+ /**
22
+ * Enables strict mode for the update operation.
23
+ *
24
+ * When enabled, you won't be able to add new keys to an object. If
25
+ * you need to add new keys, set to `false`.
26
+ * @default true
27
+ */
28
+ strict: boolean;
29
+ /**
30
+ * Enables partial mode for the update operation.
31
+ *
32
+ * When enabled, you will be required to return the whole object. If
33
+ * you need to return a partial object, set to `false`.
34
+ * @default false
35
+ */
36
+ partial: boolean;
37
+ };
38
+ export type additionalUpdaterData = Record<string, unknown> | (() => Record<string, unknown>);
39
+ export type inferAdditionalUpdaterData<T extends additionalUpdaterData> = T extends (() => infer _) ? _ : T;
40
+ export type resolvedUpdaterReturnType<T, TMode extends mode, TAdditionalCtx extends additionalUpdaterData> = TMode['strict'] extends true ? TMode['partial'] extends true ? DeepPartial<T> : T : TMode['partial'] extends true ? DeepPartial<T> & TAdditionalCtx : T & TAdditionalCtx;
41
+ export interface DebugOptions {
42
+ /**
43
+ * Enables verbose debug logging for this update operation.
44
+ * Set to `true` to output helpful information for troubleshooting.
45
+ */
46
+ debug?: boolean;
47
+ /**
48
+ * Controls whether console errors should be silenced.
49
+ *
50
+ * By default, errors will be silenced when `partial: true` OR `strict: false`.
51
+ *
52
+ */
53
+ silentErrors?: boolean;
54
+ }
55
+ export interface BaseOptions<value extends steps.instantiateSteps, targetStep extends steps.StepNumbers<value>, fields extends chosenFields<currentStep>, currentStep extends resolvedStep<value, targetStep> = resolvedStep<value, targetStep>> extends DebugOptions {
56
+ /**
57
+ * The step to update.
58
+ */
59
+ targetStep: targetStep;
60
+ /**
61
+ * The specific fields to update.
62
+ *
63
+ * Optionally provide a value to narrow the results of the `ctx` in the
64
+ * updater `fn`.
65
+ */
66
+ fields?: fields;
67
+ }
68
+ export interface ModeOptions<TMode extends mode> {
69
+ /**
70
+ * Enables verbose debug logging for this update operation.
71
+ * Set to `true` to output helpful information for troubleshooting.
72
+ */
73
+ debug?: boolean;
74
+ /**
75
+ * Controls whether console errors should be silenced.
76
+ *
77
+ * By default, errors will be silenced when `partial: true` OR `strict: false`.
78
+ *
79
+ */
80
+ silentErrors?: boolean;
81
+ /**
82
+ * Enables strict mode for the update operation.
83
+ *
84
+ * When enabled, you won't be able to add new keys to an object. If
85
+ * you need to add new keys, set to `false`.
86
+ * @default true
87
+ */
88
+ strict?: TMode['strict'];
89
+ /**
90
+ * Enables partial mode for the update operation.
91
+ *
92
+ * When enabled, you will be required to return the whole object. If
93
+ * you need to return a partial object, set to `false`.
94
+ * @default false
95
+ */
96
+ partial?: TMode['partial'];
97
+ }
98
+ export interface SharedOptions<value extends steps.instantiateSteps, targetStep extends steps.StepNumbers<value>, fields extends chosenFields<currentStep>, updateMode extends mode, currentStep extends resolvedStep<value, targetStep> = resolvedStep<value, targetStep>> extends BaseOptions<value, targetStep, fields, currentStep>, ModeOptions<updateMode> {}
99
+ export type options<value extends steps.instantiateSteps, targetStep extends steps.StepNumbers<value>, field extends chosenFields<TCurrentStep>, strict extends boolean, partial extends boolean, additionalCtx extends Record<string, unknown>, updaterData extends additionalUpdaterData, TCurrentStep extends resolvedStep<value, targetStep> = resolvedStep<value, targetStep>, TMode extends mode = {
100
+ strict: strict;
101
+ partial: partial;
102
+ }> = SharedOptions<value, targetStep, field, TMode, TCurrentStep> & HelperFn.CtxDataSelector<value, [targetStep], additionalCtx> & {
103
+ updater: Updater<Expand<HelperFn.BaseInput<value, [targetStep], never, additionalCtx>>, resolvedUpdaterReturnType<resolvedFieldValue<value, targetStep, field, TCurrentStep>, TMode, updaterData>>;
104
+ };
105
+ export type general<value extends steps.instantiateSteps> = <targetStep extends steps.StepNumbers<value>, field extends chosenFields<resolvedStep<value, targetStep>> = 'all', strict extends boolean = true, partial extends boolean = false, additionalCtx extends Record<string, unknown> = {}, additionalUpdaterData extends Record<string, unknown> = {}>(options: options<value, targetStep, field, strict, partial, additionalCtx, additionalUpdaterData>) => void;
106
+ export type stepSpecific<value extends steps.instantiateSteps, targetStep extends stepNumbers, stepNumbers extends steps.StepNumbers<value> = steps.StepNumbers<value>> = <field extends chosenFields<resolvedStep<value, targetStep>> = 'all', strict extends boolean = true, partial extends boolean = false, additionalCtx extends Record<string, unknown> = {}, additionalUpdaterData extends Record<string, unknown> = {}>(options: Omit<options<value, targetStep, field, strict, partial, additionalCtx, additionalUpdaterData>, 'targetStep'>) => void;
107
+ export type StepSpecificHelperFn<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = { [key in HelperFnChosenSteps.resolve<value, chosenSteps>]: stepSpecific<value, key> };
108
+ export type createHelperFnForAllSteps<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = chosenSteps extends HelperFnChosenSteps.defaultStringOption ? StepSpecificHelperFn<value, chosenSteps> : never;
109
+ export type createHelperFnForTupleSteps<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = chosenSteps extends HelperFnChosenSteps.tupleNotation<steps.StepNumbers<value>> ? StepSpecificHelperFn<value, chosenSteps> : never;
110
+ export type createHelperFnForObjectSteps<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = chosenSteps extends HelperFnChosenSteps.objectNotation<steps.StepNumbers<value>> ? { [key in keyof chosenSteps]: key extends HelperFnChosenSteps.resolve<value, chosenSteps> ? StepSpecificHelperFn<value, chosenSteps>[key] : never } : never;
111
+ type HelperFnMap<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = {
112
+ all: createHelperFnForAllSteps<value, chosenSteps>;
113
+ tuple: createHelperFnForTupleSteps<value, chosenSteps>;
114
+ object: createHelperFnForObjectSteps<value, chosenSteps>;
115
+ };
116
+ export type HelperFn<value extends steps.instantiateSteps, chosenSteps extends HelperFnChosenSteps.main<value, steps.StepNumbers<value>>> = general<value> & HelperFnMap<value, chosenSteps>[HelperFnChosenSteps.resolveType<value, chosenSteps>];
117
+ export {};
118
+ }
119
+ //#endregion
120
+ export { UpdateFn };
121
+ //# sourceMappingURL=update-fn.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-fn.d.mts","names":[],"sources":["../../../src/steps/fn-utils/update-fn.ts"],"sourcesContent":[],"mappings":";;;;;;kBAaiB,QAAA;gDAC+B,KAAA,CAAM,OAChD,mBAAA,CAAoB,sBACpB,mBAAA,CAAo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B,CAAA;EACA,OAAA,KAAA,QAAA,CAAA,cAyNY,KAAA,CAAM,gBAzNlB,EAAA,oBA0NkB,mBAAA,CAAoB,IA1NtC,CA2NA,KA3NA,EA4NA,KAAA,CAAM,WA5NN,CA4NkB,KA5NlB,CAAA,CAAA,CAAA,GA8NA,OA9NA,CA8NQ,KA9NR,CAAA,GA+NF,WA/NE,CA+NU,KA/NV,EA+NiB,WA/NjB,CAAA,CA+N8B,mBAAA,CAAoB,WA/NlD,CAgOA,KAhOA,EAiOA,WAjOA,CAAA,CAAA;EACc"}
@@ -1,4 +1,6 @@
1
- const require_utils = require('./utils.cjs');
1
+ const require_index = require('./fn-utils/helper-fn/index.cjs');
2
2
  const require_fields = require('./fields.cjs');
3
+ const require_steps = require('./steps.cjs');
4
+ const require_utils = require('./utils.cjs');
3
5
  const require_schema = require('./schema.cjs');
4
- const require_types = require('./types.cjs');
6
+ require('./fn-utils/index.cjs');
@@ -1,6 +1,8 @@
1
- import { createCtx } from "./utils.mjs";
1
+ import { HelperFnChosenSteps } from "./fn-utils/helper-fn/index.mjs";
2
2
  import { fields } from "./fields.mjs";
3
- import { MultiStepFormStepSchema } from "./schema.mjs";
4
- import { HelperFnChosenSteps } from "./types.mjs";
3
+ import { VALIDATED_STEP_REGEX, steps } from "./steps.mjs";
4
+ import { createCtx } from "./utils.mjs";
5
+ import { MultiStepFormStepSchema, createIsValidStepFn } from "./schema.mjs";
6
+ import "./fn-utils/index.mjs";
5
7
 
6
8
  export { };
@@ -1,32 +1,39 @@
1
+ const require_casing = require('../utils/casing.cjs');
1
2
  const require_invariant = require('../utils/invariant.cjs');
3
+ require('../utils/index.cjs');
4
+ const require_fields = require('./fields.cjs');
5
+ const require_steps = require('./steps.cjs');
6
+ const require_helpers = require('../utils/helpers.cjs');
2
7
  const require_utils = require('./utils.cjs');
3
- const require_casing = require('../utils/casing.cjs');
4
- const require_field_types = require('../utils/field-types.cjs');
5
- const require_utils$1 = require('../internals/utils.cjs');
6
8
  const require_step_schema = require('../internals/step-schema.cjs');
7
9
  const require_storage = require('../storage.cjs');
8
10
  const require_subscribable = require('../subscribable.cjs');
9
- const require_fields = require('./fields.cjs');
10
11
 
11
12
  //#region src/steps/schema.ts
13
+ const STRING_KEYS = ["string", "string.keys"];
14
+ const NUMBER_KEYS = ["number"];
15
+ const ARRAY_STRING_KEYS = require_helpers.addToTuple(require_helpers.mapToTuple(STRING_KEYS, (key) => `array.${key}`), "array.string.untyped");
16
+ const ARRAY_NUMBER_KEYS = require_helpers.mapToTuple(NUMBER_KEYS, (key) => `array.${key}`);
12
17
  /**
13
18
  * Available transformation types for the step numbers.
14
19
  */
15
20
  const AS_TYPES = [
16
- "string",
17
- "number",
18
- "array.string",
19
- "array.string.untyped"
21
+ ...STRING_KEYS,
22
+ ...NUMBER_KEYS,
23
+ ...ARRAY_STRING_KEYS,
24
+ ...ARRAY_NUMBER_KEYS
20
25
  ];
21
- function assertObjectFields(obj, checks) {
22
- if (typeof obj !== "object" || obj === null) return false;
23
- for (const key of Object.keys(checks)) {
24
- if (!(key in obj)) return false;
25
- const checkFn = checks[key];
26
- const value = obj[key];
27
- if (!checkFn(value)) return false;
26
+ function createIsValidStepFn(stepNumbers) {
27
+ function isValidStep(value) {
28
+ require_invariant.createInvariant("[isValidStep]")(typeof value === "string" || typeof value === "number", `The value must be a string or a number, was ${typeof value}`);
29
+ if (typeof value === "string") {
30
+ if (!value.includes("step")) return false;
31
+ return stepNumbers.includes(Number.parseInt(value.replace("step", "")));
32
+ }
33
+ if (typeof value === "number") return stepNumbers.includes(value);
34
+ return false;
28
35
  }
29
- return true;
36
+ return isValidStep;
30
37
  }
31
38
  var MultiStepFormStepSchema = class extends require_subscribable.Subscribable {
32
39
  /**
@@ -39,45 +46,43 @@ var MultiStepFormStepSchema = class extends require_subscribable.Subscribable {
39
46
  value;
40
47
  steps;
41
48
  defaultNameTransformationCasing;
42
- firstStep;
43
- lastStep;
44
- stepNumbers;
45
- storage;
49
+ #stepNumbers;
50
+ #storage;
46
51
  #internal;
47
52
  constructor(config) {
48
53
  super();
49
- const { steps, nameTransformCasing, storage } = config;
54
+ const { steps: steps$1, nameTransformCasing, storage } = config;
50
55
  this.defaultNameTransformationCasing = require_casing.setCasingType(nameTransformCasing);
51
- this.original = steps;
52
- this.value = require_utils$1.createStep(this.original);
53
- this.storage = new require_storage.MultiStepFormStorage({
54
- data: this.value,
55
- key: storage?.key ?? require_storage.DEFAULT_STORAGE_KEY,
56
- store: storage?.store,
57
- throwWhenUndefined: storage?.throwWhenUndefined ?? false
58
- });
56
+ this.original = steps$1;
57
+ this.value = require_steps.instantiateSteps({ steps: steps$1 });
59
58
  this.#internal = new require_step_schema.MultiStepFormStepSchemaInternal({
60
59
  originalValue: this.original,
61
60
  getValue: () => this.value,
62
61
  setValue: (next) => this.handlePostUpdate(next)
63
62
  });
64
63
  this.value = this.#internal.enrichValues(this.value);
65
- this.stepNumbers = Object.keys(this.value).map((key) => Number.parseInt(key.replace("step", "")));
66
- this.firstStep = this.first();
67
- this.lastStep = this.last();
64
+ this.#storage = new require_storage.MultiStepFormStorage({
65
+ data: this.value,
66
+ key: storage?.key ?? require_storage.DEFAULT_STORAGE_KEY,
67
+ store: storage?.store,
68
+ throwWhenUndefined: storage?.throwWhenUndefined
69
+ });
70
+ this.#stepNumbers = Object.keys(this.value).map((key) => Number.parseInt(key.replace("step", "")));
68
71
  this.steps = {
69
- first: this.firstStep.step,
70
- last: this.lastStep.step,
71
- value: this.stepNumbers,
72
+ value: this.#stepNumbers,
72
73
  as: (asType) => {
73
74
  require_invariant.invariant(typeof asType === "string", `The type of the target transformation type must be a string, was ${typeof asType}`);
74
- if (asType === "string") return this.stepNumbers.map((value) => `'${value}'`).join(" | ");
75
- if (asType === "number") return this.stepNumbers.join(" | ");
76
- if (asType.includes("array.string")) return this.stepNumbers.map((value) => `${value}`);
75
+ if (asType === "string") return this.#stepNumbers.map((value) => `'${value}'`).join(" | ");
76
+ if (asType === "string.keys") return this.#stepNumbers.map((value) => `'step${value}'`).join(" | ");
77
+ if (asType === "number") return this.#stepNumbers.join(" | ");
78
+ if (asType.includes("array.string")) {
79
+ if (asType.includes("keys")) return this.#stepNumbers.map((value) => `step${value}`);
80
+ return this.#stepNumbers.map((value) => `${value}`);
81
+ }
82
+ if (asType.includes("array.number")) return this.#stepNumbers;
77
83
  throw new Error(`Transformation type "${asType}" is not supported. Available transformations include: ${AS_TYPES.map((value) => `"${value}"`).join(", ")}`);
78
84
  },
79
- isValidStepNumber: (stepNumber) => this.stepNumbers.includes(stepNumber),
80
- isValidStepKey: (value) => require_utils$1.isValidStepKey(this.value, value)
85
+ isValidStep: createIsValidStepFn(this.#stepNumbers)
81
86
  };
82
87
  this.sync();
83
88
  }
@@ -85,7 +90,7 @@ var MultiStepFormStepSchema = class extends require_subscribable.Subscribable {
85
90
  * @internal
86
91
  */
87
92
  __getStorage() {
88
- return this.storage;
93
+ return this.#storage;
89
94
  }
90
95
  getSnapshot() {
91
96
  return this;
@@ -113,28 +118,17 @@ var MultiStepFormStepSchema = class extends require_subscribable.Subscribable {
113
118
  get(options) {
114
119
  return require_utils.getStep(this.value)(options);
115
120
  }
116
- /**
117
- * Gets the data for the first step.
118
- * @returns The data for the first step.
119
- */
120
- first() {
121
- const firstStep = Math.min(...this.stepNumbers);
122
- return this.get({ step: firstStep });
123
- }
124
- /**
125
- * Gets the data for the last step.
126
- * @returns The data for the last step.
127
- */
128
- last() {
129
- const lastStep = Math.max(...this.stepNumbers);
130
- return this.get({ step: lastStep });
131
- }
132
121
  handlePostUpdate(next) {
133
122
  this.value = { ...next };
134
123
  this.__getStorage().add(this.value);
135
124
  this.sync();
136
125
  this.notify();
137
126
  }
127
+ /**
128
+ * Updates the step with the given options.
129
+ * @param options The options for updating the step.
130
+ * @returns The return value of the updater function.
131
+ */
138
132
  update(options) {
139
133
  this.#internal.update(options);
140
134
  }
@@ -149,29 +143,8 @@ var MultiStepFormStepSchema = class extends require_subscribable.Subscribable {
149
143
  * Validates that a given object is the proper shape for step data.
150
144
  * @param value
151
145
  */
152
- static hasData(value, options) {
153
- if (value === null || typeof value !== "object") return false;
154
- return assertObjectFields(value, {
155
- title: (v) => typeof v === "string",
156
- fields: (v) => {
157
- if (v === null || typeof v !== "object") return false;
158
- for (const key of Object.keys(v)) {
159
- if (typeof key !== "string" || !(key in v)) return false;
160
- const current = v[key];
161
- if (current === null || typeof current !== "object") return false;
162
- if (!assertObjectFields(current, {
163
- defaultValue: (v$1) => v$1 !== "undefined" && v$1 !== null,
164
- label: (v$1) => typeof v$1 === "string" || typeof v$1 === "boolean" && !v$1,
165
- nameTransformCasing: require_casing.isCasingValid,
166
- type: require_field_types.isFieldType
167
- })) return false;
168
- }
169
- return true;
170
- },
171
- createHelperFn: (v) => typeof v === "function",
172
- nameTransformCasing: require_casing.isCasingValid,
173
- ...options?.optionalKeysToCheck
174
- });
146
+ static hasData(value) {
147
+ return require_steps.steps.isValidSteps(value);
175
148
  }
176
149
  /**
177
150
  * Gets the value of a given field for a given step.
@@ -181,14 +154,18 @@ var MultiStepFormStepSchema = class extends require_subscribable.Subscribable {
181
154
  */
182
155
  getValue(step, field) {
183
156
  const stepData = this.value[step];
157
+ const invariant$1 = require_invariant.createInvariant("[getValue]");
184
158
  const baseErrorMessage = `Unable to get the value for "${String(step)}.fields.${String(field)}"`;
185
- require_invariant.invariant("fields" in stepData, baseErrorMessage);
186
- require_invariant.invariant(typeof stepData.fields === "object", `${baseErrorMessage} because "fields" is not an object. This shouldn't be the case, so please open an issue`);
187
- const fields$1 = stepData.fields;
188
- return require_fields.fields.resolvedDeepPath(field, fields$1);
159
+ const errorSuffix = "This shouldn't be the case, so please open an issue";
160
+ const createErrorMessage = (reason) => `${baseErrorMessage} because ${reason}. ${errorSuffix}`;
161
+ invariant$1(typeof stepData === "object" && stepData !== null, createErrorMessage("the step data is not an object"));
162
+ invariant$1("fields" in stepData, createErrorMessage("the step data does not have a \"fields\" property"));
163
+ invariant$1(typeof stepData.fields === "object", createErrorMessage("\"fields\" is not an object"));
164
+ return require_fields.fields.resolvedDeepPath(field, stepData.fields);
189
165
  }
190
166
  };
191
167
 
192
168
  //#endregion
193
169
  exports.MultiStepFormStepSchema = MultiStepFormStepSchema;
170
+ exports.createIsValidStepFn = createIsValidStepFn;
194
171
  //# sourceMappingURL=schema.cjs.map