@flowrunner/cli 0.1.15 → 0.1.17

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.
@@ -17,6 +17,7 @@ and behaviors.
17
17
  | `z.array(inner)` | list | | `.labels({ value: 'Label' })` | `z.enum` | UI shows the label; the flow stores and `execute` receives the VALUE |
18
18
  | `z.union([...])` | the **first** branch's widget — see below | | | | |
19
19
  | `z.filesUploadOptions([...])`, `z.filesListOptions([...])`, `z.filesGetOptions([...])`, `z.filesDeleteOptions([...])` | nested form — the platform's own file-storage options, one group per Files call (see [03-parameters.md](03-parameters.md)) | | | | |
20
+ | | | | `.required()` | `z.unknown()` / `z.any()` field | required, any value — the open types are the only ones optional by default (see [Any value, but required](#any-value-but-required)) |
20
21
  | | | | `.secret()` | `z.string()` config field | Masks the input, with a reveal toggle. **Display only** — see below |
21
22
  | | | | `.dynamicProps({ dependsOn, execute })` | top-level **action** param: `z.looseObject()` or `z.array(z.looseObject())` | the object's inner fields are loaded at design time from other params (see [03-parameters.md](03-parameters.md)) |
22
23
 
@@ -27,7 +28,8 @@ Notes:
27
28
  config field is the `type` it **publishes**: a closed set in which `z.number()` lands on `string`. That is
28
29
  what a test asserts, not what the form renders. See
29
30
  [Config fields publish a smaller set of types](#config-fields-publish-a-smaller-set-of-types).
30
- - **Required is the default** — mark optional fields with `.optional()`.
31
+ - **Required is the default** — mark optional fields with `.optional()`. The exception is `z.unknown()` / `z.any()`,
32
+ optional unless marked `.required()`.
31
33
  - `.shared()` marks a config field as a **shared** (global) config value rather than per-app — used for
32
34
  OAuth client id/secret and other secrets. It is a **UI directive**: it decides who fills the field in and
33
35
  in which dialog, not how your handler reads it. `config.clientId` is the same either way, and a service
@@ -87,7 +89,8 @@ but the runtime parses it before your handler runs, and `execute` receives the p
87
89
 
88
90
  `z.json()` declares nothing about the value's SHAPE. When you do know the shape, declare it — a
89
91
  `z.object({ … })` gives the user a real form and gives you a checked value, where this gives a textarea and
90
- `unknown`.
92
+ `unknown`. A declared `z.object()` / `z.array()` also takes JSON text (see
93
+ [Text and structures](#text-and-structures)), so you lose nothing by declaring the shape.
91
94
 
92
95
  ## The type list is CLOSED
93
96
 
@@ -98,7 +101,7 @@ The table above is what a service declares day to day. A few more types are acce
98
101
  | `z.bigint()` | numeric stepper | your handler receives a `BigInt`. A fractional value is refused rather than rounded, since the conversion would lose information |
99
102
  | `z.literal(v)` | the widget of `v`'s own type — a toggle for `z.literal(true)`, a stepper for `z.literal(7)` | a literal of several values of *different* types has no such type and publishes as text |
100
103
  | `z.record(k, v)` | nested form with no declared fields, because the keys are open | the values are converted against `v` like any other declaration |
101
- | `z.any()` / `z.unknown()` | single-line | declares nothing: the value reaches your handler exactly as it arrived, unconverted |
104
+ | `z.any()` / `z.unknown()` | single-line | declares nothing: the value reaches your handler exactly as it arrived, unconverted. **Optional unless marked** — the one exception to *required is the default*; see [Any value, but required](#any-value-but-required) |
102
105
 
103
106
  **Those two tables together are the whole surface.** A declaration outside them — `z.tuple()`,
104
107
  `z.intersection()`, a modifier a future zod release adds — **fails when the extension loads**, naming the
@@ -118,12 +121,33 @@ These modifiers are looked THROUGH — the parameter publishes and coerces as th
118
121
  | Modifier | Published as |
119
122
  |---|---|
120
123
  | `.optional()` / `.nullable()` / `.nullish()` | the inner type, not required |
121
- | `.default(v)` / `.prefault(v)` | the inner type, not required, with `defaultValue` |
124
+ | `.default(v)` / `.prefault(v)` | the inner type, **not required**, with `defaultValue` — always, even with `.nonoptional()` around it: the runner fills the default, so an empty field never reaches the handler |
122
125
  | `.readonly()` | the inner type |
123
- | `.nonoptional()` | the inner type, required — it overrides an `.optional()` inside it |
126
+ | `.nonoptional()` / `.required()` | the inner type, required — it overrides an `.optional()` inside it, but not a `.default(v)`. `.required()` is the FlowRunner spelling for `z.unknown()` / `z.any()`; on `z.object()` it is zod's own (every key required) |
124
127
  | `.pipe(…)` / `.transform(fn)` | the **input** side. `bodyParams` describes what a caller supplies, which is what the console renders a form for; what your handler receives afterwards is the pipe's business |
125
128
  | `z.lazy(() => …)` | the type the thunk returns |
126
129
 
130
+ ### Any value, but required
131
+
132
+ `z.unknown()` and `z.any()` pass a value through **unconverted** — a number or a boolean bound from an
133
+ expression keeps its type, an object stays an object — which is what you want for a field the vendor takes
134
+ in any type (a Redis value, a Cosmos DB partition key, a custom-field value). Unlike every other type they
135
+ are **optional unless marked**, so mark the ones that must be set:
136
+
137
+ ```js
138
+ value: z.unknown().required().label('Value') // or .nonoptional() — the same thing
139
+ ```
140
+
141
+ | The flow sends | The handler receives |
142
+ |---|---|
143
+ | text (`''` included), a number, `0`, `false`, an object, a list, a date | the value, as given |
144
+ | `null` | `null` — a value the flow passed on purpose |
145
+ | nothing (`undefined`) | refused: `«Value» is required` — the handler never runs |
146
+
147
+ A bare `z.unknown()` is optional: a missing value reaches the handler as `undefined`, while `''` and `null` arrive
148
+ as given, as on a required one. Use `.required()` rather than guarding for `undefined` in the handler — it also marks the field required in the
149
+ form, where a guard cannot.
150
+
127
151
  ### `.catch(v)` is refused — use `.default(v)`
128
152
 
129
153
  `.catch(v)` looks like the natural way to say "if this isn't a valid list, use an empty one", so it is what
@@ -155,22 +179,42 @@ Both declarations validate identically. They **publish differently**, and nothin
155
179
  — so reordering branches to read more nicely silently changes what the flow author is shown. Put the shape
156
180
  you want on the form first, and treat the order as part of the contract.
157
181
 
158
- ### Coercion tries the branches in that same order, and the first that fits wins
182
+ ### A value that already fits a branch is kept as given
183
+
184
+ The branches are checked in that same order against the value **exactly as it arrived**, and the first that
185
+ accepts it wins — nothing is converted. Only a value that fits no branch is converted, into the first branch
186
+ it can become.
187
+
188
+ ```js
189
+ badge: z.union([z.number(), z.string()]) // 5 → 5 '+1' → '+1' true → 'true' (fits neither, converted)
190
+ id : z.union([z.string(), z.number()]) // 5 → 5 '5' → '5'
191
+ ```
192
+
193
+ So one field can keep both forms of a mixed value — a count and an increment, a number and a vendor's text
194
+ decimal — whichever order you declare.
195
+
196
+ **Text always fits a `z.string()` branch.** A value bound from a template or typed into an expression is
197
+ text, so a union with a `z.string()` branch never turns it into a number or a boolean, whatever the order.
198
+ That is worth spelling out for booleans, because the failure is silent: in `z.union([z.boolean(),
199
+ z.string()])` the expression text `'false'` reaches `execute` as the string `'false'`, which is truthy —
200
+ `if (params.flag)` runs the *on* path for an explicit *off*. (The toggle itself sends a real `false`.)
159
201
 
160
- A flow supplies every value as text, so a union has to convert before it can tell which branch applies.
202
+ When the other accepted forms are **a few fixed words**, declare the words, not `z.string()`. A
203
+ `z.literal()` or a `z.enum()` does not fit arbitrary text, so text that is a number or a boolean is
204
+ converted:
161
205
 
162
206
  ```js
163
- flag: z.union([z.boolean(), z.string()]) // 'true' → your handler receives the boolean true
164
- flag: z.union([z.string(), z.boolean()]) // 'true' → your handler receives the string 'true'
207
+ limit: z.union([z.number(), z.literal('max')]) // '5' → 5 'max' → 'max'
208
+ mode : z.union([z.boolean(), z.literal('auto')]) // 'false' → false 'auto' → 'auto'
209
+ scope: z.union([z.number(), z.enum(['all', 'none'])]) // '5' → 5 'all' → 'all' 'x' → «Scope» is invalid
165
210
  ```
166
211
 
167
- **A branch that accepts anything hides every branch after it.** `z.string()` takes `'true'` as-is, so the
168
- boolean branch is never reached. If one branch is a fallback, declare it last.
212
+ Keep `z.string()` in a union only when free text really is one of the forms, and convert in the handler if
213
+ you need a number out of it. For a value that must pass through untouched whatever its type, use
214
+ `z.unknown()` (see [Any value, but required](#any-value-but-required)).
169
215
 
170
- That is worth spelling out for booleans, because the failure is silent. In `z.union([z.string(),
171
- z.boolean()])` the field draws as the **first** branch's widget — a text box, not a toggle — the boolean
172
- vocabulary below is never applied, and `execute` receives the string `'false'`, which is truthy: `if
173
- (params.flag)` runs the *on* path for an explicit *off*. Put the boolean branch first.
216
+ A constraint is part of "fits": `z.union([z.number().min(10), z.string()])` given `5` hands over `'5'`,
217
+ because the number branch refuses it and the string branch takes it converted.
174
218
 
175
219
  ### A blank means "not set"
176
220
 
@@ -214,7 +258,7 @@ The two other differences are structural:
214
258
 
215
259
  | Declared in `configItems` | What happens |
216
260
  |---|---|
217
- | `z.object({...})`, `z.array(inner)` | **no config control** — a config value is one field, not a form. Declare structured input as a param |
261
+ | `z.object({...})`, `z.array(inner)` | **a plain text box** that takes the value as JSON text (`{"region":"eu"}`, `["a","b"]`), parsed and checked like any object or list — see [Text and structures](#text-and-structures). Usable, but a poor form: prefer a param for structured input |
218
262
  | `.dictionary(ref)` | **ignored** — a config value is resolved before any method runs, so there is no invocation to fetch options for. Use `z.enum([...])` for a fixed set of choices |
219
263
 
220
264
  `z.date()` in a config field is a date, with no time of day. Declare a string if you need one.
@@ -224,6 +268,36 @@ conversion.** `z.coerce.*` does not add to it, so `z.coerce.number()` and `z.num
224
268
  as do the boolean and string forms. The one exception is `z.date()` — declare **`z.coerce.date()`** when your handler wants a real `Date`
225
269
  instance rather than the string or epoch-millis the caller sent.
226
270
 
271
+ ### Text and structures
272
+
273
+ Text and structured values convert into each other, so a value survives a trip through a text box or an
274
+ expression either way:
275
+
276
+ - **A text field takes any value.** An object or a list given to `z.string()`, `z.text()` or a format becomes
277
+ its JSON text. `null` and a missing value are still blanks, never the text `'null'`.
278
+ - **An object or list field takes JSON text.** Text given to `z.object()`, `z.looseObject()`, `z.record()` or
279
+ `z.array()` is parsed when it is JSON of the matching kind — `{…}` for an object or record, `[…]` for a list —
280
+ and then converted and checked like any other value.
281
+
282
+ ```js
283
+ note : z.string() // { a: 1 } → '{"a":1}'
284
+ title: z.string().max(5) // { a: 1 } → «Title» must be at most 5 (checks run on the text)
285
+ point: z.object({ x: z.number() }) // '{"x":"1"}' → { x: 1 }
286
+ ids : z.array(z.number()) // '[1,"2"]' → [1, 2]
287
+ ids : z.array(z.number()) // '1,2' → «Ids» must be an array (not JSON — not split)
288
+ ```
289
+
290
+ Anything that is not JSON of the right kind is refused as before: a comma-separated value is not split for
291
+ you, and `'{a:1}'` (unquoted key) is not JSON. `''` is still a blank; `'{}'` and `'[]'` are values.
292
+
293
+ In a union, a value that already fits a branch is kept (see above), and an object or a list is **never** turned
294
+ into text through a `z.string()` branch: it takes a branch of its own kind or the union's error, so a malformed
295
+ object is reported rather than sent as JSON text. `z.json()` is unchanged — use it for JSON whose shape you do
296
+ not declare.
297
+
298
+ The flip side: an object bound by mistake to a plain text field (a subject, a name) is sent as JSON text
299
+ rather than refused.
300
+
227
301
  ### What a boolean accepts
228
302
 
229
303
  A `z.boolean()` is rarely filled in by hand — its value usually arrives from a spreadsheet column, a CSV
@@ -239,12 +313,15 @@ booleans `true`/`false` and the numbers `1`/`0`:
239
313
  So `'YES'`, `' Off '` and `'Enabled'` all work.
240
314
 
241
315
  **Anything else is a validation error, not a guess.** `'maybe'`, `'2'`, `'tr'`, a list or an object each
242
- fail with `«Field» is invalid — expects true or false`. That matters more than the width of the list: a
316
+ fail with `«Field» must be true or false`. That matters more than the width of the list: a
243
317
  conversion that quietly turned an unrecognised value into `false` would read an explicit *on* as *off* and
244
318
  never say so.
245
319
 
246
320
  A blank is absence rather than `false` — see [16-gotchas.md](16-gotchas.md).
247
321
 
322
+ This list applies to **params** only. A vendor's response is never converted: compare a response flag with the
323
+ value the vendor documents — see [16-gotchas.md](16-gotchas.md#conversion-runs-on-the-way-in-never-on-the-way-back).
324
+
248
325
  If you need a spelling that is not listed, the test for adding one is that **it has an unambiguous opposite
249
326
  and the pair is added together.** A word with no opposite is a status, not a boolean, and belongs in a
250
327
  `z.enum([...])`.
@@ -272,5 +349,6 @@ knowing:
272
349
  - **Absence follows your modifiers, not the transport.** Whether an empty field arrives as `undefined`,
273
350
  `null`, or the declared `.default(v)` is decided by what your schema accepts, so you write `.optional()` or
274
351
  `.nullable()` — whichever reads naturally — instead of guarding for all three. One exception: an empty
275
- string on a `z.string()` field is a *value*, not absence, so it does not fail a required field. See
352
+ string on a `z.string()` field — and on `z.unknown()` / `z.any()` — is a *value*, not absence, so it does not
353
+ fail a required field. See
276
354
  [16-gotchas.md](16-gotchas.md).
@@ -104,6 +104,10 @@ execute: async ({ params, apiRequest }) => {
104
104
  The same applies to a list endpoint: return the items **and** the paging fields around them, not a bare
105
105
  array. Adding a derived field is fine — spread the response and add to it — but the original fields stay.
106
106
 
107
+ A response is not converted the way params are: a vendor's `"0"` arrives as the string `"0"`, which is truthy.
108
+ Branch on a response flag by comparing it with the value the vendor documents — see
109
+ [16-gotchas.md](16-gotchas.md#conversion-runs-on-the-way-in-never-on-the-way-back).
110
+
107
111
  ## `execute` context bag
108
112
 
109
113
  The same bag is passed to actions, dictionaries, triggers, and result-loaders (accessed via arguments,
@@ -6,6 +6,10 @@ in full.
6
6
 
7
7
  ## An empty string is a value, not an absence
8
8
 
9
+ On a plain `z.string()`, and on `z.unknown()` / `z.any()`, which take any value as given. On every other type
10
+ `''` is absence; and a `.default(v)` — on any type, an enum included — fills `''` and `null` as well as a missing
11
+ value, so a defaulted field never sees either.
12
+
9
13
  Request bodies are usually built by dropping unset params. Drop only `undefined` and `null`:
10
14
 
11
15
  ```js
@@ -152,6 +156,37 @@ The general rule: when one value is reachable in more than one form, either deri
152
156
  place, or make the derivation itself idempotent to the difference. This applies to anything `initContext`
153
157
  touches — a base URL with or without a trailing slash, an id as a string or a number.
154
158
 
159
+ ## Conversion runs on the way in, never on the way back
160
+
161
+ A `z.boolean()` **param** accepts `yes`, `on`, `1`, `'false'` and the rest of the list in
162
+ [02-zod-types.md](02-zod-types.md#what-a-boolean-accepts). Nothing like that happens to what a **vendor** sends
163
+ back: a response is not declared, so it reaches your code exactly as the API serialized it. A flag sent as the
164
+ string `"0"` is truthy:
165
+
166
+ ```js
167
+ note: record.is_active ? 'Active' : 'Archived' // ✗ "0" → 'Active'
168
+ ```
169
+
170
+ That shipped as a disconnected device badged *Online*, unverified senders offered as verified, and archived
171
+ projects labelled *Active* — and in a dictionary's `note` or `label` it is a wrong choice made by a person,
172
+ with nothing anywhere to catch it.
173
+
174
+ **Compare the flag strictly against the value the vendor documents**, at the point you branch on it:
175
+
176
+ | The vendor documents | Branch on |
177
+ |---|---|
178
+ | a JSON boolean | `entry.toll_free === true` |
179
+ | `'1'` / `'0'` | `form.is_active === '1'` |
180
+ | `'true'` / `'false'` | `rule.hidden === 'true'` |
181
+
182
+ - **Read the vendor's docs (or a real response) per field** for the form it sends, and test with that form.
183
+ - **Widen only where the vendor really varies** — one endpoint answering `1` and another `"1"`:
184
+ `[1, '1'].includes(entry.active)`. Not a helper that knows ten spellings.
185
+ - **A pass-through is not this trap.** `list.counts.subscribed ?? 0` forwards a value; only a *branch* on a
186
+ flag can invert one.
187
+ - **An input flag is a param, not a response flag.** A flag that reaches you as a param — a criterion, a
188
+ value bound from a template — is declared `z.boolean()`, and the runtime converts it.
189
+
155
190
  ## A schema slot must be a `z.object`, or the method quietly has no inputs
156
191
 
157
192
  `params`, `criteria` and `configItems` are containers of named fields. Hand one anything else and there is
package/dist/cli.js CHANGED
@@ -14508,7 +14508,7 @@ var require_package = __commonJS({
14508
14508
  "package.json"(exports2, module2) {
14509
14509
  module2.exports = {
14510
14510
  name: "@flowrunner/cli",
14511
- version: "0.1.15",
14511
+ version: "0.1.17",
14512
14512
  publishConfig: {
14513
14513
  access: "public"
14514
14514
  },
@@ -16291,16 +16291,39 @@ function declaredAbsence(schema) {
16291
16291
  current = def.innerType;
16292
16292
  }
16293
16293
  const absence = acceptsUndefined && acceptsNull ? "as-received" : acceptsUndefined ? "undefined" : acceptsNull ? "null" : "required";
16294
- return { absence, absorbsBlank };
16294
+ return { absence, absorbsBlank, keepsEmpty: false, blankIsValue: false };
16295
16295
  }
16296
16296
  function coerces(schema) {
16297
16297
  return inspect(schema).core?._zod?.def?.coerce === true;
16298
16298
  }
16299
16299
  var parsesJson = (schema) => !!inspect(schema).meta.frJson;
16300
+ var OPEN_TYPES = /* @__PURE__ */ new Set(["unknown", "any"]);
16301
+ var isOpenType = (schema) => OPEN_TYPES.has(inspect(schema).coreType);
16302
+ function requiredOpenType(schema) {
16303
+ if (!isOpenType(schema)) {
16304
+ return false;
16305
+ }
16306
+ let current = schema;
16307
+ while (current?._zod) {
16308
+ const def = current._zod.def ?? {};
16309
+ const type = def.type;
16310
+ if (type === "nonoptional") {
16311
+ return true;
16312
+ }
16313
+ if (!TRANSPARENT_WRAPPERS.has(type)) {
16314
+ return false;
16315
+ }
16316
+ current = innerOf(def, type);
16317
+ }
16318
+ return false;
16319
+ }
16300
16320
  function probeAbsence(schema) {
16301
16321
  if (coerces(schema) || parsesJson(schema)) {
16302
16322
  return declaredAbsence(schema);
16303
16323
  }
16324
+ if (requiredOpenType(schema)) {
16325
+ return { absence: "required", absorbsBlank: false, keepsEmpty: true, blankIsValue: true };
16326
+ }
16304
16327
  const parse = (value) => {
16305
16328
  try {
16306
16329
  return schema.safeParse(value);
@@ -16311,24 +16334,24 @@ function probeAbsence(schema) {
16311
16334
  const asUndefined = parse(void 0);
16312
16335
  const asNull = parse(null);
16313
16336
  const absence = asUndefined.success && asNull.success ? "as-received" : asUndefined.success ? "undefined" : asNull.success ? "null" : "required";
16314
- return { absence, absorbsBlank: asUndefined.success && asUndefined.data !== void 0 };
16337
+ return { absence, absorbsBlank: asUndefined.success && asUndefined.data !== void 0, keepsEmpty: false, blankIsValue: false };
16315
16338
  }
16316
16339
  var probeCache = /* @__PURE__ */ new WeakMap();
16317
16340
  function absenceOf(schema) {
16318
16341
  if (!schema || typeof schema !== "object") {
16319
- return { absence: "as-received", absorbsBlank: false };
16342
+ return { absence: "as-received", absorbsBlank: false, keepsEmpty: false, blankIsValue: false };
16320
16343
  }
16321
16344
  const cached2 = probeCache.get(schema);
16322
16345
  if (cached2) {
16323
16346
  return cached2;
16324
16347
  }
16325
- const probed = probeAbsence(schema);
16348
+ const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) && !parsesJson(schema) };
16326
16349
  probeCache.set(schema, probed);
16327
16350
  return probed;
16328
16351
  }
16329
16352
  function planField(name, schema) {
16330
16353
  const ins = inspect(schema);
16331
- const { absence, absorbsBlank } = probeAbsence(schema);
16354
+ const { absence, absorbsBlank, keepsEmpty, blankIsValue } = absenceOf(schema);
16332
16355
  return {
16333
16356
  name,
16334
16357
  schema,
@@ -16337,6 +16360,8 @@ function planField(name, schema) {
16337
16360
  isUnion: !!ins.branches,
16338
16361
  absence,
16339
16362
  absorbsBlank,
16363
+ keepsEmpty,
16364
+ blankIsValue,
16340
16365
  passThroughDate: passesDateThrough(ins),
16341
16366
  restoresDates: hasPassThroughDate(schema, inspect, shapeEntries)
16342
16367
  };
@@ -16354,8 +16379,29 @@ function toStringValue(value) {
16354
16379
  if (typeof value === "boolean") {
16355
16380
  return ok(String(value));
16356
16381
  }
16382
+ if (value !== null && typeof value === "object") {
16383
+ return ok(value instanceof Date ? value.toISOString() : JSON.stringify(value));
16384
+ }
16357
16385
  return typeof value === "number" && Number.isFinite(value) ? ok(String(value)) : fail2("string");
16358
16386
  }
16387
+ var OPENS = { array: "[", object: "{" };
16388
+ function parseContainerText(value, kind) {
16389
+ if (typeof value !== "string") {
16390
+ return value;
16391
+ }
16392
+ const text2 = value.trim();
16393
+ if (!text2.startsWith(OPENS[kind])) {
16394
+ return value;
16395
+ }
16396
+ try {
16397
+ const parsed = JSON.parse(text2);
16398
+ const isList = Array.isArray(parsed);
16399
+ const fits = kind === "array" ? isList : parsed !== null && typeof parsed === "object" && !isList;
16400
+ return fits ? parsed : value;
16401
+ } catch {
16402
+ return value;
16403
+ }
16404
+ }
16359
16405
  function toNumberValue(value) {
16360
16406
  if (typeof value === "number") {
16361
16407
  return Number.isFinite(value) ? ok(value) : fail2("number");
@@ -16435,7 +16481,14 @@ function accepts(schema, value) {
16435
16481
  }
16436
16482
  }
16437
16483
  function coerceUnion(value, branches) {
16484
+ if (branches.some((branch) => accepts(branch, value))) {
16485
+ return value;
16486
+ }
16487
+ const isStructure = value !== null && typeof value === "object";
16438
16488
  for (const branch of branches) {
16489
+ if (isStructure && inspect(branch).coreType === "string") {
16490
+ continue;
16491
+ }
16439
16492
  const coerced = coerceDeep(value, branch);
16440
16493
  if (accepts(branch, coerced)) {
16441
16494
  return coerced;
@@ -16460,22 +16513,25 @@ function coerceDeep(value, schema) {
16460
16513
  }
16461
16514
  if (ins.coreType === "array") {
16462
16515
  const element = ins.core?._zod?.def?.element;
16463
- return Array.isArray(value) ? value.map((item) => coerceDeep(item, element)) : value;
16516
+ const list = parseContainerText(value, "array");
16517
+ return Array.isArray(list) ? list.map((item) => coerceDeep(item, element)) : list;
16464
16518
  }
16465
16519
  if (ins.coreType === "record") {
16466
- if (typeof value !== "object" || Array.isArray(value)) {
16467
- return value;
16520
+ const map = parseContainerText(value, "object");
16521
+ if (typeof map !== "object" || Array.isArray(map)) {
16522
+ return map;
16468
16523
  }
16469
16524
  const valueType = ins.core?._zod?.def?.valueType;
16470
16525
  return Object.fromEntries(
16471
- Object.entries(value).map(([key, item]) => [key, coerceDeep(item, valueType)])
16526
+ Object.entries(map).map(([key, item]) => [key, coerceDeep(item, valueType)])
16472
16527
  );
16473
16528
  }
16474
16529
  if (ins.coreType === "object") {
16475
- if (typeof value !== "object" || Array.isArray(value)) {
16476
- return value;
16530
+ const parsed = parseContainerText(value, "object");
16531
+ if (typeof parsed !== "object" || Array.isArray(parsed)) {
16532
+ return parsed;
16477
16533
  }
16478
- const source = value;
16534
+ const source = parsed;
16479
16535
  const coerced = { ...source };
16480
16536
  for (const [name, property] of shapeEntries(ins.core)) {
16481
16537
  if (name in source) {
@@ -16510,7 +16566,13 @@ function coerceLeaf(value, ins) {
16510
16566
  return coerceValue(value, ins.coreType);
16511
16567
  }
16512
16568
  function isBlank(value, ins, schema) {
16513
- if (value === void 0 || value === null) {
16569
+ if (value === void 0) {
16570
+ return true;
16571
+ }
16572
+ if (absenceOf(schema).keepsEmpty) {
16573
+ return false;
16574
+ }
16575
+ if (value === null) {
16514
16576
  return true;
16515
16577
  }
16516
16578
  if (value !== "") {
@@ -16519,6 +16581,9 @@ function isBlank(value, ins, schema) {
16519
16581
  if (ins.branches) {
16520
16582
  return true;
16521
16583
  }
16584
+ if (absenceOf(schema).blankIsValue) {
16585
+ return absenceOf(schema).absorbsBlank;
16586
+ }
16522
16587
  return ins.coreType !== "string" || absenceOf(schema).absorbsBlank;
16523
16588
  }
16524
16589
  function absentAs(schema, value) {
@@ -16579,6 +16644,8 @@ var EXPECTED = {
16579
16644
  date: "a date",
16580
16645
  object: "an object",
16581
16646
  array: "an array",
16647
+ // zod's own token for `z.record()`, which the author declared as a map — to a person it is an object.
16648
+ record: "an object",
16582
16649
  // `z.json()`. Not a zod token — ./coerce.ts raises it when the submitted text will not parse.
16583
16650
  json: "valid JSON"
16584
16651
  };
@@ -16655,7 +16722,13 @@ function toFieldIssue(plan2, issue, fieldValue) {
16655
16722
  var resolved2 = (value) => ({ value, present: true, issues: [] });
16656
16723
  var rejected = (issues) => ({ present: false, issues });
16657
16724
  function isAbsent(value, plan2) {
16658
- if (value === void 0 || value === null) {
16725
+ if (value === void 0) {
16726
+ return true;
16727
+ }
16728
+ if (plan2.keepsEmpty) {
16729
+ return false;
16730
+ }
16731
+ if (value === null) {
16659
16732
  return true;
16660
16733
  }
16661
16734
  if (value !== "") {
@@ -16664,6 +16737,9 @@ function isAbsent(value, plan2) {
16664
16737
  if (plan2.isUnion) {
16665
16738
  return true;
16666
16739
  }
16740
+ if (plan2.blankIsValue) {
16741
+ return plan2.absorbsBlank;
16742
+ }
16667
16743
  return plan2.coreType !== "string" || plan2.absorbsBlank;
16668
16744
  }
16669
16745
  function normalizeAbsence(value, plan2) {
@@ -16951,6 +17027,9 @@ function extendPrototype() {
16951
17027
  const existing = this.meta()?.examples ?? [];
16952
17028
  return this.meta({ examples: [...existing, value] });
16953
17029
  };
17030
+ proto.required = function required() {
17031
+ return this.nonoptional();
17032
+ };
16954
17033
  proto.shared = function shared() {
16955
17034
  return this.meta({ frShared: true });
16956
17035
  };