diff --git a/packages/k8s.contrib.crd/PklProject b/packages/k8s.contrib.crd/PklProject index 33fd01b..6e1d730 100644 --- a/packages/k8s.contrib.crd/PklProject +++ b/packages/k8s.contrib.crd/PklProject @@ -29,5 +29,5 @@ dependencies { } package { - version = "2.0.1" + version = "2.0.2" } diff --git a/packages/k8s.contrib.crd/PklProject.deps.json b/packages/k8s.contrib.crd/PklProject.deps.json index 58e1781..fa3beab 100644 --- a/packages/k8s.contrib.crd/PklProject.deps.json +++ b/packages/k8s.contrib.crd/PklProject.deps.json @@ -15,12 +15,12 @@ }, "package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib@1": { "type": "local", - "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib@1.1.3", + "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib@1.1.4", "path": "../org.json_schema.contrib" }, "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax@1": { "type": "local", - "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax@1.0.3", + "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax@1.1.0", "path": "../pkl.experimental.syntax" }, "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1": { diff --git a/packages/org.json_schema.contrib/PklProject b/packages/org.json_schema.contrib/PklProject index 1464113..0479f1c 100644 --- a/packages/org.json_schema.contrib/PklProject +++ b/packages/org.json_schema.contrib/PklProject @@ -25,5 +25,5 @@ dependencies { } package { - version = "1.1.3" + version = "1.1.4" } diff --git a/packages/org.json_schema.contrib/PklProject.deps.json b/packages/org.json_schema.contrib/PklProject.deps.json index 3ffa263..d025a51 100644 --- a/packages/org.json_schema.contrib/PklProject.deps.json +++ b/packages/org.json_schema.contrib/PklProject.deps.json @@ -3,7 +3,7 @@ "resolvedDependencies": { "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax@1": { "type": "local", - "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax@1.0.3", + "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax@1.1.0", "path": "../pkl.experimental.syntax" }, "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1": { diff --git a/packages/pkl.experimental.syntax/PklProject b/packages/pkl.experimental.syntax/PklProject index 675c147..13f5f9c 100644 --- a/packages/pkl.experimental.syntax/PklProject +++ b/packages/pkl.experimental.syntax/PklProject @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. +// Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,6 +17,6 @@ amends "../basePklProject.pkl" package { - version = "1.0.3" + version = "1.1.0" apiTests = import*("tests/*.pkl").keys.toListing() } diff --git a/packages/pkl.experimental.syntax/TypeNode.pkl b/packages/pkl.experimental.syntax/TypeNode.pkl index f57f0c5..55272e3 100644 --- a/packages/pkl.experimental.syntax/TypeNode.pkl +++ b/packages/pkl.experimental.syntax/TypeNode.pkl @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. +// Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ extends "Node.pkl" import "QualifiedIdentifierNode.pkl" import "ExpressionNode.pkl" import "TypeNode.pkl" +import "Node.pkl" class NullableTypeNode extends TypeNode { typeNode: TypeNode @@ -65,8 +66,17 @@ class ConstrainedTypeNode extends TypeNode { renderedUnderlyingType + renderConstraints(currentIndent) } +class UnionDefaultType extends Node { + typeNode: TypeNode + + function render(currentIndent: String) = "*\(typeNode.render(currentIndent))" +} + class UnionTypeNode extends TypeNode { - members: Listing + members: Listing(atMostOneUnionDefaultType) + + const local atMostOneUnionDefaultType = (members: Listing) -> + members.fold(0, (acc, member) -> acc + if (member is UnionDefaultType) 1 else 0) <= 1 function render(currentIndent: String) = let (childrenRendered = members.toList().map((t) -> t.render(currentIndent))) diff --git a/packages/pkl.experimental.syntax/tests/TypeNode.pkl b/packages/pkl.experimental.syntax/tests/TypeNode.pkl index 0acc38f..b3377e6 100644 --- a/packages/pkl.experimental.syntax/tests/TypeNode.pkl +++ b/packages/pkl.experimental.syntax/tests/TypeNode.pkl @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. +// Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -106,5 +106,37 @@ facts { }.render("") == """ "one"|"two" """ + + new TypeNode.UnionTypeNode { + members { + new TypeNode.UnionDefaultType { + typeNode = new TypeNode.StringLiteralTypeNode { + value = "one" + } + } + new TypeNode.StringLiteralTypeNode { + value = "two" + } + } + }.render("") == """ + *"one"|"two" + """ + + module.catch(() -> + new TypeNode.UnionTypeNode { + members { + new TypeNode.UnionDefaultType { + typeNode = new TypeNode.StringLiteralTypeNode { + value = "one" + } + } + new TypeNode.UnionDefaultType { + typeNode = new TypeNode.StringLiteralTypeNode { + value = "two" + } + } + } + }.render("") + ).startsWith("Type constraint `atMostOneUnionDefaultType` violated.") } }