@wix/himalaya-cli 0.1795.0 → 0.1797.0

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 (78) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/online-programs/src/index.d.ts +6 -0
  2. package/dist/browser-plane/assets.json +5 -5
  3. package/dist/browser-plane/preview-deferred/{11bd915805d61287157c1beca36b2d642d15e8107049a7d0fed28468d2965395.bin → 04eac2ea24e0edfcc5aaa757dc5d06c6bf35c3c5ce9ccbb448b305db05715492.bin} +1 -1
  4. package/dist/browser-plane/sw.js +6 -6
  5. package/dist/cli.mjs +44 -41
  6. package/dist/preview-assets.generated.bin +0 -0
  7. package/guides/sdk-reference.json +2 -2
  8. package/package.json +2 -2
  9. package/templates/beauty-salon/l10n/en.json +1 -1
  10. package/templates/branded-lite/dev/index.ts +483 -0
  11. package/templates/branded-lite/l10n/ar.json +66 -0
  12. package/templates/branded-lite/l10n/cs.json +66 -0
  13. package/templates/branded-lite/l10n/da.json +66 -0
  14. package/templates/branded-lite/l10n/de.json +66 -0
  15. package/templates/branded-lite/l10n/el.json +66 -0
  16. package/templates/branded-lite/l10n/en.json +8 -1
  17. package/templates/branded-lite/l10n/es.json +66 -0
  18. package/templates/branded-lite/l10n/fi.json +66 -0
  19. package/templates/branded-lite/l10n/fr.json +66 -0
  20. package/templates/branded-lite/l10n/he.json +53 -0
  21. package/templates/branded-lite/l10n/hu.json +66 -0
  22. package/templates/branded-lite/l10n/id.json +66 -0
  23. package/templates/branded-lite/l10n/it.json +66 -0
  24. package/templates/branded-lite/l10n/ja.json +66 -0
  25. package/templates/branded-lite/l10n/ko.json +66 -0
  26. package/templates/branded-lite/l10n/lt.json +66 -0
  27. package/templates/branded-lite/l10n/nl.json +66 -0
  28. package/templates/branded-lite/l10n/no.json +66 -0
  29. package/templates/branded-lite/l10n/pl.json +66 -0
  30. package/templates/branded-lite/l10n/pt.json +66 -0
  31. package/templates/branded-lite/l10n/ru.json +66 -0
  32. package/templates/branded-lite/l10n/sv.json +66 -0
  33. package/templates/branded-lite/l10n/th.json +66 -0
  34. package/templates/branded-lite/l10n/tr.json +66 -0
  35. package/templates/branded-lite/l10n/uk.json +66 -0
  36. package/templates/branded-lite/l10n/vi.json +66 -0
  37. package/templates/branded-lite/l10n/zh.json +66 -0
  38. package/templates/branded-lite/tier5-src/himi-branded-lite-program-step/index.ts +396 -14
  39. package/templates/branded-lite/tier5-src/himi-branded-lite-program-step/quiz.ts +114 -0
  40. package/templates/community-club/l10n/en.json +1 -1
  41. package/templates/events-meetups/l10n/en.json +1 -1
  42. package/templates/gym-fitness/l10n/en.json +1 -1
  43. package/templates/nonprofit-cause/l10n/en.json +1 -1
  44. package/templates/podcast-creator/l10n/en.json +1 -1
  45. package/templates/portfolio-creative/l10n/en.json +1 -1
  46. package/templates/restaurant/l10n/en.json +1 -1
  47. package/templates/retail-store/l10n/en.json +1 -1
  48. package/templates/yoga-studio/dev/index.ts +483 -0
  49. package/templates/yoga-studio/l10n/ar.json +66 -0
  50. package/templates/yoga-studio/l10n/cs.json +66 -0
  51. package/templates/yoga-studio/l10n/da.json +66 -0
  52. package/templates/yoga-studio/l10n/de.json +66 -0
  53. package/templates/yoga-studio/l10n/el.json +66 -0
  54. package/templates/yoga-studio/l10n/en.json +8 -1
  55. package/templates/yoga-studio/l10n/es.json +66 -0
  56. package/templates/yoga-studio/l10n/fi.json +66 -0
  57. package/templates/yoga-studio/l10n/fr.json +66 -0
  58. package/templates/yoga-studio/l10n/he.json +53 -0
  59. package/templates/yoga-studio/l10n/hu.json +66 -0
  60. package/templates/yoga-studio/l10n/id.json +66 -0
  61. package/templates/yoga-studio/l10n/it.json +66 -0
  62. package/templates/yoga-studio/l10n/ja.json +66 -0
  63. package/templates/yoga-studio/l10n/ko.json +66 -0
  64. package/templates/yoga-studio/l10n/lt.json +66 -0
  65. package/templates/yoga-studio/l10n/nl.json +66 -0
  66. package/templates/yoga-studio/l10n/no.json +66 -0
  67. package/templates/yoga-studio/l10n/pl.json +66 -0
  68. package/templates/yoga-studio/l10n/pt.json +66 -0
  69. package/templates/yoga-studio/l10n/ru.json +66 -0
  70. package/templates/yoga-studio/l10n/sv.json +66 -0
  71. package/templates/yoga-studio/l10n/th.json +66 -0
  72. package/templates/yoga-studio/l10n/tr.json +66 -0
  73. package/templates/yoga-studio/l10n/uk.json +66 -0
  74. package/templates/yoga-studio/l10n/vi.json +66 -0
  75. package/templates/yoga-studio/l10n/zh.json +66 -0
  76. package/templates/yoga-studio/tier5-src/_shared/branded-form.ts +321 -0
  77. package/templates/yoga-studio/tier5-src/himi-branded-lite-program-step/index.ts +396 -14
  78. package/templates/yoga-studio/tier5-src/himi-branded-lite-program-step/quiz.ts +114 -0
@@ -0,0 +1,321 @@
1
+ // The Wix Forms schema → what the Branded Lite Form screen can render and send.
2
+ //
3
+ // Pure functions, so the hermetic tests drive them without a worker. The source for every
4
+ // rule here is Wix's "About Form Fields" and "About Submission Values" articles
5
+ // (dev.wix.com/docs/api-reference/crm/forms/…):
6
+ // • `formFields` is an unordered set; the display order is `steps[].layout.<bp>.items`
7
+ // sorted by row, then column (a breakpoint may be missing, so fall back across them).
8
+ // • `identifier`, not `componentType`, names the field: TEXT_INPUT serves a short answer,
9
+ // a long answer, a link, an email, an address and the contact names.
10
+ // • a checkbox label is Ricos rich content; every other label is a plain string.
11
+ // • a submission is keyed by each field's `target`, and its value shape follows `inputType`.
12
+ // A field the app cannot fill (file, signature, payment, appointment, a multi-line address,
13
+ // image choice, rating, time) or any conditional rule makes the whole form "unsupported":
14
+ // a hidden required field would fail the whole send, so the screen offers the website instead.
15
+ import { ricosToPlainText } from "@himalaya/wix-rich-content";
16
+ import { validate } from "@himalaya/core/validation";
17
+
18
+ export type FieldKind = "text" | "area" | "email" | "phone" | "number" | "url" | "date" | "checkbox" | "choice" | "multi" | "display";
19
+
20
+ export interface FormOption { value: string; label: string }
21
+
22
+ export interface FormFieldModel {
23
+ id: string;
24
+ target: string;
25
+ kind: FieldKind;
26
+ label: string;
27
+ required: boolean;
28
+ placeholder: string;
29
+ help: string;
30
+ options: FormOption[];
31
+ /** `inputOptions.contactMapping.contactField` — EMAIL, FIRST_NAME, … — for member prefill. */
32
+ contactField: string;
33
+ }
34
+
35
+ export interface FormModel {
36
+ id: string;
37
+ title: string;
38
+ /** Field ids per page, in display order. A form with no layout is one page in array order. */
39
+ pages: string[][];
40
+ fields: Record<string, FormFieldModel>;
41
+ submitText: string;
42
+ nextText: string;
43
+ backText: string;
44
+ thankYou: string;
45
+ /** Something on the form the app cannot fill: show the website notice. */
46
+ unsupported: boolean;
47
+ /** The form stopped taking submissions (its deadline passed). */
48
+ closed: boolean;
49
+ }
50
+
51
+ type Obj = Record<string, unknown>;
52
+ const obj = (v: unknown): Obj => (v && typeof v === "object" && !Array.isArray(v) ? v as Obj : {});
53
+ const arr = (v: unknown): unknown[] => (Array.isArray(v) ? v : []);
54
+ const str = (v: unknown): string => (typeof v === "string" ? v : "");
55
+
56
+ /** Ricos rich content (or a plain string) → plain text, through the shared Ricos walker. */
57
+ export function plainText(v: unknown): string {
58
+ if (typeof v === "string") return v.trim();
59
+ return ricosToPlainText(obj(v) as never).trim();
60
+ }
61
+
62
+ const TEXT_IDENTIFIERS = new Set([
63
+ "TEXT_INPUT", "CONTACTS_FIRST_NAME", "CONTACTS_LAST_NAME", "CONTACTS_COMPANY", "CONTACTS_POSITION",
64
+ "CONTACTS_TAX_ID", "CONTACTS_ADDRESS",
65
+ ]);
66
+ const KIND_BY_IDENTIFIER: Record<string, FieldKind> = {
67
+ TEXT_AREA: "area", CONTACTS_EMAIL: "email", CONTACTS_PHONE: "phone", NUMBER_INPUT: "number", URL_INPUT: "url",
68
+ CONTACTS_BIRTHDATE: "date", DATE_INPUT: "date", DATE_PICKER: "date",
69
+ CHECKBOX: "checkbox", CONTACTS_SUBSCRIBE: "checkbox",
70
+ RADIO_GROUP: "choice", DROPDOWN: "choice", CHECKBOX_GROUP: "multi", TAGS: "multi",
71
+ };
72
+
73
+ /** The `inputType` options object for an input field: `stringOptions`, `booleanOptions`, … */
74
+ function typeOptions(input: Obj): Obj {
75
+ const t = str(input.inputType).toLowerCase().replace(/_([a-z])/g, (_m, c: string) => c.toUpperCase());
76
+ return obj(input[`${t}Options`]);
77
+ }
78
+
79
+ /** The component options object: `textInputOptions`, `radioGroupOptions`, … */
80
+ function componentOptions(typeOpts: Obj): Obj {
81
+ const c = str(typeOpts.componentType).toLowerCase().replace(/_([a-z])/g, (_m, ch: string) => ch.toUpperCase());
82
+ return obj(typeOpts[`${c}Options`]);
83
+ }
84
+
85
+ /** One `formFields` entry → its model, `null` for the submit button / a hidden field, or
86
+ * `"unsupported"` for a field the app cannot fill. */
87
+ export function parseField(raw: unknown): FormFieldModel | null | "unsupported" {
88
+ const f = obj(raw);
89
+ const id = str(f.id).toLowerCase();
90
+ // A hidden field the visitor cannot fill, but Wix requires, would fail every send.
91
+ if (f.hidden === true) return f.fieldType === "INPUT" && obj(f.inputOptions).required === true ? "unsupported" : null;
92
+ if (f.fieldType === "DISPLAY") {
93
+ const d = obj(f.displayOptions);
94
+ if (d.displayFieldType !== "RICH_CONTENT") return null;
95
+ const label = plainText(obj(d.richContentOptions).richContent);
96
+ return label ? { id, target: "", kind: "display", label, required: false, placeholder: "", help: "", options: [], contactField: "" } : null;
97
+ }
98
+ if (f.fieldType !== "INPUT") return "unsupported";
99
+ const identifier = str(f.identifier);
100
+ const kind: FieldKind | undefined = TEXT_IDENTIFIERS.has(identifier) ? "text" : KIND_BY_IDENTIFIER[identifier];
101
+ const input = obj(f.inputOptions);
102
+ const target = str(input.target);
103
+ if (!kind || !target) return "unsupported";
104
+ const opts = componentOptions(typeOptions(input));
105
+ const options = (kind === "choice" || kind === "multi")
106
+ ? arr(opts.options).map((o) => ({ value: str(obj(o).value), label: str(obj(o).label) || str(obj(o).value) })).filter((o) => o.value)
107
+ : [];
108
+ if ((kind === "choice" || kind === "multi") && !options.length) return "unsupported";
109
+ return {
110
+ id,
111
+ target,
112
+ kind,
113
+ label: plainText(opts.label),
114
+ required: input.required === true,
115
+ placeholder: str(opts.placeholder).trim(),
116
+ help: plainText(opts.description),
117
+ options,
118
+ contactField: str(obj(input.contactMapping).contactField),
119
+ };
120
+ }
121
+
122
+ /** Field ids of one step, in display order (row, then column). */
123
+ function stepFieldIds(step: unknown): string[] {
124
+ const layout = obj(obj(step).layout);
125
+ const bp = [layout.small, layout.medium, layout.large].map(obj).find((b) => arr(b.items).length) ?? {};
126
+ return arr(bp.items)
127
+ .map(obj)
128
+ .sort((a, b) => (Number(a.row) - Number(b.row)) || (Number(a.column) - Number(b.column)))
129
+ .map((i) => str(i.fieldId).toLowerCase())
130
+ .filter(Boolean);
131
+ }
132
+
133
+ export function parseForm(raw: unknown, now: number = Date.now()): FormModel {
134
+ const form = obj(obj(raw).form ?? raw);
135
+ const fields: Record<string, FormFieldModel> = {};
136
+ let unsupported = arr(form.formRules).length > 0 || arr(form.rules).length > 0;
137
+ let submitText = "", nextText = "", backText = "";
138
+ const arrayOrder: string[] = [];
139
+ for (const rawField of arr(form.formFields)) {
140
+ const f = obj(rawField);
141
+ const nav = obj(obj(f.displayOptions).pageNavigationOptions);
142
+ // A form has one navigation field per step and `formFields` is unordered: keep the first
143
+ // non-empty text of each kind, so another step's blank value never erases it.
144
+ if (obj(f.displayOptions).displayFieldType === "PAGE_NAVIGATION") {
145
+ submitText ||= str(nav.submitText).trim(); nextText ||= str(nav.nextPageText).trim(); backText ||= str(nav.previousPageText).trim();
146
+ }
147
+ const model = parseField(rawField);
148
+ if (model === "unsupported") { unsupported = true; continue; }
149
+ if (model) { fields[model.id] = model; arrayOrder.push(model.id); }
150
+ }
151
+ const steps = arr(form.steps);
152
+ const placed = steps.filter((st) => obj(st).hidden !== true).map((st) => stepFieldIds(st).filter((id) => fields[id]));
153
+ // A hidden step's fields are placed too — on no page. Adding them to the last page would show
154
+ // the visitor fields the owner hid (and block the send on a hidden required one).
155
+ const hiddenStepIds = steps.filter((st) => obj(st).hidden === true).flatMap(stepFieldIds);
156
+ const seen = new Set([...placed.flat(), ...hiddenStepIds]);
157
+ // …and a required field on a hidden step is the same dead end.
158
+ if (hiddenStepIds.some((id) => fields[id]?.required)) unsupported = true;
159
+ // A field missing from the layout still renders, on the last page, rather than vanishing.
160
+ const unplaced = arrayOrder.filter((id) => !seen.has(id));
161
+ const pages = placed.filter((p) => p.length);
162
+ if (unplaced.length) pages.length ? pages[pages.length - 1].push(...unplaced) : pages.push(unplaced);
163
+ const hasInput = Object.values(fields).some((f) => f.kind !== "display");
164
+ const deadline = Date.parse(str(obj(form.limitationRule).dateTimeDeadline));
165
+ const thanks = obj(obj(form.submitSettings).thankYouMessageOptions);
166
+ return {
167
+ id: str(form.id),
168
+ title: str(form.name).trim(),
169
+ pages: pages.length ? pages : [[]],
170
+ fields,
171
+ submitText, nextText, backText,
172
+ thankYou: plainText(thanks.richContent),
173
+ unsupported: unsupported || !hasInput,
174
+ closed: Number.isFinite(deadline) && deadline <= now,
175
+ };
176
+ }
177
+
178
+ // Legacy standalone forms use an ordered fields array and direct primitive values.
179
+ // Verified against the One App forms client and the reported short-ID form views.
180
+ export function parseLegacyForm(raw: unknown): FormModel {
181
+ const form = obj(obj(raw).form);
182
+ const view = obj(form.formViewInfo);
183
+ const fields: Record<string, FormFieldModel> = {};
184
+ const order: string[] = [];
185
+ // Step buttons identify a legacy multi-step flow whose boundaries we do not render.
186
+ let unsupported = arr(view.rule).length > 0 || view.nextButtonInfo != null || view.previousButtonInfo != null;
187
+ const kinds: Record<string, FieldKind> = { TEXT: "text", EMAIL: "email", PHONE: "phone", URL: "url",
188
+ PARAGRAPH: "area", NUMBER: "number", DATE_PICKER: "date", CHECKBOX: "checkbox",
189
+ SUBSCRIPTION_CHECKBOX: "checkbox", RADIO_GROUP: "choice", DROP_DOWN: "choice", CHECKBOX_GROUP: "multi" };
190
+ for (const rawField of arr(form.fields)) {
191
+ const field = obj(rawField), render = obj(field.renderInfo), display = obj(render.displayProperties);
192
+ const key = str(field.key), kind = kinds[str(render.type)];
193
+ // Keep unsupported/defaulted/read-only fields honest instead of sending a partial form.
194
+ if (!key || !kind || fields[key] || display.disabled === true || display.readOnly === true
195
+ || (display.defaultValue != null && display.defaultValue !== "")) { unsupported = true; continue; }
196
+ // Linked consent text must stay available before submitting. This form UI has no
197
+ // checkbox-link affordance, so keep the authored control on the website.
198
+ const checkbox = obj(display.checkboxSettings);
199
+ if (kind === "checkbox" && (checkbox.link != null || str(checkbox.linkLabel).trim())) {
200
+ unsupported = true; continue;
201
+ }
202
+ const settingsKey = ({ TEXT: "textSettings", EMAIL: "emailSettings", PHONE: "phoneSettings",
203
+ URL: "urlSettings", PARAGRAPH: "paragraphSettings", RADIO_GROUP: "radioGroupSettings",
204
+ DROP_DOWN: "dropdownSettings", CHECKBOX_GROUP: "checkboxGroupSettings" } as Record<string, string>)[str(render.type)];
205
+ const settings = obj(display[settingsKey]);
206
+ const options = (arr(display.options).length ? arr(display.options) : arr(settings.options)).map(value => {
207
+ const option = obj(value); return { value: str(option.value), label: str(option.label) || str(option.value) };
208
+ }).filter(option => option.value);
209
+ if ((kind === "choice" || kind === "multi") && !options.length) { unsupported = true; continue; }
210
+ order.push(key);
211
+ fields[key] = { id: key, target: key, kind, label: str(display.label), required: obj(render.validationProperties).required === true,
212
+ placeholder: str(display.placeholder) || str(settings.placeholder), help: "", options, contactField: "" };
213
+ }
214
+ return { id: str(form.formId), title: str(view.title), pages: [order], fields,
215
+ submitText: str(obj(view.submitButtonInfo).text), nextText: "", backText: "", thankYou: str(view.successMessage),
216
+ unsupported: unsupported || !Object.keys(fields).length, closed: false };
217
+ }
218
+
219
+ /** A typed number. A locale decimal keyboard types "1,5": one comma and no dot is a decimal comma. */
220
+ export function toNumber(text: string): number {
221
+ const t = text.trim();
222
+ return Number(/^[+-]?\d*,\d+$/.test(t) ? t.replace(",", ".") : t);
223
+ }
224
+
225
+ /** A form a visitor can fill has at least one input field. The demo site has a form with
226
+ * no name and no fields; listing it opened a screen with nothing to fill. */
227
+ export function hasInputFields(form: unknown): boolean {
228
+ return arr(obj(form).formFields).some((f) => obj(f).fieldType === "INPUT");
229
+ }
230
+
231
+ /** What the screen holds for one field. */
232
+ export interface FieldValue { text: string; checked: boolean; selected: string[] }
233
+
234
+ export const EMPTY_VALUE: FieldValue = { text: "", checked: false, selected: [] };
235
+
236
+ function isEmpty(f: FormFieldModel, v: FieldValue): boolean {
237
+ if (f.kind === "checkbox") return !v.checked;
238
+ if (f.kind === "choice" || f.kind === "multi") return v.selected.length === 0;
239
+ return v.text.trim() === "";
240
+ }
241
+
242
+ export type FieldProblem = "required" | "email" | "number" | "url" | "phone";
243
+
244
+ /** An email's loose shape: one @ and a dot after it (see localProblems). */
245
+ const LOOSE_EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
246
+ /** A link's loose shape: an optional http(s) scheme, then a name with a dot in it. */
247
+ const LOOSE_URL = /^(https?:\/\/)?[^\s.]+\.[^\s]+$/i;
248
+ /** The platform's own semantic type for a field kind: the same rule a `TextField` with
249
+ * `validation: { type }` applies on iOS, Android and web. */
250
+ const SEMANTIC_TYPE: Partial<Record<FieldKind, "email" | "phone" | "url" | "number">> = {
251
+ email: "email", phone: "phone", url: "url", number: "number",
252
+ };
253
+
254
+ /** The checks the app can make before Wix sees the values. Wix's own validation (format,
255
+ * length, allowed values) runs on the server; v4 can also check without submitting. */
256
+ export function localProblems(fields: FormFieldModel[], values: Record<string, FieldValue>): Record<string, FieldProblem> {
257
+ const out: Record<string, FieldProblem> = {};
258
+ for (const f of fields) {
259
+ if (f.kind === "display") continue;
260
+ const v = values[f.target] ?? EMPTY_VALUE;
261
+ if (isEmpty(f, v)) { if (f.required) out[f.target] = "required"; continue; }
262
+ const t = v.text.trim();
263
+ const type = SEMANTIC_TYPE[f.kind];
264
+ if (!type) continue;
265
+ // An email and a link get only a loose shape check: the shared rules are ASCII only and
266
+ // would block valid addresses (münchen.de); Wix's own check still runs on send.
267
+ if (type === "email") { if (!LOOSE_EMAIL.test(t)) out[f.target] = type; continue; }
268
+ if (type === "url") { if (!LOOSE_URL.test(t)) out[f.target] = type; continue; }
269
+ // A decimal comma is a decimal point; the text itself is checked otherwise, so a very small
270
+ // or very large number is not turned into exponent notation the rule refuses.
271
+ const checked = type === "number" && /^[+-]?\d*,\d+$/.test(t) ? t.replace(",", ".") : t;
272
+ if (validate({ type }, checked)) out[f.target] = type;
273
+ }
274
+ return out;
275
+ }
276
+
277
+ /** The `submissions` map: keyed by target, shaped by input type, empty optional values left out. */
278
+ export function submissionValues(fields: FormFieldModel[], values: Record<string, FieldValue>): Record<string, unknown> {
279
+ const out: Record<string, unknown> = {};
280
+ for (const f of fields) {
281
+ if (f.kind === "display") continue;
282
+ const v = values[f.target] ?? EMPTY_VALUE;
283
+ if (f.kind === "checkbox") { out[f.target] = v.checked; continue; }
284
+ if (f.kind === "multi") { if (v.selected.length) out[f.target] = [...v.selected]; continue; }
285
+ if (f.kind === "choice") { if (v.selected[0]) out[f.target] = v.selected[0]; continue; }
286
+ const t = v.text.trim();
287
+ if (!t) continue;
288
+ out[f.target] = f.kind === "number" ? toNumber(t) : t;
289
+ }
290
+ return out;
291
+ }
292
+
293
+ /** Wix's per-field validation errors (`submissionValidationErrors.errors[]`, in a
294
+ * validateFormSubmission answer or in a rejected createSubmission body) → target → errorType. */
295
+ export function serverProblems(answerOrError: unknown): Record<string, string> {
296
+ let source: unknown = answerOrError;
297
+ if (answerOrError instanceof Error || typeof answerOrError === "string") {
298
+ const msg = String((answerOrError as Error)?.message ?? answerOrError);
299
+ const json = msg.slice(msg.indexOf("{"));
300
+ try { source = JSON.parse(json); } catch { return {}; }
301
+ }
302
+ const out: Record<string, string> = {};
303
+ const visit = (v: unknown): void => {
304
+ if (Array.isArray(v)) { v.forEach(visit); return; }
305
+ const o = obj(v);
306
+ for (const e of arr(obj(o.submissionValidationErrors).errors)) {
307
+ const path = str(obj(e).errorPath), type = str(obj(e).errorType);
308
+ if (path && !out[path]) out[path] = type || "INVALID";
309
+ }
310
+ for (const k of ["violationErrors", "details", "applicationError", "data", "validationError"]) if (k in o) visit(o[k]);
311
+ };
312
+ visit(source);
313
+ return out;
314
+ }
315
+
316
+ /** A unix-seconds date (the DatePicker's `args.value`) → the `YYYY-MM-DD` Wix's DATE format takes. */
317
+ export function isoDate(unixSeconds: number): string {
318
+ const d = new Date(unixSeconds * 1000);
319
+ const p = (n: number) => String(n).padStart(2, "0");
320
+ return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`;
321
+ }