Commit Graph

30 Commits

Author SHA1 Message Date
Aditya Singh a9c98e4396 Fix incorrect Facts in pkl:base doc comments (#1669)
Several `Facts:` examples in the `pkl:base` standard library docs assert
statements that are false when evaluated. Since these examples are not
run by any test, the mistakes went unnoticed and are rendered verbatim
into the generated API docs, where they mislead readers.

The corrected examples:

- `String.isNotBlank`: `"\t\n\r".isNotBlank` was listed as holding, but
a string of only whitespace is blank, so it is false. Negated it to
match the neighboring `!"".isNotBlank` and `!" ".isNotBlank` examples.
- `DataSize.toBinaryUnit` / `toDecimalUnit`: the `mb`/`mib` lines
mirrored the `kb`/`kib` lines, but the identity only holds for adjacent
units. `1024.kb == 1000.kib` (both 1,024,000 b), whereas `1024.mb` is
1,024,000,000 b and `1000.mib` is 1,048,576,000 b, so they are not
equal. There is no clean round-number equivalent at this magnitude, so I
removed the two false lines; the remaining examples still demonstrate
the conversion.
- `Collection.any`: `!List(1, 2, 3).any((n) -> n.isEven)` is false
because 2 is even. Changed the list to `List(1, 3, 5)` so the negation
holds.
- `IntSeq.end`: the example read `IntSeq(2, 5).start == 5`, which
documents the wrong property and is false (`start` is 2). Corrected it
to `IntSeq(2, 5).end == 5`.
- `List.isDistinctBy` / `distinctBy`: `List("a", "b", "abc")` is not
distinct by length, since `"a"` and `"b"` both have length 1. Switched
to `List("a", "bb", "ccc")` so the distinctness examples hold.
- `Map`: `Map(...).values` returns a `List`, not a `Set`. Corrected the
expected type.

I verified that each corrected example evaluates to `true`, and that the
neighboring examples I kept still pass, using the released Pkl 0.31.1
binary. The changes are confined to doc-comment text, so formatting is
unaffected.

---------

Signed-off-by: Aditya Singh <adisin650@gmail.com>
2026-06-11 17:10:14 +00:00
Jen Basch 74eae0388e Fix error rendering @ConvertProperty annotations during error reporting (#1648)
The added snippet test originally produced error "A value of type
`Function2` cannot be exported."

This PR actually fixes the bug twice:
* By marking `ConvertProperty.render` as `hidden` so that it is skipped
when the enclosing object is exported. This broke any attempts to obtain
the module schema because this requires exporting all annotations on all
class properties.
* By changing the way that `VmUndefinedValueException.fillInHint()`
obtains the module URI to avoid obtaining the module schema (and
triggering the more expensive module schema generation process).

It also makes function-typed annotation properties in `pkl:Command` hidden to avoid similar issues there.
2026-06-05 16:50:34 +00:00
Daniel Chao 8e2e5e4ba8 Improve HTTP headers logic (#1584)
* Relax forbidden headers constraints
  - remove restriction on browser-related headers
- allow any glob pattern (no need to end with `/` or `*`, because glob
patterns already require users to explicitly declare prefix matches if
that's the intention)
* Replace `List<Pair<, ...>>`; use `Map<String, ...>` instead
* Use glob pattern strings as an API throughout, instead of `Pattern`
(e.g. in `HttpClientBuilder`)
* Add HTTP headers to message passing API
* Add HTTP headers to executor API (introduces `ExecutorSpiOptions4`)
* Add tests for Gradle, CLI, and pkl-executor invocations
* Improve documentation
* Add `isGlobPattern` API to class `String` for in-language validation
of http headers
* Behavior change: make sure explicitly configured `User-Agent` in
`HttpClientBuilder` can be shadowed by headers (allows users to set
`--http-header "**=User-Agent: My User Agent"` and for this to be the
only user agent).

CC @kyokuping
2026-05-21 20:07:06 -07:00
Islon Scherer cac3e483b5 Start next dev iteration 2026-02-26 09:51:27 -08:00
Jen Basch 4611d181a8 Remove broken Collection.transpose method (#1437) 2026-02-24 08:09:52 -08:00
Jen Basch 73264e8fd1 SPICE-0024: Annotation converters (#1333)
This enables defining declarative key and/or value transformations in
cases where neither `Class`- nor path-based converters can be applied
gracefully. It is also the only way to express transforming the
resulting property names in `Typed` objects without applying a converter
to the entire containing type, which is cumbersome at best.

SPICE: https://github.com/apple/pkl-evolution/pull/26
2026-01-23 12:44:41 -08:00
Jen Basch 9b6f72d5d0 Fix doc links from pkl:base to pkl:math (#1400) 2026-01-09 11:30:56 -08:00
Daniel Chao ac4f2fd9a6 Add isNotEmpty, isNotBlank methods (#1396)
Adds convenience methods `isNotEmpty` and `isNotBlank`. This borrows the
same methods from Kotlin.

This helps users write more fluent constraints, for example,
`foo.isNotEmpty.implies(bar)`.

Adds:

* List#isNotEmpty
* Map#isNotEmpty
* Set#isNotEmpty
* Mapping#isNotEmpty
* Listing#isNotEmpty
* String#isNotEmpty
* String#isNotBlank
2026-01-08 13:22:43 -08:00
Dan Chao 4d70baba86 Start next dev iteration 2025-11-03 12:26:58 -08:00
Daniel Chao ef4989aa35 Wrap comments in base.pkl to 100 chars (#1258)
Also, strip line numbers from reflectedDeclaration.pcf
2025-10-27 16:00:48 -07:00
Daniel Chao c7680aea1f Enforce Pkl formatting of stdlib with spotless (#1253)
This adds a spotless formatting step using the new pkl formatter.

This only formats Pkl sources in the stdlib, because other sources
are possibly test input and not meant to be formatted.
2025-10-24 10:15:14 -07:00
Jen Basch 6c036bf82a Implement Pkl binary renderer and parser (#1203)
Implements a binary renderer for Pkl values, which is a lossless capturing of Pkl data.

This follows the pkl binary format that is already used with `pkl server` calls, and is
made available as a Java API and also an in-language API.

Also, introduces a binary parser into the corresponding `PObject` types in Java.
2025-10-20 09:10:22 -07:00
Daniel Chao 8c5bd3b7dd Apply pkl formatter to codebase (#1236)
This applies the Pkl formatter to `stdlib/` and `.circleci/`
2025-10-09 15:16:38 -07:00
Daniel Chao a66ac0eb35 Refine documentation for class Any (#1194) 2025-09-02 08:19:39 -07:00
Islon Scherer a3cc2f0ea6 Start next dev iteration 2025-07-24 20:06:01 +02:00
Daniel Chao bdf6aa6b60 Un-deprecate Resource.base64, compute bytes/base64 in terms of each other (#1138)
This makes changes to avoid a needless breaking change.
It preserves code like `new Resource { base64 = someValue }.sha256`,
and also code that renders `Resource` into static formats.

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2025-07-23 06:25:49 -07:00
Jen Basch 85e4f133a4 Add getOrDefault method to Listing and Mapping (#1053)
This PR adds methods to Listing and Mapping that can be used to retrieve members. If the member for the index/key isn't present, it applies default to the index/key. In both cases, this is essentially sugar for getOrNull(<index/key>) ?? default.apply(<index/key>).

Co-authored-by: Daniel Chao <daniel.h.chao@gmail.com>
2025-07-22 15:45:49 -07:00
Daniel Chao e9320557b7 Introduces Bytes class (#1019)
This introduces a new `Bytes` standard library class, for working with
binary data.

* Add Bytes class to the standard library
* Change CLI to eval `output.bytes`
* Change code generators to map Bytes to respective underlying type
* Add subscript and concat operator support
* Add binary encoding for Bytes
* Add PCF and Plist rendering for Bytes

Co-authored-by: Kushal Pisavadia <kushi.p@gmail.com>
2025-06-11 16:23:55 -07:00
Josh B 948a20ad0c Add mapNonNullIndexed API to List and Set (#1063) 2025-05-08 15:57:28 +02:00
Islon Scherer d3ba0f9e47 Start next dev iteration 2025-02-26 09:48:20 -08:00
Daniel Chao 7c3f8ad261 Improve documentation about Set/Map ordering (#944)
The language reference and stdlib are both slightly incorrect;
maps and sets are ordered when iterated on, but unordered in terms of
equality.
2025-02-12 06:43:51 -08:00
Dan Chao 44fd680e43 Start next dev iteration 2024-11-05 10:34:31 -08:00
Philip K.F. Hölzenspies a03827951c Add methods from List/Map to Listing/Mapping (#683)
* Add `values` to `Mapping`

* Add `entries` to `Mapping`

* Add `containsValue` to `Mapping`

* Add `every` to `Mapping`

* Add `any` to `Mapping`

* Add `toDynamic` to `Mapping`

* Add `lastIndex` to `Listing`

* Add `getOrNull` to `Listing`

* Add `first` to `Listing`

* Add `firstOrNull` to `Listing`

* Add `last` to `Listing`

* Add `lastOrNull` to `Listing`

* Add `single` to `Listing`

* Add `singleOrNull` to `Listing`

* Add `contains` to `Listing`

* Add `any` to `Listing`

* Add `every` to `Listing`

* Fixup `any` to `Listing`

* Revert "Add `toDynamic` to `Mapping`"

This reverts commit 5551974ecd8110aa2eb8f546e992c32d3181df9b.

* Revert "Add `values` to `Mapping`"

This reverts commit 6fc78796

* Revert "Add `entries` to `Mapping`"

This reverts commit a7e8dfc4

* Annotate new members with `Since` 0.27

* Fix documentation in `base.pkl`

* Add location information to empty/single checks in `Listing` operations

* Remove additional variable for laziness preservation

* Apply spotless

* Apply suggestions from code review

Co-authored-by: Daniel Chao <daniel.h.chao@gmail.com>

---------

Co-authored-by: Daniel Chao <daniel.h.chao@gmail.com>
2024-10-31 14:54:27 +00:00
Josh B 1e63c48ce4 Add String.splitLimit API (#666)
* Add String.splitLimit API

* Update stdlib/base.pkl

Co-authored-by: Daniel Chao <daniel.h.chao@gmail.com>

---------

Co-authored-by: Daniel Chao <daniel.h.chao@gmail.com>
2024-10-07 15:28:19 +01:00
Philip K.F. Hölzenspies 0ef22a73fb Start next dev iteration 2024-06-17 19:53:30 +01:00
Daniel Chao 6e2ea07986 Fix documentation about ValueRenderer converters (#422)
* Class-based converters are covariant, not invariant.
* The most specific class-based converter wins
* The first declared path-based converter that matches wins
2024-04-16 10:28:05 -07:00
Kushal Pisavadia 3d1db25864 Fix name resolution in typealias with constraint (#144)
The body of a typealias gets inlined into wherever the typealias
is used. This fixes a bug where the references in the typealias body can
resolve to the wrong value.
2024-02-15 13:28:10 -08:00
Dan Chao ce65290aae Start next dev iteration 2024-02-01 20:55:37 -08:00
Dan Chao c31119e41f Prepare 0.25.1 release 2024-02-01 19:23:49 -08:00
Peter Niederwieser ecad035dca Initial commit 2024-02-01 14:00:22 -08:00